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 <sebastian+dev@ramacher.at>
This commit is contained in:
Sebastian Ramacher 2013-02-24 03:26:29 +01:00 committed by Sebastian Ramacher
parent 35adeacbf5
commit 7ad6c2f422

View File

@ -22,6 +22,7 @@ typedef struct zathura_page_widget_private_s {
zathura_page_t* page; /**< Page object */ zathura_page_t* page; /**< Page object */
zathura_t* zathura; /**< Zathura object */ zathura_t* zathura; /**< Zathura object */
cairo_surface_t* surface; /**< Cairo surface */ 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 */ gint64 last_view; /**< Last time the page has been viewed */
mutex lock; /**< Lock */ mutex lock; /**< Lock */
@ -142,6 +143,7 @@ zathura_page_widget_init(ZathuraPage* widget)
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
priv->page = NULL; priv->page = NULL;
priv->surface = NULL; priv->surface = NULL;
priv->render_requested = false;
priv->last_view = g_get_real_time(); priv->last_view = g_get_real_time();
priv->links.list = NULL; priv->links.list = NULL;
@ -467,8 +469,11 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
} }
/* render real page */ /* render real page */
if (priv->render_requested == false) {
priv->render_requested = true;
render_page(priv->zathura->sync.render_thread, priv->page); render_page(priv->zathura->sync.render_thread, priv->page);
} }
}
mutex_unlock(&(priv->lock)); mutex_unlock(&(priv->lock));
return FALSE; return FALSE;
} }
@ -489,6 +494,7 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface
cairo_surface_finish(priv->surface); cairo_surface_finish(priv->surface);
cairo_surface_destroy(priv->surface); cairo_surface_destroy(priv->surface);
} }
priv->render_requested = false;
priv->surface = surface; priv->surface = surface;
mutex_unlock(&(priv->lock)); mutex_unlock(&(priv->lock));
/* force a redraw here */ /* force a redraw here */