Break out the css background render node in a function

This is in preparation for creating separate render nodes
for individual backgrounds.
This commit is contained in:
Matthias Clasen 2016-08-12 18:13:17 -04:00 committed by Emmanuele Bassi
parent f74dd416d6
commit cffb8ae4b5
3 changed files with 49 additions and 18 deletions

View File

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

View File

@ -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)
{

View File

@ -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