Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/include/mupdf/fitz/device.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 // Copyright (C) 2004-2025 Artifex Software, Inc. | |
| 2 // | |
| 3 // This file is part of MuPDF. | |
| 4 // | |
| 5 // MuPDF is free software: you can redistribute it and/or modify it under the | |
| 6 // terms of the GNU Affero General Public License as published by the Free | |
| 7 // Software Foundation, either version 3 of the License, or (at your option) | |
| 8 // any later version. | |
| 9 // | |
| 10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | |
| 13 // details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU Affero General Public License | |
| 16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html> | |
| 17 // | |
| 18 // Alternative licensing terms are available from the licensor. | |
| 19 // For commercial licensing, see <https://www.artifex.com/> or contact | |
| 20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, | |
| 21 // CA 94129, USA, for further information. | |
| 22 | |
| 23 #ifndef MUPDF_FITZ_DEVICE_H | |
| 24 #define MUPDF_FITZ_DEVICE_H | |
| 25 | |
| 26 #include "mupdf/fitz/system.h" | |
| 27 #include "mupdf/fitz/context.h" | |
| 28 #include "mupdf/fitz/geometry.h" | |
| 29 #include "mupdf/fitz/image.h" | |
| 30 #include "mupdf/fitz/shade.h" | |
| 31 #include "mupdf/fitz/path.h" | |
| 32 #include "mupdf/fitz/text.h" | |
| 33 | |
| 34 /** | |
| 35 The different format handlers (pdf, xps etc) interpret pages to | |
| 36 a device. These devices can then process the stream of calls | |
| 37 they receive in various ways: | |
| 38 The trace device outputs debugging information for the calls. | |
| 39 The draw device will render them. | |
| 40 The list device stores them in a list to play back later. | |
| 41 The text device performs text extraction and searching. | |
| 42 The bbox device calculates the bounding box for the page. | |
| 43 Other devices can (and will) be written in the future. | |
| 44 */ | |
| 45 typedef struct fz_device fz_device; | |
| 46 | |
| 47 enum | |
| 48 { | |
| 49 /* Flags */ | |
| 50 FZ_DEVFLAG_MASK = 1, | |
| 51 FZ_DEVFLAG_COLOR = 2, | |
| 52 FZ_DEVFLAG_UNCACHEABLE = 4, | |
| 53 FZ_DEVFLAG_FILLCOLOR_UNDEFINED = 8, | |
| 54 FZ_DEVFLAG_STROKECOLOR_UNDEFINED = 16, | |
| 55 FZ_DEVFLAG_STARTCAP_UNDEFINED = 32, | |
| 56 FZ_DEVFLAG_DASHCAP_UNDEFINED = 64, | |
| 57 FZ_DEVFLAG_ENDCAP_UNDEFINED = 128, | |
| 58 FZ_DEVFLAG_LINEJOIN_UNDEFINED = 256, | |
| 59 FZ_DEVFLAG_MITERLIMIT_UNDEFINED = 512, | |
| 60 FZ_DEVFLAG_LINEWIDTH_UNDEFINED = 1024, | |
| 61 FZ_DEVFLAG_BBOX_DEFINED = 2048, | |
| 62 FZ_DEVFLAG_GRIDFIT_AS_TILED = 4096, | |
| 63 FZ_DEVFLAG_DASH_PATTERN_UNDEFINED = 8192, | |
| 64 }; | |
| 65 | |
| 66 enum | |
| 67 { | |
| 68 /* PDF 1.4 -- standard separable */ | |
| 69 FZ_BLEND_NORMAL, | |
| 70 FZ_BLEND_MULTIPLY, | |
| 71 FZ_BLEND_SCREEN, | |
| 72 FZ_BLEND_OVERLAY, | |
| 73 FZ_BLEND_DARKEN, | |
| 74 FZ_BLEND_LIGHTEN, | |
| 75 FZ_BLEND_COLOR_DODGE, | |
| 76 FZ_BLEND_COLOR_BURN, | |
| 77 FZ_BLEND_HARD_LIGHT, | |
| 78 FZ_BLEND_SOFT_LIGHT, | |
| 79 FZ_BLEND_DIFFERENCE, | |
| 80 FZ_BLEND_EXCLUSION, | |
| 81 | |
| 82 /* PDF 1.4 -- standard non-separable */ | |
| 83 FZ_BLEND_HUE, | |
| 84 FZ_BLEND_SATURATION, | |
| 85 FZ_BLEND_COLOR, | |
| 86 FZ_BLEND_LUMINOSITY, | |
| 87 | |
| 88 /* For packing purposes */ | |
| 89 FZ_BLEND_MODEMASK = 15, | |
| 90 FZ_BLEND_ISOLATED = 16, | |
| 91 FZ_BLEND_KNOCKOUT = 32 | |
| 92 }; | |
| 93 | |
| 94 /** | |
| 95 Map from (case sensitive) blend mode string to enumeration. | |
| 96 */ | |
| 97 int fz_lookup_blendmode(const char *name); | |
| 98 | |
| 99 /** | |
| 100 Map from enumeration to blend mode string. | |
| 101 | |
| 102 The string is static, with arbitrary lifespan. | |
| 103 */ | |
| 104 const char *fz_blendmode_name(int blendmode); | |
| 105 | |
| 106 /* | |
| 107 Generic function type. | |
| 108 | |
| 109 Different function implementations will derive from this. | |
| 110 */ | |
| 111 typedef struct fz_function fz_function; | |
| 112 | |
| 113 typedef void (fz_function_eval_fn)(fz_context *, fz_function *, const float *, float *); | |
| 114 | |
| 115 enum | |
| 116 { | |
| 117 FZ_FUNCTION_MAX_N = FZ_MAX_COLORS, | |
| 118 FZ_FUNCTION_MAX_M = FZ_MAX_COLORS | |
| 119 }; | |
| 120 | |
| 121 struct fz_function | |
| 122 { | |
| 123 fz_storable storable; | |
| 124 size_t size; | |
| 125 int m; /* number of input values */ | |
| 126 int n; /* number of output values */ | |
| 127 | |
| 128 fz_function_eval_fn *eval; | |
| 129 }; | |
| 130 | |
| 131 fz_function *fz_new_function_of_size(fz_context *ctx, int size, size_t size2, int m, int n, fz_function_eval_fn *eval, fz_store_drop_fn *drop); | |
| 132 | |
| 133 #define fz_new_derived_function(CTX,TYPE,SIZE,M,N,EVAL,DROP) \ | |
| 134 ((TYPE*)Memento_label(fz_new_function_of_size(CTX,sizeof(TYPE),SIZE,M,N,EVAL,DROP), #TYPE)) | |
| 135 | |
| 136 /* | |
| 137 Evaluate a function. | |
| 138 | |
| 139 Input vector = (in[0], ..., in[inlen-1]) | |
| 140 Output vector = (out[0], ..., out[outlen-1]) | |
| 141 | |
| 142 If inlen or outlen do not match that expected by the function, this | |
| 143 routine will truncate or extend the input/output (with 0's) as | |
| 144 required. | |
| 145 */ | |
| 146 void fz_eval_function(fz_context *ctx, fz_function *func, const float *in, int inlen, float *out, int outlen); | |
| 147 | |
| 148 /* | |
| 149 Keep a function reference. | |
| 150 */ | |
| 151 fz_function *fz_keep_function(fz_context *ctx, fz_function *func); | |
| 152 | |
| 153 /* | |
| 154 Drop a function reference. | |
| 155 */ | |
| 156 void fz_drop_function(fz_context *ctx, fz_function *func); | |
| 157 | |
| 158 /* | |
| 159 Function size | |
| 160 */ | |
| 161 size_t fz_function_size(fz_context *ctx, fz_function *func); | |
| 162 | |
| 163 /** | |
| 164 The device structure is public to allow devices to be | |
| 165 implemented outside of fitz. | |
| 166 | |
| 167 Device methods should always be called using e.g. | |
| 168 fz_fill_path(ctx, dev, ...) rather than | |
| 169 dev->fill_path(ctx, dev, ...) | |
| 170 */ | |
| 171 | |
| 172 /** | |
| 173 Devices can keep track of containers (clips/masks/groups/tiles) | |
| 174 as they go to save callers having to do it. | |
| 175 */ | |
| 176 typedef struct | |
| 177 { | |
| 178 fz_rect scissor; | |
| 179 int type; | |
| 180 int user; | |
| 181 } fz_device_container_stack; | |
| 182 | |
| 183 enum | |
| 184 { | |
| 185 fz_device_container_stack_is_clip, | |
| 186 fz_device_container_stack_is_mask, | |
| 187 fz_device_container_stack_is_group, | |
| 188 fz_device_container_stack_is_tile, | |
| 189 }; | |
| 190 | |
| 191 /* Structure types */ | |
| 192 typedef enum | |
| 193 { | |
| 194 FZ_STRUCTURE_INVALID = -1, | |
| 195 | |
| 196 /* Grouping elements (PDF 1.7 - Table 10.20) */ | |
| 197 FZ_STRUCTURE_DOCUMENT, | |
| 198 FZ_STRUCTURE_PART, | |
| 199 FZ_STRUCTURE_ART, | |
| 200 FZ_STRUCTURE_SECT, | |
| 201 FZ_STRUCTURE_DIV, | |
| 202 FZ_STRUCTURE_BLOCKQUOTE, | |
| 203 FZ_STRUCTURE_CAPTION, | |
| 204 FZ_STRUCTURE_TOC, | |
| 205 FZ_STRUCTURE_TOCI, | |
| 206 FZ_STRUCTURE_INDEX, | |
| 207 FZ_STRUCTURE_NONSTRUCT, | |
| 208 FZ_STRUCTURE_PRIVATE, | |
| 209 /* Grouping elements (PDF 2.0 - Table 364) */ | |
| 210 FZ_STRUCTURE_DOCUMENTFRAGMENT, | |
| 211 /* Grouping elements (PDF 2.0 - Table 365) */ | |
| 212 FZ_STRUCTURE_ASIDE, | |
| 213 /* Grouping elements (PDF 2.0 - Table 366) */ | |
| 214 FZ_STRUCTURE_TITLE, | |
| 215 FZ_STRUCTURE_FENOTE, | |
| 216 /* Grouping elements (PDF 2.0 - Table 367) */ | |
| 217 FZ_STRUCTURE_SUB, | |
| 218 | |
| 219 /* Paragraphlike elements (PDF 1.7 - Table 10.21) */ | |
| 220 FZ_STRUCTURE_P, | |
| 221 FZ_STRUCTURE_H, | |
| 222 FZ_STRUCTURE_H1, | |
| 223 FZ_STRUCTURE_H2, | |
| 224 FZ_STRUCTURE_H3, | |
| 225 FZ_STRUCTURE_H4, | |
| 226 FZ_STRUCTURE_H5, | |
| 227 FZ_STRUCTURE_H6, | |
| 228 | |
| 229 /* List elements (PDF 1.7 - Table 10.23) */ | |
| 230 FZ_STRUCTURE_LIST, | |
| 231 FZ_STRUCTURE_LISTITEM, | |
| 232 FZ_STRUCTURE_LABEL, | |
| 233 FZ_STRUCTURE_LISTBODY, | |
| 234 | |
| 235 /* Table elements (PDF 1.7 - Table 10.24) */ | |
| 236 FZ_STRUCTURE_TABLE, | |
| 237 FZ_STRUCTURE_TR, | |
| 238 FZ_STRUCTURE_TH, | |
| 239 FZ_STRUCTURE_TD, | |
| 240 FZ_STRUCTURE_THEAD, | |
| 241 FZ_STRUCTURE_TBODY, | |
| 242 FZ_STRUCTURE_TFOOT, | |
| 243 | |
| 244 /* Inline elements (PDF 1.7 - Table 10.25) */ | |
| 245 FZ_STRUCTURE_SPAN, | |
| 246 FZ_STRUCTURE_QUOTE, | |
| 247 FZ_STRUCTURE_NOTE, | |
| 248 FZ_STRUCTURE_REFERENCE, | |
| 249 FZ_STRUCTURE_BIBENTRY, | |
| 250 FZ_STRUCTURE_CODE, | |
| 251 FZ_STRUCTURE_LINK, | |
| 252 FZ_STRUCTURE_ANNOT, | |
| 253 /* Inline elements (PDF 2.0 - Table 368) */ | |
| 254 FZ_STRUCTURE_EM, | |
| 255 FZ_STRUCTURE_STRONG, | |
| 256 | |
| 257 /* Ruby inline element (PDF 1.7 - Table 10.26) */ | |
| 258 FZ_STRUCTURE_RUBY, | |
| 259 FZ_STRUCTURE_RB, | |
| 260 FZ_STRUCTURE_RT, | |
| 261 FZ_STRUCTURE_RP, | |
| 262 | |
| 263 /* Warichu inline element (PDF 1.7 - Table 10.26) */ | |
| 264 FZ_STRUCTURE_WARICHU, | |
| 265 FZ_STRUCTURE_WT, | |
| 266 FZ_STRUCTURE_WP, | |
| 267 | |
| 268 /* Illustration elements (PDF 1.7 - Table 10.27) */ | |
| 269 FZ_STRUCTURE_FIGURE, | |
| 270 FZ_STRUCTURE_FORMULA, | |
| 271 FZ_STRUCTURE_FORM, | |
| 272 | |
| 273 /* Artifact structure type (PDF 2.0 - Table 375) */ | |
| 274 FZ_STRUCTURE_ARTIFACT | |
| 275 } fz_structure; | |
| 276 | |
| 277 const char *fz_structure_to_string(fz_structure type); | |
| 278 fz_structure fz_structure_from_string(const char *str); | |
| 279 | |
| 280 typedef enum | |
| 281 { | |
| 282 FZ_METATEXT_ACTUALTEXT, | |
| 283 FZ_METATEXT_ALT, | |
| 284 FZ_METATEXT_ABBREVIATION, | |
| 285 FZ_METATEXT_TITLE | |
| 286 } fz_metatext; | |
| 287 | |
| 288 struct fz_device | |
| 289 { | |
| 290 int refs; | |
| 291 int hints; | |
| 292 int flags; | |
| 293 | |
| 294 void (*close_device)(fz_context *, fz_device *); | |
| 295 void (*drop_device)(fz_context *, fz_device *); | |
| 296 | |
| 297 void (*fill_path)(fz_context *, fz_device *, const fz_path *, int even_odd, fz_matrix, fz_colorspace *, const float *color, float alpha, fz_color_params ); | |
| 298 void (*stroke_path)(fz_context *, fz_device *, const fz_path *, const fz_stroke_state *, fz_matrix, fz_colorspace *, const float *color, float alpha, fz_color_params ); | |
| 299 void (*clip_path)(fz_context *, fz_device *, const fz_path *, int even_odd, fz_matrix, fz_rect scissor); | |
| 300 void (*clip_stroke_path)(fz_context *, fz_device *, const fz_path *, const fz_stroke_state *, fz_matrix, fz_rect scissor); | |
| 301 | |
| 302 void (*fill_text)(fz_context *, fz_device *, const fz_text *, fz_matrix, fz_colorspace *, const float *color, float alpha, fz_color_params ); | |
| 303 void (*stroke_text)(fz_context *, fz_device *, const fz_text *, const fz_stroke_state *, fz_matrix, fz_colorspace *, const float *color, float alpha, fz_color_params ); | |
| 304 void (*clip_text)(fz_context *, fz_device *, const fz_text *, fz_matrix, fz_rect scissor); | |
| 305 void (*clip_stroke_text)(fz_context *, fz_device *, const fz_text *, const fz_stroke_state *, fz_matrix, fz_rect scissor); | |
| 306 void (*ignore_text)(fz_context *, fz_device *, const fz_text *, fz_matrix ); | |
| 307 | |
| 308 void (*fill_shade)(fz_context *, fz_device *, fz_shade *shd, fz_matrix ctm, float alpha, fz_color_params color_params); | |
| 309 void (*fill_image)(fz_context *, fz_device *, fz_image *img, fz_matrix ctm, float alpha, fz_color_params color_params); | |
| 310 void (*fill_image_mask)(fz_context *, fz_device *, fz_image *img, fz_matrix ctm, fz_colorspace *, const float *color, float alpha, fz_color_params color_params); | |
| 311 void (*clip_image_mask)(fz_context *, fz_device *, fz_image *img, fz_matrix ctm, fz_rect scissor); | |
| 312 | |
| 313 void (*pop_clip)(fz_context *, fz_device *); | |
| 314 | |
| 315 void (*begin_mask)(fz_context *, fz_device *, fz_rect area, int luminosity, fz_colorspace *, const float *bc, fz_color_params ); | |
| 316 void (*end_mask)(fz_context *, fz_device *, fz_function *fn); | |
| 317 void (*begin_group)(fz_context *, fz_device *, fz_rect area, fz_colorspace *cs, int isolated, int knockout, int blendmode, float alpha); | |
| 318 void (*end_group)(fz_context *, fz_device *); | |
| 319 | |
| 320 int (*begin_tile)(fz_context *, fz_device *, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm, int id, int doc_id); | |
| 321 void (*end_tile)(fz_context *, fz_device *); | |
| 322 | |
| 323 void (*render_flags)(fz_context *, fz_device *, int set, int clear); | |
| 324 void (*set_default_colorspaces)(fz_context *, fz_device *, fz_default_colorspaces *); | |
| 325 | |
| 326 void (*begin_layer)(fz_context *, fz_device *, const char *layer_name); | |
| 327 void (*end_layer)(fz_context *, fz_device *); | |
| 328 | |
| 329 void (*begin_structure)(fz_context *, fz_device *, fz_structure standard, const char *raw, int idx); | |
| 330 void (*end_structure)(fz_context *, fz_device *); | |
| 331 | |
| 332 void (*begin_metatext)(fz_context *, fz_device *, fz_metatext meta, const char *text); | |
| 333 void (*end_metatext)(fz_context *, fz_device *); | |
| 334 | |
| 335 fz_rect d1_rect; | |
| 336 | |
| 337 int container_len; | |
| 338 int container_cap; | |
| 339 fz_device_container_stack *container; | |
| 340 }; | |
| 341 | |
| 342 /** | |
| 343 Device calls; graphics primitives and containers. | |
| 344 */ | |
| 345 void fz_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, const float *color, float alpha, fz_color_params color_params); | |
| 346 void fz_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, const float *color, float alpha, fz_color_params color_params); | |
| 347 void fz_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, fz_matrix ctm, fz_rect scissor); | |
| 348 void fz_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, fz_matrix ctm, fz_rect scissor); | |
| 349 void fz_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, const float *color, float alpha, fz_color_params color_params); | |
| 350 void fz_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, const float *color, float alpha, fz_color_params color_params); | |
| 351 void fz_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, fz_matrix ctm, fz_rect scissor); | |
| 352 void fz_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, fz_matrix ctm, fz_rect scissor); | |
| 353 void fz_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, fz_matrix ctm); | |
| 354 void fz_pop_clip(fz_context *ctx, fz_device *dev); | |
| 355 void fz_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, fz_matrix ctm, float alpha, fz_color_params color_params); | |
| 356 void fz_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, fz_matrix ctm, float alpha, fz_color_params color_params); | |
| 357 void fz_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, fz_matrix ctm, fz_colorspace *colorspace, const float *color, float alpha, fz_color_params color_params); | |
| 358 void fz_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, fz_matrix ctm, fz_rect scissor); | |
| 359 void fz_begin_mask(fz_context *ctx, fz_device *dev, fz_rect area, int luminosity, fz_colorspace *colorspace, const float *bc, fz_color_params color_params); | |
| 360 void fz_end_mask(fz_context *ctx, fz_device *dev); | |
| 361 void fz_end_mask_tr(fz_context *ctx, fz_device *dev, fz_function *fn); | |
| 362 void fz_begin_group(fz_context *ctx, fz_device *dev, fz_rect area, fz_colorspace *cs, int isolated, int knockout, int blendmode, float alpha); | |
| 363 void fz_end_group(fz_context *ctx, fz_device *dev); | |
| 364 void fz_begin_tile(fz_context *ctx, fz_device *dev, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm); | |
| 365 int fz_begin_tile_id(fz_context *ctx, fz_device *dev, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm, int id); | |
| 366 int fz_begin_tile_tid(fz_context *ctx, fz_device *dev, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm, int id, int doc_id); | |
| 367 void fz_end_tile(fz_context *ctx, fz_device *dev); | |
| 368 void fz_render_flags(fz_context *ctx, fz_device *dev, int set, int clear); | |
| 369 void fz_set_default_colorspaces(fz_context *ctx, fz_device *dev, fz_default_colorspaces *default_cs); | |
| 370 void fz_begin_layer(fz_context *ctx, fz_device *dev, const char *layer_name); | |
| 371 void fz_end_layer(fz_context *ctx, fz_device *dev); | |
| 372 void fz_begin_structure(fz_context *ctx, fz_device *dev, fz_structure standard, const char *raw, int idx); | |
| 373 void fz_end_structure(fz_context *ctx, fz_device *dev); | |
| 374 void fz_begin_metatext(fz_context *ctx, fz_device *dev, fz_metatext meta, const char *text); | |
| 375 void fz_end_metatext(fz_context *ctx, fz_device *dev); | |
| 376 | |
| 377 /** | |
| 378 Devices are created by calls to device implementations, for | |
| 379 instance: foo_new_device(). These will be implemented by calling | |
| 380 fz_new_derived_device(ctx, foo_device) where foo_device is a | |
| 381 structure "derived from" fz_device, for instance | |
| 382 typedef struct { fz_device base; ...extras...} foo_device; | |
| 383 */ | |
| 384 fz_device *fz_new_device_of_size(fz_context *ctx, int size); | |
| 385 #define fz_new_derived_device(CTX, TYPE) \ | |
| 386 ((TYPE *)Memento_label(fz_new_device_of_size(ctx,sizeof(TYPE)),#TYPE)) | |
| 387 | |
| 388 /** | |
| 389 Signal the end of input, and flush any buffered output. | |
| 390 This is NOT called implicitly on fz_drop_device. This | |
| 391 may throw exceptions. | |
| 392 */ | |
| 393 void fz_close_device(fz_context *ctx, fz_device *dev); | |
| 394 | |
| 395 /** | |
| 396 Reduce the reference count on a device. When the reference count | |
| 397 reaches zero, the device and its resources will be freed. | |
| 398 Don't forget to call fz_close_device before dropping the device, | |
| 399 or you may get incomplete output! | |
| 400 | |
| 401 Never throws exceptions. | |
| 402 */ | |
| 403 void fz_drop_device(fz_context *ctx, fz_device *dev); | |
| 404 | |
| 405 /** | |
| 406 Increment the reference count for a device. Returns the same | |
| 407 pointer. | |
| 408 | |
| 409 Never throws exceptions. | |
| 410 */ | |
| 411 fz_device *fz_keep_device(fz_context *ctx, fz_device *dev); | |
| 412 | |
| 413 /** | |
| 414 Enable (set) hint bits within the hint bitfield for a device. | |
| 415 */ | |
| 416 void fz_enable_device_hints(fz_context *ctx, fz_device *dev, int hints); | |
| 417 | |
| 418 /** | |
| 419 Disable (clear) hint bits within the hint bitfield for a device. | |
| 420 */ | |
| 421 void fz_disable_device_hints(fz_context *ctx, fz_device *dev, int hints); | |
| 422 | |
| 423 /** | |
| 424 Find current scissor region as tracked by the device. | |
| 425 */ | |
| 426 fz_rect fz_device_current_scissor(fz_context *ctx, fz_device *dev); | |
| 427 | |
| 428 enum | |
| 429 { | |
| 430 /* Hints */ | |
| 431 FZ_DONT_INTERPOLATE_IMAGES = 1, | |
| 432 FZ_NO_CACHE = 2, | |
| 433 FZ_DONT_DECODE_IMAGES = 4 | |
| 434 }; | |
| 435 | |
| 436 /** | |
| 437 Cookie support - simple communication channel between app/library. | |
| 438 */ | |
| 439 | |
| 440 /** | |
| 441 Provide two-way communication between application and library. | |
| 442 Intended for multi-threaded applications where one thread is | |
| 443 rendering pages and another thread wants to read progress | |
| 444 feedback or abort a job that takes a long time to finish. The | |
| 445 communication is unsynchronized without locking. | |
| 446 | |
| 447 abort: The application should set this field to 0 before | |
| 448 calling fz_run_page to render a page. At any point when the | |
| 449 page is being rendered the application my set this field to 1 | |
| 450 which will cause the rendering to finish soon. This field is | |
| 451 checked periodically when the page is rendered, but exactly | |
| 452 when is not known, therefore there is no upper bound on | |
| 453 exactly when the rendering will abort. If the application | |
| 454 did not provide a set of locks to fz_new_context, it must also | |
| 455 await the completion of fz_run_page before issuing another | |
| 456 call to fz_run_page. Note that once the application has set | |
| 457 this field to 1 after it called fz_run_page it may not change | |
| 458 the value again. | |
| 459 | |
| 460 progress: Communicates rendering progress back to the | |
| 461 application and is read only. Increments as a page is being | |
| 462 rendered. The value starts out at 0 and is limited to less | |
| 463 than or equal to progress_max, unless progress_max is -1. | |
| 464 | |
| 465 progress_max: Communicates the known upper bound of rendering | |
| 466 back to the application and is read only. The maximum value | |
| 467 that the progress field may take. If there is no known upper | |
| 468 bound on how long the rendering may take this value is -1 and | |
| 469 progress is not limited. Note that the value of progress_max | |
| 470 may change from -1 to a positive value once an upper bound is | |
| 471 known, so take this into consideration when comparing the | |
| 472 value of progress to that of progress_max. | |
| 473 | |
| 474 errors: count of errors during current rendering. | |
| 475 | |
| 476 incomplete: Initially should be set to 0. Will be set to | |
| 477 non-zero if a TRYLATER error is thrown during rendering. | |
| 478 */ | |
| 479 typedef struct | |
| 480 { | |
| 481 int abort; | |
| 482 int progress; | |
| 483 size_t progress_max; /* (size_t)-1 for unknown */ | |
| 484 int errors; | |
| 485 int incomplete; | |
| 486 } fz_cookie; | |
| 487 | |
| 488 /** | |
| 489 Create a device to print a debug trace of all device calls. | |
| 490 */ | |
| 491 fz_device *fz_new_trace_device(fz_context *ctx, fz_output *out); | |
| 492 | |
| 493 /** | |
| 494 Create a device to output raw information. | |
| 495 */ | |
| 496 fz_device *fz_new_xmltext_device(fz_context *ctx, fz_output *out); | |
| 497 | |
| 498 /** | |
| 499 Create a device to compute the bounding | |
| 500 box of all marks on a page. | |
| 501 | |
| 502 The returned bounding box will be the union of all bounding | |
| 503 boxes of all objects on a page. | |
| 504 */ | |
| 505 fz_device *fz_new_bbox_device(fz_context *ctx, fz_rect *rectp); | |
| 506 | |
| 507 /** | |
| 508 Create a device to test for features. | |
| 509 | |
| 510 Currently only tests for the presence of non-grayscale colors. | |
| 511 | |
| 512 is_color: Possible values returned: | |
| 513 0: Definitely greyscale | |
| 514 1: Probably color (all colors were grey, but there | |
| 515 were images or shadings in a non grey colorspace). | |
| 516 2: Definitely color | |
| 517 | |
| 518 threshold: The difference from grayscale that will be tolerated. | |
| 519 Typical values to use are either 0 (be exact) and 0.02 (allow an | |
| 520 imperceptible amount of slop). | |
| 521 | |
| 522 options: A set of bitfield options, from the FZ_TEST_OPT set. | |
| 523 | |
| 524 passthrough: A device to pass all calls through to, or NULL. | |
| 525 If set, then the test device can both test and pass through to | |
| 526 an underlying device (like, say, the display list device). This | |
| 527 means that a display list can be created and at the end we'll | |
| 528 know if it's colored or not. | |
| 529 | |
| 530 In the absence of a passthrough device, the device will throw | |
| 531 an exception to stop page interpretation when color is found. | |
| 532 */ | |
| 533 fz_device *fz_new_test_device(fz_context *ctx, int *is_color, float threshold, int options, fz_device *passthrough); | |
| 534 | |
| 535 enum | |
| 536 { | |
| 537 /* If set, test every pixel of images exhaustively. | |
| 538 * If clear, just look at colorspaces for images. */ | |
| 539 FZ_TEST_OPT_IMAGES = 1, | |
| 540 | |
| 541 /* If set, test every pixel of shadings. */ | |
| 542 /* If clear, just look at colorspaces for shadings. */ | |
| 543 FZ_TEST_OPT_SHADINGS = 2 | |
| 544 }; | |
| 545 | |
| 546 /** | |
| 547 Create a device to draw on a pixmap. | |
| 548 | |
| 549 dest: Target pixmap for the draw device. See fz_new_pixmap* | |
| 550 for how to obtain a pixmap. The pixmap is not cleared by the | |
| 551 draw device, see fz_clear_pixmap* for how to clear it prior to | |
| 552 calling fz_new_draw_device. Free the device by calling | |
| 553 fz_drop_device. | |
| 554 | |
| 555 transform: Transform from user space in points to device space | |
| 556 in pixels. | |
| 557 */ | |
| 558 fz_device *fz_new_draw_device(fz_context *ctx, fz_matrix transform, fz_pixmap *dest); | |
| 559 | |
| 560 /** | |
| 561 Create a device to draw on a pixmap. | |
| 562 | |
| 563 dest: Target pixmap for the draw device. See fz_new_pixmap* | |
| 564 for how to obtain a pixmap. The pixmap is not cleared by the | |
| 565 draw device, see fz_clear_pixmap* for how to clear it prior to | |
| 566 calling fz_new_draw_device. Free the device by calling | |
| 567 fz_drop_device. | |
| 568 | |
| 569 transform: Transform from user space in points to device space | |
| 570 in pixels. | |
| 571 | |
| 572 clip: Bounding box to restrict any marking operations of the | |
| 573 draw device. | |
| 574 */ | |
| 575 fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_matrix transform, fz_pixmap *dest, const fz_irect *clip); | |
| 576 | |
| 577 /** | |
| 578 Create a device to draw on a pixmap. | |
| 579 | |
| 580 dest: Target pixmap for the draw device. See fz_new_pixmap* | |
| 581 for how to obtain a pixmap. The pixmap is not cleared by the | |
| 582 draw device, see fz_clear_pixmap* for how to clear it prior to | |
| 583 calling fz_new_draw_device. Free the device by calling | |
| 584 fz_drop_device. | |
| 585 | |
| 586 transform: Transform from user space in points to device space | |
| 587 in pixels. | |
| 588 | |
| 589 proof_cs: Intermediate color space to map though when mapping to | |
| 590 color space defined by pixmap. | |
| 591 */ | |
| 592 fz_device *fz_new_draw_device_with_proof(fz_context *ctx, fz_matrix transform, fz_pixmap *dest, fz_colorspace *proof_cs); | |
| 593 | |
| 594 /** | |
| 595 Create a device to draw on a pixmap. | |
| 596 | |
| 597 dest: Target pixmap for the draw device. See fz_new_pixmap* | |
| 598 for how to obtain a pixmap. The pixmap is not cleared by the | |
| 599 draw device, see fz_clear_pixmap* for how to clear it prior to | |
| 600 calling fz_new_draw_device. Free the device by calling | |
| 601 fz_drop_device. | |
| 602 | |
| 603 transform: Transform from user space in points to device space | |
| 604 in pixels. | |
| 605 | |
| 606 clip: Bounding box to restrict any marking operations of the | |
| 607 draw device. | |
| 608 | |
| 609 proof_cs: Color space to render to prior to mapping to color | |
| 610 space defined by pixmap. | |
| 611 */ | |
| 612 fz_device *fz_new_draw_device_with_bbox_proof(fz_context *ctx, fz_matrix transform, fz_pixmap *dest, const fz_irect *clip, fz_colorspace *cs); | |
| 613 | |
| 614 fz_device *fz_new_draw_device_type3(fz_context *ctx, fz_matrix transform, fz_pixmap *dest); | |
| 615 | |
| 616 /** | |
| 617 struct fz_draw_options: Options for creating a pixmap and draw | |
| 618 device. | |
| 619 */ | |
| 620 typedef struct | |
| 621 { | |
| 622 int rotate; | |
| 623 int x_resolution; | |
| 624 int y_resolution; | |
| 625 int width; | |
| 626 int height; | |
| 627 fz_colorspace *colorspace; | |
| 628 int alpha; | |
| 629 int graphics; | |
| 630 int text; | |
| 631 } fz_draw_options; | |
| 632 | |
| 633 FZ_DATA extern const char *fz_draw_options_usage; | |
| 634 | |
| 635 /** | |
| 636 Parse draw device options from a comma separated key-value string. | |
| 637 */ | |
| 638 fz_draw_options *fz_parse_draw_options(fz_context *ctx, fz_draw_options *options, const char *string); | |
| 639 | |
| 640 /** | |
| 641 Create a new pixmap and draw device, using the specified options. | |
| 642 | |
| 643 options: Options to configure the draw device, and choose the | |
| 644 resolution and colorspace. | |
| 645 | |
| 646 mediabox: The bounds of the page in points. | |
| 647 | |
| 648 pixmap: An out parameter containing the newly created pixmap. | |
| 649 */ | |
| 650 fz_device *fz_new_draw_device_with_options(fz_context *ctx, const fz_draw_options *options, fz_rect mediabox, fz_pixmap **pixmap); | |
| 651 | |
| 652 #endif |
