[gtk+/wip/ebassi/gsk-renderer: 77/83] gtk: Add convenience function for creating render nodes



commit 0271c96711e3bc66e2d6f3d7d756b8686f7bc852
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Aug 4 15:22:00 2016 +0100

    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.

 gtk/gtkwidget.c        |   26 ++++++++++++++++++++++++++
 gtk/gtkwidgetprivate.h |    4 ++++
 2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 54da028..40d7d38 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -17478,6 +17478,32 @@ gtk_widget_get_renderer (GtkWidget *widget)
 }
 
 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)
 {
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 7d6aba0..7125f44 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -305,6 +305,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


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