diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c index 6cc2fcc3f2..da582e693a 100644 --- a/gtk/gtkcssimagecrossfade.c +++ b/gtk/gtkcssimagecrossfade.c @@ -448,6 +448,49 @@ gtk_css_image_cross_fade_is_computed (GtkCssImage *image) return TRUE; } +static gboolean +gtk_css_image_cross_fade_contains_current_color (GtkCssImage *image) +{ + GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image); + guint i; + + for (i = 0; i < cross_fade->images->len; i++) + { + const CrossFadeEntry *entry = &g_array_index (cross_fade->images, CrossFadeEntry, i); + if (gtk_css_image_contains_current_color (entry->image)) + return TRUE; + } + + return FALSE; +} + +static GtkCssImage * +gtk_css_image_cross_fade_resolve (GtkCssImage *image, + GtkCssComputeContext *context, + GtkCssValue *current) +{ + GtkCssImageCrossFade *self = GTK_CSS_IMAGE_CROSS_FADE (image); + GtkCssImageCrossFade *result; + guint i; + + if (!gtk_css_image_cross_fade_contains_current_color (image)) + return g_object_ref (image); + + result = gtk_css_image_cross_fade_new_empty (); + + for (i = 0; i < self->images->len; i++) + { + CrossFadeEntry *entry = &g_array_index (self->images, CrossFadeEntry, i); + + gtk_css_image_cross_fade_add (result, + entry->has_progress, + entry->progress, + gtk_css_image_resolve (entry->image, context, current)); + } + + return GTK_CSS_IMAGE (result); +} + static void gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass) { @@ -464,6 +507,8 @@ gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass) image_class->parse = gtk_css_image_cross_fade_parse; image_class->print = gtk_css_image_cross_fade_print; image_class->is_computed = gtk_css_image_cross_fade_is_computed; + image_class->contains_current_color = gtk_css_image_cross_fade_contains_current_color; + image_class->resolve = gtk_css_image_cross_fade_resolve; object_class->dispose = gtk_css_image_cross_fade_dispose; } diff --git a/gtk/gtkcssimagefallback.c b/gtk/gtkcssimagefallback.c index 1bea6b7362..f1658d02f0 100644 --- a/gtk/gtkcssimagefallback.c +++ b/gtk/gtkcssimagefallback.c @@ -323,7 +323,7 @@ gtk_css_image_fallback_contains_current_color (GtkCssImage *image) } } - return FALSE; + return gtk_css_image_contains_current_color (fallback->images[fallback->used]); } static GtkCssImage * @@ -335,6 +335,9 @@ gtk_css_image_fallback_resolve (GtkCssImage *image, GtkCssImageFallback *resolved; int i; + if (!gtk_css_image_fallback_contains_current_color (image)) + return g_object_ref (image); + if (fallback->used < 0) { GtkCssValue *resolved_color = NULL; @@ -351,7 +354,7 @@ gtk_css_image_fallback_resolve (GtkCssImage *image, resolved->images = g_new (GtkCssImage *, fallback->n_images); for (i = 0; i < fallback->n_images; i++) { - resolved->images[i] = g_object_ref (fallback->images[i]); + resolved->images[i] = gtk_css_image_resolve (fallback->images[i], context, current_color); if (gtk_css_image_is_invalid (resolved->images[i])) continue; @@ -365,7 +368,7 @@ gtk_css_image_fallback_resolve (GtkCssImage *image, return GTK_CSS_IMAGE (resolved); } else - return GTK_CSS_IMAGE (g_object_ref (image)); + return gtk_css_image_resolve (fallback->images[fallback->used], context, current_color); } static void diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index abf3f6f1ae..21174c0ff9 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -772,6 +772,9 @@ gtk_css_image_linear_resolve (GtkCssImage *image, GtkCssImageLinear *copy; guint i; + if (!gtk_css_image_linear_contains_current_color (image)) + return g_object_ref (image); + copy = g_object_new (GTK_TYPE_CSS_IMAGE_LINEAR, NULL); copy->repeating = linear->repeating; copy->side = linear->side; diff --git a/gtk/gtkcssimagepaintable.c b/gtk/gtkcssimagepaintable.c index 40d2650480..8878e95146 100644 --- a/gtk/gtkcssimagepaintable.c +++ b/gtk/gtkcssimagepaintable.c @@ -157,6 +157,20 @@ gtk_css_image_paintable_is_computed (GtkCssImage *image) return (gdk_paintable_get_flags (self->paintable) & GDK_PAINTABLE_IMMUTABLE) == GDK_PAINTABLE_IMMUTABLE; } +static gboolean +gtk_css_image_paintable_contains_current_color (GtkCssImage *image) +{ + return FALSE; +} + +static GtkCssImage * +gtk_css_image_paintable_resolve (GtkCssImage *image, + GtkCssComputeContext *context, + GtkCssValue *value) +{ + return g_object_ref (image); +} + static void gtk_css_image_paintable_class_init (GtkCssImagePaintableClass *klass) { @@ -173,6 +187,8 @@ gtk_css_image_paintable_class_init (GtkCssImagePaintableClass *klass) image_class->is_dynamic = gtk_css_image_paintable_is_dynamic; image_class->is_computed = gtk_css_image_paintable_is_computed; image_class->get_dynamic_image = gtk_css_image_paintable_get_dynamic_image; + image_class->contains_current_color = gtk_css_image_paintable_contains_current_color; + image_class->resolve = gtk_css_image_paintable_resolve; object_class->dispose = gtk_css_image_paintable_dispose; } diff --git a/gtk/gtkcssimageradial.c b/gtk/gtkcssimageradial.c index 2a90878101..a8b00db04c 100644 --- a/gtk/gtkcssimageradial.c +++ b/gtk/gtkcssimageradial.c @@ -773,6 +773,9 @@ gtk_css_image_radial_resolve (GtkCssImage *image, GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image); GtkCssImageRadial *copy; + if (!gtk_css_image_radial_contains_current_color (image)) + return g_object_ref (image); + copy = g_object_new (GTK_TYPE_CSS_IMAGE_RADIAL, NULL); copy->repeating = radial->repeating; copy->circle = radial->circle; diff --git a/gtk/gtkcssimagescaled.c b/gtk/gtkcssimagescaled.c index d55e0cfcc4..14b17f71a1 100644 --- a/gtk/gtkcssimagescaled.c +++ b/gtk/gtkcssimagescaled.c @@ -230,6 +230,9 @@ gtk_css_image_scaled_resolve (GtkCssImage *image, GtkCssImageScaled *self = GTK_CSS_IMAGE_SCALED (image); GtkCssImageScaled *res; + if (!gtk_css_image_scaled_contains_current_color (image)) + return g_object_ref (image); + res = g_object_new (GTK_TYPE_CSS_IMAGE_SCALED, NULL); res->n_images = self->n_images; diff --git a/gtk/gtkcssimageurl.c b/gtk/gtkcssimageurl.c index 99fbb28847..9c6053b6a5 100644 --- a/gtk/gtkcssimageurl.c +++ b/gtk/gtkcssimageurl.c @@ -159,6 +159,21 @@ gtk_css_image_url_is_computed (GtkCssImage *image) return TRUE; } +static GtkCssImage * +gtk_css_image_url_resolve (GtkCssImage *image, + GtkCssComputeContext *context, + GtkCssValue *current) +{ + return g_object_ref (image); +} + +static gboolean +gtk_css_image_url_contains_current_color (GtkCssImage *image) +{ + return FALSE; +} + + static gboolean gtk_css_image_url_parse (GtkCssImage *image, GtkCssParser *parser) @@ -253,6 +268,8 @@ _gtk_css_image_url_class_init (GtkCssImageUrlClass *klass) image_class->equal = gtk_css_image_url_equal; image_class->is_invalid = gtk_css_image_url_is_invalid; image_class->is_computed = gtk_css_image_url_is_computed; + image_class->contains_current_color = gtk_css_image_url_contains_current_color; + image_class->resolve = gtk_css_image_url_resolve; object_class->dispose = gtk_css_image_url_dispose; }