X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libview%2Fev-transition-animation.c;h=49d77f79ebf1df70108fbb08b51507b8ec00711c;hb=e769474337c9a6ffdaed2327056e8de2f7ca9ee4;hp=148b4c7734eccaba3e576e1f1ec5ef060ce722e3;hpb=68d0fc3c59185065d9694ba3f8cb2665b984eb9f;p=evince.git diff --git a/libview/ev-transition-animation.c b/libview/ev-transition-animation.c index 148b4c77..49d77f79 100644 --- a/libview/ev-transition-animation.c +++ b/libview/ev-transition-animation.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. */ #include @@ -189,27 +189,14 @@ paint_surface (cairo_t *cr, gdouble alpha, GdkRectangle page_area) { - gint width, height; + cairo_save (cr); gdk_cairo_rectangle (cr, &page_area); cairo_clip (cr); - - width = cairo_image_surface_get_width (surface); - height = cairo_image_surface_get_height (surface); - - cairo_save (cr); - - if (width != page_area.width || height != page_area.height) { - cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_FAST); - cairo_scale (cr, - (gdouble) page_area.width / width, - (gdouble) page_area.height / height); - } - cairo_surface_set_device_offset (surface, x_offset, y_offset); cairo_set_source_surface (cr, surface, 0, 0); - if (alpha == 0.) + if (alpha == 1.) cairo_paint (cr); else cairo_paint_with_alpha (cr, alpha); @@ -240,7 +227,7 @@ ev_transition_animation_split (cairo_t *cr, NULL); if (direction == EV_TRANSITION_DIRECTION_INWARD) { - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); if (alignment == EV_TRANSITION_ALIGNMENT_HORIZONTAL) { cairo_rectangle (cr, @@ -258,9 +245,9 @@ ev_transition_animation_split (cairo_t *cr, cairo_clip (cr); - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); } else { - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); if (alignment == EV_TRANSITION_ALIGNMENT_HORIZONTAL) { cairo_rectangle (cr, @@ -278,7 +265,7 @@ ev_transition_animation_split (cairo_t *cr, cairo_clip (cr); - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); } } @@ -301,7 +288,7 @@ ev_transition_animation_blinds (cairo_t *cr, "alignment", &alignment, NULL); - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); for (i = 0; i < N_BLINDS; i++) { cairo_save (cr); @@ -321,7 +308,7 @@ ev_transition_animation_blinds (cairo_t *cr, } cairo_clip (cr); - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); cairo_restore (cr); } } @@ -346,7 +333,7 @@ ev_transition_animation_box (cairo_t *cr, NULL); if (direction == EV_TRANSITION_DIRECTION_INWARD) { - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); cairo_rectangle (cr, width * progress / 2, @@ -355,9 +342,9 @@ ev_transition_animation_box (cairo_t *cr, height * (1 - progress)); cairo_clip (cr); - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); } else { - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); cairo_rectangle (cr, (width / 2) - (width * progress / 2), @@ -366,7 +353,7 @@ ev_transition_animation_box (cairo_t *cr, height * progress); cairo_clip (cr); - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); } } @@ -389,7 +376,7 @@ ev_transition_animation_wipe (cairo_t *cr, "angle", &angle, NULL); - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); if (angle == 0) { /* left to right */ @@ -421,7 +408,7 @@ ev_transition_animation_wipe (cairo_t *cr, cairo_clip (cr); - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); } static void @@ -435,7 +422,7 @@ ev_transition_animation_dissolve (cairo_t *cr, priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); paint_surface (cr, priv->origin_surface, 0, 0, 1 - progress, page_area); } @@ -460,12 +447,12 @@ ev_transition_animation_push (cairo_t *cr, if (angle == 0) { /* left to right */ - paint_surface (cr, priv->origin_surface, - (width * progress), 0, 0, page_area); - paint_surface (cr, priv->dest_surface, width * (1 - progress), 0, 0, page_area); + paint_surface (cr, priv->origin_surface, - (width * progress), 0, 1., page_area); + paint_surface (cr, priv->dest_surface, width * (1 - progress), 0, 1., page_area); } else { /* top to bottom */ - paint_surface (cr, priv->origin_surface, 0, - (height * progress), 0, page_area); - paint_surface (cr, priv->dest_surface, 0, height * (1 - progress), 0, page_area); + paint_surface (cr, priv->origin_surface, 0, - (height * progress), 1., page_area); + paint_surface (cr, priv->dest_surface, 0, height * (1 - progress), 1., page_area); } } @@ -488,14 +475,14 @@ ev_transition_animation_cover (cairo_t *cr, "angle", &angle, NULL); - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); if (angle == 0) { /* left to right */ - paint_surface (cr, priv->dest_surface, width * (1 - progress), 0, 0, page_area); + paint_surface (cr, priv->dest_surface, width * (1 - progress), 0, 1., page_area); } else { /* top to bottom */ - paint_surface (cr, priv->dest_surface, 0, height * (1 - progress), 0, page_area); + paint_surface (cr, priv->dest_surface, 0, height * (1 - progress), 1., page_area); } } @@ -518,14 +505,14 @@ ev_transition_animation_uncover (cairo_t *cr, "angle", &angle, NULL); - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); if (angle == 0) { /* left to right */ - paint_surface (cr, priv->origin_surface, - (width * progress), 0, 0, page_area); + paint_surface (cr, priv->origin_surface, - (width * progress), 0, 1., page_area); } else { /* top to bottom */ - paint_surface (cr, priv->origin_surface, 0, - (height * progress), 0, page_area); + paint_surface (cr, priv->origin_surface, 0, - (height * progress), 1., page_area); } } @@ -540,7 +527,7 @@ ev_transition_animation_fade (cairo_t *cr, priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); paint_surface (cr, priv->dest_surface, 0, 0, progress, page_area); } @@ -556,19 +543,20 @@ ev_transition_animation_paint (EvTransitionAnimation *animation, g_return_if_fail (EV_IS_TRANSITION_ANIMATION (animation)); priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); - g_object_get (priv->effect, "type", &type, NULL); - progress = ev_timeline_get_progress (EV_TIMELINE (animation)); if (!priv->dest_surface) { /* animation is still not ready, paint the origin surface */ - paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1., page_area); return; } + g_object_get (priv->effect, "type", &type, NULL); + progress = ev_timeline_get_progress (EV_TIMELINE (animation)); + switch (type) { case EV_TRANSITION_EFFECT_REPLACE: /* just paint the destination slide */ - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); break; case EV_TRANSITION_EFFECT_SPLIT: ev_transition_animation_split (cr, animation, priv->effect, progress, page_area); @@ -608,7 +596,7 @@ ev_transition_animation_paint (EvTransitionAnimation *animation, enum_value->value_nick); /* just paint the destination slide */ - paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, 1., page_area); } } } @@ -634,6 +622,9 @@ ev_transition_animation_set_origin_surface (EvTransitionAnimation *animation, priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + if (priv->origin_surface == origin_surface) + return; + surface = cairo_surface_reference (origin_surface); if (priv->origin_surface) @@ -657,6 +648,9 @@ ev_transition_animation_set_dest_surface (EvTransitionAnimation *animation, priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + if (priv->dest_surface == dest_surface) + return; + surface = cairo_surface_reference (dest_surface); if (priv->dest_surface) @@ -678,5 +672,5 @@ ev_transition_animation_ready (EvTransitionAnimation *animation) priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); - return (priv->origin_surface && priv->dest_surface); + return (priv->origin_surface != NULL); }