This commit is contained in:
Sebastian Ramacher 2024-03-02 21:27:06 +01:00
parent 0c395610ff
commit ab78c1ddb0

View file

@ -56,7 +56,8 @@ typedef struct request_private_s {
/* define the two types */ /* define the two types */
G_DEFINE_TYPE_WITH_CODE(ZathuraRenderer, zathura_renderer, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraRenderer)) G_DEFINE_TYPE_WITH_CODE(ZathuraRenderer, zathura_renderer, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraRenderer))
G_DEFINE_TYPE_WITH_CODE(ZathuraRenderRequest, zathura_render_request, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraRenderRequest)) G_DEFINE_TYPE_WITH_CODE(ZathuraRenderRequest, zathura_render_request, G_TYPE_OBJECT,
G_ADD_PRIVATE(ZathuraRenderRequest))
/* private methods for ZathuraRenderer */ /* private methods for ZathuraRenderer */
static void renderer_finalize(GObject* object); static void renderer_finalize(GObject* object);
@ -78,17 +79,13 @@ typedef struct render_job_s {
/* init, new and free for ZathuraRenderer */ /* init, new and free for ZathuraRenderer */
static void static void zathura_renderer_class_init(ZathuraRendererClass* class) {
zathura_renderer_class_init(ZathuraRendererClass* class)
{
/* overwrite methods */ /* overwrite methods */
GObjectClass* object_class = G_OBJECT_CLASS(class); GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->finalize = renderer_finalize; object_class->finalize = renderer_finalize;
} }
static void static void zathura_renderer_init(ZathuraRenderer* renderer) {
zathura_renderer_init(ZathuraRenderer* renderer)
{
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL); priv->pool = g_thread_pool_new(render_job, renderer, 1, TRUE, NULL);
priv->about_to_close = false; priv->about_to_close = false;
@ -110,9 +107,7 @@ zathura_renderer_init(ZathuraRenderer* renderer)
priv->requests = girara_list_new(); priv->requests = girara_list_new();
} }
static bool static bool page_cache_init(ZathuraRenderer* renderer, size_t cache_size) {
page_cache_init(ZathuraRenderer* renderer, size_t cache_size)
{
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
priv->page_cache.size = cache_size; priv->page_cache.size = cache_size;
@ -125,9 +120,7 @@ page_cache_init(ZathuraRenderer* renderer, size_t cache_size)
return true; return true;
} }
ZathuraRenderer* ZathuraRenderer* zathura_renderer_new(size_t cache_size) {
zathura_renderer_new(size_t cache_size)
{
g_return_val_if_fail(cache_size > 0, NULL); g_return_val_if_fail(cache_size > 0, NULL);
GObject* obj = g_object_new(ZATHURA_TYPE_RENDERER, NULL); GObject* obj = g_object_new(ZATHURA_TYPE_RENDERER, NULL);
@ -141,9 +134,7 @@ zathura_renderer_new(size_t cache_size)
return ret; return ret;
} }
static void static void renderer_finalize(GObject* object) {
renderer_finalize(GObject* object)
{
ZathuraRenderer* renderer = ZATHURA_RENDERER(object); ZathuraRenderer* renderer = ZATHURA_RENDERER(object);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
@ -159,18 +150,12 @@ renderer_finalize(GObject* object)
/* (un)register requests at the renderer */ /* (un)register requests at the renderer */
static void static void renderer_unregister_request(ZathuraRenderer* renderer, ZathuraRenderRequest* request) {
renderer_unregister_request(ZathuraRenderer* renderer,
ZathuraRenderRequest* request)
{
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
girara_list_remove(priv->requests, request); girara_list_remove(priv->requests, request);
} }
static void static void renderer_register_request(ZathuraRenderer* renderer, ZathuraRenderRequest* request) {
renderer_register_request(ZathuraRenderer* renderer,
ZathuraRenderRequest* request)
{
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
if (girara_list_contains(priv->requests, request) == false) { if (girara_list_contains(priv->requests, request) == false) {
girara_list_append(priv->requests, request); girara_list_append(priv->requests, request);
@ -179,66 +164,35 @@ renderer_register_request(ZathuraRenderer* renderer,
/* init, new and free for ZathuraRenderRequest */ /* init, new and free for ZathuraRenderRequest */
enum { enum { REQUEST_COMPLETED, REQUEST_CACHE_ADDED, REQUEST_CACHE_INVALIDATED, REQUEST_LAST_SIGNAL };
REQUEST_COMPLETED,
REQUEST_CACHE_ADDED,
REQUEST_CACHE_INVALIDATED,
REQUEST_LAST_SIGNAL
};
static guint request_signals[REQUEST_LAST_SIGNAL] = { 0 }; static guint request_signals[REQUEST_LAST_SIGNAL] = {0};
static void static void zathura_render_request_class_init(ZathuraRenderRequestClass* class) {
zathura_render_request_class_init(ZathuraRenderRequestClass* class)
{
/* overwrite methods */ /* overwrite methods */
GObjectClass* object_class = G_OBJECT_CLASS(class); GObjectClass* object_class = G_OBJECT_CLASS(class);
object_class->dispose = render_request_dispose; object_class->dispose = render_request_dispose;
object_class->finalize = render_request_finalize; object_class->finalize = render_request_finalize;
request_signals[REQUEST_COMPLETED] = g_signal_new("completed", request_signals[REQUEST_COMPLETED] =
ZATHURA_TYPE_RENDER_REQUEST, g_signal_new("completed", ZATHURA_TYPE_RENDER_REQUEST, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
G_SIGNAL_RUN_LAST, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_POINTER);
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
1,
G_TYPE_POINTER);
request_signals[REQUEST_CACHE_ADDED] = g_signal_new("cache-added", request_signals[REQUEST_CACHE_ADDED] = g_signal_new("cache-added", ZATHURA_TYPE_RENDER_REQUEST, G_SIGNAL_RUN_LAST, 0,
ZATHURA_TYPE_RENDER_REQUEST, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0);
G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
0);
request_signals[REQUEST_CACHE_INVALIDATED] = g_signal_new("cache-invalidated", request_signals[REQUEST_CACHE_INVALIDATED] =
ZATHURA_TYPE_RENDER_REQUEST, g_signal_new("cache-invalidated", ZATHURA_TYPE_RENDER_REQUEST, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
G_SIGNAL_RUN_LAST, g_cclosure_marshal_generic, G_TYPE_NONE, 0);
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
0);
} }
static void static void zathura_render_request_init(ZathuraRenderRequest* request) {
zathura_render_request_init(ZathuraRenderRequest* request)
{
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
priv->renderer = NULL; priv->renderer = NULL;
priv->page = NULL; priv->page = NULL;
} }
ZathuraRenderRequest* ZathuraRenderRequest* zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page) {
zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
{
g_return_val_if_fail(renderer != NULL && page != NULL, NULL); g_return_val_if_fail(renderer != NULL && page != NULL, NULL);
GObject* obj = g_object_new(ZATHURA_TYPE_RENDER_REQUEST, NULL); GObject* obj = g_object_new(ZATHURA_TYPE_RENDER_REQUEST, NULL);
@ -261,9 +215,7 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
return request; return request;
} }
static void static void render_request_dispose(GObject* object) {
render_request_dispose(GObject* object)
{
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object); ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
@ -277,9 +229,7 @@ render_request_dispose(GObject* object)
G_OBJECT_CLASS(zathura_render_request_parent_class)->dispose(object); G_OBJECT_CLASS(zathura_render_request_parent_class)->dispose(object);
} }
static void static void render_request_finalize(GObject* object) {
render_request_finalize(GObject* object)
{
ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object); ZathuraRenderRequest* request = ZATHURA_RENDER_REQUEST(object);
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
@ -294,63 +244,48 @@ render_request_finalize(GObject* object)
/* renderer methods */ /* renderer methods */
bool bool zathura_renderer_recolor_enabled(ZathuraRenderer* renderer) {
zathura_renderer_recolor_enabled(ZathuraRenderer* renderer)
{
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false); g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
return priv->recolor.enabled; return priv->recolor.enabled;
} }
void void zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable) {
zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
priv->recolor.enabled = enable; priv->recolor.enabled = enable;
} }
bool bool zathura_renderer_recolor_hue_enabled(ZathuraRenderer* renderer) {
zathura_renderer_recolor_hue_enabled(ZathuraRenderer* renderer)
{
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false); g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
return priv->recolor.hue; return priv->recolor.hue;
} }
void void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable) {
zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
priv->recolor.hue = enable; priv->recolor.hue = enable;
} }
bool bool zathura_renderer_recolor_reverse_video_enabled(ZathuraRenderer* renderer) {
zathura_renderer_recolor_reverse_video_enabled(ZathuraRenderer* renderer)
{
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false); g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer), false);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
return priv->recolor.reverse_video; return priv->recolor.reverse_video;
} }
void void zathura_renderer_enable_recolor_reverse_video(ZathuraRenderer* renderer, bool enable) {
zathura_renderer_enable_recolor_reverse_video(ZathuraRenderer* renderer, bool enable)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
priv->recolor.reverse_video = enable; priv->recolor.reverse_video = enable;
} }
void void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer, const GdkRGBA* light, const GdkRGBA* dark) {
zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
const GdkRGBA* light, const GdkRGBA* dark)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
@ -362,10 +297,7 @@ zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
} }
} }
void void zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer, const char* light, const char* dark) {
zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
const char* light, const char* dark)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
if (dark != NULL) { if (dark != NULL) {
@ -382,10 +314,7 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
} }
} }
void void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer, GdkRGBA* light, GdkRGBA* dark) {
zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
GdkRGBA* light, GdkRGBA* dark)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
@ -397,33 +326,26 @@ zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
} }
} }
void void zathura_renderer_lock(ZathuraRenderer* renderer) {
zathura_renderer_lock(ZathuraRenderer* renderer)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
g_mutex_lock(&priv->mutex); g_mutex_lock(&priv->mutex);
} }
void void zathura_renderer_unlock(ZathuraRenderer* renderer) {
zathura_renderer_unlock(ZathuraRenderer* renderer)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
g_mutex_unlock(&priv->mutex); g_mutex_unlock(&priv->mutex);
} }
void void zathura_renderer_stop(ZathuraRenderer* renderer) {
zathura_renderer_stop(ZathuraRenderer* renderer)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
priv->about_to_close = true; priv->about_to_close = true;
} }
/* ZathuraRenderRequest methods */ /* ZathuraRenderRequest methods */
void zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time) { void zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time) {
@ -475,9 +397,7 @@ void zathura_render_request_abort(ZathuraRenderRequest* request) {
g_mutex_unlock(&request_priv->jobs_mutex); g_mutex_unlock(&request_priv->jobs_mutex);
} }
void void zathura_render_request_update_view_time(ZathuraRenderRequest* request) {
zathura_render_request_update_view_time(ZathuraRenderRequest* request)
{
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request)); g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
@ -486,9 +406,7 @@ zathura_render_request_update_view_time(ZathuraRenderRequest* request)
/* render job */ /* render job */
static void static void remove_job_and_free(render_job_t* job) {
remove_job_and_free(render_job_t* job)
{
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(job->request); ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(job->request);
g_mutex_lock(&request_priv->jobs_mutex); g_mutex_lock(&request_priv->jobs_mutex);
@ -499,15 +417,12 @@ remove_job_and_free(render_job_t* job)
g_free(job); g_free(job);
} }
typedef struct emit_completed_signal_s typedef struct emit_completed_signal_s {
{
render_job_t* job; render_job_t* job;
cairo_surface_t* surface; cairo_surface_t* surface;
} emit_completed_signal_t; } emit_completed_signal_t;
static gboolean static gboolean emit_completed_signal(void* data) {
emit_completed_signal(void* data)
{
emit_completed_signal_t* ecs = data; emit_completed_signal_t* ecs = data;
render_job_t* job = ecs->job; render_job_t* job = ecs->job;
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(job->request); ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(job->request);
@ -515,12 +430,10 @@ emit_completed_signal(void* data)
if (priv->about_to_close == false && job->aborted == false) { if (priv->about_to_close == false && job->aborted == false) {
/* emit the signal */ /* emit the signal */
girara_debug("Emitting signal for page %d", girara_debug("Emitting signal for page %d", zathura_page_get_index(request_priv->page) + 1);
zathura_page_get_index(request_priv->page) + 1);
g_signal_emit(job->request, request_signals[REQUEST_COMPLETED], 0, ecs->surface); g_signal_emit(job->request, request_signals[REQUEST_COMPLETED], 0, ecs->surface);
} else { } else {
girara_debug("Rendering of page %d aborted", girara_debug("Rendering of page %d aborted", zathura_page_get_index(request_priv->page) + 1);
zathura_page_get_index(request_priv->page) + 1);
} }
/* mark the request as done */ /* mark the request as done */
remove_job_and_free(job); remove_job_and_free(job);
@ -535,9 +448,7 @@ emit_completed_signal(void* data)
/* Returns the maximum possible saturation for given h and l. /* Returns the maximum possible saturation for given h and l.
Assumes that l is in the interval l1, l2 and corrects the value to Assumes that l is in the interval l1, l2 and corrects the value to
force u=0 on l1 and l2 */ force u=0 on l1 and l2 */
static double static double colorumax(const double h[3], double l, double l1, double l2) {
colorumax(const double h[3], double l, double l1, double l2)
{
if (fabs(h[0]) <= DBL_EPSILON && fabs(h[1]) <= DBL_EPSILON && fabs(h[2]) <= DBL_EPSILON) { if (fabs(h[0]) <= DBL_EPSILON && fabs(h[1]) <= DBL_EPSILON && fabs(h[2]) <= DBL_EPSILON) {
return 0; return 0;
} }
@ -547,11 +458,11 @@ colorumax(const double h[3], double l, double l1, double l2)
double v = DBL_MAX; double v = DBL_MAX;
for (unsigned int k = 0; k < 3; ++k) { for (unsigned int k = 0; k < 3; ++k) {
if (h[k] > DBL_EPSILON) { if (h[k] > DBL_EPSILON) {
u = fmin(fabs((1-l)/h[k]), u); u = fmin(fabs((1 - l) / h[k]), u);
v = fmin(fabs((1-lv)/h[k]), v); v = fmin(fabs((1 - lv) / h[k]), v);
} else if (h[k] < -DBL_EPSILON) { } else if (h[k] < -DBL_EPSILON) {
u = fmin(fabs(l/h[k]), u); u = fmin(fabs(l / h[k]), u);
v = fmin(fabs(lv/h[k]), v); v = fmin(fabs(lv / h[k]), v);
} }
} }
@ -562,10 +473,8 @@ colorumax(const double h[3], double l, double l1, double l2)
return fmin(u, v); return fmin(u, v);
} }
static void static void recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_width,
recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_width, unsigned int page_height, cairo_surface_t* surface) {
unsigned int page_height, cairo_surface_t* surface)
{
/* uses a representation of a rgb color as follows: /* uses a representation of a rgb color as follows:
- a lightness scalar (between 0,1), which is a weighted average of r, g, b, - a lightness scalar (between 0,1), which is a weighted average of r, g, b,
- a hue vector, which indicates a radian direction from the grey axis, - a hue vector, which indicates a radian direction from the grey axis,
@ -586,39 +495,35 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
unsigned char* image = cairo_image_surface_get_data(surface); unsigned char* image = cairo_image_surface_get_data(surface);
/* RGB weights for computing lightness. Must sum to one */ /* RGB weights for computing lightness. Must sum to one */
static const double a[] = {0.30, 0.59, 0.11}; static const double weights[] = {0.30, 0.59, 0.11};
const GdkRGBA rgb1 = priv->recolor.dark; const GdkRGBA rgb1 = priv->recolor.dark;
const GdkRGBA rgb2 = priv->recolor.light; const GdkRGBA rgb2 = priv->recolor.light;
const double l1 = a[0]*rgb1.red + a[1]*rgb1.green + a[2]*rgb1.blue; const double l1 = weights[0] * rgb1.red + weights[1] * rgb1.green + weights[2] * rgb1.blue;
const double l2 = a[0]*rgb2.red + a[1]*rgb2.green + a[2]*rgb2.blue; const double l2 = weights[0] * rgb2.red + weights[1] * rgb2.green + weights[2] * rgb2.blue;
const double negalph1 = 1. - rgb1.alpha; const double negalph1 = 1. - rgb1.alpha;
const double negalph2 = 1. - rgb2.alpha; const double negalph2 = 1. - rgb2.alpha;
const double rgb_diff[] = { const double rgb_diff[] = {rgb2.red - rgb1.red, rgb2.green - rgb1.green, rgb2.blue - rgb1.blue};
rgb2.red - rgb1.red,
rgb2.green - rgb1.green,
rgb2.blue - rgb1.blue
};
const double h1[3] = { const double h1[3] = {
rgb1.red*rgb1.alpha - l1, rgb1.red * rgb1.alpha - l1,
rgb1.green*rgb1.alpha - l1, rgb1.green * rgb1.alpha - l1,
rgb1.blue*rgb1.alpha - l1, rgb1.blue * rgb1.alpha - l1,
}; };
const double h2[3] = { const double h2[3] = {
rgb2.red*rgb2.alpha - l2, rgb2.red * rgb2.alpha - l2,
rgb2.green*rgb2.alpha - l2, rgb2.green * rgb2.alpha - l2,
rgb2.blue*rgb2.alpha - l2, rgb2.blue * rgb2.alpha - l2,
}; };
/* Decide if we can use the older, faster formulas */ /* Decide if we can use the older, faster formulas */
const bool fast_formula = (!priv->recolor.hue || ( const bool fast_formula =
fabs(rgb1.red - rgb1.blue) < DBL_EPSILON && fabs(rgb1.red - rgb1.green) < DBL_EPSILON && (!priv->recolor.hue || (fabs(rgb1.red - rgb1.blue) < DBL_EPSILON && fabs(rgb1.red - rgb1.green) < DBL_EPSILON &&
fabs(rgb2.red - rgb2.blue) < DBL_EPSILON && fabs(rgb2.red - rgb2.green) < DBL_EPSILON fabs(rgb2.red - rgb2.blue) < DBL_EPSILON && fabs(rgb2.red - rgb2.green) < DBL_EPSILON)) &&
)) && (rgb1.alpha >= 1. - DBL_EPSILON && rgb2.alpha >= 1. - DBL_EPSILON); (rgb1.alpha >= 1. - DBL_EPSILON && rgb2.alpha >= 1. - DBL_EPSILON);
girara_list_t* images = NULL; girara_list_t* images = NULL;
girara_list_t* rectangles = NULL; girara_list_t* rectangles = NULL;
@ -672,23 +577,15 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
} }
/* Careful. data color components blue, green, red. */ /* Careful. data color components blue, green, red. */
const double rgb[3] = { const double rgb[3] = {data[2] / 255., data[1] / 255., data[0] / 255.};
data[2] / 255.,
data[1] / 255.,
data[0] / 255.
};
/* compute h, s, l data */ /* compute h, s, l data */
double l = a[0]*rgb[0] + a[1]*rgb[1] + a[2]*rgb[2]; double l = weights[0] * rgb[0] + weights[1] * rgb[1] + weights[2] * rgb[2];
if (priv->recolor.hue == true) { if (priv->recolor.hue == true) {
/* adjusting lightness keeping hue of current color. white and black /* adjusting lightness keeping hue of current color. white and black
* go to grays of same ligtness as light and dark colors. */ * go to grays of same ligtness as light and dark colors. */
const double h[3] = { const double h[3] = {rgb[0] - l, rgb[1] - l, rgb[2] - l};
rgb[0] - l,
rgb[1] - l,
rgb[2] - l
};
/* u is the maximum possible saturation for given h and l. s is a /* u is the maximum possible saturation for given h and l. s is a
* rescaled saturation between 0 and 1 */ * rescaled saturation between 0 and 1 */
@ -703,34 +600,34 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
if (fast_formula) { if (fast_formula) {
data[3] = 255; data[3] = 255;
data[2] = (unsigned char)round(255.*(l + su * h[0])); data[2] = (unsigned char)round(255. * (l + su * h[0]));
data[1] = (unsigned char)round(255.*(l + su * h[1])); data[1] = (unsigned char)round(255. * (l + su * h[1]));
data[0] = (unsigned char)round(255.*(l + su * h[2])); data[0] = (unsigned char)round(255. * (l + su * h[2]));
} else { } else {
/* Mix lightcolor, darkcolor and the original color, according to the /* Mix lightcolor, darkcolor and the original color, according to the
* minimal and maximal channel of the original color */ * minimal and maximal channel of the original color */
const double tr1 = (1. - fmax(fmax(rgb[0], rgb[1]), rgb[2])); const double tr1 = (1. - fmax(fmax(rgb[0], rgb[1]), rgb[2]));
const double tr2 = fmin(fmin(rgb[0], rgb[1]), rgb[2]); const double tr2 = fmin(fmin(rgb[0], rgb[1]), rgb[2]);
data[3] = (unsigned char)round(255.*(1. - tr1*negalph1 - tr2*negalph2)); data[3] = (unsigned char)round(255. * (1. - tr1 * negalph1 - tr2 * negalph2));
data[2] = (unsigned char)round(255.*fmin(1, fmax(0, tr1*h1[0] + tr2*h2[0] + (l + su * h[0])))); data[2] = (unsigned char)round(255. * fmin(1, fmax(0, tr1 * h1[0] + tr2 * h2[0] + (l + su * h[0]))));
data[1] = (unsigned char)round(255.*fmin(1, fmax(0, tr1*h1[1] + tr2*h2[1] + (l + su * h[1])))); data[1] = (unsigned char)round(255. * fmin(1, fmax(0, tr1 * h1[1] + tr2 * h2[1] + (l + su * h[1]))));
data[0] = (unsigned char)round(255.*fmin(1, fmax(0, tr1*h1[2] + tr2*h2[2] + (l + su * h[2])))); data[0] = (unsigned char)round(255. * fmin(1, fmax(0, tr1 * h1[2] + tr2 * h2[2] + (l + su * h[2]))));
} }
} else { } else {
/* linear interpolation between dark and light with color ligtness as /* linear interpolation between dark and light with color ligtness as
* a parameter */ * a parameter */
if (fast_formula) { if (fast_formula) {
data[3] = 255; data[3] = 255;
data[2] = (unsigned char)round(255.*(l * rgb_diff[0] + rgb1.red)); data[2] = (unsigned char)round(255. * (l * rgb_diff[0] + rgb1.red));
data[1] = (unsigned char)round(255.*(l * rgb_diff[1] + rgb1.green)); data[1] = (unsigned char)round(255. * (l * rgb_diff[1] + rgb1.green));
data[0] = (unsigned char)round(255.*(l * rgb_diff[2] + rgb1.blue)); data[0] = (unsigned char)round(255. * (l * rgb_diff[2] + rgb1.blue));
} else { } else {
const double f1 = 1. - (1. - fmax(fmax(rgb[0], rgb[1]), rgb[2]))*negalph1; const double f1 = 1. - (1. - fmax(fmax(rgb[0], rgb[1]), rgb[2])) * negalph1;
const double f2 = fmin(fmin(rgb[0], rgb[1]), rgb[2])*negalph2; const double f2 = fmin(fmin(rgb[0], rgb[1]), rgb[2]) * negalph2;
data[3] = (unsigned char)round(255.*(f1 - f2)); data[3] = (unsigned char)round(255. * (f1 - f2));
data[2] = (unsigned char)round(255.*(l * rgb_diff[0] - f2*rgb2.red + f1*rgb1.red)); data[2] = (unsigned char)round(255. * (l * rgb_diff[0] - f2 * rgb2.red + f1 * rgb1.red));
data[1] = (unsigned char)round(255.*(l * rgb_diff[1] - f2*rgb2.green + f1*rgb1.green)); data[1] = (unsigned char)round(255. * (l * rgb_diff[1] - f2 * rgb2.green + f1 * rgb1.green));
data[0] = (unsigned char)round(255.*(l * rgb_diff[2] - f2*rgb2.blue + f1*rgb1.blue)); data[0] = (unsigned char)round(255. * (l * rgb_diff[2] - f2 * rgb2.blue + f1 * rgb1.blue));
} }
} }
} }
@ -746,9 +643,7 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
cairo_surface_mark_dirty(surface); cairo_surface_mark_dirty(surface);
} }
static bool static bool invoke_completed_signal(render_job_t* job, cairo_surface_t* surface) {
invoke_completed_signal(render_job_t* job, cairo_surface_t* surface)
{
emit_completed_signal_t* ecs = g_try_malloc0(sizeof(emit_completed_signal_t)); emit_completed_signal_t* ecs = g_try_malloc0(sizeof(emit_completed_signal_t));
if (ecs == NULL) { if (ecs == NULL) {
return false; return false;
@ -762,9 +657,8 @@ invoke_completed_signal(render_job_t* job, cairo_surface_t* surface)
return true; return true;
} }
static bool static bool render_to_cairo_surface(cairo_surface_t* surface, zathura_page_t* page, ZathuraRenderer* renderer,
render_to_cairo_surface(cairo_surface_t* surface, zathura_page_t* page, ZathuraRenderer* renderer, double real_scale) double real_scale) {
{
cairo_t* cairo = cairo_create(surface); cairo_t* cairo = cairo_create(surface);
if (cairo_status(cairo) != CAIRO_STATUS_SUCCESS) { if (cairo_status(cairo) != CAIRO_STATUS_SUCCESS) {
return false; return false;
@ -788,9 +682,7 @@ render_to_cairo_surface(cairo_surface_t* surface, zathura_page_t* page, ZathuraR
return err == ZATHURA_ERROR_OK; return err == ZATHURA_ERROR_OK;
} }
static bool static bool render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* renderer) {
render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* renderer)
{
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
zathura_page_t* page = request_priv->page; zathura_page_t* page = request_priv->page;
@ -804,14 +696,13 @@ 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 }; zathura_device_factors_t device_factors = {0};
double real_scale = 1; double real_scale = 1;
if (request_priv->render_plain == false) { 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). */
real_scale = page_calc_height_width(document, height, width, real_scale = page_calc_height_width(document, height, width, &page_height, &page_width, false);
&page_height, &page_width, false);
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;
@ -824,12 +715,10 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
cairo_format_t format; cairo_format_t format;
if (priv->recolor.enabled) { if (priv->recolor.enabled) {
format = CAIRO_FORMAT_ARGB32; format = CAIRO_FORMAT_ARGB32;
} } else {
else {
format = CAIRO_FORMAT_RGB24; format = CAIRO_FORMAT_RGB24;
} }
cairo_surface_t* surface = cairo_image_surface_create(format, cairo_surface_t* surface = cairo_image_surface_create(format, page_width, page_height);
page_width, page_height);
if (request_priv->render_plain == 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);
} }
@ -847,8 +736,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
/* before recoloring, check if we've been aborted */ /* before recoloring, check if we've been aborted */
if (priv->about_to_close == true || job->aborted == true) { if (priv->about_to_close == true || job->aborted == true) {
girara_debug("Rendering of page %d aborted", girara_debug("Rendering of page %d aborted", zathura_page_get_index(request_priv->page) + 1);
zathura_page_get_index(request_priv->page) + 1);
remove_job_and_free(job); remove_job_and_free(job);
cairo_surface_destroy(surface); cairo_surface_destroy(surface);
return true; return true;
@ -869,9 +757,7 @@ render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* render
return true; return true;
} }
static void static void render_job(void* data, void* user_data) {
render_job(void* data, void* user_data)
{
render_job_t* job = data; render_job_t* job = data;
ZathuraRenderRequest* request = job->request; ZathuraRenderRequest* request = job->request;
ZathuraRenderer* renderer = user_data; ZathuraRenderer* renderer = user_data;
@ -886,19 +772,14 @@ render_job(void* data, void* user_data)
} }
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
girara_debug("Rendering page %d ...", girara_debug("Rendering page %d ...", zathura_page_get_index(request_priv->page) + 1);
zathura_page_get_index(request_priv->page) + 1);
if (render(job, request, renderer) != true) { if (render(job, request, renderer) != true) {
girara_error("Rendering failed (page %d)\n", girara_error("Rendering failed (page %d)\n", zathura_page_get_index(request_priv->page) + 1);
zathura_page_get_index(request_priv->page) + 1);
remove_job_and_free(job); remove_job_and_free(job);
} }
} }
void render_all(zathura_t* zathura) {
void
render_all(zathura_t* zathura)
{
if (zathura == NULL || zathura->document == NULL) { if (zathura == NULL || zathura->document == NULL) {
return; return;
} }
@ -906,14 +787,14 @@ render_all(zathura_t* zathura)
/* unmark all pages */ /* unmark all pages */
const unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document); const unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) { for (unsigned int page_id = 0; page_id < number_of_pages; ++page_id) {
zathura_page_t* page = zathura_document_get_page(zathura->document, zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
page_id);
unsigned int page_height = 0, page_width = 0; unsigned int page_height = 0, page_width = 0;
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);
page_calc_height_width(zathura->document, height, width, &page_height, &page_width, true); page_calc_height_width(zathura->document, height, width, &page_height, &page_width, true);
girara_debug("Queuing resize for page %u to %u x %u (%0.2f x %0.2f).", page_id, page_width, page_height, width, height); girara_debug("Queuing resize for page %u to %u x %u (%0.2f x %0.2f).", page_id, page_width, page_height, width,
height);
GtkWidget* widget = zathura_page_get_widget(zathura, page); GtkWidget* widget = zathura_page_get_widget(zathura, page);
if (widget != NULL) { if (widget != NULL) {
gtk_widget_set_size_request(widget, page_width, page_height); gtk_widget_set_size_request(widget, page_width, page_height);
@ -922,9 +803,7 @@ render_all(zathura_t* zathura)
} }
} }
static gint static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data)) {
render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
{
if (a == NULL || b == NULL) { if (a == NULL || b == NULL) {
return 0; return 0;
} }
@ -935,8 +814,8 @@ render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
ZathuraRenderRequestPrivate* priv_a = zathura_render_request_get_instance_private(job_a->request); ZathuraRenderRequestPrivate* priv_a = zathura_render_request_get_instance_private(job_a->request);
ZathuraRenderRequestPrivate* priv_b = zathura_render_request_get_instance_private(job_b->request); ZathuraRenderRequestPrivate* priv_b = zathura_render_request_get_instance_private(job_b->request);
return priv_a->last_view_time < priv_b->last_view_time ? -1 : return priv_a->last_view_time < priv_b->last_view_time ? -1
(priv_a->last_view_time > priv_b->last_view_time ? 1 : 0); : (priv_a->last_view_time > priv_b->last_view_time ? 1 : 0);
} }
/* sort aborted entries earlier so that they are thrown out of the queue */ /* sort aborted entries earlier so that they are thrown out of the queue */
@ -945,16 +824,13 @@ render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
/* cache functions */ /* cache functions */
static bool static bool page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index) {
page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index)
{
g_return_val_if_fail(renderer != NULL, false); g_return_val_if_fail(renderer != NULL, false);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
if (priv->page_cache.num_cached_pages != 0) { if (priv->page_cache.num_cached_pages != 0) {
for (size_t i = 0; i < priv->page_cache.size; ++i) { for (size_t i = 0; i < priv->page_cache.size; ++i) {
if (priv->page_cache.cache[i] >= 0 && if (priv->page_cache.cache[i] >= 0 && page_index == (unsigned int)priv->page_cache.cache[i]) {
page_index == (unsigned int)priv->page_cache.cache[i]) {
girara_debug("Page %d is a cache hit", page_index + 1); girara_debug("Page %d is a cache hit", page_index + 1);
return true; return true;
} }
@ -965,10 +841,8 @@ page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index)
return false; return false;
} }
static int static int find_request_by_page_index(const void* req, const void* data) {
find_request_by_page_index(const void* req, const void* data) ZathuraRenderRequest* request = (void*)req;
{
ZathuraRenderRequest* request = (void*) req;
const unsigned int page_index = *((const int*)data); const unsigned int page_index = *((const int*)data);
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
@ -978,9 +852,7 @@ find_request_by_page_index(const void* req, const void* data)
return 1; return 1;
} }
static ssize_t static ssize_t page_cache_lru_invalidate(ZathuraRenderer* renderer) {
page_cache_lru_invalidate(ZathuraRenderer* renderer)
{
g_return_val_if_fail(renderer != NULL, -1); g_return_val_if_fail(renderer != NULL, -1);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
g_return_val_if_fail(priv->page_cache.size != 0, -1); g_return_val_if_fail(priv->page_cache.size != 0, -1);
@ -989,8 +861,8 @@ page_cache_lru_invalidate(ZathuraRenderer* renderer)
gint64 lru_view_time = G_MAXINT64; gint64 lru_view_time = G_MAXINT64;
ZathuraRenderRequest* request = NULL; ZathuraRenderRequest* request = NULL;
for (size_t i = 0; i < priv->page_cache.size; ++i) { for (size_t i = 0; i < priv->page_cache.size; ++i) {
ZathuraRenderRequest* tmp_request = girara_list_find(priv->requests, ZathuraRenderRequest* tmp_request =
find_request_by_page_index, &priv->page_cache.cache[i]); girara_list_find(priv->requests, find_request_by_page_index, &priv->page_cache.cache[i]);
g_return_val_if_fail(tmp_request != NULL, -1); g_return_val_if_fail(tmp_request != NULL, -1);
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(tmp_request); ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(tmp_request);
@ -1005,17 +877,14 @@ page_cache_lru_invalidate(ZathuraRenderer* renderer)
/* emit the signal */ /* emit the signal */
g_signal_emit(request, request_signals[REQUEST_CACHE_INVALIDATED], 0); g_signal_emit(request, request_signals[REQUEST_CACHE_INVALIDATED], 0);
girara_debug("Invalidated page %d at cache index %zd", girara_debug("Invalidated page %d at cache index %zd", zathura_page_get_index(request_priv->page) + 1, lru_index);
zathura_page_get_index(request_priv->page) + 1, lru_index);
priv->page_cache.cache[lru_index] = -1; priv->page_cache.cache[lru_index] = -1;
--priv->page_cache.num_cached_pages; --priv->page_cache.num_cached_pages;
return lru_index; return lru_index;
} }
static bool static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result) {
page_cache_is_full(ZathuraRenderer* renderer, bool* result)
{
g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer) && result != NULL, false); g_return_val_if_fail(ZATHURA_IS_RENDERER(renderer) && result != NULL, false);
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
@ -1024,9 +893,7 @@ page_cache_is_full(ZathuraRenderer* renderer, bool* result)
return true; return true;
} }
static void static void page_cache_invalidate_all(ZathuraRenderer* renderer) {
page_cache_invalidate_all(ZathuraRenderer* renderer)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer); ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
@ -1036,10 +903,7 @@ page_cache_invalidate_all(ZathuraRenderer* renderer)
priv->page_cache.num_cached_pages = 0; priv->page_cache.num_cached_pages = 0;
} }
void void zathura_renderer_page_cache_add(ZathuraRenderer* renderer, unsigned int page_index) {
zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
unsigned int page_index)
{
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
if (page_cache_is_cached(renderer, page_index) == true) { if (page_cache_is_cached(renderer, page_index) == true) {
return; return;
@ -1060,31 +924,24 @@ zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
girara_debug("Page %d is cached at cache index %zd", page_index + 1, idx); girara_debug("Page %d is cached at cache index %zd", page_index + 1, idx);
} else { } else {
priv->page_cache.cache[priv->page_cache.num_cached_pages++] = page_index; priv->page_cache.cache[priv->page_cache.num_cached_pages++] = page_index;
girara_debug("Page %d is cached at cache index %zu", page_index + 1, girara_debug("Page %d is cached at cache index %zu", page_index + 1, priv->page_cache.num_cached_pages - 1);
priv->page_cache.num_cached_pages - 1);
} }
ZathuraRenderRequest* request = girara_list_find(priv->requests, ZathuraRenderRequest* request = girara_list_find(priv->requests, find_request_by_page_index, &page_index);
find_request_by_page_index, &page_index);
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, void zathura_render_request_set_render_plain(ZathuraRenderRequest* request, bool render_plain) {
bool render_plain)
{
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request)); g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
priv->render_plain =render_plain; priv->render_plain = render_plain;
} }
bool bool zathura_render_request_get_render_plain(ZathuraRenderRequest* request) {
zathura_render_request_get_render_plain(ZathuraRenderRequest* request)
{
g_return_val_if_fail(ZATHURA_IS_RENDER_REQUEST(request), false); g_return_val_if_fail(ZATHURA_IS_RENDER_REQUEST(request), false);
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request); ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
return priv->render_plain; return priv->render_plain;
} }