From f974b4850351acb277b6f44ef78c49ee2b7c223b Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 2 Apr 2018 08:04:39 +0200 Subject: [PATCH] widgetpaintable: Implement get_current_image() Now that snapshot and empty paintables exist, this is rather trivial. --- gtk/gtkwidgetpaintable.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gtk/gtkwidgetpaintable.c b/gtk/gtkwidgetpaintable.c index 948beb1b23..4ed58a0465 100644 --- a/gtk/gtkwidgetpaintable.c +++ b/gtk/gtkwidgetpaintable.c @@ -125,13 +125,22 @@ static GdkPaintable * gtk_widget_paintable_paintable_get_current_image (GdkPaintable *paintable) { GtkWidgetPaintable *self = GTK_WIDGET_PAINTABLE (paintable); + GtkSnapshot *snapshot; + int width, height; self->contents_invalid = FALSE; self->size_invalid = FALSE; - g_warning ("FIXME: Implement once we can create paintables from render nodes"); + width = gdk_paintable_get_intrinsic_width (paintable); + height = gdk_paintable_get_intrinsic_width (paintable); + if (width == 0 || height == 0) + return gdk_paintable_new_empty (width, height); - return NULL; + snapshot = gtk_snapshot_new (FALSE, "WidgetPaintableCurrentImage"); + gdk_paintable_snapshot (GDK_PAINTABLE (self), + snapshot, + width, height); + return gtk_snapshot_free_to_paintable (snapshot, &(graphene_size_t) { width, height }); } static int