[gtk+/wip/ebassi/gsk-renderer: 125/194] gtk: Add GtkContainer API to gather render nodes



commit cb3c4664f849438126a2a785db9ff09f5a1ce824
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Jul 27 09:40:29 2016 +0100

    gtk: Add GtkContainer API to gather render nodes
    
    We cannot implement GtkWidgetClass.get_render_node() in GtkContainer
    without breaking the fallback path that renders a widget to a single
    render node rasterization. For GtkContainer subclasses we should provide
    a simple API, similar to gtk_container_propagate_draw(), that gathers
    all the render nodes for each child.

 gtk/gtkcontainer.c        |   37 ++++++++++++++++++++++++++++++++++++-
 gtk/gtkcontainerprivate.h |    5 +++++
 2 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 44c6573..c5d792d 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -24,7 +24,6 @@
 
 #include "config.h"
 
-#include "gtkcontainer.h"
 #include "gtkcontainerprivate.h"
 
 #include <stdarg.h>
@@ -54,6 +53,7 @@
 #include "gtkpopovermenu.h"
 #include "gtkshortcutswindow.h"
 
+
 /* A handful of containers inside GTK+ are cheating and widgets
  * inside internal structure as direct children for the purpose
  * of forall().
@@ -3878,3 +3878,38 @@ gtk_container_get_path_for_child (GtkContainer *container,
 
   return path;
 }
+
+typedef struct {
+  GtkContainer *container;
+  GskRenderer *renderer;
+  GskRenderNode *parent;
+} RenderData;
+
+static void
+propagate_render_node (GtkWidget *widget,
+                       gpointer   data_)
+{
+  RenderData *data = data_;
+  GskRenderNode *node;
+
+  node = gtk_widget_get_render_node (widget, data->renderer);
+  if (node != NULL)
+    {
+      gsk_render_node_append_child (data->parent, node);
+      gsk_render_node_unref (node);
+    }
+}
+
+void
+gtk_container_propagate_render_node (GtkContainer  *container,
+                                     GskRenderer   *renderer,
+                                     GskRenderNode *parent_node)
+{
+  RenderData data = {
+    container,
+    renderer,
+    parent_node
+  };
+
+  gtk_container_forall (container, propagate_render_node, &data);
+}
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index 7402a66..04fd0a2 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -21,6 +21,7 @@
 #define __GTK_CONTAINER_PRIVATE_H__
 
 #include "gtkcontainer.h"
+#include <gsk/gsk.h>
 
 G_BEGIN_DECLS
 
@@ -47,6 +48,10 @@ void      gtk_container_get_children_clip       (GtkContainer  *container,
 void      gtk_container_set_default_resize_mode (GtkContainer *container,
                                                  GtkResizeMode resize_mode);
 
+void      gtk_container_propagate_render_node   (GtkContainer  *container,
+                                                 GskRenderer   *renderer,
+                                                 GskRenderNode *parent_node);
+
 G_END_DECLS
 
 #endif /* __GTK_CONTAINER_PRIVATE_H__ */


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