[gtk/wip/matthiasc/opbuffer] gl: Speed up icon cache lookups
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/opbuffer] gl: Speed up icon cache lookups
- Date: Tue, 15 Oct 2019 12:28:24 +0000 (UTC)
commit f3280a2f0bdc392a027826dec1c83f492dd7aca4
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 15 08:27:16 2019 -0400
gl: Speed up icon cache lookups
Use gdk_texture_set_render_data to avoid
hash table lookups when we can.
gsk/gl/gskgliconcache.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/gsk/gl/gskgliconcache.c b/gsk/gl/gskgliconcache.c
index 7f2e30257e..fd96ae2101 100644
--- a/gsk/gl/gskgliconcache.c
+++ b/gsk/gl/gskgliconcache.c
@@ -10,7 +10,10 @@
static void
icon_data_free (gpointer p)
{
- g_object_unref (((IconData *)p)->source_texture);
+ IconData *icon_data = p;
+
+ gdk_texture_clear_render_data (icon_data->source_texture);
+ g_object_unref (icon_data->source_texture);
g_free (p);
}
@@ -69,7 +72,9 @@ gsk_gl_icon_cache_begin_frame (GskGLIconCache *self,
while (g_hash_table_iter_next (&iter, (gpointer *)&texture, (gpointer *)&icon_data))
{
if (g_ptr_array_find (removed_atlases, icon_data->atlas, NULL))
- g_hash_table_iter_remove (&iter);
+ {
+ g_hash_table_iter_remove (&iter);
+ }
}
}
@@ -101,7 +106,12 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
GdkTexture *texture,
const IconData **out_icon_data)
{
- IconData *icon_data = g_hash_table_lookup (self->icons, texture);
+ IconData *icon_data;
+
+ icon_data = gdk_texture_get_render_data (texture, self);
+
+ if (!icon_data)
+ icon_data = g_hash_table_lookup (self->icons, texture);
if (icon_data)
{
@@ -220,6 +230,8 @@ gsk_gl_icon_cache_lookup_or_add (GskGLIconCache *self,
gdk_gl_context_pop_debug_group (gdk_gl_context_get_current ());
+ gdk_texture_set_render_data (texture, self, icon_data, NULL);
+
*out_icon_data = icon_data;
cairo_surface_destroy (surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]