diff options
author | Benjamin Otte <otte@redhat.com> | 2018-04-02 06:15:50 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-04-05 14:56:39 +0200 |
commit | ffc7b2bb0afd04cacbe45cff6f27eb5d644d5b2b (patch) | |
tree | 620bed58191f6d4985cf8e09693c79bba0aeda02 /gtk/gtksnapshot.c | |
parent | 12fedca726d42f2087ffc3c5621eeb6757265319 (diff) | |
download | gtk+-ffc7b2bb0afd04cacbe45cff6f27eb5d644d5b2b.tar.gz |
snapshot: Allow passing the bounds of the created paintable
This allows being more specific about the size.
It's useful in particular when the resulting render nodes might be
too small for the size, not only when they are too large. For the
latter case, using a clip node would be enough.
It also requires adding a clip node when rendering the resulting
paintable, but that should be optimized out by GtkSnapshot when not
necessary.
Diffstat (limited to 'gtk/gtksnapshot.c')
-rw-r--r-- | gtk/gtksnapshot.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gtk/gtksnapshot.c b/gtk/gtksnapshot.c index 14514a9689..c383364275 100644 --- a/gtk/gtksnapshot.c +++ b/gtk/gtksnapshot.c @@ -277,6 +277,8 @@ gtk_snapshot_free_to_node (GtkSnapshot *snapshot) /** * gtk_snapshot_free_to_paintable: (skip) * @snapshot: (transfer full): a #GtkSnapshot + * @size: (allow-none): The size of the resulting paintable + * or %NULL to use the bounds of the snapshot * * Returns a paintable for the node that was * constructed by @snapshot and frees @snapshot. @@ -284,11 +286,12 @@ gtk_snapshot_free_to_node (GtkSnapshot *snapshot) * Returns: (transfer full): a newly-created #GdkPaintable */ GdkPaintable * -gtk_snapshot_free_to_paintable (GtkSnapshot *snapshot) +gtk_snapshot_free_to_paintable (GtkSnapshot *snapshot, + const graphene_size_t *size) { GdkPaintable *result; - result = gtk_snapshot_to_paintable (snapshot); + result = gtk_snapshot_to_paintable (snapshot, size); g_object_unref (snapshot); return result; @@ -1286,6 +1289,8 @@ gtk_snapshot_to_node (GtkSnapshot *snapshot) /** * gtk_snapshot_to_paintable: * @snapshot: a #GtkSnapshot + * @size: (allow-none): The size of the resulting paintable + * or %NULL to use the bounds of the snapshot * * Returns a paintable encapsulating the render node * that was constructed by @snapshot. After calling @@ -1296,13 +1301,18 @@ gtk_snapshot_to_node (GtkSnapshot *snapshot) * Returns: (transfer full): a new #GdkPaintable */ GdkPaintable * -gtk_snapshot_to_paintable (GtkSnapshot *snapshot) +gtk_snapshot_to_paintable (GtkSnapshot *snapshot, + const graphene_size_t *size) { GskRenderNode *node; GdkPaintable *paintable; + graphene_rect_t bounds; node = gtk_snapshot_to_node (snapshot); - paintable = gtk_render_node_paintable_new (node); + gsk_render_node_get_bounds (node, &bounds); + bounds.origin.x = 0; + bounds.origin.y = 0; + paintable = gtk_render_node_paintable_new (node, &bounds); gsk_render_node_unref (node); return paintable; |