gtk: Add convenience function for creating render nodes

GtkWidget.create_render_node() sets up a GskRenderNode appropriate for
rendering the contents of a widget, including its bounds,
transformation, and anchor point.
This commit is contained in:
Emmanuele Bassi 2016-08-04 15:22:00 +01:00
parent a146618de0
commit 354d4435b1
2 changed files with 30 additions and 0 deletions

View File

@ -15839,6 +15839,32 @@ gtk_widget_get_renderer (GtkWidget *widget)
return NULL;
}
GskRenderNode *
gtk_widget_create_render_node (GtkWidget *widget,
GskRenderer *renderer,
const char *name)
{
GskRenderNode *res = gsk_renderer_create_render_node (renderer);
GtkAllocation allocation, clip;
graphene_point3d_t p;
graphene_rect_t bounds;
graphene_matrix_t m;
gtk_widget_get_allocation (widget, &allocation);
gtk_widget_get_clip (widget, &clip);
graphene_rect_init (&bounds, 0, 0, clip.width, clip.height);
graphene_matrix_init_translate (&m, graphene_point3d_init (&p, allocation.x, allocation.y, 0));
graphene_point3d_init (&p, clip.x - allocation.x, clip.y - allocation.y, 0);
gsk_render_node_set_name (res, name);
gsk_render_node_set_bounds (res, &bounds);
gsk_render_node_set_transform (res, &m);
gsk_render_node_set_anchor_point (res, &p);
return res;
}
GskRenderNode *
gtk_widget_get_render_node (GtkWidget *widget,
GskRenderer *renderer)

View File

@ -299,6 +299,10 @@ void gtk_widget_render (GtkWidget
GskRenderNode * gtk_widget_get_render_node (GtkWidget *widget,
GskRenderer *renderer);
GskRenderNode * gtk_widget_create_render_node (GtkWidget *widget,
GskRenderer *renderer,
const char *name);
/* inline getters */
static inline gboolean