From 7594280f6850f95297ef88aeb2dac9ca6a6de53f Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Mon, 04 Jan 2010 10:58:31 +0000 Subject: [presentation] Make sure we always have a valid surface to draw a page It avoids flickering or even a black screen when changing pages fast. Fixes bug #602738. --- (limited to 'libview') diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c index 2dfed6a..c516602 100644 --- a/libview/ev-view-presentation.c +++ b/libview/ev-view-presentation.c @@ -57,6 +57,7 @@ struct _EvViewPresentation GtkWidget base; guint current_page; + cairo_surface_t *current_surface; EvDocument *document; guint rotation; EvPresentationState state; @@ -291,7 +292,9 @@ ev_view_presentation_animation_start (EvViewPresentation *pview, pview->animation = ev_transition_animation_new (effect); surface = EV_JOB_RENDER (pview->curr_job)->surface; - ev_transition_animation_set_origin_surface (pview->animation, surface); + ev_transition_animation_set_origin_surface (pview->animation, + surface != NULL ? + surface : pview->current_surface); jump = new_page - pview->current_page; if (jump == -1) @@ -878,6 +881,19 @@ ev_view_presentation_hide_cursor_timeout_start (EvViewPresentation *pview) } static void +ev_view_presentation_update_current_surface (EvViewPresentation *pview, + cairo_surface_t *surface) +{ + if (!surface || pview->current_surface == surface) + return; + + cairo_surface_reference (surface); + if (pview->current_surface) + cairo_surface_destroy (pview->current_surface); + pview->current_surface = surface; +} + +static void ev_view_presentation_destroy (GtkObject *object) { EvViewPresentation *pview = EV_VIEW_PRESENTATION (object); @@ -906,6 +922,11 @@ ev_view_presentation_destroy (GtkObject *object) pview->next_job = NULL; } + if (pview->current_surface) { + cairo_surface_destroy (pview->current_surface); + pview->current_surface = NULL; + } + if (pview->page_cache) { g_object_unref (pview->page_cache); pview->page_cache = NULL; @@ -1026,8 +1047,13 @@ ev_view_presentation_expose_event (GtkWidget *widget, } surface = pview->curr_job ? EV_JOB_RENDER (pview->curr_job)->surface : NULL; - if (!surface) + if (surface) { + ev_view_presentation_update_current_surface (pview, surface); + } else if (pview->current_surface) { + surface = pview->current_surface; + } else { return FALSE; + } ev_view_presentation_get_page_area (pview, &page_area); if (gdk_rectangle_intersect (&page_area, &(event->area), &overlap)) { -- cgit v0.9.1