Commit 2c9e34fa authored by Sebastian Ramacher's avatar Sebastian Ramacher
Browse files

Merge branch 'feature/renderer-take-2' into develop

parents f3ef76f9 7127a460
......@@ -6,6 +6,7 @@ girara user interface library and several document libraries.
Requirements
------------
gtk2 (>= 2.28)
glib (>= 2.28)
girara
sqlite3 (optional, >= 3.5.9)
check (for tests)
......
......@@ -90,13 +90,14 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
.height = zathura_page_get_height(page) * scale
};
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
ZathuraPage* zathura_page_widget = ZATHURA_PAGE(page_widget);
gtk_widget_translate_coordinates(page_widget,
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) {
if (zathura_page_get_visibility(page) == false) {
zathura_page_set_visibility(page, true);
zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget));
zathura_page_widget_update_view_time(zathura_page_widget);
zathura_page_cache_add(zathura, zathura_page_get_index(page));
}
if (zathura->global.update_page_number == true && updated == false
......@@ -106,11 +107,13 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
}
} else {
zathura_page_set_visibility(page, false);
/* If a page becomes invisible, abort the render request. */
zathura_page_widget_abort_render_request(zathura_page_widget);
/* if the page is not visible and not cached, but still has a surface, we
* need to get rid of the surface */
if (zathura_page_widget_have_surface(ZATHURA_PAGE(page_widget)) == true &&
if (zathura_page_widget_have_surface(zathura_page_widget) == true &&
zathura_page_cache_is_cached(zathura, zathura_page_get_index(page)) == false) {
zathura_page_widget_update_surface(ZATHURA_PAGE(page_widget), NULL);
zathura_page_widget_update_surface(zathura_page_widget, NULL);
}
girara_list_t* results = NULL;
......@@ -367,6 +370,13 @@ cb_sc_display_link(GtkEntry* entry, girara_session_t* session)
return handle_link(entry, session, ZATHURA_LINK_ACTION_DISPLAY);
}
static gboolean
file_monitor_reload(void* data)
{
sc_reload((girara_session_t*) data, NULL, NULL, 0);
return FALSE;
}
void
cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), GFileMonitorEvent event, girara_session_t* session)
{
......@@ -377,9 +387,7 @@ cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), G
switch (event) {
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_CREATED:
gdk_threads_enter();
sc_reload(session, NULL, NULL, 0);
gdk_threads_leave();
g_main_context_invoke(NULL, file_monitor_reload, session);
break;
default:
return;
......@@ -488,11 +496,11 @@ cb_setting_recolor_change(girara_session_t* session, const char* name,
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data;
bool bool_value = *((bool*) value);
const bool bool_value = *((bool*) value);
if (zathura->global.recolor != bool_value) {
zathura->global.recolor = bool_value;
render_all(zathura);
if (zathura->sync.render_thread != NULL && zathura_renderer_recolor_enabled(zathura->sync.render_thread) != bool_value) {
zathura_renderer_enable_recolor(zathura->sync.render_thread, bool_value);
render_all(zathura);
}
}
......@@ -506,11 +514,11 @@ cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data;
bool bool_value = *((bool*) value);
const bool bool_value = *((bool*) value);
if (zathura->global.recolor_keep_hue != bool_value) {
zathura->global.recolor_keep_hue = bool_value;
render_all(zathura);
if (zathura->sync.render_thread != NULL && zathura_renderer_recolor_hue_enabled(zathura->sync.render_thread) != bool_value) {
zathura_renderer_enable_recolor_hue(zathura->sync.render_thread, bool_value);
render_all(zathura);
}
}
......@@ -529,7 +537,8 @@ cb_unknown_command(girara_session_t* session, const char* input)
}
/* check for number */
for (unsigned int i = 0; i < strlen(input); i++) {
const size_t size = strlen(input);
for (size_t i = 0; i < size; i++) {
if (g_ascii_isdigit(input[i]) == FALSE) {
return false;
}
......
......@@ -381,9 +381,9 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
g_object_set(page_widget, "draw-links", FALSE, NULL);
render_lock(zathura->sync.render_thread);
zathura_renderer_lock(zathura->sync.render_thread);
girara_list_t* result = zathura_page_search_text(page, input, &error);
render_unlock(zathura->sync.render_thread);
zathura_renderer_unlock(zathura->sync.render_thread);
if (result == NULL || girara_list_size(result) == 0) {
girara_list_free(result);
......
......@@ -57,9 +57,13 @@ cb_color_change(girara_session_t* session, const char* name,
} else if (g_strcmp0(name, "highlight-active-color") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active));
} else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
if (zathura->sync.render_thread != NULL) {
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, NULL, string_value);
}
} else if (g_strcmp0(name, "recolor-lightcolor") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
if (zathura->sync.render_thread != NULL) {
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, string_value, NULL);
}
} else if (g_strcmp0(name, "render-loading-bg") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_bg));
} else if (g_strcmp0(name, "render-loading-fg") == 0) {
......@@ -169,10 +173,8 @@ config_load_default(zathura_t* zathura)
int_value = 2000;
girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL);
girara_setting_add(gsession, "recolor-darkcolor", NULL, STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
girara_setting_set(gsession, "recolor-darkcolor", "#FFFFFF");
girara_setting_add(gsession, "recolor-lightcolor", NULL, STRING, false, _("Recoloring (light color)"), cb_color_change, NULL);
girara_setting_set(gsession, "recolor-lightcolor", "#000000");
girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL);
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-color", "#9FBC00");
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
......
......@@ -52,6 +52,9 @@ GTHREAD_LIB ?= $(shell pkg-config --libs gthread-2.0)
GMODULE_INC ?= $(shell pkg-config --cflags gmodule-no-export-2.0)
GMODULE_LIB ?= $(shell pkg-config --libs gmodule-no-export-2.0)
GLIB_INC ?= $(shell pkg-config --cflags --atleast-version=2.28 glib-2.0)
GLIB_LIB ?= $(shell pkg-config --libs --atleast-version=2.28 glib-2.0)
GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk${ZATHURA_GTK_VERSION})
GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk${ZATHURA_GTK_VERSION})
......@@ -65,8 +68,8 @@ MAGIC_INC ?=
MAGIC_LIB ?= -lmagic
endif
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC}
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} -lpthread -lm
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC}
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} -lpthread -lm
# flags
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)
......
......@@ -25,7 +25,9 @@ main(int argc, char* argv[])
#if !GLIB_CHECK_VERSION(2, 31, 0)
g_thread_init(NULL);
#endif
#if !GTK_CHECK_VERSION(3, 6, 0)
gdk_threads_init();
#endif
gtk_init(&argc, &argv);
/* create zathura session */
......@@ -46,7 +48,7 @@ main(int argc, char* argv[])
bool synctex = false;
int page_number = ZATHURA_PAGE_NUMBER_UNSPECIFIED;
#if (GTK_MAJOR_VERSION == 3)
#if GTK_CHECK_VERSION(3, 0, 0)
Window embed = 0;
#else
GdkNativeWindow embed = 0;
......@@ -148,9 +150,13 @@ main(int argc, char* argv[])
}
/* run zathura */
#if !GTK_CHECK_VERSION(3, 6, 0)
gdk_threads_enter();
#endif
gtk_main();
#if !GTK_CHECK_VERSION(3, 6, 0)
gdk_threads_leave();
#endif
/* free zathura */
zathura_free(zathura);
......
......@@ -15,6 +15,7 @@
#include "utils.h"
#include "shortcuts.h"
#include "synctex.h"
#include "zathura.h"
G_DEFINE_TYPE(ZathuraPage, zathura_page_widget, GTK_TYPE_DRAWING_AREA)
......@@ -22,7 +23,7 @@ typedef struct zathura_page_widget_private_s {
zathura_page_t* page; /**< Page object */
zathura_t* zathura; /**< Zathura object */
cairo_surface_t* surface; /**< Cairo surface */
bool render_requested; /**< No surface and rendering has been requested */
ZathuraRenderRequest* render_request; /* Request object */
gint64 last_view; /**< Last time the page has been viewed */
mutex lock; /**< Lock */
......@@ -75,6 +76,7 @@ static gboolean cb_zathura_page_widget_motion_notify(GtkWidget* widget, GdkEvent
static gboolean cb_zathura_page_widget_popup_menu(GtkWidget* widget);
static void cb_menu_image_copy(GtkMenuItem* item, ZathuraPage* page);
static void cb_menu_image_save(GtkMenuItem* item, ZathuraPage* page);
static void cb_update_surface(ZathuraRenderRequest* request, cairo_surface_t* surface, void* data);
enum properties_e {
PROP_0,
......@@ -174,7 +176,7 @@ zathura_page_widget_init(ZathuraPage* widget)
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
priv->page = NULL;
priv->surface = NULL;
priv->render_requested = false;
priv->render_request = NULL;
priv->last_view = g_get_real_time();
priv->links.list = NULL;
......@@ -208,7 +210,18 @@ zathura_page_widget_new(zathura_t* zathura, zathura_page_t* page)
{
g_return_val_if_fail(page != NULL, NULL);
return g_object_new(ZATHURA_TYPE_PAGE, "page", page, "zathura", zathura, NULL);
GObject* ret = g_object_new(ZATHURA_TYPE_PAGE, "page", page, "zathura", zathura, NULL);
if (ret == NULL) {
return NULL;
}
ZathuraPage* widget = ZATHURA_PAGE(ret);
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
priv->render_request = zathura_render_request_new(zathura->sync.render_thread, page);
g_signal_connect_object(priv->render_request, "completed",
G_CALLBACK(cb_update_surface), widget, 0);
return GTK_WIDGET(ret);
}
static void
......@@ -221,6 +234,10 @@ zathura_page_widget_finalize(GObject* object)
cairo_surface_destroy(priv->surface);
}
if (priv->render_request != NULL) {
g_object_unref(priv->render_request);
}
if (priv->search.list != NULL) {
girara_list_free(priv->search.list);
}
......@@ -311,7 +328,7 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
*/
if (priv->search.list != NULL && zathura_page_get_visibility(priv->page)) {
gtk_widget_queue_draw(GTK_WIDGET(object));
gtk_widget_queue_draw(GTK_WIDGET(object));
}
break;
default:
......@@ -479,8 +496,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
}
} else {
/* set background color */
if (priv->zathura->global.recolor == true) {
GdkColor color = priv->zathura->ui.colors.recolor_light_color;
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {
GdkColor color;
zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, &color, NULL);
cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0);
} else {
GdkColor color = priv->zathura->ui.colors.render_loading_bg;
......@@ -494,8 +512,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
/* write text */
if (render_loading == true) {
if (priv->zathura->global.recolor == true) {
GdkColor color = priv->zathura->ui.colors.recolor_dark_color;
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {
GdkColor color;
zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, NULL, &color);
cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0);
} else {
GdkColor color = priv->zathura->ui.colors.render_loading_fg;
......@@ -514,10 +533,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
}
/* render real page */
if (priv->render_requested == false) {
priv->render_requested = true;
render_page(priv->zathura->sync.render_thread, priv->page);
}
zathura_render_request(priv->render_request, priv->last_view);
}
mutex_unlock(&(priv->lock));
return FALSE;
......@@ -539,11 +555,10 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface
cairo_surface_destroy(priv->surface);
priv->surface = NULL;
}
priv->render_requested = false;
if (surface != NULL) {
/* if we're not visible or not cached, we don't care about the surface */
if (zathura_page_get_visibility(priv->page) == true ||
zathura_page_cache_is_cached(priv->zathura, zathura_page_get_index(priv->page)) == true) {
/*if (zathura_page_get_visibility(priv->page) == true ||
zathura_page_cache_is_cached(priv->zathura, zathura_page_get_index(priv->page)) == true) */ {
priv->surface = surface;
cairo_surface_reference(surface);
}
......@@ -555,6 +570,14 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface
}
}
static void
cb_update_surface(ZathuraRenderRequest* UNUSED(request), cairo_surface_t* surface, void* data)
{
ZathuraPage* widget = data;
g_return_if_fail(ZATHURA_IS_PAGE(widget));
zathura_page_widget_update_surface(widget, surface);
}
static void
zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation)
{
......@@ -914,3 +937,11 @@ zathura_page_widget_have_surface(ZathuraPage* widget)
return priv->surface != NULL;
}
void
zathura_page_widget_abort_render_request(ZathuraPage* widget)
{
g_return_if_fail(ZATHURA_IS_PAGE(widget));
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
zathura_render_request_abort(priv->render_request);
}
......@@ -94,4 +94,11 @@ void zathura_page_widget_update_view_time(ZathuraPage* widget);
*/
bool zathura_page_widget_have_surface(ZathuraPage* widget);
/**
* Abort outstanding render requests
*
* @param widget the widget
*/
void zathura_page_widget_abort_render_request(ZathuraPage* widget);
#endif
......@@ -109,9 +109,9 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
/* Try to render the page without a temporary surface. This only works with
* plugins that support rendering to any surface. */
girara_debug("printing page %d ...", page_number);
render_lock(zathura->sync.render_thread);
zathura_renderer_lock(zathura->sync.render_thread);
int err = zathura_page_render(page, cairo, true);
render_unlock(zathura->sync.render_thread);
zathura_renderer_unlock(zathura->sync.render_thread);
if (err == ZATHURA_ERROR_OK) {
return;
}
......@@ -144,9 +144,9 @@ cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
/* Render the page to the temporary surface */
girara_debug("printing page %d ...", page_number);
render_lock(zathura->sync.render_thread);
zathura_renderer_lock(zathura->sync.render_thread);
err = zathura_page_render(page, temp_cairo, true);
render_unlock(zathura->sync.render_thread);
zathura_renderer_unlock(zathura->sync.render_thread);
if (err != ZATHURA_ERROR_OK) {
cairo_destroy(temp_cairo);
cairo_surface_destroy(surface);
......
This diff is collapsed.
......@@ -5,58 +5,185 @@
#include <stdbool.h>
#include <stdlib.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <girara/types.h>
#include "types.h"
#include "zathura.h"
#include "callbacks.h"
typedef struct zathura_renderer_class_s ZathuraRendererClass;
struct zathura_renderer_s
{
GObject parent;
};
struct zathura_renderer_class_s
{
GObjectClass parent_class;
};
#define ZATHURA_TYPE_RENDERER \
(zathura_renderer_get_type())
#define ZATHURA_RENDERER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_RENDERER, ZathuraRenderer))
#define ZATHURA_RENDERER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_RENDERER, ZathuraRendererClass))
#define ZATHURA_IS_RENDERER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_RENDERER))
#define ZATHURA_IS_RENDERER_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_RENDERER))
#define ZATHURA_RENDERER_GET_CLASS \
(G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_RENDERER, ZathuraRendererClass))
/**
* This function initializes a render thread
*
* @param zathura object
* @return The render thread object or NULL if an error occured
* Returns the type of the renderer.
* @return the type
*/
render_thread_t* render_init(zathura_t* zathura);
GType zathura_renderer_get_type(void);
/**
* Create a renderer.
* @return a renderer object
*/
ZathuraRenderer* zathura_renderer_new(void);
/**
* This function destroys the render thread object
* Return whether recoloring is enabled.
* @param renderer a renderer object
* @returns true if recoloring is enabled, false otherwise
*/
bool zathura_renderer_recolor_enabled(ZathuraRenderer* renderer);
/**
* Enable/disable recoloring.
* @param renderer a renderer object
* @param enable wheter to enable or disable recoloring
*/
void zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable);
/**
* Return whether hue should be preserved while recoloring.
* @param renderer a renderer object
* @returns true if hue should be preserved, false otherwise
*/
bool zathura_renderer_recolor_hue_enabled(ZathuraRenderer* renderer);
/**
* Enable/disable preservation of hue while recoloring.
* @param renderer a renderer object
* @param enable wheter to enable or disable hue preservation
*/
void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer,
bool enable);
/**
* Set light and dark colors for recoloring.
* @param renderer a renderer object
* @param light light color
* @param dark dark color
*/
void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
const GdkColor* light, const GdkColor* dark);
/**
* Set light and dark colors for recoloring.
* @param renderer a renderer object
* @param light light color
* @param dark dark color
*/
void zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
const char* light, const char* dark);
/**
* Get light and dark colors for recoloring.
* @param renderer a renderer object
* @param light light color
* @param dark dark color
*/
void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
GdkColor* light, GdkColor* dark);
/**
* Stop rendering.
* @param renderer a render object
*/
void zathura_renderer_stop(ZathuraRenderer* renderer);
/**
* Lock the render thread. This is useful if you want to render on your own (e.g
* for printing).
*
* @param render_thread The render thread object
* @param renderer renderer object
*/
void render_free(render_thread_t* render_thread);
void zathura_renderer_lock(ZathuraRenderer* renderer);
/**
* This function is used to add a page to the render thread list
* that should be rendered.
* Unlock the render thread.
*
* @param render_thread The render thread object
* @param page The page that should be rendered
* @return true if no error occured
* @param renderer renderer object.
*/
bool render_page(render_thread_t* render_thread, zathura_page_t* page);
void zathura_renderer_unlock(ZathuraRenderer* renderer);
typedef struct zathura_render_request_s ZathuraRenderRequest;
typedef struct zathura_render_request_class_s ZathuraRenderRequestClass;
struct zathura_render_request_s
{
GObject parent;
};
struct zathura_render_request_class_s
{
GObjectClass parent_class;
};
#define ZATHURA_TYPE_RENDER_REQUEST \
(zathura_render_request_get_type())
#define ZATHURA_RENDER_REQUEST(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_RENDER_REQUEST, \
ZathuraRenderRequest))
#define ZATHURA_RENDER_REQUEST_CLASS(obj) \
(G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_RENDER_REQUEST, \
ZathuraRenderRequestClass))
#define ZATHURA_IS_RENDER_REQUEST(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_RENDER_REQUEST))
#define ZATHURA_IS_RENDER_REQUEST_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_RENDER_REQUEST))
#define ZATHURA_RENDER_REQUEST_GET_CLASS \
(G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_RENDER_REQUEST, \
ZathuraRenderRequestClass))
/**
* This function is used to unmark all pages as not rendered. This should
* be used if all pages should be rendered again (e.g.: the zoom level or the
* colors have changed)
* Returns the type of the render request.
* @return the type
*/
GType zathura_page_render_info_get_type(void);
/**
* Create a render request object
* @param renderer a renderer object
* @param page the page to be displayed
* @returns render request object
*/
ZathuraRenderRequest* zathura_render_request_new(ZathuraRenderer* renderer,
zathura_page_t* page);
/**
* This function is used to add a page to the render thread list
* that should be rendered.
*
* @param zathura Zathura object
* @param request request object of the page that should be renderer
* @param last_view_time last view time of the page
*/
void render_all(zathura_t* zathura);
void zathura_render_request(ZathuraRenderRequest* request,
gint64 last_view_time);
/**
* Lock the render thread. This is useful if you want to render on your own (e.g
* for printing).
* Abort an existing render request.
*
* @param render_thread The render thread object.
* @param reqeust request that should be aborted
*/
void render_lock(render_thread_t* render_thread);
void zathura_render_request_abort(ZathuraRenderRequest* request);
/**
* Unlock the render thread.
* This function is used to unmark all pages as not rendered. This should
* be used if all pages should be rendered again (e.g.: the zoom level or the
* colors have changed)
*
* @param render_thread The render thread object.
* @param zathura Zathura object
*/
void render_unlock(render_thread_t* render_thread);
void render_all(zathura_t* zathura);
#endif // RENDER_H
......@@ -30,6 +30,11 @@ typedef struct zathura_s zathura_t;
*/
typedef struct zathura_plugin_manager_s zathura_plugin_manager_t;
/**
* Renderer
*/
typedef struct zathura_renderer_s ZathuraRenderer;
/**
* Error types
*/
......
......@@ -68,7 +68,6 @@ zathura_create(void)
zathura_t* zathura = g_malloc0(sizeof(zathura_t));
/* global settings */
zathura->global.recolor = false;
zathura->global.update_page_number = true;
zathura->global.search_direction = FORWARD;
......@@ -711,6 +710,29 @@ document_open(zathura_t* zathura, const char* path, const char* password,
zathura->document = document;
/* threads */
zathura->sync.render_thread = zathura_renderer_new();
if (zathura->sync.render_thread == NULL) {
goto error_free;