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.
This commit is contained in:
committed by
Matthias Clasen
parent
615cf2a782
commit
3b147ad630
@@ -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
|
||||
|
||||
@@ -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 *
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user