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.
This commit is contained in:
Emmanuele Bassi 2016-07-27 09:40:29 +01:00
parent 43904892bc
commit cd0de3f87c
2 changed files with 41 additions and 1 deletions

View File

@ -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);
}

View File

@ -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__ */