mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:15:59 +01:00
Add option to request "plain" rendering of a page
"Plain" in this context means without any recoloring or rescaling.
This commit is contained in:
parent
36cd8da61f
commit
448a7cb57d
2 changed files with 56 additions and 13 deletions
|
@ -51,6 +51,7 @@ typedef struct request_private_s {
|
||||||
gint64 last_view_time;
|
gint64 last_view_time;
|
||||||
girara_list_t* active_jobs;
|
girara_list_t* active_jobs;
|
||||||
GMutex jobs_mutex;
|
GMutex jobs_mutex;
|
||||||
|
bool render_plain;
|
||||||
} ZathuraRenderRequestPrivate;
|
} ZathuraRenderRequestPrivate;
|
||||||
|
|
||||||
/* define the two types */
|
/* define the two types */
|
||||||
|
@ -252,6 +253,7 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
|
||||||
priv->page = page;
|
priv->page = page;
|
||||||
priv->active_jobs = girara_list_new();
|
priv->active_jobs = girara_list_new();
|
||||||
g_mutex_init(&priv->jobs_mutex);
|
g_mutex_init(&priv->jobs_mutex);
|
||||||
|
priv->render_plain = false;
|
||||||
|
|
||||||
/* register the request with the renderer */
|
/* register the request with the renderer */
|
||||||
renderer_register_request(renderer, request);
|
renderer_register_request(renderer, request);
|
||||||
|
@ -759,16 +761,22 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
||||||
const double height = zathura_page_get_height(page);
|
const double height = zathura_page_get_height(page);
|
||||||
const double width = zathura_page_get_width(page);
|
const double width = zathura_page_get_width(page);
|
||||||
|
|
||||||
|
zathura_device_factors_t device_factors = { 0 };
|
||||||
|
double real_scale = 1;
|
||||||
|
if (request_priv->render_plain == false) {
|
||||||
/* page size in user pixels based on document zoom: if PPI information is
|
/* page size in user pixels based on document zoom: if PPI information is
|
||||||
* correct, 100% zoom will result in 72 documents points per inch of screen
|
* correct, 100% zoom will result in 72 documents points per inch of screen
|
||||||
* (i.e. document size on screen matching the physical paper size). */
|
* (i.e. document size on screen matching the physical paper size). */
|
||||||
const double real_scale = page_calc_height_width(document, height, width,
|
real_scale = page_calc_height_width(document, height, width,
|
||||||
&page_height, &page_width,
|
&page_height, &page_width, false);
|
||||||
false);
|
|
||||||
|
|
||||||
const zathura_device_factors_t device_factors = zathura_document_get_device_factors(document);
|
device_factors = zathura_document_get_device_factors(document);
|
||||||
page_width *= device_factors.x;
|
page_width *= device_factors.x;
|
||||||
page_height *= device_factors.y;
|
page_height *= device_factors.y;
|
||||||
|
} else {
|
||||||
|
page_width = width;
|
||||||
|
page_height = height;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
|
cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
|
||||||
page_width, page_height);
|
page_width, page_height);
|
||||||
|
@ -776,7 +784,9 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request_priv->render_plain == false) {
|
||||||
cairo_surface_set_device_scale(surface, device_factors.x, device_factors.y);
|
cairo_surface_set_device_scale(surface, device_factors.x, device_factors.y);
|
||||||
|
}
|
||||||
|
|
||||||
if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
|
if (cairo_surface_status(surface) != CAIRO_STATUS_SUCCESS) {
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
@ -799,7 +809,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
|
||||||
}
|
}
|
||||||
|
|
||||||
/* recolor */
|
/* recolor */
|
||||||
if (priv->recolor.enabled == true) {
|
if (request_priv->render_plain == false && priv->recolor.enabled == true) {
|
||||||
recolor(priv, page, page_width, page_height, surface);
|
recolor(priv, page, page_width, page_height, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,3 +1023,22 @@ zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
|
||||||
g_return_if_fail(request != NULL);
|
g_return_if_fail(request != NULL);
|
||||||
g_signal_emit(request, request_signals[REQUEST_CACHE_ADDED], 0);
|
g_signal_emit(request, request_signals[REQUEST_CACHE_ADDED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void zathura_render_request_set_render_plain(ZathuraRenderRequest* request,
|
||||||
|
bool render_plain)
|
||||||
|
{
|
||||||
|
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
||||||
|
|
||||||
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
|
priv->render_plain =render_plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
zathura_render_request_get_render_plain(ZathuraRenderRequest* request)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(ZATHURA_IS_RENDER_REQUEST(request), false);
|
||||||
|
|
||||||
|
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
||||||
|
return priv->render_plain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,7 @@ ZathuraRenderRequest* zathura_render_request_new(ZathuraRenderer* renderer,
|
||||||
zathura_page_t* page);
|
zathura_page_t* page);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to add a page to the render thread list
|
* Add a page to the render thread list that should be rendered.
|
||||||
* that should be rendered.
|
|
||||||
*
|
*
|
||||||
* @param request request object of the page that should be renderer
|
* @param request request object of the page that should be renderer
|
||||||
* @param last_view_time last view time of the page
|
* @param last_view_time last view time of the page
|
||||||
|
@ -206,6 +205,21 @@ void zathura_render_request_abort(ZathuraRenderRequest* request);
|
||||||
*/
|
*/
|
||||||
void zathura_render_request_update_view_time(ZathuraRenderRequest* request);
|
void zathura_render_request_update_view_time(ZathuraRenderRequest* request);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set "plain" rendering mode, i.e. disabling scaling, recoloring, etc.
|
||||||
|
* @param request request that should be updated
|
||||||
|
* @param render_plain "plain" rendering setting
|
||||||
|
*/
|
||||||
|
void zathura_render_request_set_render_plain(ZathuraRenderRequest* request,
|
||||||
|
bool render_plain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get "plain" rendering mode, i.e. disabling scaling, recoloring, etc.
|
||||||
|
* @param request request that should be updated
|
||||||
|
* @returns "plain" rendering setting
|
||||||
|
*/
|
||||||
|
bool zathura_render_request_get_render_plain(ZathuraRenderRequest* request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used to unmark all pages as not rendered. This should
|
* This function is used to unmark all pages as not rendered. This should
|
||||||
* be used if all pages should be rendered again (e.g.: the zoom level or the
|
* be used if all pages should be rendered again (e.g.: the zoom level or the
|
||||||
|
|
Loading…
Reference in a new issue