[gnome-shell] st-texture-cache: Save cairo surfaces to a different map
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-texture-cache: Save cairo surfaces to a different map
- Date: Wed, 20 Jun 2018 22:58:49 +0000 (UTC)
commit 1f03599d1cf888f73a33363212b99905064e2c9e
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Apr 17 04:53:02 2018 -0500
st-texture-cache: Save cairo surfaces to a different map
The default keyed_surface is meant to handle CoglTextures thus we can't
add cairo surfaces to it, as the DestroyNotify function won't handle them.
Then the quicker way is to just add another Hash table for handling
such types of textures, with proper destroy function.
src/st/st-texture-cache.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 58185120e..0c794a3ab 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -37,6 +37,7 @@ struct _StTextureCachePrivate
/* Things that were loaded with a cache policy != NONE */
GHashTable *keyed_cache; /* char * -> CoglTexture* */
+ GHashTable *keyed_surface_cache; /* char * -> cairo_surface_t* */
/* Presently this is used to de-duplicate requests for GIcons and async URIs. */
GHashTable *outstanding_requests; /* char * -> AsyncTextureLoadData * */
@@ -145,6 +146,10 @@ st_texture_cache_init (StTextureCache *self)
self->priv->keyed_cache = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, cogl_object_unref);
+ self->priv->keyed_surface_cache = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify) cairo_surface_destroy);
self->priv->outstanding_requests = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
self->priv->file_monitors = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal,
@@ -166,6 +171,7 @@ st_texture_cache_dispose (GObject *object)
}
g_clear_pointer (&self->priv->keyed_cache, g_hash_table_destroy);
+ g_clear_pointer (&self->priv->keyed_surface_cache, g_hash_table_destroy);
g_clear_pointer (&self->priv->outstanding_requests, g_hash_table_destroy);
g_clear_pointer (&self->priv->file_monitors, g_hash_table_destroy);
@@ -988,7 +994,7 @@ file_changed_cb (GFileMonitor *monitor,
g_free (key);
key = g_strdup_printf (CACHE_PREFIX_FILE_FOR_CAIRO "%u", file_hash);
- g_hash_table_remove (cache->priv->keyed_cache, key);
+ g_hash_table_remove (cache->priv->keyed_surface_cache, key);
g_free (key);
g_signal_emit (cache, signals[TEXTURE_FILE_CHANGED], 0, file);
@@ -1309,7 +1315,7 @@ st_texture_cache_load_file_sync_to_cairo_surface (StTextureCache *cache,
key = g_strdup_printf (CACHE_PREFIX_FILE_FOR_CAIRO "%u", g_file_hash (file));
- surface = g_hash_table_lookup (cache->priv->keyed_cache, key);
+ surface = g_hash_table_lookup (cache->priv->keyed_surface_cache, key);
if (surface == NULL)
{
@@ -1323,7 +1329,8 @@ st_texture_cache_load_file_sync_to_cairo_surface (StTextureCache *cache,
if (policy == ST_TEXTURE_CACHE_POLICY_FOREVER)
{
cairo_surface_reference (surface);
- g_hash_table_insert (cache->priv->keyed_cache, g_strdup (key), surface);
+ g_hash_table_insert (cache->priv->keyed_surface_cache,
+ g_strdup (key), surface);
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]