X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkcssimagecrossfade.c;h=1b02af94f73f5e8b6d1cd37f7587d38af3c12346;hb=7c2a752b3724ad9ac88b7abfecc63e4e0eb7eb54;hp=c08c89f63066c5a21b6a410f6dab2d6d61dd5fa3;hpb=eb6ad3562e7c38fb0f4d9f5806cef1afca45d48a;p=~andy%2Fgtk diff --git a/gtk/gtkcssimagecrossfade.c b/gtk/gtkcssimagecrossfade.c index c08c89f63..1b02af94f 100644 --- a/gtk/gtkcssimagecrossfade.c +++ b/gtk/gtkcssimagecrossfade.c @@ -19,6 +19,7 @@ #include "config.h" +#include #include #include "gtkcssimagecrossfadeprivate.h" @@ -85,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, @@ -105,37 +118,36 @@ gtk_css_image_cross_fade_draw (GtkCssImage *image, } else { - cairo_surface_t *surface; - if (cross_fade->start && cross_fade->end) { /* to reduce the group size */ - cairo_rectangle (cr, 0, 0, width, height); + cairo_rectangle (cr, 0, 0, ceil (width), ceil (height)); cairo_clip (cr); cairo_push_group (cr); + /* performance trick */ + cairo_reset_clip (cr); + _gtk_css_image_draw (cross_fade->start, cr, width, height); - surface = _gtk_css_image_get_surface (cross_fade->end, - cairo_get_target (cr), - width, height); - cairo_set_source_surface (cr, surface, 0, 0); + cairo_push_group (cr); + _gtk_css_image_draw (cross_fade->end, cr, width, height); + cairo_pop_group_to_source (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_paint_with_alpha (cr, cross_fade->progress); - cairo_surface_destroy (surface); cairo_pop_group_to_source (cr); cairo_paint (cr); } else if (cross_fade->start || cross_fade->end) { - surface = _gtk_css_image_get_surface (cross_fade->start ? cross_fade->start : cross_fade->end, - cairo_get_target (cr), - width, height); - cairo_set_source_surface (cr, surface, 0, 0); + cairo_push_group (cr); + _gtk_css_image_draw (cross_fade->start ? cross_fade->start : cross_fade->end, cr, width, height); + cairo_pop_group_to_source (cr); + cairo_paint_with_alpha (cr, cross_fade->start ? 1.0 - cross_fade->progress : cross_fade->progress); - cairo_surface_destroy (surface); } } } @@ -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;