[paint-extents] Lazy-load paint_extents funcs

This commit is contained in:
Behdad Esfahbod 2022-12-24 11:40:44 -07:00
parent 4280ed290d
commit 1c595ec17f
3 changed files with 37 additions and 22 deletions

View File

@ -479,8 +479,6 @@ hb_ft_paint_glyph_colr (hb_font_t *font,
extents.ymin,
extents.xmax,
extents.ymax);
hb_paint_funcs_destroy (extents_funcs);
}
paint_funcs->push_root_transform (paint_data, font);

View File

@ -2008,8 +2008,6 @@ struct COLR
extents->width = e.xmax - e.xmin;
extents->height = e.ymin - e.ymax;
hb_paint_funcs_destroy (extents_funcs);
return true;
}
@ -2067,8 +2065,6 @@ struct COLR
extents.xmax,
extents.ymax);
hb_paint_funcs_destroy (extents_funcs);
c.funcs->push_root_transform (c.data, font);
pop_clip_first = false;

View File

@ -122,6 +122,7 @@ static struct hb_draw_extents_funcs_lazy_loader_t : hb_draw_funcs_lazy_loader_t<
static hb_draw_funcs_t *create ()
{
hb_draw_funcs_t *funcs = hb_draw_funcs_create ();
hb_draw_funcs_set_move_to_func (funcs, hb_draw_extents_move_to, nullptr, nullptr);
hb_draw_funcs_set_line_to_func (funcs, hb_draw_extents_line_to, nullptr, nullptr);
hb_draw_funcs_set_cubic_to_func (funcs, hb_draw_extents_cubic_to, nullptr, nullptr);
@ -281,8 +282,11 @@ hb_paint_extents_paint_sweep_gradient (hb_paint_funcs_t *funcs HB_UNUSED,
c->paint ();
}
hb_paint_funcs_t *
hb_paint_extents_get_funcs ()
static inline void free_static_paint_extents_funcs ();
static struct hb_paint_extents_funcs_lazy_loader_t : hb_paint_funcs_lazy_loader_t<hb_paint_extents_funcs_lazy_loader_t>
{
static hb_paint_funcs_t *create ()
{
hb_paint_funcs_t *funcs = hb_paint_funcs_create ();
@ -299,5 +303,22 @@ hb_paint_extents_get_funcs ()
hb_paint_funcs_set_radial_gradient_func (funcs, hb_paint_extents_paint_radial_gradient, nullptr, nullptr);
hb_paint_funcs_set_sweep_gradient_func (funcs, hb_paint_extents_paint_sweep_gradient, nullptr, nullptr);
hb_paint_funcs_make_immutable (funcs);
hb_atexit (free_static_paint_extents_funcs);
return funcs;
}
} static_paint_extents_funcs;
static inline
void free_static_paint_extents_funcs ()
{
static_paint_extents_funcs.free_instance ();
}
hb_paint_funcs_t *
hb_paint_extents_get_funcs ()
{
return static_paint_extents_funcs.get_unconst ();
}