mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 20:56:00 +01:00
Don't store surface for invisible and uncached pages
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
f98514d5ed
commit
b5237680f2
5 changed files with 43 additions and 6 deletions
|
@ -106,6 +106,12 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
|
|||
}
|
||||
} else {
|
||||
zathura_page_set_visibility(page, false);
|
||||
/* if the page is not visible and not cached, but still has a surface, we
|
||||
* need to get rid of the surface */
|
||||
if (zathura_page_widget_have_surface(ZATHURA_PAGE(page_widget)) == true &&
|
||||
zathura_page_cache_is_cached(zathura, zathura_page_get_index(page)) == false) {
|
||||
zathura_page_widget_update_surface(ZATHURA_PAGE(page_widget), NULL);
|
||||
}
|
||||
|
||||
girara_list_t* results = NULL;
|
||||
g_object_get(page_widget, "search-results", &results, NULL);
|
||||
|
|
|
@ -506,11 +506,16 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface
|
|||
mutex_lock(&(priv->lock));
|
||||
if (priv->surface != NULL) {
|
||||
cairo_surface_destroy(priv->surface);
|
||||
priv->surface = NULL;
|
||||
}
|
||||
priv->render_requested = false;
|
||||
priv->surface = surface;
|
||||
if (priv->surface != NULL) {
|
||||
cairo_surface_reference(surface);
|
||||
if (surface != NULL) {
|
||||
/* if we're not visible or not cached, we don't care about the surface */
|
||||
if (zathura_page_get_visibility(priv->page) == true ||
|
||||
zathura_page_cache_is_cached(priv->zathura, zathura_page_get_index(priv->page)) == true) {
|
||||
priv->surface = surface;
|
||||
cairo_surface_reference(surface);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&(priv->lock));
|
||||
/* force a redraw here */
|
||||
|
@ -876,3 +881,12 @@ zathura_page_widget_update_view_time(ZathuraPage* widget)
|
|||
priv->last_view = g_get_real_time();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
zathura_page_widget_have_surface(ZathuraPage* widget)
|
||||
{
|
||||
g_return_val_if_fail(ZATHURA_IS_PAGE(widget) == TRUE, false);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
return priv->surface != NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -88,4 +88,12 @@ zathura_link_t* zathura_page_widget_link_get(ZathuraPage* widget, unsigned int i
|
|||
*/
|
||||
void zathura_page_widget_update_view_time(ZathuraPage* widget);
|
||||
|
||||
/**
|
||||
* Check if we have a surface.
|
||||
*
|
||||
* @param widget the widget
|
||||
* @returns true if the widget has a surface, false otherwise
|
||||
*/
|
||||
bool zathura_page_widget_have_surface(ZathuraPage* widget);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -54,7 +54,6 @@ typedef struct position_set_delayed_s {
|
|||
} position_set_delayed_t;
|
||||
|
||||
static gboolean document_info_open(gpointer data);
|
||||
static bool zathura_page_cache_is_cached(zathura_t* zathura, unsigned int page_index);
|
||||
static ssize_t zathura_page_cache_lru_invalidate(zathura_t* zathura);
|
||||
static void zathura_page_cache_invalidate_all(zathura_t* zathura);
|
||||
static bool zathura_page_cache_is_full(zathura_t* zathura, bool* result);
|
||||
|
@ -1364,7 +1363,7 @@ zathura_jumplist_save(zathura_t* zathura)
|
|||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
bool
|
||||
zathura_page_cache_is_cached(zathura_t* zathura, unsigned int page_index)
|
||||
{
|
||||
g_return_val_if_fail(zathura != NULL, false);
|
||||
|
@ -1452,7 +1451,7 @@ zathura_page_cache_add(zathura_t* zathura, unsigned int page_index)
|
|||
|
||||
g_return_if_fail(page != NULL);
|
||||
|
||||
if (zathura_page_cache_is_cached(zathura, page_index)) {
|
||||
if (zathura_page_cache_is_cached(zathura, page_index) == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
10
zathura.h
10
zathura.h
|
@ -421,4 +421,14 @@ bool zathura_jumplist_load(zathura_t* zathura, const char* file);
|
|||
*/
|
||||
void zathura_page_cache_add(zathura_t* zathura, unsigned int page_index);
|
||||
|
||||
/**
|
||||
* Checks if the given page is cached
|
||||
*
|
||||
* @param zathura The zathura session
|
||||
* @param page_index The index of the page that may be cached
|
||||
*
|
||||
* @return true if page is cached otherwise false
|
||||
*/
|
||||
bool zathura_page_cache_is_cached(zathura_t* zathura, unsigned int page_index);
|
||||
|
||||
#endif // ZATHURA_H
|
||||
|
|
Loading…
Reference in a new issue