[gtk+/wip/ebassi/gsk-1: 419/420] gsk: Flush the GL render items cache



commit fcb095fcf95de7d4218356a787d63121208e4b27
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Apr 26 14:23:12 2016 +0100

    gsk: Flush the GL render items cache
    
    Whenever the render tree changes we want to drop the RenderItem arrays,
    as each item contains a pointer to the GskRenderNode which becomes
    dangling once the root node changed.

 gsk/gskglrenderer.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 92a3304..c46d758 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -953,6 +953,30 @@ out:
 }
 
 static void
+gsk_gl_renderer_clear_tree (GskRenderer *renderer,
+                            GskRenderNode *root_node)
+{
+  GskGLRenderer *self = GSK_GL_RENDERER (renderer);
+
+  if (self->context == NULL)
+    return;
+
+  gdk_gl_context_make_current (self->context);
+
+  g_clear_pointer (&self->opaque_render_items, g_array_unref);
+  g_clear_pointer (&self->transparent_render_items, g_array_unref);
+
+  if (gsk_renderer_is_realized (renderer))
+    {
+      self->opaque_render_items = g_array_sized_new (FALSE, FALSE, sizeof (RenderItem), 16);
+      g_array_set_clear_func (self->opaque_render_items, render_item_clear);
+
+      self->transparent_render_items = g_array_sized_new (FALSE, FALSE, sizeof (RenderItem), 16);
+      g_array_set_clear_func (self->opaque_render_items, render_item_clear);
+    }
+}
+
+static void
 gsk_gl_renderer_clear (GskRenderer *renderer)
 {
 }
@@ -1051,6 +1075,7 @@ gsk_gl_renderer_class_init (GskGLRendererClass *klass)
   renderer_class->update = gsk_gl_renderer_update;
   renderer_class->clear = gsk_gl_renderer_clear;
   renderer_class->validate_tree = gsk_gl_renderer_validate_tree;
+  renderer_class->clear_tree = gsk_gl_renderer_clear_tree;
   renderer_class->render = gsk_gl_renderer_render;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]