gpu: Don't replace cache items

Instead, keep them. This is not useful yet, but will become so in the
next commits.
This commit is contained in:
Benjamin Otte 2024-07-06 16:55:48 +02:00
parent ad757cccb6
commit cf12503fec
3 changed files with 17 additions and 4 deletions

View File

@ -1061,6 +1061,14 @@ gdk_texture_set_render_data (GdkTexture *self,
return TRUE;
}
void
gdk_texture_steal_render_data (GdkTexture *self)
{
self->render_key = NULL;
self->render_data = NULL;
self->render_notify = NULL;
}
void
gdk_texture_clear_render_data (GdkTexture *self)
{

View File

@ -76,6 +76,7 @@ gboolean gdk_texture_set_render_data (GdkTexture
gpointer key,
gpointer data,
GDestroyNotify notify);
void gdk_texture_steal_render_data (GdkTexture *self);
void gdk_texture_clear_render_data (GdkTexture *self);
gpointer gdk_texture_get_render_data (GdkTexture *self,
gpointer key);

View File

@ -336,10 +336,14 @@ gsk_gpu_cached_texture_new (GskGpuCache *cache,
{
GskGpuCachedTexture *self;
if (gdk_texture_get_render_data (texture, cache))
gdk_texture_clear_render_data (texture);
else if ((self = g_hash_table_lookup (cache->texture_cache, texture)))
g_hash_table_remove (cache->texture_cache, texture);
/* First, move any existing renderdata */
self = gdk_texture_get_render_data (texture, cache);
if (self)
{
gdk_texture_steal_render_data (texture);
g_object_weak_ref (G_OBJECT (texture), (GWeakNotify) gsk_gpu_cached_texture_destroy_cb, self);
g_hash_table_insert (cache->texture_cache, texture, self);
}
self = gsk_gpu_cached_new (cache, &GSK_GPU_CACHED_TEXTURE_CLASS, NULL);
self->texture = texture;