[gnome-shell/gbsneto/clutter-image-on-texture-cache: 2/2] texture-cache: Avoid creating unnecessary ClutterImages
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/clutter-image-on-texture-cache: 2/2] texture-cache: Avoid creating unnecessary ClutterImages
- Date: Thu, 24 Jan 2019 16:08:27 +0000 (UTC)
commit 4f6ff7984a01bf547f99e72c069f4335f8229eaf
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Jan 24 13:57:40 2019 -0200
texture-cache: Avoid creating unnecessary ClutterImages
After loading the GdkPixbuf, StTextureCache unconditionally
creates a ClutterImage and, if it's not in the cache, add
it to the cache. That's a waste of resources when the image
is already committed to the texture cache.
Fix that by reusing the ClutterImage of the cache if it is
already there; otherwise, create a new ClutterImage as we
were previously doing.
src/st/st-texture-cache.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 5f98270bc..335b34415 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -530,20 +530,30 @@ finish_texture_load (AsyncTextureLoadData *data,
if (pixbuf == NULL)
goto out;
- image = pixbuf_to_clutter_image (pixbuf);
- if (!image)
- goto out;
-
if (data->policy != ST_TEXTURE_CACHE_POLICY_NONE)
{
- gpointer orig_key, value;
+ gpointer orig_key = NULL, value = NULL;
if (!g_hash_table_lookup_extended (cache->priv->keyed_cache, data->key,
&orig_key, &value))
{
+ image = pixbuf_to_clutter_image (pixbuf);
+ if (!image)
+ goto out;
+
g_hash_table_insert (cache->priv->keyed_cache, g_strdup (data->key),
g_object_ref (image));
}
+ else
+ {
+ image = g_object_ref (value);
+ }
+ }
+ else
+ {
+ image = pixbuf_to_clutter_image (pixbuf);
+ if (!image)
+ goto out;
}
for (iter = data->actors; iter; iter = iter->next)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]