cssimagefallback: Don't snapshot invisible colors
authorTimm Bäder <mail@baedert.org>
Thu, 16 Jan 2020 12:41:55 +0000 (13:41 +0100)
committerTimm Bäder <mail@baedert.org>
Sat, 18 Jan 2020 07:49:52 +0000 (08:49 +0100)
This avoids a few render nodes later.

gtk/gtkcssimagefallback.c

index d922da942ba5a1615dc3397d18009759748ce6cc..c6549c6bd41409dd06b75ff3bad3dbc3c6208ba5 100644 (file)
@@ -70,15 +70,18 @@ gtk_css_image_fallback_snapshot (GtkCssImage *image,
 
   if (fallback->used < 0)
     {
-      GdkRGBA red = { 1, 0, 0, 1 };
-      const GdkRGBA *color;
-
       if (fallback->color)
-        color = gtk_css_color_value_get_rgba (fallback->color);
+        {
+          const GdkRGBA *color = gtk_css_color_value_get_rgba (fallback->color);
+          if (!gdk_rgba_is_clear (color))
+            gtk_snapshot_append_color (snapshot, color,
+                                       &GRAPHENE_RECT_INIT (0, 0, width, height));
+        }
       else
-        color = &red;
-
-      gtk_snapshot_append_color (snapshot, color, &GRAPHENE_RECT_INIT (0, 0, width, height));
+        {
+          gtk_snapshot_append_color (snapshot, &(GdkRGBA) {1, 0, 0, 1},
+                                     &GRAPHENE_RECT_INIT (0, 0, width, height));
+        }
     }
   else
     gtk_css_image_snapshot (fallback->images[fallback->used], snapshot, width, height);