From 0bfbf39306203d11d04c3aac93dea1155a52ba70 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 1 Nov 2012 00:22:39 +0100 Subject: [PATCH] cssimage: Implement some equal functions --- gtk/gtkcssimagecrossfade.c | 13 +++++++++++++ gtk/gtkcssimagelinear.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c index 2aa9f29539..1b02af94f7 100644 --- a/gtk/gtkcssimagecrossfade.c +++ b/gtk/gtkcssimagecrossfade.c @@ -86,6 +86,18 @@ gtk_css_image_cross_fade_get_height (GtkCssImage *image) return start_height + (end_height - start_height) * cross_fade->progress; } +static gboolean +gtk_css_image_cross_fade_equal (GtkCssImage *image1, + GtkCssImage *image2) +{ + GtkCssImageCrossFade *cross_fade1 = GTK_CSS_IMAGE_CROSS_FADE (image1); + GtkCssImageCrossFade *cross_fade2 = GTK_CSS_IMAGE_CROSS_FADE (image2); + + return cross_fade1->progress == cross_fade2->progress && + _gtk_css_image_equal (cross_fade1->start, cross_fade2->start) && + _gtk_css_image_equal (cross_fade1->end, cross_fade2->end); +} + static void gtk_css_image_cross_fade_draw (GtkCssImage *image, cairo_t *cr, @@ -234,6 +246,7 @@ _gtk_css_image_cross_fade_class_init (GtkCssImageCrossFadeClass *klass) image_class->get_width = gtk_css_image_cross_fade_get_width; image_class->get_height = gtk_css_image_cross_fade_get_height; + image_class->equal = gtk_css_image_cross_fade_equal; image_class->draw = gtk_css_image_cross_fade_draw; image_class->parse = gtk_css_image_cross_fade_parse; image_class->print = gtk_css_image_cross_fade_print; diff --git a/gtk/gtkcssimagelinear.c b/gtk/gtkcssimagelinear.c index b09131d423..9f94e49233 100644 --- a/gtk/gtkcssimagelinear.c +++ b/gtk/gtkcssimagelinear.c @@ -533,6 +533,34 @@ fail: return GTK_CSS_IMAGE_CLASS (_gtk_css_image_linear_parent_class)->transition (start_image, end_image, property_id, progress); } +static gboolean +gtk_css_image_linear_equal (GtkCssImage *image1, + GtkCssImage *image2) +{ + GtkCssImageLinear *linear1 = GTK_CSS_IMAGE_LINEAR (image1); + GtkCssImageLinear *linear2 = GTK_CSS_IMAGE_LINEAR (image2); + guint i; + + if (linear1->repeating != linear2->repeating || + !_gtk_css_value_equal (linear1->angle, linear2->angle) || + linear1->stops->len != linear2->stops->len) + return FALSE; + + for (i = 0; i < linear1->stops->len; i++) + { + GtkCssImageLinearColorStop *stop1, *stop2; + + stop1 = &g_array_index (linear1->stops, GtkCssImageLinearColorStop, i); + stop2 = &g_array_index (linear2->stops, GtkCssImageLinearColorStop, i); + + if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) || + !_gtk_css_value_equal (stop1->color, stop2->color)) + return FALSE; + } + + return TRUE; +} + static void gtk_css_image_linear_dispose (GObject *object) { @@ -563,6 +591,7 @@ _gtk_css_image_linear_class_init (GtkCssImageLinearClass *klass) image_class->parse = gtk_css_image_linear_parse; image_class->print = gtk_css_image_linear_print; image_class->compute = gtk_css_image_linear_compute; + image_class->equal = gtk_css_image_linear_equal; image_class->transition = gtk_css_image_linear_transition; object_class->dispose = gtk_css_image_linear_dispose;