cssimage: Implement some equal functions

This commit is contained in:
Benjamin Otte 2012-11-01 00:22:39 +01:00
parent 86ecf54139
commit 0bfbf39306
2 changed files with 42 additions and 0 deletions

View File

@ -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;

View File

@ -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;