diff options
author | Benjamin Otte <otte@redhat.com> | 2016-12-13 03:05:15 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-12-20 18:01:10 +0100 |
commit | e82d02432e57b00606976e8a84e06628dd9d4918 (patch) | |
tree | 61ca9bf52340f34af57eac21c623dbcd7cc461d8 /gsk/gskrendernode.c | |
parent | 02131d590e2f4bdf9d2f487e619a3f08c1cf178e (diff) | |
download | gtk+-e82d02432e57b00606976e8a84e06628dd9d4918.tar.gz |
gsk: Add gsk_render_node_draw()
Draws a node to a given cairo_t. This is mostly intended for fallback
usage.
Diffstat (limited to 'gsk/gskrendernode.c')
-rw-r--r-- | gsk/gskrendernode.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gsk/gskrendernode.c b/gsk/gskrendernode.c index 5b53c9197f..1a343ae852 100644 --- a/gsk/gskrendernode.c +++ b/gsk/gskrendernode.c @@ -335,3 +335,62 @@ gsk_render_node_make_immutable (GskRenderNode *node) node->is_mutable = FALSE; } +/** + * gsk_render_node_draw: + * @node: a #GskRenderNode + * @cr: cairo context to draw to + * + * Draw the contents of @node to the given cairo context. + * + * Typically, you'll use this function to implement fallback rendering + * of #GskRenderNodes on an intermediate Cairo context, instead of using + * the drawing context associated to a #GdkWindow's rendering buffer. + * + * For advanced nodes that cannot be supported using Cairo, in particular + * for nodes doing 3D operations, this function may fail. + **/ +void +gsk_render_node_draw (GskRenderNode *node, + cairo_t *cr) +{ + g_return_if_fail (GSK_IS_RENDER_NODE (node)); + g_return_if_fail (cr != NULL); + + cairo_save (cr); + + if (!GSK_RENDER_MODE_CHECK (GEOMETRY)) + { + graphene_rect_t frame; + + gsk_render_node_get_bounds (node, &frame); + GSK_NOTE (CAIRO, g_print ("CLIP = { .x = %g, .y = %g, .width = %g, .height = %g }\n", + frame.origin.x, frame.origin.y, + frame.size.width, frame.size.height)); + + cairo_rectangle (cr, frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); + cairo_clip (cr); + } + + GSK_NOTE (CAIRO, g_print ("Rendering node %s[%p]\n", + node->name, + node)); + + node->node_class->draw (node, cr); + + if (GSK_RENDER_MODE_CHECK (GEOMETRY)) + { + graphene_rect_t frame; + + gsk_render_node_get_bounds (node, &frame); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_rectangle (cr, frame.origin.x - 1, frame.origin.y - 1, frame.size.width + 2, frame.size.height + 2); + cairo_set_line_width (cr, 2); + cairo_set_source_rgba (cr, 0, 0, 0, 0.5); + cairo_stroke (cr); + } + + cairo_restore (cr); +} + + |