1*2d1272b8SAndroid Build Coastguard Worker /*
2*2d1272b8SAndroid Build Coastguard Worker * Copyright © 2022 Behdad Esfahbod
3*2d1272b8SAndroid Build Coastguard Worker *
4*2d1272b8SAndroid Build Coastguard Worker * This is part of HarfBuzz, a text shaping library.
5*2d1272b8SAndroid Build Coastguard Worker *
6*2d1272b8SAndroid Build Coastguard Worker * Permission is hereby granted, without written agreement and without
7*2d1272b8SAndroid Build Coastguard Worker * license or royalty fees, to use, copy, modify, and distribute this
8*2d1272b8SAndroid Build Coastguard Worker * software and its documentation for any purpose, provided that the
9*2d1272b8SAndroid Build Coastguard Worker * above copyright notice and the following two paragraphs appear in
10*2d1272b8SAndroid Build Coastguard Worker * all copies of this software.
11*2d1272b8SAndroid Build Coastguard Worker *
12*2d1272b8SAndroid Build Coastguard Worker * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13*2d1272b8SAndroid Build Coastguard Worker * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14*2d1272b8SAndroid Build Coastguard Worker * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15*2d1272b8SAndroid Build Coastguard Worker * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16*2d1272b8SAndroid Build Coastguard Worker * DAMAGE.
17*2d1272b8SAndroid Build Coastguard Worker *
18*2d1272b8SAndroid Build Coastguard Worker * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19*2d1272b8SAndroid Build Coastguard Worker * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20*2d1272b8SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21*2d1272b8SAndroid Build Coastguard Worker * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22*2d1272b8SAndroid Build Coastguard Worker * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23*2d1272b8SAndroid Build Coastguard Worker */
24*2d1272b8SAndroid Build Coastguard Worker
25*2d1272b8SAndroid Build Coastguard Worker #include "hb.hh"
26*2d1272b8SAndroid Build Coastguard Worker
27*2d1272b8SAndroid Build Coastguard Worker #ifndef HB_NO_PAINT
28*2d1272b8SAndroid Build Coastguard Worker
29*2d1272b8SAndroid Build Coastguard Worker #include "hb-paint-extents.hh"
30*2d1272b8SAndroid Build Coastguard Worker
31*2d1272b8SAndroid Build Coastguard Worker #include "hb-draw.h"
32*2d1272b8SAndroid Build Coastguard Worker
33*2d1272b8SAndroid Build Coastguard Worker #include "hb-machinery.hh"
34*2d1272b8SAndroid Build Coastguard Worker
35*2d1272b8SAndroid Build Coastguard Worker
36*2d1272b8SAndroid Build Coastguard Worker /*
37*2d1272b8SAndroid Build Coastguard Worker * This file implements bounds-extraction as well as boundedness
38*2d1272b8SAndroid Build Coastguard Worker * computation of COLRv1 fonts as described in:
39*2d1272b8SAndroid Build Coastguard Worker *
40*2d1272b8SAndroid Build Coastguard Worker * https://learn.microsoft.com/en-us/typography/opentype/spec/colr#glyph-metrics-and-boundedness
41*2d1272b8SAndroid Build Coastguard Worker */
42*2d1272b8SAndroid Build Coastguard Worker
43*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_push_transform(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,float xx,float yx,float xy,float yy,float dx,float dy,void * user_data HB_UNUSED)44*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_push_transform (hb_paint_funcs_t *funcs HB_UNUSED,
45*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
46*2d1272b8SAndroid Build Coastguard Worker float xx, float yx,
47*2d1272b8SAndroid Build Coastguard Worker float xy, float yy,
48*2d1272b8SAndroid Build Coastguard Worker float dx, float dy,
49*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
50*2d1272b8SAndroid Build Coastguard Worker {
51*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
52*2d1272b8SAndroid Build Coastguard Worker
53*2d1272b8SAndroid Build Coastguard Worker c->push_transform (hb_transform_t {xx, yx, xy, yy, dx, dy});
54*2d1272b8SAndroid Build Coastguard Worker }
55*2d1272b8SAndroid Build Coastguard Worker
56*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_pop_transform(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,void * user_data HB_UNUSED)57*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_pop_transform (hb_paint_funcs_t *funcs HB_UNUSED,
58*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
59*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
60*2d1272b8SAndroid Build Coastguard Worker {
61*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
62*2d1272b8SAndroid Build Coastguard Worker
63*2d1272b8SAndroid Build Coastguard Worker c->pop_transform ();
64*2d1272b8SAndroid Build Coastguard Worker }
65*2d1272b8SAndroid Build Coastguard Worker
66*2d1272b8SAndroid Build Coastguard Worker static void
hb_draw_extents_move_to(hb_draw_funcs_t * dfuncs HB_UNUSED,void * data,hb_draw_state_t * st,float to_x,float to_y,void * user_data HB_UNUSED)67*2d1272b8SAndroid Build Coastguard Worker hb_draw_extents_move_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
68*2d1272b8SAndroid Build Coastguard Worker void *data,
69*2d1272b8SAndroid Build Coastguard Worker hb_draw_state_t *st,
70*2d1272b8SAndroid Build Coastguard Worker float to_x, float to_y,
71*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
72*2d1272b8SAndroid Build Coastguard Worker {
73*2d1272b8SAndroid Build Coastguard Worker hb_extents_t *extents = (hb_extents_t *) data;
74*2d1272b8SAndroid Build Coastguard Worker
75*2d1272b8SAndroid Build Coastguard Worker extents->add_point (to_x, to_y);
76*2d1272b8SAndroid Build Coastguard Worker }
77*2d1272b8SAndroid Build Coastguard Worker
78*2d1272b8SAndroid Build Coastguard Worker static void
hb_draw_extents_line_to(hb_draw_funcs_t * dfuncs HB_UNUSED,void * data,hb_draw_state_t * st,float to_x,float to_y,void * user_data HB_UNUSED)79*2d1272b8SAndroid Build Coastguard Worker hb_draw_extents_line_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
80*2d1272b8SAndroid Build Coastguard Worker void *data,
81*2d1272b8SAndroid Build Coastguard Worker hb_draw_state_t *st,
82*2d1272b8SAndroid Build Coastguard Worker float to_x, float to_y,
83*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
84*2d1272b8SAndroid Build Coastguard Worker {
85*2d1272b8SAndroid Build Coastguard Worker hb_extents_t *extents = (hb_extents_t *) data;
86*2d1272b8SAndroid Build Coastguard Worker
87*2d1272b8SAndroid Build Coastguard Worker extents->add_point (to_x, to_y);
88*2d1272b8SAndroid Build Coastguard Worker }
89*2d1272b8SAndroid Build Coastguard Worker
90*2d1272b8SAndroid Build Coastguard Worker static void
hb_draw_extents_quadratic_to(hb_draw_funcs_t * dfuncs HB_UNUSED,void * data,hb_draw_state_t * st,float control_x,float control_y,float to_x,float to_y,void * user_data HB_UNUSED)91*2d1272b8SAndroid Build Coastguard Worker hb_draw_extents_quadratic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
92*2d1272b8SAndroid Build Coastguard Worker void *data,
93*2d1272b8SAndroid Build Coastguard Worker hb_draw_state_t *st,
94*2d1272b8SAndroid Build Coastguard Worker float control_x, float control_y,
95*2d1272b8SAndroid Build Coastguard Worker float to_x, float to_y,
96*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
97*2d1272b8SAndroid Build Coastguard Worker {
98*2d1272b8SAndroid Build Coastguard Worker hb_extents_t *extents = (hb_extents_t *) data;
99*2d1272b8SAndroid Build Coastguard Worker
100*2d1272b8SAndroid Build Coastguard Worker extents->add_point (control_x, control_y);
101*2d1272b8SAndroid Build Coastguard Worker extents->add_point (to_x, to_y);
102*2d1272b8SAndroid Build Coastguard Worker }
103*2d1272b8SAndroid Build Coastguard Worker
104*2d1272b8SAndroid Build Coastguard Worker static void
hb_draw_extents_cubic_to(hb_draw_funcs_t * dfuncs HB_UNUSED,void * data,hb_draw_state_t * st,float control1_x,float control1_y,float control2_x,float control2_y,float to_x,float to_y,void * user_data HB_UNUSED)105*2d1272b8SAndroid Build Coastguard Worker hb_draw_extents_cubic_to (hb_draw_funcs_t *dfuncs HB_UNUSED,
106*2d1272b8SAndroid Build Coastguard Worker void *data,
107*2d1272b8SAndroid Build Coastguard Worker hb_draw_state_t *st,
108*2d1272b8SAndroid Build Coastguard Worker float control1_x, float control1_y,
109*2d1272b8SAndroid Build Coastguard Worker float control2_x, float control2_y,
110*2d1272b8SAndroid Build Coastguard Worker float to_x, float to_y,
111*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
112*2d1272b8SAndroid Build Coastguard Worker {
113*2d1272b8SAndroid Build Coastguard Worker hb_extents_t *extents = (hb_extents_t *) data;
114*2d1272b8SAndroid Build Coastguard Worker
115*2d1272b8SAndroid Build Coastguard Worker extents->add_point (control1_x, control1_y);
116*2d1272b8SAndroid Build Coastguard Worker extents->add_point (control2_x, control2_y);
117*2d1272b8SAndroid Build Coastguard Worker extents->add_point (to_x, to_y);
118*2d1272b8SAndroid Build Coastguard Worker }
119*2d1272b8SAndroid Build Coastguard Worker
120*2d1272b8SAndroid Build Coastguard Worker static inline void free_static_draw_extents_funcs ();
121*2d1272b8SAndroid Build Coastguard Worker
122*2d1272b8SAndroid Build Coastguard Worker static struct hb_draw_extents_funcs_lazy_loader_t : hb_draw_funcs_lazy_loader_t<hb_draw_extents_funcs_lazy_loader_t>
123*2d1272b8SAndroid Build Coastguard Worker {
createhb_draw_extents_funcs_lazy_loader_t124*2d1272b8SAndroid Build Coastguard Worker static hb_draw_funcs_t *create ()
125*2d1272b8SAndroid Build Coastguard Worker {
126*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_t *funcs = hb_draw_funcs_create ();
127*2d1272b8SAndroid Build Coastguard Worker
128*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_set_move_to_func (funcs, hb_draw_extents_move_to, nullptr, nullptr);
129*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_set_line_to_func (funcs, hb_draw_extents_line_to, nullptr, nullptr);
130*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_set_quadratic_to_func (funcs, hb_draw_extents_quadratic_to, nullptr, nullptr);
131*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_set_cubic_to_func (funcs, hb_draw_extents_cubic_to, nullptr, nullptr);
132*2d1272b8SAndroid Build Coastguard Worker
133*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_make_immutable (funcs);
134*2d1272b8SAndroid Build Coastguard Worker
135*2d1272b8SAndroid Build Coastguard Worker hb_atexit (free_static_draw_extents_funcs);
136*2d1272b8SAndroid Build Coastguard Worker
137*2d1272b8SAndroid Build Coastguard Worker return funcs;
138*2d1272b8SAndroid Build Coastguard Worker }
139*2d1272b8SAndroid Build Coastguard Worker } static_draw_extents_funcs;
140*2d1272b8SAndroid Build Coastguard Worker
141*2d1272b8SAndroid Build Coastguard Worker static inline
free_static_draw_extents_funcs()142*2d1272b8SAndroid Build Coastguard Worker void free_static_draw_extents_funcs ()
143*2d1272b8SAndroid Build Coastguard Worker {
144*2d1272b8SAndroid Build Coastguard Worker static_draw_extents_funcs.free_instance ();
145*2d1272b8SAndroid Build Coastguard Worker }
146*2d1272b8SAndroid Build Coastguard Worker
147*2d1272b8SAndroid Build Coastguard Worker static hb_draw_funcs_t *
hb_draw_extents_get_funcs()148*2d1272b8SAndroid Build Coastguard Worker hb_draw_extents_get_funcs ()
149*2d1272b8SAndroid Build Coastguard Worker {
150*2d1272b8SAndroid Build Coastguard Worker return static_draw_extents_funcs.get_unconst ();
151*2d1272b8SAndroid Build Coastguard Worker }
152*2d1272b8SAndroid Build Coastguard Worker
153*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_push_clip_glyph(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_codepoint_t glyph,hb_font_t * font,void * user_data HB_UNUSED)154*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_push_clip_glyph (hb_paint_funcs_t *funcs HB_UNUSED,
155*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
156*2d1272b8SAndroid Build Coastguard Worker hb_codepoint_t glyph,
157*2d1272b8SAndroid Build Coastguard Worker hb_font_t *font,
158*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
159*2d1272b8SAndroid Build Coastguard Worker {
160*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
161*2d1272b8SAndroid Build Coastguard Worker
162*2d1272b8SAndroid Build Coastguard Worker hb_extents_t extents;
163*2d1272b8SAndroid Build Coastguard Worker hb_draw_funcs_t *draw_extent_funcs = hb_draw_extents_get_funcs ();
164*2d1272b8SAndroid Build Coastguard Worker hb_font_draw_glyph (font, glyph, draw_extent_funcs, &extents);
165*2d1272b8SAndroid Build Coastguard Worker c->push_clip (extents);
166*2d1272b8SAndroid Build Coastguard Worker }
167*2d1272b8SAndroid Build Coastguard Worker
168*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_push_clip_rectangle(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,float xmin,float ymin,float xmax,float ymax,void * user_data)169*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_push_clip_rectangle (hb_paint_funcs_t *funcs HB_UNUSED,
170*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
171*2d1272b8SAndroid Build Coastguard Worker float xmin, float ymin, float xmax, float ymax,
172*2d1272b8SAndroid Build Coastguard Worker void *user_data)
173*2d1272b8SAndroid Build Coastguard Worker {
174*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
175*2d1272b8SAndroid Build Coastguard Worker
176*2d1272b8SAndroid Build Coastguard Worker hb_extents_t extents = {xmin, ymin, xmax, ymax};
177*2d1272b8SAndroid Build Coastguard Worker c->push_clip (extents);
178*2d1272b8SAndroid Build Coastguard Worker }
179*2d1272b8SAndroid Build Coastguard Worker
180*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_pop_clip(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,void * user_data HB_UNUSED)181*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_pop_clip (hb_paint_funcs_t *funcs HB_UNUSED,
182*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
183*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
184*2d1272b8SAndroid Build Coastguard Worker {
185*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
186*2d1272b8SAndroid Build Coastguard Worker
187*2d1272b8SAndroid Build Coastguard Worker c->pop_clip ();
188*2d1272b8SAndroid Build Coastguard Worker }
189*2d1272b8SAndroid Build Coastguard Worker
190*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_push_group(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,void * user_data HB_UNUSED)191*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_push_group (hb_paint_funcs_t *funcs HB_UNUSED,
192*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
193*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
194*2d1272b8SAndroid Build Coastguard Worker {
195*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
196*2d1272b8SAndroid Build Coastguard Worker
197*2d1272b8SAndroid Build Coastguard Worker c->push_group ();
198*2d1272b8SAndroid Build Coastguard Worker }
199*2d1272b8SAndroid Build Coastguard Worker
200*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_pop_group(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_paint_composite_mode_t mode,void * user_data HB_UNUSED)201*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_pop_group (hb_paint_funcs_t *funcs HB_UNUSED,
202*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
203*2d1272b8SAndroid Build Coastguard Worker hb_paint_composite_mode_t mode,
204*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
205*2d1272b8SAndroid Build Coastguard Worker {
206*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
207*2d1272b8SAndroid Build Coastguard Worker
208*2d1272b8SAndroid Build Coastguard Worker c->pop_group (mode);
209*2d1272b8SAndroid Build Coastguard Worker }
210*2d1272b8SAndroid Build Coastguard Worker
211*2d1272b8SAndroid Build Coastguard Worker static hb_bool_t
hb_paint_extents_paint_image(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_blob_t * blob HB_UNUSED,unsigned int width HB_UNUSED,unsigned int height HB_UNUSED,hb_tag_t format HB_UNUSED,float slant HB_UNUSED,hb_glyph_extents_t * glyph_extents,void * user_data HB_UNUSED)212*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_paint_image (hb_paint_funcs_t *funcs HB_UNUSED,
213*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
214*2d1272b8SAndroid Build Coastguard Worker hb_blob_t *blob HB_UNUSED,
215*2d1272b8SAndroid Build Coastguard Worker unsigned int width HB_UNUSED,
216*2d1272b8SAndroid Build Coastguard Worker unsigned int height HB_UNUSED,
217*2d1272b8SAndroid Build Coastguard Worker hb_tag_t format HB_UNUSED,
218*2d1272b8SAndroid Build Coastguard Worker float slant HB_UNUSED,
219*2d1272b8SAndroid Build Coastguard Worker hb_glyph_extents_t *glyph_extents,
220*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
221*2d1272b8SAndroid Build Coastguard Worker {
222*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
223*2d1272b8SAndroid Build Coastguard Worker
224*2d1272b8SAndroid Build Coastguard Worker hb_extents_t extents = {(float) glyph_extents->x_bearing,
225*2d1272b8SAndroid Build Coastguard Worker (float) glyph_extents->y_bearing + glyph_extents->height,
226*2d1272b8SAndroid Build Coastguard Worker (float) glyph_extents->x_bearing + glyph_extents->width,
227*2d1272b8SAndroid Build Coastguard Worker (float) glyph_extents->y_bearing};
228*2d1272b8SAndroid Build Coastguard Worker c->push_clip (extents);
229*2d1272b8SAndroid Build Coastguard Worker c->paint ();
230*2d1272b8SAndroid Build Coastguard Worker c->pop_clip ();
231*2d1272b8SAndroid Build Coastguard Worker
232*2d1272b8SAndroid Build Coastguard Worker return true;
233*2d1272b8SAndroid Build Coastguard Worker }
234*2d1272b8SAndroid Build Coastguard Worker
235*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_paint_color(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_bool_t use_foreground HB_UNUSED,hb_color_t color HB_UNUSED,void * user_data HB_UNUSED)236*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_paint_color (hb_paint_funcs_t *funcs HB_UNUSED,
237*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
238*2d1272b8SAndroid Build Coastguard Worker hb_bool_t use_foreground HB_UNUSED,
239*2d1272b8SAndroid Build Coastguard Worker hb_color_t color HB_UNUSED,
240*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
241*2d1272b8SAndroid Build Coastguard Worker {
242*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
243*2d1272b8SAndroid Build Coastguard Worker
244*2d1272b8SAndroid Build Coastguard Worker c->paint ();
245*2d1272b8SAndroid Build Coastguard Worker }
246*2d1272b8SAndroid Build Coastguard Worker
247*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_paint_linear_gradient(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_color_line_t * color_line HB_UNUSED,float x0 HB_UNUSED,float y0 HB_UNUSED,float x1 HB_UNUSED,float y1 HB_UNUSED,float x2 HB_UNUSED,float y2 HB_UNUSED,void * user_data HB_UNUSED)248*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_paint_linear_gradient (hb_paint_funcs_t *funcs HB_UNUSED,
249*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
250*2d1272b8SAndroid Build Coastguard Worker hb_color_line_t *color_line HB_UNUSED,
251*2d1272b8SAndroid Build Coastguard Worker float x0 HB_UNUSED, float y0 HB_UNUSED,
252*2d1272b8SAndroid Build Coastguard Worker float x1 HB_UNUSED, float y1 HB_UNUSED,
253*2d1272b8SAndroid Build Coastguard Worker float x2 HB_UNUSED, float y2 HB_UNUSED,
254*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
255*2d1272b8SAndroid Build Coastguard Worker {
256*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
257*2d1272b8SAndroid Build Coastguard Worker
258*2d1272b8SAndroid Build Coastguard Worker c->paint ();
259*2d1272b8SAndroid Build Coastguard Worker }
260*2d1272b8SAndroid Build Coastguard Worker
261*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_paint_radial_gradient(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_color_line_t * color_line HB_UNUSED,float x0 HB_UNUSED,float y0 HB_UNUSED,float r0 HB_UNUSED,float x1 HB_UNUSED,float y1 HB_UNUSED,float r1 HB_UNUSED,void * user_data HB_UNUSED)262*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_paint_radial_gradient (hb_paint_funcs_t *funcs HB_UNUSED,
263*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
264*2d1272b8SAndroid Build Coastguard Worker hb_color_line_t *color_line HB_UNUSED,
265*2d1272b8SAndroid Build Coastguard Worker float x0 HB_UNUSED, float y0 HB_UNUSED, float r0 HB_UNUSED,
266*2d1272b8SAndroid Build Coastguard Worker float x1 HB_UNUSED, float y1 HB_UNUSED, float r1 HB_UNUSED,
267*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
268*2d1272b8SAndroid Build Coastguard Worker {
269*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
270*2d1272b8SAndroid Build Coastguard Worker
271*2d1272b8SAndroid Build Coastguard Worker c->paint ();
272*2d1272b8SAndroid Build Coastguard Worker }
273*2d1272b8SAndroid Build Coastguard Worker
274*2d1272b8SAndroid Build Coastguard Worker static void
hb_paint_extents_paint_sweep_gradient(hb_paint_funcs_t * funcs HB_UNUSED,void * paint_data,hb_color_line_t * color_line HB_UNUSED,float cx HB_UNUSED,float cy HB_UNUSED,float start_angle HB_UNUSED,float end_angle HB_UNUSED,void * user_data HB_UNUSED)275*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_paint_sweep_gradient (hb_paint_funcs_t *funcs HB_UNUSED,
276*2d1272b8SAndroid Build Coastguard Worker void *paint_data,
277*2d1272b8SAndroid Build Coastguard Worker hb_color_line_t *color_line HB_UNUSED,
278*2d1272b8SAndroid Build Coastguard Worker float cx HB_UNUSED, float cy HB_UNUSED,
279*2d1272b8SAndroid Build Coastguard Worker float start_angle HB_UNUSED,
280*2d1272b8SAndroid Build Coastguard Worker float end_angle HB_UNUSED,
281*2d1272b8SAndroid Build Coastguard Worker void *user_data HB_UNUSED)
282*2d1272b8SAndroid Build Coastguard Worker {
283*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_context_t *c = (hb_paint_extents_context_t *) paint_data;
284*2d1272b8SAndroid Build Coastguard Worker
285*2d1272b8SAndroid Build Coastguard Worker c->paint ();
286*2d1272b8SAndroid Build Coastguard Worker }
287*2d1272b8SAndroid Build Coastguard Worker
288*2d1272b8SAndroid Build Coastguard Worker static inline void free_static_paint_extents_funcs ();
289*2d1272b8SAndroid Build Coastguard Worker
290*2d1272b8SAndroid Build Coastguard Worker static struct hb_paint_extents_funcs_lazy_loader_t : hb_paint_funcs_lazy_loader_t<hb_paint_extents_funcs_lazy_loader_t>
291*2d1272b8SAndroid Build Coastguard Worker {
createhb_paint_extents_funcs_lazy_loader_t292*2d1272b8SAndroid Build Coastguard Worker static hb_paint_funcs_t *create ()
293*2d1272b8SAndroid Build Coastguard Worker {
294*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_t *funcs = hb_paint_funcs_create ();
295*2d1272b8SAndroid Build Coastguard Worker
296*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_push_transform_func (funcs, hb_paint_extents_push_transform, nullptr, nullptr);
297*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_pop_transform_func (funcs, hb_paint_extents_pop_transform, nullptr, nullptr);
298*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_push_clip_glyph_func (funcs, hb_paint_extents_push_clip_glyph, nullptr, nullptr);
299*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_push_clip_rectangle_func (funcs, hb_paint_extents_push_clip_rectangle, nullptr, nullptr);
300*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_pop_clip_func (funcs, hb_paint_extents_pop_clip, nullptr, nullptr);
301*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_push_group_func (funcs, hb_paint_extents_push_group, nullptr, nullptr);
302*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_pop_group_func (funcs, hb_paint_extents_pop_group, nullptr, nullptr);
303*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_color_func (funcs, hb_paint_extents_paint_color, nullptr, nullptr);
304*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_image_func (funcs, hb_paint_extents_paint_image, nullptr, nullptr);
305*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_linear_gradient_func (funcs, hb_paint_extents_paint_linear_gradient, nullptr, nullptr);
306*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_radial_gradient_func (funcs, hb_paint_extents_paint_radial_gradient, nullptr, nullptr);
307*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_set_sweep_gradient_func (funcs, hb_paint_extents_paint_sweep_gradient, nullptr, nullptr);
308*2d1272b8SAndroid Build Coastguard Worker
309*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_make_immutable (funcs);
310*2d1272b8SAndroid Build Coastguard Worker
311*2d1272b8SAndroid Build Coastguard Worker hb_atexit (free_static_paint_extents_funcs);
312*2d1272b8SAndroid Build Coastguard Worker
313*2d1272b8SAndroid Build Coastguard Worker return funcs;
314*2d1272b8SAndroid Build Coastguard Worker }
315*2d1272b8SAndroid Build Coastguard Worker } static_paint_extents_funcs;
316*2d1272b8SAndroid Build Coastguard Worker
317*2d1272b8SAndroid Build Coastguard Worker static inline
free_static_paint_extents_funcs()318*2d1272b8SAndroid Build Coastguard Worker void free_static_paint_extents_funcs ()
319*2d1272b8SAndroid Build Coastguard Worker {
320*2d1272b8SAndroid Build Coastguard Worker static_paint_extents_funcs.free_instance ();
321*2d1272b8SAndroid Build Coastguard Worker }
322*2d1272b8SAndroid Build Coastguard Worker
323*2d1272b8SAndroid Build Coastguard Worker hb_paint_funcs_t *
hb_paint_extents_get_funcs()324*2d1272b8SAndroid Build Coastguard Worker hb_paint_extents_get_funcs ()
325*2d1272b8SAndroid Build Coastguard Worker {
326*2d1272b8SAndroid Build Coastguard Worker return static_paint_extents_funcs.get_unconst ();
327*2d1272b8SAndroid Build Coastguard Worker }
328*2d1272b8SAndroid Build Coastguard Worker
329*2d1272b8SAndroid Build Coastguard Worker
330*2d1272b8SAndroid Build Coastguard Worker #endif
331