From 7ad6c2f42296533858db3de0749bd4f0f9c5dddf Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 24 Feb 2013 03:26:29 +0100 Subject: [PATCH] Don't render same page multiple times If we have already requested a page to be rendered, we don't have to request it once again. Signed-off-by: Sebastian Ramacher --- page-widget.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/page-widget.c b/page-widget.c index 58ccd71..bf94ba3 100644 --- a/page-widget.c +++ b/page-widget.c @@ -22,6 +22,7 @@ typedef struct zathura_page_widget_private_s { zathura_page_t* page; /**< Page object */ zathura_t* zathura; /**< Zathura object */ cairo_surface_t* surface; /**< Cairo surface */ + bool render_requested; /**< No surface and rendering has been requested */ gint64 last_view; /**< Last time the page has been viewed */ mutex lock; /**< Lock */ @@ -140,9 +141,10 @@ static void zathura_page_widget_init(ZathuraPage* widget) { zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); - priv->page = NULL; - priv->surface = NULL; - priv->last_view = g_get_real_time(); + priv->page = NULL; + priv->surface = NULL; + priv->render_requested = false; + priv->last_view = g_get_real_time(); priv->links.list = NULL; priv->links.retrieved = false; @@ -467,7 +469,10 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) } /* render real page */ - render_page(priv->zathura->sync.render_thread, priv->page); + if (priv->render_requested == false) { + priv->render_requested = true; + render_page(priv->zathura->sync.render_thread, priv->page); + } } mutex_unlock(&(priv->lock)); return FALSE; @@ -489,6 +494,7 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface cairo_surface_finish(priv->surface); cairo_surface_destroy(priv->surface); } + priv->render_requested = false; priv->surface = surface; mutex_unlock(&(priv->lock)); /* force a redraw here */