[gtk+] Break out the css background render node in a function



commit cffb8ae4b50a9397c0c953a6e7d86a75fc018dc4
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Aug 12 18:13:17 2016 -0400

    Break out the css background render node in a function
    
    This is in preparation for creating separate render nodes
    for individual backgrounds.

 gtk/gtkcssgadget.c               |   29 +++++++++++------------------
 gtk/gtkrenderbackground.c        |   26 ++++++++++++++++++++++++++
 gtk/gtkrenderbackgroundprivate.h |   12 ++++++++++++
 3 files changed, 49 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c
index 2efac8d..0b67ede 100644
--- a/gtk/gtkcssgadget.c
+++ b/gtk/gtkcssgadget.c
@@ -821,7 +821,7 @@ gtk_css_gadget_get_render_node (GtkCssGadget  *gadget,
   GtkBorder clip, margin, border, padding;
   GtkCssStyle *style;
   cairo_t *cr;
-  GskRenderNode *box_node, *bg_node, *border_node;
+  GskRenderNode *box_node, *border_node;
   graphene_rect_t bounds;
   int width, height;
   int contents_x, contents_y, contents_width, contents_height;
@@ -867,25 +867,18 @@ gtk_css_gadget_get_render_node (GtkCssGadget  *gadget,
   get_box_padding (style, &padding);
 
   str = g_strconcat ("Background<", G_OBJECT_TYPE_NAME (gtk_css_gadget_get_owner (gadget)), ">", NULL);
-  bg_node = gsk_renderer_create_render_node (renderer);
-  gsk_render_node_set_name (bg_node, str);
-  gsk_render_node_set_bounds (bg_node, &bounds);
-  cr = gsk_render_node_get_draw_context (bg_node);
-
-  gtk_css_style_render_background (style,
-                                   cr,
-                                   clip.left + margin.left,
-                                   clip.top + margin.top,
-                                   width - clip.left - clip.right - margin.left - margin.right,
-                                   height - clip.top - clip.bottom - margin.top - margin.bottom,
-                                   gtk_css_node_get_junction_sides (priv->node));
-
-  cairo_destroy (cr);
+  gtk_css_style_add_background_render_nodes (style,
+                                             renderer,
+                                             box_node,
+                                             &bounds,
+                                             str,
+                                             clip.left + margin.left,
+                                             clip.top + margin.top,
+                                             width - clip.left - clip.right - margin.left - margin.right,
+                                             height - clip.top - clip.bottom - margin.top - margin.bottom,
+                                             gtk_css_node_get_junction_sides (priv->node));
   g_free (str);
 
-  gsk_render_node_append_child (box_node, bg_node);
-  gsk_render_node_unref (bg_node);
-
   str = g_strconcat ("Border<", G_OBJECT_TYPE_NAME (gtk_css_gadget_get_owner (gadget)), ">", NULL);
   border_node = gsk_renderer_create_render_node (renderer);
   gsk_render_node_set_name (border_node, str);
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index b41d3a5..b877245 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -428,6 +428,32 @@ gtk_css_style_render_background (GtkCssStyle      *style,
   cairo_restore (cr);
 }
 
+void
+gtk_css_style_add_background_render_nodes (GtkCssStyle      *style,
+                                           GskRenderer      *renderer,
+                                           GskRenderNode    *parent_node,
+                                           graphene_rect_t  *bounds,
+                                           const char       *name,
+                                           gdouble           x,
+                                           gdouble           y,
+                                           gdouble           width,
+                                           gdouble           height,
+                                           GtkJunctionSides  junction)
+{
+  GskRenderNode *bg_node;
+  cairo_t *cr;
+
+  bg_node = gsk_renderer_create_render_node (renderer);
+  gsk_render_node_set_name (bg_node, name);
+  gsk_render_node_set_bounds (bg_node, bounds);
+  cr = gsk_render_node_get_draw_context (bg_node);
+  gtk_css_style_render_background (style, cr, x, y, width, height, junction);
+  cairo_destroy (cr);
+
+  gsk_render_node_append_child (parent_node, bg_node);
+  gsk_render_node_unref (bg_node);
+}
+
 static gboolean
 corner_value_is_right_angle (GtkCssValue *value)
 {
diff --git a/gtk/gtkrenderbackgroundprivate.h b/gtk/gtkrenderbackgroundprivate.h
index 52a6ffd..a3927f0 100644
--- a/gtk/gtkrenderbackgroundprivate.h
+++ b/gtk/gtkrenderbackgroundprivate.h
@@ -25,6 +25,7 @@
 
 #include "gtkcsstypesprivate.h"
 #include "gtktypes.h"
+#include "gsk/gsk.h"
 
 G_BEGIN_DECLS
 
@@ -36,6 +37,17 @@ void            gtk_css_style_render_background                 (GtkCssStyle
                                                                  gdouble               height,
                                                                  GtkJunctionSides      junction);
 gboolean        gtk_css_style_render_background_is_opaque       (GtkCssStyle          *style);
+void            gtk_css_style_add_background_render_nodes       (GtkCssStyle      *style,
+                                                                 GskRenderer      *renderer,
+                                                                 GskRenderNode    *parent_node,
+                                                                 graphene_rect_t  *bounds,
+                                                                 const char       *name,
+                                                                 gdouble           x,
+                                                                 gdouble           y,
+                                                                 gdouble           width,
+                                                                 gdouble           height,
+                                                                 GtkJunctionSides  junction);
+
 
 
 G_END_DECLS


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