summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2016-11-01 05:45:01 +0100
committerBenjamin Otte <otte@redhat.com>2016-11-01 16:32:26 +0100
commita0e63b8a07d2796bcf2d3cfec9ba984fe8ca9066 (patch)
treec41e103a2b5d7d374d163007e29e50fe50fe1e92
parente201c4dc926dd21cd99b9442b8aebf235a33142a (diff)
downloadgtk+-a0e63b8a07d2796bcf2d3cfec9ba984fe8ca9066.tar.gz
rendernode: Require passing a renderer to get_draw_context()
This is in preparation of making render nodes independent of the renderer, so that they can be rendered multiple times with different renderers.
-rw-r--r--gsk/gskrenderer.h1
-rw-r--r--gsk/gskrendernode.c27
-rw-r--r--gsk/gskrendernode.h3
-rw-r--r--gsk/gsktypes.h2
-rw-r--r--gtk/gtkaccellabel.c2
-rw-r--r--gtk/gtkcssgadget.c6
-rw-r--r--gtk/gtkdebugupdates.c2
-rw-r--r--gtk/gtkflowbox.c2
-rw-r--r--gtk/gtkframe.c2
-rw-r--r--gtk/gtkimage.c2
-rw-r--r--gtk/gtklabel.c2
-rw-r--r--gtk/gtkpopover.c2
-rw-r--r--gtk/gtkrenderbackground.c8
-rw-r--r--gtk/gtkwidget.c4
-rw-r--r--gtk/gtkwindow.c2
15 files changed, 42 insertions, 25 deletions
diff --git a/gsk/gskrenderer.h b/gsk/gskrenderer.h
index 094fc7ee0e..d3e1b3e46b 100644
--- a/gsk/gskrenderer.h
+++ b/gsk/gskrenderer.h
@@ -33,7 +33,6 @@ G_BEGIN_DECLS
#define GSK_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSK_TYPE_RENDERER, GskRenderer))
#define GSK_IS_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSK_TYPE_RENDERER))
-typedef struct _GskRenderer GskRenderer;
typedef struct _GskRendererClass GskRendererClass;
GDK_AVAILABLE_IN_3_90
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c
index 6a1625dc22..c1494cb79a 100644
--- a/gsk/gskrendernode.c
+++ b/gsk/gskrendernode.c
@@ -1378,9 +1378,12 @@ gsk_render_node_get_blend_mode (GskRenderNode *node)
/**
* gsk_render_node_get_draw_context:
* @node: a #GskRenderNode
+ * @renderer: (nullable): Renderer to optimize for or %NULL for any
*
* Creates a Cairo context for drawing using the surface associated
* to the render node.
+ * If no surface exists yet, a surface will be created optimized for
+ * rendering to @renderer.
*
* Returns: (transfer full): a Cairo context used for drawing; use
* cairo_destroy() when done drawing
@@ -1388,20 +1391,32 @@ gsk_render_node_get_blend_mode (GskRenderNode *node)
* Since: 3.90
*/
cairo_t *
-gsk_render_node_get_draw_context (GskRenderNode *node)
+gsk_render_node_get_draw_context (GskRenderNode *node,
+ GskRenderer *renderer)
{
cairo_t *res;
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
g_return_val_if_fail (node->is_mutable, NULL);
+ g_return_val_if_fail (renderer == NULL || GSK_IS_RENDERER (renderer), NULL);
if (node->surface == NULL)
{
- node->surface = gsk_renderer_create_cairo_surface (node->renderer,
- node->opaque ? CAIRO_FORMAT_RGB24
- : CAIRO_FORMAT_ARGB32,
- ceilf (node->bounds.size.width),
- ceilf (node->bounds.size.height));
+ if (renderer)
+ {
+ node->surface = gsk_renderer_create_cairo_surface (renderer,
+ node->opaque ? CAIRO_FORMAT_RGB24
+ : CAIRO_FORMAT_ARGB32,
+ ceilf (node->bounds.size.width),
+ ceilf (node->bounds.size.height));
+ }
+ else
+ {
+ node->surface = cairo_image_surface_create (node->opaque ? CAIRO_FORMAT_RGB24
+ : CAIRO_FORMAT_ARGB32,
+ ceilf (node->bounds.size.width),
+ ceilf (node->bounds.size.height));
+ }
}
res = cairo_create (node->surface);
diff --git a/gsk/gskrendernode.h b/gsk/gskrendernode.h
index 90006f1c7e..3863423762 100644
--- a/gsk/gskrendernode.h
+++ b/gsk/gskrendernode.h
@@ -111,7 +111,8 @@ void gsk_render_node_set_opaque (GskRenderNode *
GDK_AVAILABLE_IN_3_90
gboolean gsk_render_node_is_opaque (GskRenderNode *node);
GDK_AVAILABLE_IN_3_90
-cairo_t * gsk_render_node_get_draw_context (GskRenderNode *node);
+cairo_t * gsk_render_node_get_draw_context (GskRenderNode *node,
+ GskRenderer *renderer);
GDK_AVAILABLE_IN_3_90
void gsk_render_node_set_blend_mode (GskRenderNode *node,
diff --git a/gsk/gsktypes.h b/gsk/gsktypes.h
index 8513328ba5..eae1591dad 100644
--- a/gsk/gsktypes.h
+++ b/gsk/gsktypes.h
@@ -26,4 +26,6 @@
#include <gdk/gdk.h>
#include <gsk/gskenums.h>
+typedef struct _GskRenderer GskRenderer;
+
#endif /* __GSK_TYPES_H__ */
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index 3be1e68b7a..93b660af96 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -489,7 +489,7 @@ gtk_accel_label_get_render_node (GtkWidget *widget,
gtk_widget_get_clip (widget, &clip);
_gtk_widget_get_allocation (widget, &alloc);
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
context = gtk_widget_get_style_context (widget);
diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c
index d7eac83fc7..dbce0c94d7 100644
--- a/gtk/gtkcssgadget.c
+++ b/gtk/gtkcssgadget.c
@@ -889,7 +889,7 @@ gtk_css_gadget_get_render_node (GtkCssGadget *gadget,
border_node = gsk_renderer_create_render_node (renderer);
gsk_render_node_set_name (border_node, str);
gsk_render_node_set_bounds (border_node, &bounds);
- cr = gsk_render_node_get_draw_context (border_node);
+ cr = gsk_render_node_get_draw_context (border_node, renderer);
gtk_css_style_render_border (style,
cr,
@@ -933,7 +933,7 @@ gtk_css_gadget_get_render_node (GtkCssGadget *gadget,
gsk_render_node_set_bounds (content_node, &content_bounds);
gsk_render_node_set_transform (content_node, &content_transform);
- cr = gsk_render_node_get_draw_context (content_node);
+ cr = gsk_render_node_get_draw_context (content_node, renderer);
/* Compatibility mode: draw_focus is left to the draw() implementation */
draw_focus = gadget_class->draw (gadget, cr,
@@ -956,7 +956,7 @@ gtk_css_gadget_get_render_node (GtkCssGadget *gadget,
gsk_render_node_set_name (focus_node, str);
gsk_render_node_set_bounds (focus_node, &bounds);
- cr = gsk_render_node_get_draw_context (focus_node);
+ cr = gsk_render_node_get_draw_context (focus_node, renderer);
gtk_css_style_render_outline (style,
cr,
clip.left + margin.left,
diff --git a/gtk/gtkdebugupdates.c b/gtk/gtkdebugupdates.c
index 1d3ab2133d..42e89b6b19 100644
--- a/gtk/gtkdebugupdates.c
+++ b/gtk/gtkdebugupdates.c
@@ -292,7 +292,7 @@ gtk_debug_updates_get_render_node (GtkWidget *widget,
gtk_debug_updates_queue_get_extents (updates, &rect);
gsk_render_node_set_bounds (node, &(graphene_rect_t) GRAPHENE_RECT_INIT(rect.x, rect.y, rect.width, rect.height));
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
for (l = g_queue_peek_head_link (updates); l != NULL; l = l->next)
{
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index fd83a4861c..f1bee97b96 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -2575,7 +2575,7 @@ gtk_flow_box_get_render_node (GtkWidget *widget,
node = gtk_widget_create_render_node (widget, renderer, "FlowBox RubberBand");
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
vertical = priv->orientation == GTK_ORIENTATION_VERTICAL;
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 8ff208869f..d362de71b6 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -695,7 +695,7 @@ gtk_frame_get_render_node (GtkWidget *widget,
node = gtk_css_gadget_get_render_node (priv->gadget, renderer, FALSE);
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
/* We want to use the standard gadget drawing for the border,
* so we clip out the label allocation in order to get the
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index cb8b5430b0..ae8dec8c5e 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1425,7 +1425,7 @@ gtk_image_get_render_node (GtkWidget *widget,
gtk_widget_get_clip (widget, &clip);
_gtk_widget_get_allocation (widget, &alloc);
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
x = 0;
y = 0;
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 1f74a8b4fa..16943f9ee8 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -4181,7 +4181,7 @@ gtk_label_get_render_node (GtkWidget *widget,
gtk_widget_get_clip (widget, &clip);
_gtk_widget_get_allocation (widget, &alloc);
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
x = 0;
y = 0;
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 88d234c881..9cbe815f54 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -1395,7 +1395,7 @@ gtk_popover_get_render_node (GtkWidget *widget, GskRenderer *renderer)
if (node == NULL)
return NULL;
- ct = gsk_render_node_get_draw_context (node);
+ ct = gsk_render_node_get_draw_context (node, renderer);
gtk_popover_draw (widget, ct);
cairo_destroy (ct);
diff --git a/gtk/gtkrenderbackground.c b/gtk/gtkrenderbackground.c
index 6d0daf1189..80e17dcb18 100644
--- a/gtk/gtkrenderbackground.c
+++ b/gtk/gtkrenderbackground.c
@@ -499,7 +499,7 @@ gtk_css_style_add_background_render_nodes (GtkCssStyle *style,
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);
+ cr = gsk_render_node_get_draw_context (bg_node, renderer);
cairo_translate (cr, x, y);
_gtk_css_shadows_value_paint_box (box_shadow,
cr,
@@ -518,7 +518,7 @@ gtk_css_style_add_background_render_nodes (GtkCssStyle *style,
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);
+ cr = gsk_render_node_get_draw_context (bg_node, renderer);
cairo_translate (cr, x, y);
_gtk_theming_background_paint_color (&bg, cr, bg_color, background_image);
cairo_destroy (cr);
@@ -543,7 +543,7 @@ gtk_css_style_add_background_render_nodes (GtkCssStyle *style,
translate_blend_mode (blend_mode));
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);
+ cr = gsk_render_node_get_draw_context (bg_node, renderer);
cairo_translate (cr, x, y);
_gtk_theming_background_paint_layer (&bg, idx, cr, GTK_CSS_BLEND_MODE_NORMAL);
cairo_destroy (cr);
@@ -559,7 +559,7 @@ gtk_css_style_add_background_render_nodes (GtkCssStyle *style,
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);
+ cr = gsk_render_node_get_draw_context (bg_node, renderer);
cairo_translate (cr, x, y);
_gtk_css_shadows_value_paint_box (box_shadow,
cr,
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 1fd5d7ee0e..cdb69f49ff 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15676,7 +15676,7 @@ gtk_widget_get_render_node (GtkWidget *widget,
gsk_render_node_set_bounds (tmp, &bounds);
gsk_render_node_set_transform (tmp, &m);
- cr = gsk_render_node_get_draw_context (tmp);
+ cr = gsk_render_node_get_draw_context (tmp, renderer);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
gtk_widget_draw_internal (widget, cr, TRUE);
cairo_destroy (cr);
@@ -15705,7 +15705,7 @@ gtk_widget_get_render_node (GtkWidget *widget,
gsk_render_node_set_name (tmp, str);
gsk_render_node_set_bounds (tmp, &bounds);
- cr = gsk_render_node_get_draw_context (tmp);
+ cr = gsk_render_node_get_draw_context (tmp, renderer);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
g_signal_emit (widget, widget_signals[DRAW], 0, cr, &result);
cairo_destroy (cr);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 1eeb746450..46030d1a12 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -9410,7 +9410,7 @@ gtk_window_get_render_node (GtkWidget *widget,
gsk_render_node_set_bounds (node, &bounds);
gsk_render_node_set_transform (node, &m);
- cr = gsk_render_node_get_draw_context (node);
+ cr = gsk_render_node_get_draw_context (node, renderer);
if (priv->client_decorated &&
priv->decorated &&