From bb56b4ef5d975fff91e7caa39e058d02fd7373bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 15 Oct 2019 07:13:28 +0200 Subject: [PATCH] cssimagebuiltin: Don't create cairo nodes for empty icons GTK_CSS_IMAGE_BUILTIN_NONE is not going to draw anything of course, so don't bother creating an empty cairo node for it. --- gtk/gtkcssimagebuiltin.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gtk/gtkcssimagebuiltin.c b/gtk/gtkcssimagebuiltin.c index f377e44e89..e005eb6e2a 100644 --- a/gtk/gtkcssimagebuiltin.c +++ b/gtk/gtkcssimagebuiltin.c @@ -649,8 +649,6 @@ gtk_css_image_builtin_snapshot (GtkCssImage *image, double height, GtkCssImageBuiltinType image_type) { - cairo_t *cr; - g_return_if_fail (GTK_IS_CSS_IMAGE (image)); g_return_if_fail (snapshot != NULL); g_return_if_fail (width > 0); @@ -662,10 +660,11 @@ gtk_css_image_builtin_snapshot (GtkCssImage *image, return; } - cr = gtk_snapshot_append_cairo (snapshot, - &GRAPHENE_RECT_INIT (0, 0, width, height)); - gtk_css_image_builtin_draw (image, cr, width, height, image_type); - cairo_destroy (cr); + if (image_type != GTK_CSS_IMAGE_BUILTIN_NONE) + { + cairo_t *cr = gtk_snapshot_append_cairo (snapshot, + &GRAPHENE_RECT_INIT (0, 0, width, height)); + gtk_css_image_builtin_draw (image, cr, width, height, image_type); + cairo_destroy (cr); + } } - -