[gtk/ngl-text-tweaks: 6/8] gsk: Avoid empty glyphs early




commit 2afa443baae48d9618515e2c4b041a1d43da0e5d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 28 20:22:24 2021 -0400

    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.

 gsk/gskrendernodeimpl.c   | 10 ++++++++--
 gsk/ngl/gsknglrenderjob.c |  3 ---
 2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index d611977acc..c851954c54 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -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 (self->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,
diff --git a/gsk/ngl/gsknglrenderjob.c b/gsk/ngl/gsknglrenderjob.c
index b45f33b7a8..fa2c9c8cb9 100644
--- a/gsk/ngl/gsknglrenderjob.c
+++ b/gsk/ngl/gsknglrenderjob.c
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]