gsk: Avoid empty glyphs early

Strip out PANGO_GLYPH_EMPTY when text nodes are
constructed. Then we don't have to check this special
case in the inner loop in visit_text_node.
This commit is contained in:
Matthias Clasen
2021-03-28 20:22:24 -04:00
parent 3add99a9a8
commit 2c33550048
2 changed files with 8 additions and 5 deletions

View File

@@ -4435,9 +4435,15 @@ gsk_text_node_new (PangoFont *font,
self->has_color_glyphs = font_has_color_glyphs (font);
self->color = *color;
self->offset = *offset;
self->num_glyphs = glyphs->num_glyphs;
self->glyphs = g_malloc_n (glyphs->num_glyphs, sizeof (PangoGlyphInfo));
memcpy (self->glyphs, glyphs->glyphs, glyphs->num_glyphs * sizeof (PangoGlyphInfo));
/* skip empty glyphs */
self->num_glyphs = 0;
for (int i = 0; i < glyphs->num_glyphs; i++)
{
if (glyphs->glyphs[i].glyph != PANGO_GLYPH_EMPTY)
self->glyphs[self->num_glyphs++] = glyphs->glyphs[i];
}
graphene_rect_init (&node->bounds,
offset->x + ink_rect.x - 1,

View File

@@ -2720,9 +2720,6 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
float cy;
guint texture_id;
if G_UNLIKELY (gi->glyph == PANGO_GLYPH_EMPTY)
continue;
lookup.glyph = gi->glyph;
cx = (float)(x_position + gi->geometry.x_offset) / PANGO_SCALE;