render.h 6.78 KB
Newer Older
1
/* SPDX-License-Identifier: Zlib */
Moritz Lipp's avatar
Moritz Lipp committed
2

Moritz Lipp's avatar
Moritz Lipp committed
3 4 5
#ifndef RENDER_H
#define RENDER_H

Moritz Lipp's avatar
Moritz Lipp committed
6
#include <stdbool.h>
Moritz Lipp's avatar
Moritz Lipp committed
7
#include <stdlib.h>
Sebastian Ramacher's avatar
Sebastian Ramacher committed
8 9
#include <glib-object.h>
#include <gdk/gdk.h>
10
#include <girara/types.h>
11
#include "types.h"
Moritz Lipp's avatar
Moritz Lipp committed
12

13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
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))
Moritz Lipp's avatar
Moritz Lipp committed
37

Moritz Lipp's avatar
Moritz Lipp committed
38
/**
39 40 41
 * Returns the type of the renderer.
 * @return the type
 */
42
GType zathura_renderer_get_type(void) G_GNUC_CONST;
43
/**
44 45
 * Create a renderer.
 * @return a renderer object
Moritz Lipp's avatar
Moritz Lipp committed
46
 */
47
ZathuraRenderer* zathura_renderer_new(size_t cache_size);
48

49 50 51 52 53
/**
 * Return whether recoloring is enabled.
 * @param renderer a renderer object
 * @returns true if recoloring is enabled, false otherwise
 */
54
bool zathura_renderer_recolor_enabled(ZathuraRenderer* renderer);
55 56 57
/**
 * Enable/disable recoloring.
 * @param renderer a renderer object
58
 * @param enable whether to enable or disable recoloring
59
 */
60
void zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable);
61 62 63 64 65
/**
 * Return whether hue should be preserved while recoloring.
 * @param renderer a renderer object
 * @returns true if hue should be preserved, false otherwise
 */
66
bool zathura_renderer_recolor_hue_enabled(ZathuraRenderer* renderer);
67 68 69
/**
 * Enable/disable preservation of hue while recoloring.
 * @param renderer a renderer object
70
 * @param enable whether to enable or disable hue preservation
71
 */
72 73
void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer,
    bool enable);
74 75 76 77 78 79 80 81 82 83 84 85 86
/**
 * Return whether images should be recolored while recoloring.
 * @param renderer a renderer object
 * @returns true if images should be recolored, false otherwise
 */
bool zathura_renderer_recolor_reverse_video_enabled(ZathuraRenderer* renderer);
/**
 * Enable/disable recoloring of images while recoloring.
 * @param renderer a renderer object
 * @param enable or disable images recoloring
 */
void zathura_renderer_enable_recolor_reverse_video(ZathuraRenderer* renderer,
    bool enable);
87 88 89 90 91 92
/**
 * Set light and dark colors for recoloring.
 * @param renderer a renderer object
 * @param light light color
 * @param dark dark color
 */
93
void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
94
    const GdkRGBA* light, const GdkRGBA* dark);
95 96 97 98 99 100
/**
 * Set light and dark colors for recoloring.
 * @param renderer a renderer object
 * @param light light color
 * @param dark dark color
 */
101 102
void zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
    const char* light, const char* dark);
103 104 105 106 107 108
/**
 * Get light and dark colors for recoloring.
 * @param renderer a renderer object
 * @param light light color
 * @param dark dark color
 */
109
void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
110
    GdkRGBA* light, GdkRGBA* dark);
111 112 113 114
/**
 * Stop rendering.
 * @param renderer a render object
 */
115
void zathura_renderer_stop(ZathuraRenderer* renderer);
Moritz Lipp's avatar
Moritz Lipp committed
116 117

/**
118 119
 * Lock the render thread. This is useful if you want to render on your own (e.g
 * for printing).
Moritz Lipp's avatar
Moritz Lipp committed
120
 *
121
 * @param renderer renderer object
Moritz Lipp's avatar
Moritz Lipp committed
122
 */
123
void zathura_renderer_lock(ZathuraRenderer* renderer);
Moritz Lipp's avatar
Moritz Lipp committed
124 125

/**
126
 * Unlock the render thread.
Moritz Lipp's avatar
Moritz Lipp committed
127
 *
128
 * @param renderer renderer object.
Moritz Lipp's avatar
Moritz Lipp committed
129
 */
130 131
void zathura_renderer_unlock(ZathuraRenderer* renderer);

132
/**
133
 * Add a page to the page cache.
134
 *
135 136
 * @param renderer renderer object.
 * @param page_index The index of the page to be cached.
137
 */
138
void zathura_renderer_page_cache_add(ZathuraRenderer* renderer,
139 140
    unsigned int page_index);

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

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))
Moritz Lipp's avatar
Moritz Lipp committed
169

170
/**
171
 * Returns the type of the render request.
172 173
 * @return the type
 */
174
GType zathura_page_render_info_get_type(void) G_GNUC_CONST;
175
/**
176 177
 * Create a render request object
 * @param renderer a renderer object
178
 * @param page the page to be displayed
179
 * @returns render request object
180 181 182 183 184
 */
ZathuraRenderRequest* zathura_render_request_new(ZathuraRenderer* renderer,
    zathura_page_t* page);

/**
185
 * Add a page to the render thread list that should be rendered.
Moritz Lipp's avatar
Moritz Lipp committed
186
 *
187
 * @param request request object of the page that should be renderer
188
 * @param last_view_time last view time of the page
189
 */
190 191
void zathura_render_request(ZathuraRenderRequest* request,
    gint64 last_view_time);
192

193
/**
194
 * Abort an existing render request.
195
 *
Moritz Lipp's avatar
Moritz Lipp committed
196
 * @param request request that should be aborted
197
 */
198 199
void zathura_render_request_abort(ZathuraRenderRequest* request);

200 201 202 203 204 205
/**
 * Update the time the page associated to the render request has been viewed the
 * last time.
 *
 * @param request request that should be updated
 */
206 207
void zathura_render_request_update_view_time(ZathuraRenderRequest* request);

208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
/**
 * Set "plain" rendering mode, i.e. disabling scaling, recoloring, etc.
 * @param request request that should be updated
 * @param render_plain "plain" rendering setting
 */
void zathura_render_request_set_render_plain(ZathuraRenderRequest* request,
    bool render_plain);

/**
 * Get "plain" rendering mode, i.e. disabling scaling, recoloring, etc.
 * @param request request that should be updated
 * @returns "plain" rendering setting
 */
bool zathura_render_request_get_render_plain(ZathuraRenderRequest* request);

223
/**
224 225 226
 * 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)
227
 *
228
 * @param zathura Zathura object
229
 */
230
void render_all(zathura_t* zathura);
231

Moritz Lipp's avatar
Moritz Lipp committed
232
#endif // RENDER_H