[gtk/wip/chergert/glproto: 216/493] return false when texture id is 0




commit 5ab11884ab4b82f8572f4e19f955048ecec83312
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 20 11:50:41 2021 -0800

    return false when texture id is 0
    
    since there is nothing to draw for the glyph, we want to break out early
    in the text node processing.

 gsk/next/gskglglyphlibraryprivate.h | 13 +++++++------
 gsk/next/gskglrenderjob.c           |  2 ++
 2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/gsk/next/gskglglyphlibraryprivate.h b/gsk/next/gskglglyphlibraryprivate.h
index 3e7a286148..d95001c5ff 100644
--- a/gsk/next/gskglglyphlibraryprivate.h
+++ b/gsk/next/gskglglyphlibraryprivate.h
@@ -88,18 +88,19 @@ gsk_gl_glyph_library_lookup_or_add (GskGLGlyphLibrary      *self,
                                     const GskGLGlyphValue **out_value)
 {
   GskGLTextureAtlasEntry *entry;
-  GskGLGlyphKey *k;
 
   if G_LIKELY (gsk_gl_texture_library_lookup ((GskGLTextureLibrary *)self, key, &entry))
     {
       *out_value = (GskGLGlyphValue *)entry;
-      return TRUE;
+    }
+  else
+    {
+      GskGLGlyphKey *k = g_slice_copy (sizeof *key, key);
+      g_object_ref (k->font);
+      gsk_gl_glyph_library_add (self, k, out_value);
     }
 
-  k = g_slice_copy (sizeof *key, key);
-  g_object_ref (k->font);
-
-  return gsk_gl_glyph_library_add (self, k, out_value);
+  return GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (*out_value) != 0;
 }
 
 G_END_DECLS
diff --git a/gsk/next/gskglrenderjob.c b/gsk/next/gskglrenderjob.c
index fbc3677009..76c92ffaaa 100644
--- a/gsk/next/gskglrenderjob.c
+++ b/gsk/next/gskglrenderjob.c
@@ -2544,6 +2544,8 @@ gsk_gl_render_job_visit_text_node (GskGLRenderJob *job,
 
       texture_id = GSK_GL_TEXTURE_ATLAS_ENTRY_TEXTURE (glyph);
 
+      g_assert (texture_id > 0);
+
       if G_UNLIKELY (last_texture != texture_id)
         {
           gsk_gl_program_end_draw (program);


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