[gtk+/wip/ebassi/gsk-renderer: 470/545] gtk: Add GtkContainer API to gather render nodes
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 470/545] gtk: Add GtkContainer API to gather render nodes
- Date: Mon, 17 Oct 2016 13:50:42 +0000 (UTC)
commit 4cee69db47a883856bbc90ab9a40fcb9f54ddc12
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 7e549c4..26fc804 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().
@@ -3397,3 +3397,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 e581df9..2030591 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
@@ -42,6 +43,10 @@ void _gtk_container_maybe_start_idle_sizer (GtkContainer *container);
void gtk_container_get_children_clip (GtkContainer *container,
GtkAllocation *out_clip);
+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]