[gtk/readonly-all-the-things: 2/2] Revert "Cache glyph textures in render nodes"



commit 537b7ca9e2f6797341d6a61157b3b5bfa962de13
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 22 01:34:56 2019 -0400

    Revert "Cache glyph textures in render nodes"
    
    This reverts commit c5af4638434e39a0c224afb62252caed233c2acb.

 gsk/gl/gskglglyphcache.c        | 25 +++++++------------
 gsk/gl/gskglglyphcacheprivate.h |  3 ---
 gsk/gl/gskglrenderer.c          | 53 ++++-------------------------------------
 gsk/gskrendernodeimpl.c         | 21 ----------------
 gsk/gskrendernodeprivate.h      |  4 ----
 5 files changed, 14 insertions(+), 92 deletions(-)
---
diff --git a/gsk/gl/gskglglyphcache.c b/gsk/gl/gskglglyphcache.c
index 07b6389915..d61c530fd8 100644
--- a/gsk/gl/gskglglyphcache.c
+++ b/gsk/gl/gskglglyphcache.c
@@ -262,7 +262,13 @@ gsk_gl_glyph_cache_lookup_or_add (GskGLGlyphCache         *cache,
 
   if (value)
     {
-      gsk_gl_glyph_cache_entry_validate (cache, value);
+      if (value->atlas && !value->used)
+        {
+          gsk_gl_texture_atlas_mark_used (value->atlas, value->draw_width, value->draw_height);
+          value->used = TRUE;
+        }
+      value->accessed = TRUE;
+
       *cached_glyph_out = value;
       return;
     }
@@ -320,6 +326,8 @@ gsk_gl_glyph_cache_begin_frame (GskGLGlyphCache *self,
 
   if (removed_atlases->len > 0)
     {
+      guint dropped = 0;
+
       g_hash_table_iter_init (&iter, self->hash_table);
       while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&value))
         {
@@ -366,19 +374,4 @@ gsk_gl_glyph_cache_begin_frame (GskGLGlyphCache *self,
     }
 
   GSK_NOTE(GLYPH_CACHE, if (dropped > 0) g_message ("Dropped %d glyphs", dropped));
-
-  if (dropped > 0)
-    self->atlas_timestamp++;
-}
-
-void
-gsk_gl_glyph_cache_entry_validate (GskGLGlyphCache  *cache,
-                                   GskGLCachedGlyph *value)
-{
-  value->accessed = TRUE;
-  if (value->atlas && !value->used)
-    {
-      gsk_gl_texture_atlas_mark_used (value->atlas, value->draw_width, value->draw_height);
-      value->used = TRUE;
-    }
 }
diff --git a/gsk/gl/gskglglyphcacheprivate.h b/gsk/gl/gskglglyphcacheprivate.h
index 492890e603..d66b251a44 100644
--- a/gsk/gl/gskglglyphcacheprivate.h
+++ b/gsk/gl/gskglglyphcacheprivate.h
@@ -16,7 +16,6 @@ typedef struct
   GskGLTextureAtlases *atlases;
 
   int timestamp;
-  int atlas_timestamp; /* incremented whenever an atlas is dropped */
 } GskGLGlyphCache;
 
 struct _CacheKeyData
@@ -89,7 +88,5 @@ void                     gsk_gl_glyph_cache_lookup_or_add   (GskGLGlyphCache
                                                              GlyphCacheKey          *lookup,
                                                              GskGLDriver            *driver,
                                                              const GskGLCachedGlyph **cached_glyph_out);
-void                    gsk_gl_glyph_cache_entry_validate   (GskGLGlyphCache *cache,
-                                                             GskGLCachedGlyph *entry);
 
 #endif
diff --git a/gsk/gl/gskglrenderer.c b/gsk/gl/gskglrenderer.c
index b39edcca4f..de9ccf1539 100644
--- a/gsk/gl/gskglrenderer.c
+++ b/gsk/gl/gskglrenderer.c
@@ -535,39 +535,6 @@ render_fallback_node (GskGLRenderer       *self,
   ops_draw (builder, offscreen_vertex_data);
 }
 
-typedef struct {
-  int timestamp;
-  GskGLCachedGlyph *glyphs[];
-} TextRenderData;
-
-static inline TextRenderData *
-ensure_render_data (GskRenderNode *node,
-                    GskGLGlyphCache *cache)
-{
-  TextRenderData *data;
-  int num_glyphs;
-
-  num_glyphs = gsk_text_node_get_num_glyphs (node);
-  data = gsk_text_node_get_render_data (node);
-  if (data)
-    {
-      if (data->timestamp < cache->atlas_timestamp)
-        {
-          memset (data->glyphs, 0, sizeof (gpointer) * num_glyphs);
-          data->timestamp = cache->atlas_timestamp;
-        }
-    }
-  else
-    {
-      data = g_new0 (TextRenderData, sizeof (TextRenderData) + sizeof (gpointer) * num_glyphs);
-      data->timestamp = cache->atlas_timestamp;
-
-      gsk_text_node_set_render_data (node, data);
-    }
-
-  return data;
-}
-
 static inline void
 render_text_node (GskGLRenderer   *self,
                   GskRenderNode   *node,
@@ -585,7 +552,6 @@ render_text_node (GskGLRenderer   *self,
   float x = offset->x + builder->dx;
   float y = offset->y + builder->dy;
   GlyphCacheKey lookup;
-  TextRenderData *render_data;
 
   /* If the font has color glyphs, we don't need to recolor anything */
   if (!force_color && gsk_text_node_has_color_glyphs (node))
@@ -598,8 +564,6 @@ render_text_node (GskGLRenderer   *self,
       ops_set_color (builder, color);
     }
 
-  render_data = ensure_render_data (node, self->glyph_cache);
-
   memset (&lookup, 0, sizeof (CacheKeyData));
   lookup.data.font = (PangoFont *)font;
   lookup.data.scale = (guint) (text_scale * 1024);
@@ -621,19 +585,12 @@ render_text_node (GskGLRenderer   *self,
       cx = (float)(x_position + gi->geometry.x_offset) / PANGO_SCALE;
       cy = (float)(gi->geometry.y_offset) / PANGO_SCALE;
 
-      glyph = render_data->glyphs[i];
-      if (!glyph)
-        {
-          glyph_cache_key_set_glyph_and_shift (&lookup, gi->glyph, x + cx, y + cy);
-
-          gsk_gl_glyph_cache_lookup_or_add (self->glyph_cache,
-                                            &lookup,
-                                            self->gl_driver,
-                                            &glyph);
-          render_data->glyphs[i] = (GskGLCachedGlyph *)glyph;
-        }
+      glyph_cache_key_set_glyph_and_shift (&lookup, gi->glyph, x + cx, y + cy);
 
-      gsk_gl_glyph_cache_entry_validate (self->glyph_cache, render_data->glyphs[i]);
+      gsk_gl_glyph_cache_lookup_or_add (self->glyph_cache,
+                                        &lookup,
+                                        self->gl_driver,
+                                        &glyph);
 
       if (glyph->texture_id == 0)
         goto next;
diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c
index c362a6fa53..8c7be01555 100644
--- a/gsk/gskrendernodeimpl.c
+++ b/gsk/gskrendernodeimpl.c
@@ -3414,7 +3414,6 @@ struct _GskTextNode
   GdkRGBA color;
   graphene_point_t offset;
 
-  gpointer render_data;
   guint num_glyphs;
   PangoGlyphInfo glyphs[];
 };
@@ -3424,7 +3423,6 @@ gsk_text_node_finalize (GskRenderNode *node)
 {
   GskTextNode *self = (GskTextNode *) node;
 
-  g_free (self->render_data);
   g_object_unref (self->font);
 }
 
@@ -3547,7 +3545,6 @@ gsk_text_node_new (PangoFont              *font,
   self->has_color_glyphs = font_has_color_glyphs (font);
   self->color = *color;
   self->offset = *offset;
-  self->render_data = NULL;
   self->num_glyphs = glyphs->num_glyphs;
   memcpy (self->glyphs, glyphs->glyphs, sizeof (PangoGlyphInfo) * glyphs->num_glyphs);
 
@@ -3628,24 +3625,6 @@ gsk_text_node_get_offset (GskRenderNode *node)
   return &self->offset;
 }
 
-void
-gsk_text_node_set_render_data (GskRenderNode *node,
-                               gpointer       data)
-{
-  GskTextNode *self = (GskTextNode *) node;
-
-  self->render_data = data;
-}
-
-gpointer
-gsk_text_node_get_render_data (GskRenderNode *node)
-{
-  GskTextNode *self = (GskTextNode *) node;
-
-  return self->render_data;
-}
-
-
 /*** GSK_BLUR_NODE ***/
 
 typedef struct _GskBlurNode GskBlurNode;
diff --git a/gsk/gskrendernodeprivate.h b/gsk/gskrendernodeprivate.h
index f2fe034444..2ced79738b 100644
--- a/gsk/gskrendernodeprivate.h
+++ b/gsk/gskrendernodeprivate.h
@@ -46,10 +46,6 @@ void            gsk_render_node_diff             (GskRenderNode             *nod
 void            gsk_render_node_diff_impossible  (GskRenderNode             *node1,
                                                   GskRenderNode             *node2,
                                                   cairo_region_t            *region);
-void            gsk_text_node_set_render_data    (GskRenderNode *node,
-                                                  gpointer       data);
-gpointer        gsk_text_node_get_render_data    (GskRenderNode *node);
-                                                  
 
 
 G_END_DECLS


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