cssimagebuiltin: Don't create cairo nodes for empty icons
authorTimm Bäder <mail@baedert.org>
Tue, 15 Oct 2019 05:13:28 +0000 (07:13 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 15 Oct 2019 05:13:28 +0000 (07:13 +0200)
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

index f377e44e899f39172c475e10be55a03e666313e2..e005eb6e2a0122f11ee6e609728e1076ce2400af 100644 (file)
@@ -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);
+    }
 }
-
-