mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
gl: Don't leak texture atlases
We need to free the texture atlases, and the textures backing them.
This commit is contained in:
parent
a3757936c1
commit
f37274dbb0
@ -20,6 +20,17 @@ icon_data_free (gpointer p)
|
||||
g_free (p);
|
||||
}
|
||||
|
||||
static void
|
||||
free_atlas (gpointer v)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = v;
|
||||
|
||||
g_assert (atlas->image.texture_id == 0);
|
||||
gsk_gl_texture_atlas_free (atlas);
|
||||
|
||||
g_free (atlas);
|
||||
}
|
||||
|
||||
void
|
||||
gsk_gl_icon_cache_init (GskGLIconCache *self,
|
||||
GskRenderer *renderer,
|
||||
@ -28,7 +39,7 @@ gsk_gl_icon_cache_init (GskGLIconCache *self,
|
||||
self->renderer = renderer;
|
||||
self->gl_driver = gl_driver;
|
||||
|
||||
self->atlases = g_ptr_array_new ();
|
||||
self->atlases = g_ptr_array_new_with_free_func ((GDestroyNotify)free_atlas);
|
||||
self->icons = g_hash_table_new_full (NULL, NULL, NULL, icon_data_free);
|
||||
}
|
||||
|
||||
@ -41,7 +52,14 @@ gsk_gl_icon_cache_free (GskGLIconCache *self)
|
||||
{
|
||||
GskGLTextureAtlas *atlas = g_ptr_array_index (self->atlases, i);
|
||||
|
||||
if (atlas->image.texture_id != 0)
|
||||
{
|
||||
gsk_gl_image_destroy (&atlas->image, self->gl_driver);
|
||||
atlas->image.texture_id = 0;
|
||||
}
|
||||
|
||||
gsk_gl_texture_atlas_free (atlas);
|
||||
|
||||
g_free (atlas);
|
||||
}
|
||||
g_ptr_array_free (self->atlases, TRUE);
|
||||
@ -92,6 +110,12 @@ gsk_gl_icon_cache_begin_frame (GskGLIconCache *self)
|
||||
g_hash_table_iter_remove (&iter);
|
||||
}
|
||||
|
||||
if (atlas->image.texture_id != 0)
|
||||
{
|
||||
gsk_gl_image_destroy (&atlas->image, self->gl_driver);
|
||||
atlas->image.texture_id = 0;
|
||||
}
|
||||
|
||||
g_ptr_array_remove_index_fast (self->atlases, i);
|
||||
i --; /* Check the current index again */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user