Add gsk_text_node_get_font_hint_style

Getting the hint style is one of the more expensive calls we do
when adding glyph nodes, so cache this information in the node.
This commit is contained in:
Matthias Clasen 2024-09-08 11:07:28 -04:00
parent 59f334622b
commit 4f9fd5cf1d
3 changed files with 17 additions and 1 deletions

View File

@ -3009,6 +3009,7 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
unsigned int flags_mask;
GskGpuImage *last_image;
const float inv_pango_scale = 1.f / PANGO_SCALE;
cairo_hint_style_t hint_style;
if (self->opacity < 1.0 &&
gsk_text_node_has_color_glyphs (node))
@ -3023,12 +3024,14 @@ gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
glyphs = gsk_text_node_get_glyphs (node, NULL);
font = gsk_text_node_get_font (node);
offset = *gsk_text_node_get_offset (node);
hint_style = gsk_text_node_get_font_hint_style (node);
offset.x += self->offset.x;
offset.y += self->offset.y;
scale = MAX (graphene_vec2_get_x (&self->scale), graphene_vec2_get_y (&self->scale));
if (gsk_font_get_hint_style (font) != CAIRO_HINT_STYLE_NONE)
if (hint_style != CAIRO_HINT_STYLE_NONE)
{
align_scale_x = scale * 4;
align_scale_y = scale;

View File

@ -6332,6 +6332,7 @@ struct _GskTextNode
PangoFontMap *fontmap;
PangoFont *font;
gboolean has_color_glyphs;
cairo_hint_style_t hint_style;
GdkColor color;
graphene_point_t offset;
@ -6513,6 +6514,7 @@ gsk_text_node_new2 (PangoFont *font,
gdk_color_init_copy (&self->color, color);
self->offset = *offset;
self->has_color_glyphs = FALSE;
self->hint_style = gsk_font_get_hint_style (font);
glyph_infos = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
@ -6596,6 +6598,14 @@ gsk_text_node_get_font (const GskRenderNode *node)
return self->font;
}
cairo_hint_style_t
gsk_text_node_get_font_hint_style (const GskRenderNode *node)
{
const GskTextNode *self = (const GskTextNode *) node;
return self->hint_style;
}
/**
* gsk_text_node_has_color_glyphs:
* @node: (type GskTextNode): a text `GskRenderNode`

View File

@ -100,6 +100,9 @@ bool gsk_border_node_get_uniform_color (const GskRenderNode
void gsk_text_node_serialize_glyphs (GskRenderNode *self,
GString *str);
cairo_hint_style_t
gsk_text_node_get_font_hint_style (const GskRenderNode *self) G_GNUC_PURE;
GskRenderNode ** gsk_container_node_get_children (const GskRenderNode *node,
guint *n_children);