mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-27 17:24:39 +01:00
pinned
This commit is contained in:
parent
12c8cd9110
commit
46dfa2be22
8 changed files with 1003 additions and 1064 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -36,3 +36,4 @@ compile_commands.json
|
||||||
*.log
|
*.log
|
||||||
.ycm_extra_conf.py
|
.ycm_extra_conf.py
|
||||||
_*/
|
_*/
|
||||||
|
.ccls-cache/
|
||||||
|
|
|
@ -5,15 +5,19 @@
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
double
|
// @debug
|
||||||
page_calc_height_width(zathura_document_t* document, double height,
|
#include <stdio.h>
|
||||||
|
|
||||||
|
double page_calc_height_width(zathura_document_t *document, double height,
|
||||||
double width, unsigned int *page_height,
|
double width, unsigned int *page_height,
|
||||||
unsigned int* page_width, bool rotate)
|
unsigned int *page_width, bool rotate) {
|
||||||
{
|
g_return_val_if_fail(
|
||||||
g_return_val_if_fail(document != NULL && page_height != NULL && page_width != NULL, 0.0);
|
document != NULL && page_height != NULL && page_width != NULL, 0.0);
|
||||||
|
|
||||||
double scale = zathura_document_get_scale(document);
|
double scale = zathura_document_get_scale(document);
|
||||||
|
|
||||||
|
// TODO this just set all pages to the maximum.
|
||||||
|
// needs to adjust cell size based on the page size itself.
|
||||||
if (rotate == true && zathura_document_get_rotation(document) % 180 != 0) {
|
if (rotate == true && zathura_document_get_rotation(document) % 180 != 0) {
|
||||||
*page_width = round(height * scale);
|
*page_width = round(height * scale);
|
||||||
*page_height = round(width * scale);
|
*page_height = round(width * scale);
|
||||||
|
@ -27,10 +31,8 @@ page_calc_height_width(zathura_document_t* document, double height,
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void page_calc_position(zathura_document_t *document, double x, double y,
|
||||||
page_calc_position(zathura_document_t* document, double x, double y, double* xn,
|
double *xn, double *yn) {
|
||||||
double* yn)
|
|
||||||
{
|
|
||||||
g_return_if_fail(document != NULL && xn != NULL && yn != NULL);
|
g_return_if_fail(document != NULL && xn != NULL && yn != NULL);
|
||||||
|
|
||||||
const unsigned int rot = zathura_document_get_rotation(document);
|
const unsigned int rot = zathura_document_get_rotation(document);
|
||||||
|
@ -49,10 +51,8 @@ page_calc_position(zathura_document_t* document, double x, double y, double* xn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int position_to_page_number(zathura_document_t *document, double pos_x,
|
||||||
position_to_page_number(zathura_document_t* document, double pos_x,
|
double pos_y) {
|
||||||
double pos_y)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail(document != NULL, 0);
|
g_return_val_if_fail(document != NULL, 0);
|
||||||
|
|
||||||
unsigned int doc_width, doc_height;
|
unsigned int doc_width, doc_height;
|
||||||
|
@ -75,8 +75,10 @@ position_to_page_number(zathura_document_t* document, double pos_x,
|
||||||
nrow = 1 + (npag - (ncol - c0 - 1) + (ncol - 1)) / ncol;
|
nrow = 1 + (npag - (ncol - c0 - 1) + (ncol - 1)) / ncol;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int col = floor(pos_x * (double)doc_width / (double)(cell_width + pad));
|
unsigned int col =
|
||||||
unsigned int row = floor(pos_y * (double)doc_height / (double)(cell_height + pad));
|
floor(pos_x * (double)doc_width / (double)(cell_width + pad));
|
||||||
|
unsigned int row =
|
||||||
|
floor(pos_y * (double)doc_height / (double)(cell_height + pad));
|
||||||
|
|
||||||
unsigned int page = ncol * (row % nrow) + (col % ncol);
|
unsigned int page = ncol * (row % nrow) + (col % ncol);
|
||||||
if (page < c0 - 1) {
|
if (page < c0 - 1) {
|
||||||
|
@ -86,12 +88,9 @@ position_to_page_number(zathura_document_t* document, double pos_x,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void page_number_to_position(zathura_document_t *document,
|
||||||
void
|
unsigned int page_number, double xalign,
|
||||||
page_number_to_position(zathura_document_t* document, unsigned int page_number,
|
double yalign, double *pos_x, double *pos_y) {
|
||||||
double xalign, double yalign, double* pos_x,
|
|
||||||
double* pos_y)
|
|
||||||
{
|
|
||||||
g_return_if_fail(document != NULL);
|
g_return_if_fail(document != NULL);
|
||||||
|
|
||||||
unsigned int c0 = zathura_document_get_first_page_column(document);
|
unsigned int c0 = zathura_document_get_first_page_column(document);
|
||||||
|
@ -113,14 +112,18 @@ page_number_to_position(zathura_document_t* document, unsigned int page_number,
|
||||||
unsigned int doc_height = 0, doc_width = 0;
|
unsigned int doc_height = 0, doc_width = 0;
|
||||||
zathura_document_get_document_size(document, &doc_height, &doc_width);
|
zathura_document_get_document_size(document, &doc_height, &doc_width);
|
||||||
|
|
||||||
/* compute the shift to align to the viewport. If the page fits to viewport, just center it. */
|
/* compute the shift to align to the viewport. If the page fits to viewport,
|
||||||
|
* just center it. */
|
||||||
double shift_x = 0.5, shift_y = 0.5;
|
double shift_x = 0.5, shift_y = 0.5;
|
||||||
if (cell_width > view_width) {
|
if (cell_width > view_width) {
|
||||||
shift_x = 0.5 + (xalign - 0.5) * ((double)cell_width - (double)view_width) / (double)cell_width;
|
shift_x = 0.5 + (xalign - 0.5) * ((double)cell_width - (double)view_width) /
|
||||||
|
(double)cell_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell_height > view_height) {
|
if (cell_height > view_height) {
|
||||||
shift_y = 0.5 + (yalign - 0.5) * ((double)cell_height - (double)view_height) / (double)cell_height;
|
shift_y = 0.5 + (yalign - 0.5) *
|
||||||
|
((double)cell_height - (double)view_height) /
|
||||||
|
(double)cell_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute the position */
|
/* compute the position */
|
||||||
|
@ -128,10 +131,7 @@ page_number_to_position(zathura_document_t* document, unsigned int page_number,
|
||||||
*pos_y = ((double)row + shift_y) / (double)nrow;
|
*pos_y = ((double)row + shift_y) / (double)nrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool page_is_visible(zathura_document_t *document, unsigned int page_number) {
|
||||||
bool
|
|
||||||
page_is_visible(zathura_document_t *document, unsigned int page_number)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail(document != NULL, false);
|
g_return_val_if_fail(document != NULL, false);
|
||||||
|
|
||||||
/* position at the center of the viewport */
|
/* position at the center of the viewport */
|
||||||
|
@ -151,13 +151,13 @@ page_is_visible(zathura_document_t *document, unsigned int page_number)
|
||||||
unsigned int view_width, view_height;
|
unsigned int view_width, view_height;
|
||||||
zathura_document_get_viewport_size(document, &view_height, &view_width);
|
zathura_document_get_viewport_size(document, &view_height, &view_width);
|
||||||
|
|
||||||
return ( fabs(pos_x - page_x) < 0.5 * (double)(view_width + cell_width) / (double)doc_width &&
|
return (fabs(pos_x - page_x) <
|
||||||
fabs(pos_y - page_y) < 0.5 * (double)(view_height + cell_height) / (double)doc_height);
|
0.5 * (double)(view_width + cell_width) / (double)doc_width &&
|
||||||
|
fabs(pos_y - page_y) <
|
||||||
|
0.5 * (double)(view_height + cell_height) / (double)doc_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_adjustment_set_value(GtkAdjustment *adjustment, gdouble value) {
|
||||||
zathura_adjustment_set_value(GtkAdjustment* adjustment, gdouble value)
|
|
||||||
{
|
|
||||||
const gdouble lower = gtk_adjustment_get_lower(adjustment);
|
const gdouble lower = gtk_adjustment_get_lower(adjustment);
|
||||||
const gdouble upper_m_size = gtk_adjustment_get_upper(adjustment) -
|
const gdouble upper_m_size = gtk_adjustment_get_upper(adjustment) -
|
||||||
gtk_adjustment_get_page_size(adjustment);
|
gtk_adjustment_get_page_size(adjustment);
|
||||||
|
@ -165,9 +165,7 @@ zathura_adjustment_set_value(GtkAdjustment* adjustment, gdouble value)
|
||||||
gtk_adjustment_set_value(adjustment, MAX(lower, MIN(upper_m_size, value)));
|
gtk_adjustment_set_value(adjustment, MAX(lower, MIN(upper_m_size, value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
gdouble
|
gdouble zathura_adjustment_get_ratio(GtkAdjustment *adjustment) {
|
||||||
zathura_adjustment_get_ratio(GtkAdjustment* adjustment)
|
|
||||||
{
|
|
||||||
gdouble lower = gtk_adjustment_get_lower(adjustment);
|
gdouble lower = gtk_adjustment_get_lower(adjustment);
|
||||||
gdouble upper = gtk_adjustment_get_upper(adjustment);
|
gdouble upper = gtk_adjustment_get_upper(adjustment);
|
||||||
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
|
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
|
||||||
|
@ -176,10 +174,8 @@ zathura_adjustment_get_ratio(GtkAdjustment* adjustment)
|
||||||
return (value - lower + page_size / 2.0) / (upper - lower);
|
return (value - lower + page_size / 2.0) / (upper - lower);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_adjustment_set_value_from_ratio(GtkAdjustment *adjustment,
|
||||||
zathura_adjustment_set_value_from_ratio(GtkAdjustment* adjustment,
|
gdouble ratio) {
|
||||||
gdouble ratio)
|
|
||||||
{
|
|
||||||
if (ratio == 0.0) {
|
if (ratio == 0.0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
/* SPDX-License-Identifier: Zlib */
|
/* SPDX-License-Identifier: Zlib */
|
||||||
|
|
||||||
|
#include <gio/gio.h>
|
||||||
|
#include <glib.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <glib.h>
|
|
||||||
#include <gio/gio.h>
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <girara/datastructures.h>
|
#include <girara/datastructures.h>
|
||||||
#include <girara/utils.h>
|
#include <girara/utils.h>
|
||||||
|
|
||||||
#include "adjustment.h"
|
#include "adjustment.h"
|
||||||
|
#include "content-type.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "zathura.h"
|
|
||||||
#include "page.h"
|
#include "page.h"
|
||||||
#include "plugin.h"
|
#include "plugin.h"
|
||||||
#include "content-type.h"
|
#include "utils.h"
|
||||||
|
#include "zathura.h"
|
||||||
|
// @debug
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document
|
* Document
|
||||||
|
@ -34,12 +36,15 @@ struct zathura_document_s {
|
||||||
void *data; /**< Custom data */
|
void *data; /**< Custom data */
|
||||||
zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */
|
zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */
|
||||||
int page_offset; /**< Page offset */
|
int page_offset; /**< Page offset */
|
||||||
double cell_width; /**< width of a page cell in the document (not transformed by scale and rotation) */
|
double cell_width; /**< width of a page cell in the document (not transformed
|
||||||
double cell_height; /**< height of a page cell in the document (not transformed by scale and rotation) */
|
by scale and rotation) */
|
||||||
|
double cell_height; /**< height of a page cell in the document (not
|
||||||
|
transformed by scale and rotation) */
|
||||||
unsigned int view_width; /**< width of current viewport */
|
unsigned int view_width; /**< width of current viewport */
|
||||||
unsigned int view_height; /**< height of current viewport */
|
unsigned int view_height; /**< height of current viewport */
|
||||||
double view_ppi; /**< PPI of the current viewport */
|
double view_ppi; /**< PPI of the current viewport */
|
||||||
zathura_device_factors_t device_factors; /**< x and y device scale factors (for e.g. HiDPI) */
|
zathura_device_factors_t
|
||||||
|
device_factors; /**< x and y device scale factors (for e.g. HiDPI) */
|
||||||
unsigned int pages_per_row; /**< number of pages in a row */
|
unsigned int pages_per_row; /**< number of pages in a row */
|
||||||
unsigned int first_page_column; /**< column of the first page */
|
unsigned int first_page_column; /**< column of the first page */
|
||||||
unsigned int page_padding; /**< padding between pages */
|
unsigned int page_padding; /**< padding between pages */
|
||||||
|
@ -57,16 +62,13 @@ struct zathura_document_s {
|
||||||
zathura_plugin_t *plugin;
|
zathura_plugin_t *plugin;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void check_set_error(zathura_error_t *error, zathura_error_t code) {
|
||||||
check_set_error(zathura_error_t* error, zathura_error_t code) {
|
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
*error = code;
|
*error = code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool hash_file_sha256(uint8_t *dst, const char *path) {
|
||||||
hash_file_sha256(uint8_t* dst, const char* path)
|
|
||||||
{
|
|
||||||
FILE *f = fopen(path, "rb");
|
FILE *f = fopen(path, "rb");
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -97,10 +99,9 @@ hash_file_sha256(uint8_t* dst, const char* path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_document_t*
|
zathura_document_t *zathura_document_open(zathura_t *zathura, const char *path,
|
||||||
zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
const char *uri, const char *password,
|
||||||
const char* password, zathura_error_t* error)
|
zathura_error_t *error) {
|
||||||
{
|
|
||||||
if (zathura == NULL || path == NULL) {
|
if (zathura == NULL || path == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -124,14 +125,17 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
content_type = zathura_content_type_guess(zathura->content_type_context, real_path, zathura_plugin_manager_get_content_types(zathura->plugins.manager));
|
content_type = zathura_content_type_guess(
|
||||||
|
zathura->content_type_context, real_path,
|
||||||
|
zathura_plugin_manager_get_content_types(zathura->plugins.manager));
|
||||||
if (content_type == NULL) {
|
if (content_type == NULL) {
|
||||||
girara_error("Could not determine file type.");
|
girara_error("Could not determine file type.");
|
||||||
check_set_error(error, ZATHURA_ERROR_UNKNOWN);
|
check_set_error(error, ZATHURA_ERROR_UNKNOWN);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
|
plugin =
|
||||||
|
zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
|
||||||
if (plugin == NULL) {
|
if (plugin == NULL) {
|
||||||
girara_error("Unknown file type: '%s'", content_type);
|
girara_error("Unknown file type: '%s'", content_type);
|
||||||
check_set_error(error, ZATHURA_ERROR_UNKNOWN);
|
check_set_error(error, ZATHURA_ERROR_UNKNOWN);
|
||||||
|
@ -180,7 +184,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
||||||
file = NULL;
|
file = NULL;
|
||||||
|
|
||||||
/* open document */
|
/* open document */
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(plugin);
|
||||||
if (functions->document_open == NULL) {
|
if (functions->document_open == NULL) {
|
||||||
girara_error("plugin has no open function\n");
|
girara_error("plugin has no open function\n");
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
@ -200,7 +205,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) {
|
for (unsigned int page_id = 0; page_id < document->number_of_pages;
|
||||||
|
page_id++) {
|
||||||
zathura_page_t *page = zathura_page_new(document, page_id, NULL);
|
zathura_page_t *page = zathura_page_new(document, page_id, NULL);
|
||||||
if (page == NULL) {
|
if (page == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_OUT_OF_MEMORY);
|
check_set_error(error, ZATHURA_ERROR_OUT_OF_MEMORY);
|
||||||
|
@ -209,7 +215,8 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
|
||||||
|
|
||||||
document->pages[page_id] = page;
|
document->pages[page_id] = page;
|
||||||
|
|
||||||
/* cell_width and cell_height is the maximum of all the pages width and height */
|
/* cell_width and cell_height is the maximum of all the pages width and
|
||||||
|
* height */
|
||||||
const double width = zathura_page_get_width(page);
|
const double width = zathura_page_get_width(page);
|
||||||
if (document->cell_width < width)
|
if (document->cell_width < width)
|
||||||
document->cell_width = width;
|
document->cell_width = width;
|
||||||
|
@ -239,16 +246,15 @@ error_free:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_error_t
|
zathura_error_t zathura_document_free(zathura_document_t *document) {
|
||||||
zathura_document_free(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL || document->plugin == NULL) {
|
if (document == NULL || document->plugin == NULL) {
|
||||||
return ZATHURA_ERROR_INVALID_ARGUMENTS;
|
return ZATHURA_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document->pages != NULL) {
|
if (document->pages != NULL) {
|
||||||
/* free pages */
|
/* free pages */
|
||||||
for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) {
|
for (unsigned int page_id = 0; page_id < document->number_of_pages;
|
||||||
|
page_id++) {
|
||||||
zathura_page_free(document->pages[page_id]);
|
zathura_page_free(document->pages[page_id]);
|
||||||
document->pages[page_id] = NULL;
|
document->pages[page_id] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -257,7 +263,8 @@ zathura_document_free(zathura_document_t* document)
|
||||||
|
|
||||||
/* free document */
|
/* free document */
|
||||||
zathura_error_t error = ZATHURA_ERROR_OK;
|
zathura_error_t error = ZATHURA_ERROR_OK;
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(document->plugin);
|
||||||
if (functions->document_free == NULL) {
|
if (functions->document_free == NULL) {
|
||||||
error = ZATHURA_ERROR_NOT_IMPLEMENTED;
|
error = ZATHURA_ERROR_NOT_IMPLEMENTED;
|
||||||
} else {
|
} else {
|
||||||
|
@ -273,9 +280,7 @@ zathura_document_free(zathura_document_t* document)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char *zathura_document_get_path(zathura_document_t *document) {
|
||||||
zathura_document_get_path(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -283,9 +288,7 @@ zathura_document_get_path(zathura_document_t* document)
|
||||||
return document->file_path;
|
return document->file_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t*
|
const uint8_t *zathura_document_get_hash(zathura_document_t *document) {
|
||||||
zathura_document_get_hash(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -293,9 +296,7 @@ zathura_document_get_hash(zathura_document_t* document)
|
||||||
return document->hash_sha256;
|
return document->hash_sha256;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char *zathura_document_get_uri(zathura_document_t *document) {
|
||||||
zathura_document_get_uri(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -303,9 +304,7 @@ zathura_document_get_uri(zathura_document_t* document)
|
||||||
return document->uri;
|
return document->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char *zathura_document_get_basename(zathura_document_t *document) {
|
||||||
zathura_document_get_basename(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -313,9 +312,7 @@ zathura_document_get_basename(zathura_document_t* document)
|
||||||
return document->basename;
|
return document->basename;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char *zathura_document_get_password(zathura_document_t *document) {
|
||||||
zathura_document_get_password(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -323,19 +320,17 @@ zathura_document_get_password(zathura_document_t* document)
|
||||||
return document->password;
|
return document->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_page_t*
|
zathura_page_t *zathura_document_get_page(zathura_document_t *document,
|
||||||
zathura_document_get_page(zathura_document_t* document, unsigned int index)
|
unsigned int index) {
|
||||||
{
|
if (document == NULL || document->pages == NULL ||
|
||||||
if (document == NULL || document->pages == NULL || (document->number_of_pages <= index)) {
|
(document->number_of_pages <= index)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return document->pages[index];
|
return document->pages[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void *zathura_document_get_data(zathura_document_t *document) {
|
||||||
zathura_document_get_data(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -343,9 +338,7 @@ zathura_document_get_data(zathura_document_t* document)
|
||||||
return document->data;
|
return document->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_data(zathura_document_t *document, void *data) {
|
||||||
zathura_document_set_data(zathura_document_t* document, void* data)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -354,8 +347,7 @@ zathura_document_set_data(zathura_document_t* document, void* data)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
zathura_document_get_number_of_pages(zathura_document_t* document)
|
zathura_document_get_number_of_pages(zathura_document_t *document) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -363,9 +355,8 @@ zathura_document_get_number_of_pages(zathura_document_t* document)
|
||||||
return document->number_of_pages;
|
return document->number_of_pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_number_of_pages(zathura_document_t *document,
|
||||||
zathura_document_set_number_of_pages(zathura_document_t* document, unsigned int number_of_pages)
|
unsigned int number_of_pages) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -374,8 +365,7 @@ zathura_document_set_number_of_pages(zathura_document_t* document, unsigned int
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
zathura_document_get_current_page_number(zathura_document_t* document)
|
zathura_document_get_current_page_number(zathura_document_t *document) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -383,10 +373,8 @@ zathura_document_get_current_page_number(zathura_document_t* document)
|
||||||
return document->current_page_number;
|
return document->current_page_number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_current_page_number(zathura_document_t *document,
|
||||||
zathura_document_set_current_page_number(zathura_document_t* document, unsigned int
|
unsigned int current_page) {
|
||||||
current_page)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -394,9 +382,7 @@ zathura_document_set_current_page_number(zathura_document_t* document, unsigned
|
||||||
document->current_page_number = current_page;
|
document->current_page_number = current_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double zathura_document_get_position_x(zathura_document_t *document) {
|
||||||
zathura_document_get_position_x(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -404,9 +390,7 @@ zathura_document_get_position_x(zathura_document_t* document)
|
||||||
return document->position_x;
|
return document->position_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double zathura_document_get_position_y(zathura_document_t *document) {
|
||||||
zathura_document_get_position_y(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -414,9 +398,8 @@ zathura_document_get_position_y(zathura_document_t* document)
|
||||||
return document->position_y;
|
return document->position_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_position_x(zathura_document_t *document,
|
||||||
zathura_document_set_position_x(zathura_document_t* document, double position_x)
|
double position_x) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -424,9 +407,8 @@ zathura_document_set_position_x(zathura_document_t* document, double position_x)
|
||||||
document->position_x = position_x;
|
document->position_x = position_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_position_y(zathura_document_t *document,
|
||||||
zathura_document_set_position_y(zathura_document_t* document, double position_y)
|
double position_y) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -434,9 +416,7 @@ zathura_document_set_position_y(zathura_document_t* document, double position_y)
|
||||||
document->position_y = position_y;
|
document->position_y = position_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double zathura_document_get_zoom(zathura_document_t *document) {
|
||||||
zathura_document_get_zoom(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -444,9 +424,7 @@ zathura_document_get_zoom(zathura_document_t* document)
|
||||||
return document->zoom;
|
return document->zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_zoom(zathura_document_t *document, double zoom) {
|
||||||
zathura_document_set_zoom(zathura_document_t* document, double zoom)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -454,9 +432,7 @@ zathura_document_set_zoom(zathura_document_t* document, double zoom)
|
||||||
document->zoom = zoom;
|
document->zoom = zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double zathura_document_get_scale(zathura_document_t *document) {
|
||||||
zathura_document_get_scale(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -471,9 +447,7 @@ zathura_document_get_scale(zathura_document_t* document)
|
||||||
return document->zoom * ppi / 72.0;
|
return document->zoom * ppi / 72.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int zathura_document_get_rotation(zathura_document_t *document) {
|
||||||
zathura_document_get_rotation(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -481,9 +455,8 @@ zathura_document_get_rotation(zathura_document_t* document)
|
||||||
return document->rotate;
|
return document->rotate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_rotation(zathura_document_t *document,
|
||||||
zathura_document_set_rotation(zathura_document_t* document, unsigned int rotation)
|
unsigned int rotation) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -501,8 +474,7 @@ zathura_document_set_rotation(zathura_document_t* document, unsigned int rotatio
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_adjust_mode_t
|
zathura_adjust_mode_t
|
||||||
zathura_document_get_adjust_mode(zathura_document_t* document)
|
zathura_document_get_adjust_mode(zathura_document_t *document) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return ZATHURA_ADJUST_NONE;
|
return ZATHURA_ADJUST_NONE;
|
||||||
}
|
}
|
||||||
|
@ -510,9 +482,8 @@ zathura_document_get_adjust_mode(zathura_document_t* document)
|
||||||
return document->adjust_mode;
|
return document->adjust_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_adjust_mode(zathura_document_t *document,
|
||||||
zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mode_t mode)
|
zathura_adjust_mode_t mode) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -520,9 +491,7 @@ zathura_document_set_adjust_mode(zathura_document_t* document, zathura_adjust_mo
|
||||||
document->adjust_mode = mode;
|
document->adjust_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int zathura_document_get_page_offset(zathura_document_t *document) {
|
||||||
zathura_document_get_page_offset(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -530,9 +499,8 @@ zathura_document_get_page_offset(zathura_document_t* document)
|
||||||
return document->page_offset;
|
return document->page_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_page_offset(zathura_document_t *document,
|
||||||
zathura_document_set_page_offset(zathura_document_t* document, unsigned int page_offset)
|
unsigned int page_offset) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -540,55 +508,47 @@ zathura_document_set_page_offset(zathura_document_t* document, unsigned int page
|
||||||
document->page_offset = page_offset;
|
document->page_offset = page_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_viewport_width(zathura_document_t *document,
|
||||||
zathura_document_set_viewport_width(zathura_document_t* document, unsigned int width)
|
unsigned int width) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document->view_width = width;
|
document->view_width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_viewport_height(zathura_document_t *document,
|
||||||
zathura_document_set_viewport_height(zathura_document_t* document, unsigned int height)
|
unsigned int height) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document->view_height = height;
|
document->view_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_viewport_ppi(zathura_document_t *document,
|
||||||
zathura_document_set_viewport_ppi(zathura_document_t* document, double ppi)
|
double ppi) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document->view_ppi = ppi;
|
document->view_ppi = ppi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_get_viewport_size(zathura_document_t *document,
|
||||||
zathura_document_get_viewport_size(zathura_document_t* document,
|
unsigned int *height,
|
||||||
unsigned int *height, unsigned int* width)
|
unsigned int *width) {
|
||||||
{
|
|
||||||
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
||||||
*height = document->view_height;
|
*height = document->view_height;
|
||||||
*width = document->view_width;
|
*width = document->view_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double zathura_document_get_viewport_ppi(zathura_document_t *document) {
|
||||||
zathura_document_get_viewport_ppi(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
return document->view_ppi;
|
return document->view_ppi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_device_factors(zathura_document_t *document,
|
||||||
zathura_document_set_device_factors(zathura_document_t* document,
|
double x_factor, double y_factor) {
|
||||||
double x_factor, double y_factor)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -603,8 +563,7 @@ zathura_document_set_device_factors(zathura_document_t* document,
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_device_factors_t
|
zathura_device_factors_t
|
||||||
zathura_document_get_device_factors(zathura_document_t* document)
|
zathura_document_get_device_factors(zathura_document_t *document) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
/* The function is guaranteed to not return zero values */
|
/* The function is guaranteed to not return zero values */
|
||||||
return (zathura_device_factors_t){1.0, 1.0};
|
return (zathura_device_factors_t){1.0, 1.0};
|
||||||
|
@ -613,20 +572,17 @@ zathura_document_get_device_factors(zathura_document_t* document)
|
||||||
return document->device_factors;
|
return document->device_factors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_get_cell_size(zathura_document_t *document,
|
||||||
zathura_document_get_cell_size(zathura_document_t* document,
|
unsigned int *height, unsigned int *width) {
|
||||||
unsigned int* height, unsigned int* width)
|
|
||||||
{
|
|
||||||
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
||||||
|
|
||||||
page_calc_height_width(document, document->cell_height, document->cell_width,
|
page_calc_height_width(document, document->cell_height, document->cell_width,
|
||||||
height, width, true);
|
height, width, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_get_document_size(zathura_document_t *document,
|
||||||
zathura_document_get_document_size(zathura_document_t* document,
|
unsigned int *height,
|
||||||
unsigned int* height, unsigned int* width)
|
unsigned int *width) {
|
||||||
{
|
|
||||||
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
g_return_if_fail(document != NULL && height != NULL && width != NULL);
|
||||||
|
|
||||||
const unsigned int npag = zathura_document_get_number_of_pages(document);
|
const unsigned int npag = zathura_document_get_number_of_pages(document);
|
||||||
|
@ -637,7 +593,8 @@ zathura_document_get_document_size(zathura_document_t* document,
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int c0 = zathura_document_get_first_page_column(document);
|
const unsigned int c0 = zathura_document_get_first_page_column(document);
|
||||||
const unsigned int nrow = (npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */
|
const unsigned int nrow =
|
||||||
|
(npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */
|
||||||
const unsigned int pad = zathura_document_get_page_padding(document);
|
const unsigned int pad = zathura_document_get_page_padding(document);
|
||||||
|
|
||||||
unsigned int cell_height = 0;
|
unsigned int cell_height = 0;
|
||||||
|
@ -648,10 +605,10 @@ zathura_document_get_document_size(zathura_document_t* document,
|
||||||
*height = nrow * cell_height + (nrow - 1) * pad;
|
*height = nrow * cell_height + (nrow - 1) * pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_document_set_page_layout(zathura_document_t *document,
|
||||||
zathura_document_set_page_layout(zathura_document_t* document, unsigned int page_padding,
|
unsigned int page_padding,
|
||||||
unsigned int pages_per_row, unsigned int first_page_column)
|
unsigned int pages_per_row,
|
||||||
{
|
unsigned int first_page_column) {
|
||||||
g_return_if_fail(document != NULL);
|
g_return_if_fail(document != NULL);
|
||||||
|
|
||||||
document->page_padding = page_padding;
|
document->page_padding = page_padding;
|
||||||
|
@ -666,18 +623,14 @@ zathura_document_set_page_layout(zathura_document_t* document, unsigned int page
|
||||||
document->first_page_column = first_page_column;
|
document->first_page_column = first_page_column;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int zathura_document_get_page_padding(zathura_document_t *document) {
|
||||||
zathura_document_get_page_padding(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return document->page_padding;
|
return document->page_padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int zathura_document_get_pages_per_row(zathura_document_t *document) {
|
||||||
zathura_document_get_pages_per_row(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -685,22 +638,21 @@ zathura_document_get_pages_per_row(zathura_document_t* document)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
zathura_document_get_first_page_column(zathura_document_t* document)
|
zathura_document_get_first_page_column(zathura_document_t *document) {
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return document->first_page_column;
|
return document->first_page_column;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_error_t
|
zathura_error_t zathura_document_save_as(zathura_document_t *document,
|
||||||
zathura_document_save_as(zathura_document_t* document, const char* path)
|
const char *path) {
|
||||||
{
|
|
||||||
if (document == NULL || document->plugin == NULL || path == NULL) {
|
if (document == NULL || document->plugin == NULL || path == NULL) {
|
||||||
return ZATHURA_ERROR_UNKNOWN;
|
return ZATHURA_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(document->plugin);
|
||||||
if (functions->document_save_as == NULL) {
|
if (functions->document_save_as == NULL) {
|
||||||
return ZATHURA_ERROR_NOT_IMPLEMENTED;
|
return ZATHURA_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
@ -709,14 +661,15 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_tree_node_t *
|
girara_tree_node_t *
|
||||||
zathura_document_index_generate(zathura_document_t* document, zathura_error_t* error)
|
zathura_document_index_generate(zathura_document_t *document,
|
||||||
{
|
zathura_error_t *error) {
|
||||||
if (document == NULL || document->plugin == NULL) {
|
if (document == NULL || document->plugin == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
|
check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(document->plugin);
|
||||||
if (functions->document_index_generate == NULL) {
|
if (functions->document_index_generate == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
|
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -725,15 +678,15 @@ zathura_document_index_generate(zathura_document_t* document, zathura_error_t* e
|
||||||
return functions->document_index_generate(document, document->data, error);
|
return functions->document_index_generate(document, document->data, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_list_t*
|
girara_list_t *zathura_document_attachments_get(zathura_document_t *document,
|
||||||
zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error)
|
zathura_error_t *error) {
|
||||||
{
|
|
||||||
if (document == NULL || document->plugin == NULL) {
|
if (document == NULL || document->plugin == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
|
check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(document->plugin);
|
||||||
if (functions->document_attachments_get == NULL) {
|
if (functions->document_attachments_get == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
|
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -742,46 +695,49 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_error_t*
|
||||||
return functions->document_attachments_get(document, document->data, error);
|
return functions->document_attachments_get(document, document->data, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_error_t
|
zathura_error_t zathura_document_attachment_save(zathura_document_t *document,
|
||||||
zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file)
|
const char *attachment,
|
||||||
{
|
const char *file) {
|
||||||
if (document == NULL || document->plugin == NULL) {
|
if (document == NULL || document->plugin == NULL) {
|
||||||
return ZATHURA_ERROR_INVALID_ARGUMENTS;
|
return ZATHURA_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(document->plugin);
|
||||||
if (functions->document_attachment_save == NULL) {
|
if (functions->document_attachment_save == NULL) {
|
||||||
return ZATHURA_ERROR_NOT_IMPLEMENTED;
|
return ZATHURA_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return functions->document_attachment_save(document, document->data, attachment, file);
|
return functions->document_attachment_save(document, document->data,
|
||||||
|
attachment, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_list_t*
|
girara_list_t *zathura_document_get_information(zathura_document_t *document,
|
||||||
zathura_document_get_information(zathura_document_t* document, zathura_error_t* error)
|
zathura_error_t *error) {
|
||||||
{
|
|
||||||
if (document == NULL || document->plugin == NULL) {
|
if (document == NULL || document->plugin == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
|
check_set_error(error, ZATHURA_ERROR_INVALID_ARGUMENTS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const zathura_plugin_functions_t* functions = zathura_plugin_get_functions(document->plugin);
|
const zathura_plugin_functions_t *functions =
|
||||||
|
zathura_plugin_get_functions(document->plugin);
|
||||||
if (functions->document_get_information == NULL) {
|
if (functions->document_get_information == NULL) {
|
||||||
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
|
check_set_error(error, ZATHURA_ERROR_NOT_IMPLEMENTED);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
girara_list_t* result = functions->document_get_information(document, document->data, error);
|
girara_list_t *result =
|
||||||
|
functions->document_get_information(document, document->data, error);
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
girara_list_set_free_function(result, (girara_free_function_t) zathura_document_information_entry_free);
|
girara_list_set_free_function(
|
||||||
|
result,
|
||||||
|
(girara_free_function_t)zathura_document_information_entry_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
zathura_plugin_t*
|
zathura_plugin_t *zathura_document_get_plugin(zathura_document_t *document) {
|
||||||
zathura_document_get_plugin(zathura_document_t* document)
|
|
||||||
{
|
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
536
zathura/render.c
536
zathura/render.c
|
@ -1,17 +1,18 @@
|
||||||
/* SPDX-License-Identifier: Zlib */
|
/* SPDX-License-Identifier: Zlib */
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <girara/datastructures.h>
|
#include <girara/datastructures.h>
|
||||||
#include <girara/utils.h>
|
#include <girara/utils.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "render.h"
|
|
||||||
#include "adjustment.h"
|
#include "adjustment.h"
|
||||||
#include "zathura.h"
|
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
#include "page.h"
|
|
||||||
#include "page-widget.h"
|
#include "page-widget.h"
|
||||||
|
#include "page.h"
|
||||||
|
#include "render.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "zathura.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/* private data for ZathuraRenderer */
|
/* private data for ZathuraRenderer */
|
||||||
typedef struct private_s {
|
typedef struct private_s {
|
||||||
|
@ -55,8 +56,10 @@ typedef struct request_private_s {
|
||||||
} ZathuraRenderRequestPrivate;
|
} ZathuraRenderRequestPrivate;
|
||||||
|
|
||||||
/* 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_DEFINE_TYPE_WITH_CODE(ZathuraRenderRequest, zathura_render_request, G_TYPE_OBJECT, G_ADD_PRIVATE(ZathuraRenderRequest))
|
G_ADD_PRIVATE(ZathuraRenderer))
|
||||||
|
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,18 +81,15 @@ 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;
|
||||||
g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL);
|
g_thread_pool_set_sort_function(priv->pool, render_thread_sort, NULL);
|
||||||
|
@ -110,10 +110,9 @@ 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;
|
||||||
priv->page_cache.cache = g_try_malloc0(cache_size * sizeof(int));
|
priv->page_cache.cache = g_try_malloc0(cache_size * sizeof(int));
|
||||||
|
@ -125,9 +124,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,11 +138,10 @@ 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);
|
||||||
|
|
||||||
zathura_renderer_stop(renderer);
|
zathura_renderer_stop(renderer);
|
||||||
if (priv->pool != NULL) {
|
if (priv->pool != NULL) {
|
||||||
|
@ -159,19 +155,17 @@ 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,
|
||||||
renderer_unregister_request(ZathuraRenderer* renderer,
|
ZathuraRenderRequest *request) {
|
||||||
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,
|
||||||
renderer_register_request(ZathuraRenderer* renderer,
|
ZathuraRenderRequest *request) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -189,56 +183,34 @@ enum {
|
||||||
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] = g_signal_new(
|
||||||
ZATHURA_TYPE_RENDER_REQUEST,
|
"completed", ZATHURA_TYPE_RENDER_REQUEST, G_SIGNAL_RUN_LAST, 0, NULL,
|
||||||
G_SIGNAL_RUN_LAST,
|
NULL, 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(
|
||||||
ZATHURA_TYPE_RENDER_REQUEST,
|
"cache-added", ZATHURA_TYPE_RENDER_REQUEST, G_SIGNAL_RUN_LAST, 0, NULL,
|
||||||
G_SIGNAL_RUN_LAST,
|
NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 0);
|
||||||
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] = g_signal_new(
|
||||||
ZATHURA_TYPE_RENDER_REQUEST,
|
"cache-invalidated", ZATHURA_TYPE_RENDER_REQUEST, G_SIGNAL_RUN_LAST, 0,
|
||||||
G_SIGNAL_RUN_LAST,
|
NULL, NULL, 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_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
|
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);
|
||||||
|
@ -247,7 +219,8 @@ zathura_render_request_new(ZathuraRenderer* renderer, zathura_page_t* page)
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraRenderRequest *request = ZATHURA_RENDER_REQUEST(obj);
|
ZathuraRenderRequest *request = ZATHURA_RENDER_REQUEST(obj);
|
||||||
ZathuraRenderRequestPrivate* priv = zathura_render_request_get_instance_private(request);
|
ZathuraRenderRequestPrivate *priv =
|
||||||
|
zathura_render_request_get_instance_private(request);
|
||||||
/* we want to make sure that renderer lives long enough */
|
/* we want to make sure that renderer lives long enough */
|
||||||
priv->renderer = g_object_ref(renderer);
|
priv->renderer = g_object_ref(renderer);
|
||||||
priv->page = page;
|
priv->page = page;
|
||||||
|
@ -261,11 +234,10 @@ 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);
|
||||||
|
|
||||||
if (priv->renderer != NULL) {
|
if (priv->renderer != NULL) {
|
||||||
/* unregister the request */
|
/* unregister the request */
|
||||||
|
@ -277,11 +249,10 @@ 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);
|
||||||
|
|
||||||
if (girara_list_size(priv->active_jobs) != 0) {
|
if (girara_list_size(priv->active_jobs) != 0) {
|
||||||
girara_error("This should not happen!");
|
girara_error("This should not happen!");
|
||||||
|
@ -294,66 +265,62 @@ 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,
|
||||||
zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable)
|
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,
|
||||||
zathura_renderer_enable_recolor_reverse_video(ZathuraRenderer* renderer, bool enable)
|
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,
|
||||||
zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
|
const GdkRGBA *light,
|
||||||
const GdkRGBA* light, const GdkRGBA* dark)
|
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);
|
||||||
if (light != NULL) {
|
if (light != NULL) {
|
||||||
memcpy(&priv->recolor.light, light, sizeof(GdkRGBA));
|
memcpy(&priv->recolor.light, light, sizeof(GdkRGBA));
|
||||||
}
|
}
|
||||||
|
@ -362,10 +329,9 @@ zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_renderer_set_recolor_colors_str(ZathuraRenderer *renderer,
|
||||||
zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
|
const char *light,
|
||||||
const char* light, const char* dark)
|
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,13 +348,12 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_renderer_get_recolor_colors(ZathuraRenderer *renderer,
|
||||||
zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
|
GdkRGBA *light, GdkRGBA *dark) {
|
||||||
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);
|
||||||
if (light != NULL) {
|
if (light != NULL) {
|
||||||
memcpy(light, &priv->recolor.light, sizeof(GdkRGBA));
|
memcpy(light, &priv->recolor.light, sizeof(GdkRGBA));
|
||||||
}
|
}
|
||||||
|
@ -397,51 +362,47 @@ 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
|
void zathura_render_request(ZathuraRenderRequest *request,
|
||||||
zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time)
|
gint64 last_view_time) {
|
||||||
{
|
|
||||||
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);
|
||||||
g_mutex_lock(&request_priv->jobs_mutex);
|
g_mutex_lock(&request_priv->jobs_mutex);
|
||||||
|
|
||||||
bool unfinished_jobs = false;
|
bool unfinished_jobs = false;
|
||||||
/* check if there are any active jobs left */
|
/* check if there are any active jobs left */
|
||||||
GIRARA_LIST_FOREACH_BODY(request_priv->active_jobs, render_job_t*, job,
|
GIRARA_LIST_FOREACH_BODY(
|
||||||
|
request_priv->active_jobs, render_job_t *, job,
|
||||||
if (job->aborted == false) {
|
if (job->aborted == false) {
|
||||||
unfinished_jobs = true;
|
unfinished_jobs = true;
|
||||||
break;
|
break;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
/* only add a new job if there are no active ones left */
|
/* only add a new job if there are no active ones left */
|
||||||
if (unfinished_jobs == false) {
|
if (unfinished_jobs == false) {
|
||||||
|
@ -456,41 +417,38 @@ zathura_render_request(ZathuraRenderRequest* request, gint64 last_view_time)
|
||||||
job->aborted = false;
|
job->aborted = false;
|
||||||
girara_list_append(request_priv->active_jobs, job);
|
girara_list_append(request_priv->active_jobs, job);
|
||||||
|
|
||||||
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(request_priv->renderer);
|
ZathuraRendererPrivate *priv =
|
||||||
|
zathura_renderer_get_instance_private(request_priv->renderer);
|
||||||
g_thread_pool_push(priv->pool, job, NULL);
|
g_thread_pool_push(priv->pool, job, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock(&request_priv->jobs_mutex);
|
g_mutex_unlock(&request_priv->jobs_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_render_request_abort(ZathuraRenderRequest *request) {
|
||||||
zathura_render_request_abort(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);
|
||||||
g_mutex_lock(&request_priv->jobs_mutex);
|
g_mutex_lock(&request_priv->jobs_mutex);
|
||||||
GIRARA_LIST_FOREACH_BODY(request_priv->active_jobs, render_job_t *, job,
|
GIRARA_LIST_FOREACH_BODY(request_priv->active_jobs, render_job_t *, job,
|
||||||
job->aborted = true;
|
job->aborted = true;);
|
||||||
);
|
|
||||||
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);
|
||||||
request_priv->last_view_time = g_get_real_time();
|
request_priv->last_view_time = g_get_real_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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);
|
||||||
girara_list_remove(request_priv->active_jobs, job);
|
girara_list_remove(request_priv->active_jobs, job);
|
||||||
|
@ -500,25 +458,25 @@ 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 =
|
||||||
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(request_priv->renderer);
|
zathura_render_request_get_instance_private(job->request);
|
||||||
|
ZathuraRendererPrivate *priv =
|
||||||
|
zathura_renderer_get_instance_private(request_priv->renderer);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -536,14 +494,14 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
const double lv = (l - l1) / (l2 - l1); /* Remap l to the whole interval [0,1] */
|
const double lv =
|
||||||
|
(l - l1) / (l2 - l1); /* Remap l to the whole interval [0,1] */
|
||||||
double u = DBL_MAX;
|
double u = DBL_MAX;
|
||||||
double v = DBL_MAX;
|
double v = DBL_MAX;
|
||||||
for (unsigned int k = 0; k < 3; ++k) {
|
for (unsigned int k = 0; k < 3; ++k) {
|
||||||
|
@ -559,14 +517,14 @@ colorumax(const double h[3], double l, double l1, double l2)
|
||||||
/* rescale v according to the length of the interval [l1, l2] */
|
/* rescale v according to the length of the interval [l1, l2] */
|
||||||
v = fabs(l2 - l1) * v;
|
v = fabs(l2 - l1) * v;
|
||||||
|
|
||||||
/* forces the returned value to be 0 on l1 and l2, trying not to distort colors too much */
|
/* forces the returned value to be 0 on l1 and l2, trying not to distort
|
||||||
|
* colors too much */
|
||||||
return fmin(u, v);
|
return fmin(u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void recolor(ZathuraRendererPrivate *priv, zathura_page_t *page,
|
||||||
recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_width,
|
unsigned int page_width, unsigned int page_height,
|
||||||
unsigned int page_height, cairo_surface_t* surface)
|
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,
|
||||||
|
@ -597,11 +555,8 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
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.red - rgb1.red,
|
rgb2.blue - rgb1.blue};
|
||||||
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,
|
||||||
|
@ -616,10 +571,12 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 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(rgb2.red - rgb2.blue) < DBL_EPSILON && fabs(rgb2.red - rgb2.green) < DBL_EPSILON
|
fabs(rgb1.red - rgb1.green) < DBL_EPSILON &&
|
||||||
)) && (rgb1.alpha >= 1. - DBL_EPSILON && rgb2.alpha >= 1. - 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);
|
||||||
|
|
||||||
girara_list_t *images = NULL;
|
girara_list_t *images = NULL;
|
||||||
girara_list_t *rectangles = NULL;
|
girara_list_t *rectangles = NULL;
|
||||||
|
@ -638,14 +595,12 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
|
|
||||||
if (found_images == true) {
|
if (found_images == true) {
|
||||||
/* Get images bounding boxes */
|
/* Get images bounding boxes */
|
||||||
GIRARA_LIST_FOREACH_BODY(images, zathura_image_t*, image_it,
|
GIRARA_LIST_FOREACH_BODY(
|
||||||
|
images, zathura_image_t *, image_it,
|
||||||
zathura_rectangle_t *rect = g_try_malloc(sizeof(zathura_rectangle_t));
|
zathura_rectangle_t *rect = g_try_malloc(sizeof(zathura_rectangle_t));
|
||||||
if (rect == NULL) {
|
if (rect == NULL) { break; } *rect =
|
||||||
break;
|
recalc_rectangle(page, image_it->position);
|
||||||
}
|
girara_list_append(rectangles, rect););
|
||||||
*rect = recalc_rectangle(page, image_it->position);
|
|
||||||
girara_list_append(rectangles, rect);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,13 +611,13 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
/* Check if the pixel belongs to an image when in reverse video mode*/
|
/* Check if the pixel belongs to an image when in reverse video mode*/
|
||||||
if (priv->recolor.reverse_video == true && found_images == true) {
|
if (priv->recolor.reverse_video == true && found_images == true) {
|
||||||
bool inside_image = false;
|
bool inside_image = false;
|
||||||
GIRARA_LIST_FOREACH_BODY(rectangles, zathura_rectangle_t*, rect_it,
|
GIRARA_LIST_FOREACH_BODY(
|
||||||
if (rect_it->x1 <= x && rect_it->x2 >= x &&
|
rectangles, zathura_rectangle_t *, rect_it,
|
||||||
rect_it->y1 <= y && rect_it->y2 >= y) {
|
if (rect_it->x1 <= x && rect_it->x2 >= x && rect_it->y1 <= y &&
|
||||||
|
rect_it->y2 >= y) {
|
||||||
inside_image = true;
|
inside_image = true;
|
||||||
break;
|
break;
|
||||||
}
|
});
|
||||||
);
|
|
||||||
/* If it's inside and image don't recolor */
|
/* If it's inside and image don't recolor */
|
||||||
if (inside_image == true) {
|
if (inside_image == true) {
|
||||||
/* It is not guaranteed that the pixel is already opaque. */
|
/* It is not guaranteed that the pixel is already opaque. */
|
||||||
|
@ -672,11 +627,7 @@ 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 = a[0] * rgb[0] + a[1] * rgb[1] + a[2] * rgb[2];
|
||||||
|
@ -684,11 +635,7 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
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 */
|
||||||
|
@ -711,10 +658,17 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
* 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(
|
||||||
data[2] = (unsigned char)round(255.*fmin(1, fmax(0, tr1*h1[0] + tr2*h2[0] + (l + su * h[0]))));
|
255. * (1. - tr1 * negalph1 - tr2 * negalph2));
|
||||||
data[1] = (unsigned char)round(255.*fmin(1, fmax(0, tr1*h1[1] + tr2*h2[1] + (l + su * h[1]))));
|
data[2] = (unsigned char)round(
|
||||||
data[0] = (unsigned char)round(255.*fmin(1, fmax(0, tr1*h1[2] + tr2*h2[2] + (l + su * h[2]))));
|
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[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
|
||||||
|
@ -725,12 +679,16 @@ recolor(ZathuraRendererPrivate* priv, zathura_page_t* page, unsigned int page_wi
|
||||||
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(
|
||||||
data[1] = (unsigned char)round(255.*(l * rgb_diff[1] - f2*rgb2.green + f1*rgb1.green));
|
255. * (l * rgb_diff[0] - f2 * rgb2.red + f1 * rgb1.red));
|
||||||
data[0] = (unsigned char)round(255.*(l * rgb_diff[2] - f2*rgb2.blue + f1*rgb1.blue));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -746,9 +704,8 @@ 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,
|
||||||
invoke_completed_signal(render_job_t* job, cairo_surface_t* surface)
|
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 +719,10 @@ 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,
|
||||||
render_to_cairo_surface(cairo_surface_t* surface, zathura_page_t* page, ZathuraRenderer* renderer, double real_scale)
|
zathura_page_t *page,
|
||||||
{
|
ZathuraRenderer *renderer,
|
||||||
|
double real_scale) {
|
||||||
cairo_t *cairo = cairo_create(surface);
|
cairo_t *cairo = cairo_create(surface);
|
||||||
if (cairo == NULL) {
|
if (cairo == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -790,11 +748,12 @@ 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,
|
||||||
render(render_job_t* job, ZathuraRenderRequest* request, ZathuraRenderer* renderer)
|
ZathuraRenderer *renderer) {
|
||||||
{
|
ZathuraRendererPrivate *priv =
|
||||||
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
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;
|
||||||
|
|
||||||
/* create cairo surface */
|
/* create cairo surface */
|
||||||
|
@ -806,14 +765,19 @@ 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);
|
||||||
|
|
||||||
|
// @debug
|
||||||
|
fprintf(stderr, "height %f\n", height);
|
||||||
|
fprintf(stderr, "width %f\n", width);
|
||||||
|
// @
|
||||||
|
|
||||||
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_height, &page_width, false);
|
&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;
|
||||||
|
@ -826,12 +790,11 @@ 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 =
|
||||||
page_width, page_height);
|
cairo_image_surface_create(format, page_width, page_height);
|
||||||
|
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -876,23 +839,23 @@ 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;
|
||||||
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
g_return_if_fail(ZATHURA_IS_RENDER_REQUEST(request));
|
||||||
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);
|
||||||
if (priv->about_to_close == true || job->aborted == true) {
|
if (priv->about_to_close == true || job->aborted == true) {
|
||||||
/* back out early */
|
/* back out early */
|
||||||
remove_job_and_free(job);
|
remove_job_and_free(job);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -902,25 +865,25 @@ render_job(void* data, void* user_data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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 =
|
||||||
page_id);
|
zathura_document_get_page(zathura->document, 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);
|
||||||
|
@ -929,9 +892,8 @@ render_all(zathura_t* zathura)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint render_thread_sort(gconstpointer a, gconstpointer b,
|
||||||
render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
|
gpointer UNUSED(data)) {
|
||||||
{
|
|
||||||
if (a == NULL || b == NULL) {
|
if (a == NULL || b == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -939,11 +901,14 @@ render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
|
||||||
const render_job_t *job_a = a;
|
const render_job_t *job_a = a;
|
||||||
const render_job_t *job_b = b;
|
const render_job_t *job_b = b;
|
||||||
if (job_a->aborted == job_b->aborted) {
|
if (job_a->aborted == job_b->aborted) {
|
||||||
ZathuraRenderRequestPrivate* priv_a = zathura_render_request_get_instance_private(job_a->request);
|
ZathuraRenderRequestPrivate *priv_a =
|
||||||
ZathuraRenderRequestPrivate* priv_b = zathura_render_request_get_instance_private(job_b->request);
|
zathura_render_request_get_instance_private(job_a->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
|
||||||
(priv_a->last_view_time > priv_b->last_view_time ? 1 : 0);
|
? -1
|
||||||
|
: (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 */
|
||||||
|
@ -952,11 +917,11 @@ render_thread_sort(gconstpointer a, gconstpointer b, gpointer UNUSED(data))
|
||||||
|
|
||||||
/* cache functions */
|
/* cache functions */
|
||||||
|
|
||||||
static bool
|
static bool page_cache_is_cached(ZathuraRenderer *renderer,
|
||||||
page_cache_is_cached(ZathuraRenderer* renderer, unsigned int page_index)
|
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) {
|
||||||
|
@ -972,34 +937,33 @@ 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);
|
||||||
if (zathura_page_get_index(priv->page) == page_index) {
|
if (zathura_page_get_index(priv->page) == page_index) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|
||||||
ssize_t lru_index = 0;
|
ssize_t lru_index = 0;
|
||||||
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 = girara_list_find(
|
||||||
find_request_by_page_index, &priv->page_cache.cache[i]);
|
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);
|
||||||
|
|
||||||
if (request_priv->last_view_time < lru_view_time) {
|
if (request_priv->last_view_time < lru_view_time) {
|
||||||
lru_view_time = request_priv->last_view_time;
|
lru_view_time = request_priv->last_view_time;
|
||||||
|
@ -1008,7 +972,8 @@ page_cache_lru_invalidate(ZathuraRenderer* renderer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraRenderRequestPrivate* request_priv = zathura_render_request_get_instance_private(request);
|
ZathuraRenderRequestPrivate *request_priv =
|
||||||
|
zathura_render_request_get_instance_private(request);
|
||||||
|
|
||||||
/* 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);
|
||||||
|
@ -1020,39 +985,36 @@ page_cache_lru_invalidate(ZathuraRenderer* renderer)
|
||||||
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);
|
||||||
*result = priv->page_cache.num_cached_pages == priv->page_cache.size;
|
*result = priv->page_cache.num_cached_pages == priv->page_cache.size;
|
||||||
|
|
||||||
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);
|
||||||
for (size_t i = 0; i < priv->page_cache.size; ++i) {
|
for (size_t i = 0; i < priv->page_cache.size; ++i) {
|
||||||
priv->page_cache.cache[i] = -1;
|
priv->page_cache.cache[i] = -1;
|
||||||
}
|
}
|
||||||
priv->page_cache.num_cached_pages = 0;
|
priv->page_cache.num_cached_pages = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void zathura_renderer_page_cache_add(ZathuraRenderer *renderer,
|
||||||
zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
|
unsigned int page_index) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraRendererPrivate* priv = zathura_renderer_get_instance_private(renderer);
|
ZathuraRendererPrivate *priv =
|
||||||
|
zathura_renderer_get_instance_private(renderer);
|
||||||
bool full = false;
|
bool full = false;
|
||||||
if (page_cache_is_full(renderer, &full) == false) {
|
if (page_cache_is_full(renderer, &full) == false) {
|
||||||
return;
|
return;
|
||||||
|
@ -1071,27 +1033,25 @@ zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
|
||||||
priv->page_cache.num_cached_pages - 1);
|
priv->page_cache.num_cached_pages - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZathuraRenderRequest* request = girara_list_find(priv->requests,
|
ZathuraRenderRequest *request =
|
||||||
find_request_by_page_index, &page_index);
|
girara_list_find(priv->requests, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue