[gtk/wip/chergert/gsk-gl-texture-library: 4/11] gsk/gl: only clear glyph cache durign reclaimation




commit a66a0dde812a4544f3ef2579a6639d699b48cf9e
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 15 15:55:30 2022 -0700

    gsk/gl: only clear glyph cache durign reclaimation
    
    We don't need to clear the front cache on every frame as we can clear it
    specifically when we do reclaimation to avoid unnecessary memset() calls.

 gsk/gl/gskglglyphlibrary.c          | 8 ++++----
 gsk/gl/gskgltexturelibrary.c        | 8 ++++++++
 gsk/gl/gskgltexturelibraryprivate.h | 1 +
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gsk/gl/gskglglyphlibrary.c b/gsk/gl/gskglglyphlibrary.c
index b749384674..ee13198921 100644
--- a/gsk/gl/gskglglyphlibrary.c
+++ b/gsk/gl/gskglglyphlibrary.c
@@ -84,12 +84,12 @@ gsk_gl_glyph_value_free (gpointer data)
 }
 
 static void
-gsk_gl_glyph_library_begin_frame (GskGLTextureLibrary *library,
-                                  gint64               frame_id,
-                                  GPtrArray           *removed_atlases)
+gsk_gl_glyph_library_clear_cache (GskGLTextureLibrary *library)
 {
   GskGLGlyphLibrary *self = (GskGLGlyphLibrary *)library;
 
+  g_assert (GSK_IS_GL_GLYPH_LIBRARY (self));
+
   memset (self->front, 0, sizeof self->front);
 }
 
@@ -111,7 +111,7 @@ gsk_gl_glyph_library_class_init (GskGLGlyphLibraryClass *klass)
 
   object_class->finalize = gsk_gl_glyph_library_finalize;
 
-  library_class->begin_frame = gsk_gl_glyph_library_begin_frame;
+  library_class->clear_cache = gsk_gl_glyph_library_clear_cache;
 }
 
 static void
diff --git a/gsk/gl/gskgltexturelibrary.c b/gsk/gl/gskgltexturelibrary.c
index fadec60a0c..b0694e7afb 100644
--- a/gsk/gl/gskgltexturelibrary.c
+++ b/gsk/gl/gskgltexturelibrary.c
@@ -141,6 +141,7 @@ gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
                                     GPtrArray            *removed_atlases)
 {
   GHashTableIter iter;
+  gboolean drop_caches = FALSE;
 
   g_return_if_fail (GSK_IS_GL_TEXTURE_LIBRARY (self));
 
@@ -175,6 +176,8 @@ gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
                 if (dropped > 0)
                   g_message ("%s: Dropped %d items",
                              G_OBJECT_TYPE_NAME (self), dropped));
+
+      drop_caches |= dropped > 0;
     }
 
   if (frame_id % self->max_frame_age == 0)
@@ -208,7 +211,12 @@ gsk_gl_texture_library_begin_frame (GskGLTextureLibrary *self,
                                         g_hash_table_size (self->hash_table),
                                         atlased,
                                         g_hash_table_size (self->hash_table) - atlased));
+
+      drop_caches |= dropped > 0;
     }
+
+  if (drop_caches && GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->clear_cache)
+    GSK_GL_TEXTURE_LIBRARY_GET_CLASS (self)->clear_cache (self);
 }
 
 static GskGLTexture *
diff --git a/gsk/gl/gskgltexturelibraryprivate.h b/gsk/gl/gskgltexturelibraryprivate.h
index bb1db12172..39276ff69d 100644
--- a/gsk/gl/gskgltexturelibraryprivate.h
+++ b/gsk/gl/gskgltexturelibraryprivate.h
@@ -103,6 +103,7 @@ typedef struct _GskGLTextureLibraryClass
   void (*begin_frame) (GskGLTextureLibrary *library,
                        gint64               frame_id,
                        GPtrArray           *removed_atlases);
+  void (*clear_cache) (GskGLTextureLibrary *library);
 } GskGLTextureLibraryClass;
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GskGLTextureLibrary, g_object_unref)


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