mupdf
Loading...
Searching...
No Matches
context.h
Go to the documentation of this file.
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_CONTEXT_H
24#define MUPDF_FITZ_CONTEXT_H
25
26#include "mupdf/fitz/version.h"
27#include "mupdf/fitz/system.h"
28#include "mupdf/fitz/geometry.h"
29
30
31#ifndef FZ_VERBOSE_EXCEPTIONS
32#define FZ_VERBOSE_EXCEPTIONS 0
33#endif
34
40typedef struct fz_store fz_store;
44typedef struct fz_output fz_output;
45typedef struct fz_context fz_context;
46
50typedef struct
51{
52 void *user;
53 void *(*malloc)(void *, size_t);
54 void *(*realloc)(void *, void *, size_t);
55 void (*free)(void *, void *);
57
62#define fz_var(var) fz_var_imp((void *)&(var))
63#define fz_try(ctx) if (!fz_setjmp(*fz_push_try(ctx))) if (fz_do_try(ctx)) do
64#define fz_always(ctx) while (0); if (fz_do_always(ctx)) do
65#define fz_catch(ctx) while (0); if (fz_do_catch(ctx))
66
99
105FZ_NORETURN void fz_vthrow(fz_context *ctx, int errcode, const char *, va_list ap);
106FZ_NORETURN void fz_throw(fz_context *ctx, int errcode, const char *, ...) FZ_PRINTFLIKE(3,4);
108
115void fz_morph_error(fz_context *ctx, int fromcode, int tocode);
116
123void fz_vwarn(fz_context *ctx, const char *fmt, va_list ap);
124void fz_warn(fz_context *ctx, const char *fmt, ...) FZ_PRINTFLIKE(2,3);
125
133
141
142/*
143 Within an fz_catch() block, retrieve the errno code for
144 the current SYSTEM exception.
145
146 Is undefined for non-SYSTEM errors.
147*/
149
156void fz_rethrow_if(fz_context *ctx, int errcode);
157void fz_rethrow_unless(fz_context *ctx, int errcode);
158
163void fz_log_error_printf(fz_context *ctx, const char *fmt, ...) FZ_PRINTFLIKE(2,3);
164void fz_vlog_error_printf(fz_context *ctx, const char *fmt, va_list ap);
165
170void fz_log_error(fz_context *ctx, const char *str);
171
177#if FZ_VERBOSE_EXCEPTIONS
178#define fz_vthrow(CTX, ERRCODE, FMT, VA) fz_vthrowFL(CTX, __FILE__, __LINE__, ERRCODE, FMT, VA)
179#define fz_throw(CTX, ERRCODE, ...) fz_throwFL(CTX, __FILE__, __LINE__, ERRCODE, __VA_ARGS__)
180#define fz_rethrow(CTX) fz_rethrowFL(CTX, __FILE__, __LINE__)
181#define fz_morph_error(CTX, FROM, TO) fz_morph_errorFL(CTX, __FILE__, __LINE__, FROM, TO)
182#define fz_vwarn(CTX, FMT, VA) fz_vwarnFL(CTX, __FILE__, __LINE__, FMT, VA)
183#define fz_warn(CTX, ...) fz_warnFL(CTX, __FILE__, __LINE__, __VA_ARGS__)
184#define fz_rethrow_if(CTX, ERRCODE) fz_rethrow_ifFL(CTX, __FILE__, __LINE__, ERRCODE)
185#define fz_rethrow_unless(CTX, ERRCODE) fz_rethrow_unlessFL(CTX, __FILE__, __LINE__, ERRCODE)
186#define fz_log_error_printf(CTX, ...) fz_log_error_printfFL(CTX, __FILE__, __LINE__, __VA_ARGS__)
187#define fz_vlog_error_printf(CTX, FMT, VA) fz_log_error_printfFL(CTX, __FILE__, __LINE__, FMT, VA)
188#define fz_log_error(CTX, STR) fz_log_error_printfFL(CTX, __FILE__, __LINE__, STR)
189#define fz_do_catch(CTX) fz_do_catchFL(CTX, __FILE__, __LINE__)
190FZ_NORETURN void fz_vthrowFL(fz_context *ctx, const char *file, int line, int errcode, const char *fmt, va_list ap);
191FZ_NORETURN void fz_throwFL(fz_context *ctx, const char *file, int line, int errcode, const char *fmt, ...) FZ_PRINTFLIKE(5,6);
192FZ_NORETURN void fz_rethrowFL(fz_context *ctx, const char *file, int line);
193void fz_morph_errorFL(fz_context *ctx, const char *file, int line, int fromcode, int tocode);
194void fz_vwarnFL(fz_context *ctx, const char *file, int line, const char *fmt, va_list ap);
195void fz_warnFL(fz_context *ctx, const char *file, int line, const char *fmt, ...) FZ_PRINTFLIKE(4,5);
196void fz_rethrow_ifFL(fz_context *ctx, const char *file, int line, int errcode);
197void fz_rethrow_unlessFL(fz_context *ctx, const char *file, int line, int errcode);
198void fz_log_error_printfFL(fz_context *ctx, const char *file, int line, const char *fmt, ...) FZ_PRINTFLIKE(4,5);
199void fz_vlog_error_printfFL(fz_context *ctx, const char *file, int line, const char *fmt, va_list ap);
200void fz_log_errorFL(fz_context *ctx, const char *file, int line, const char *str);
201int fz_do_catchFL(fz_context *ctx, const char *file, int line);
202#endif
203
204/* Report an error to the registered error callback. */
206
207/*
208 * Swallow an error and ignore it completely.
209 * This should only be called to signal that you've handled a TRYLATER or ABORT error,
210 */
212
213/* Convert an error into another runtime exception.
214 * For use when converting an exception from Fitz to a language binding exception.
215 */
216const char *fz_convert_error(fz_context *ctx, int *code);
217
219{
222
223 FZ_ERROR_SYSTEM, // fatal out of memory or syscall error
224 FZ_ERROR_LIBRARY, // unclassified error from third-party library
225 FZ_ERROR_ARGUMENT, // invalid or out-of-range arguments to functions
226 FZ_ERROR_LIMIT, // failed because of resource or other hard limits
227 FZ_ERROR_UNSUPPORTED, // tried to use an unsupported feature
228 FZ_ERROR_FORMAT, // syntax or format errors that are unrecoverable
229 FZ_ERROR_SYNTAX, // syntax errors that should be diagnosed and ignored
230
231 // for internal use only
232 FZ_ERROR_TRYLATER, // try-later progressive loading signal
233 FZ_ERROR_ABORT, // user requested abort signal
234 FZ_ERROR_REPAIRED, // internal flag used when repairing a PDF to avoid cycles
235};
236
247
268
269typedef struct
270{
271 void *user;
272 void (*lock)(void *user, int lock);
273 void (*unlock)(void *user, int lock);
275
276enum {
281};
282
283#if defined(MEMENTO) || !defined(NDEBUG)
284#define FITZ_DEBUG_LOCKING
285#endif
286
287#ifdef FITZ_DEBUG_LOCKING
288
289void fz_assert_lock_held(fz_context *ctx, int lock);
291void fz_lock_debug_lock(fz_context *ctx, int lock);
292void fz_lock_debug_unlock(fz_context *ctx, int lock);
293
294#else
295
296#define fz_assert_lock_held(A,B) do { } while (0)
297#define fz_assert_lock_not_held(A,B) do { } while (0)
298#define fz_lock_debug_lock(A,B) do { } while (0)
299#define fz_lock_debug_unlock(A,B) do { } while (0)
300
301#endif /* !FITZ_DEBUG_LOCKING */
302
312enum {
314 FZ_STORE_DEFAULT = 256 << 20,
315};
316
345#define fz_new_context(alloc, locks, max_store) fz_new_context_imp(alloc, locks, max_store, FZ_VERSION)
346
363
375
383
388
403void fz_default_error_callback(void *user, const char *message);
404
410void fz_default_warning_callback(void *user, const char *message);
411
417typedef void (fz_error_cb)(void *user, const char *message);
418
424typedef void (fz_warning_cb)(void *user, const char *message);
425
433
441
449
457
462
480typedef void (fz_tune_image_decode_fn)(void *arg, int w, int h, int l2factor, fz_irect *subarea);
481
497typedef int (fz_tune_image_scale_fn)(void *arg, int dst_w, int dst_h, int src_w, int src_h);
498
507void fz_tune_image_decode(fz_context *ctx, fz_tune_image_decode_fn *image_decode, void *arg);
508
517void fz_tune_image_scale(fz_context *ctx, fz_tune_image_scale_fn *image_scale, void *arg);
518
522enum {
523 // We may box filter images down by a power of 2, before scaling
524 // accurately to get the final results. Rendering will be stable.
525 // This may be faster and may use less memory than 'QUALITY'
526 // rendering, for a (probably imperceptible) degradation of quality.
528
529 // We will never box filter images, and instead will always scale
530 // accurately. Rendering will be stable. This may be slower and
531 // may use more memory than 'HYBRID' rendering, for a (probably
532 // imperceptible) improvement in quality.
534
535 // We will box filter images down by a power of 2, before scaling
536 // accurately to get the final results. We will accept image
537 // tiles that have previously been box scaled and cached at higher
538 // quality than we need, thus saving us the decode again, at the
539 // cost of "rendering instability". i.e. the exact results of
540 // rendering may differ according to the order of rendering
541 // operations that have happened in the past. The quality
542 // differences here are rarely spotted, and very minor, but
543 // genuinely exist. In an interactive application, these are
544 // well within acceptability, but in an system where results are
545 // being compared pixel-by-pixel, this is probably best avoided.
547};
548void fz_tune_image_rendering(fz_context *ctx, int behavior);
549
555
563void fz_set_aa_level(fz_context *ctx, int bits);
564
570
578void fz_set_text_aa_level(fz_context *ctx, int bits);
579
585
594
602
609void fz_set_graphics_min_line_width(fz_context *ctx, float min_line_width);
610
614const char *fz_user_css(fz_context *ctx);
615
619void fz_set_user_css(fz_context *ctx, const char *text);
620
625void fz_load_user_css(fz_context *ctx, const char *filename);
626
631
636
641
646
664
671#define fz_malloc_struct(CTX, TYPE) \
672 ((TYPE*)Memento_label(fz_calloc(CTX, 1, sizeof(TYPE)), #TYPE))
673
680#define fz_malloc_struct_array(CTX, N, TYPE) \
681 ((TYPE*)Memento_label(fz_calloc(CTX, N, sizeof(TYPE)), #TYPE "[]"))
682
689#define fz_malloc_array(CTX, COUNT, TYPE) \
690 ((TYPE*)Memento_label(fz_malloc_array_imp((CTX), (COUNT), sizeof(TYPE)), #TYPE "[]"))
691#define fz_realloc_array(CTX, OLD, COUNT, TYPE) \
692 ((TYPE*)Memento_label(fz_realloc_array_imp((CTX), (OLD), (COUNT), sizeof(TYPE)), #TYPE "[]"))
693
694void *fz_malloc_array_imp(fz_context *ctx, size_t nmemb, size_t size);
695void *fz_realloc_array_imp(fz_context *ctx, void *p, size_t nmemb, size_t size);
696
705void *fz_malloc(fz_context *ctx, size_t size);
706
713void *fz_calloc(fz_context *ctx, size_t count, size_t size);
714
726void *fz_realloc(fz_context *ctx, void *p, size_t size);
727
735void fz_free(fz_context *ctx, void *p);
736
740#define fz_malloc_flexible(ctx, T, M, count) \
741 ((T*)Memento_label(fz_calloc(ctx, 1, offsetof(T, M) + sizeof(*((T*)0)->M) * (count)), #T))
742#define fz_realloc_flexible(ctx, p, T, M, count) \
743 ((T*)Memento_label(fz_realloc(ctx, p, offsetof(T, M) + sizeof(*((T*)0)->M) * (count)), #T))
744#define fz_pool_alloc_flexible(ctx, pool, T, M, count) \
745 ((T*)fz_pool_alloc(ctx, pool, offsetof(T, M) + sizeof(*((T*)0)->M) * (count)))
746#define fz_sizeof_flexible(T, M, count) \
747 (offsetof(T, M) + sizeof(*((T*)0)->M) * (count))
748
753void *fz_malloc_no_throw(fz_context *ctx, size_t size);
754
759void *fz_calloc_no_throw(fz_context *ctx, size_t count, size_t size);
760
765void *fz_realloc_no_throw(fz_context *ctx, void *p, size_t size);
766
771void *fz_malloc_aligned(fz_context *ctx, size_t size, int align);
772
776void fz_free_aligned(fz_context *ctx, void *p);
777
781char *fz_strdup(fz_context *ctx, const char *s);
782
786void fz_memrnd(fz_context *ctx, uint8_t *block, int len);
787
788/*
789 Reference counted malloced C strings.
790*/
791typedef struct
792{
793 int refs;
795} fz_string;
796
797/*
798 Allocate a new string to hold a copy of str.
799
800 Returns with a refcount of 1.
801*/
802fz_string *fz_new_string(fz_context *ctx, const char *str);
803
804/*
805 Take another reference to a string.
806*/
808
809/*
810 Drop a reference to a string, freeing if the refcount
811 reaches 0.
812*/
814
815#define fz_cstring_from_string(A) ((A) == NULL ? NULL : (A)->str)
816
817/* Implementation details: subject to change. */
818
819/* Implementations exposed for speed, but considered private. */
820
821void fz_var_imp(void *);
826
827#ifndef FZ_JMPBUF_ALIGN
828#define FZ_JMPBUF_ALIGN 32
829#endif
830
831typedef struct
832{
835 char padding[FZ_JMPBUF_ALIGN-sizeof(int)*2];
837
838typedef struct
839{
845 int errnum; /* errno for SYSTEM class errors */
847 void (*print)(void *user, const char *message);
848 char message[256];
850
851typedef struct
852{
854 void (*print)(void *user, const char *message);
855 int count;
856 char message[256];
858
859typedef struct
860{
863 int scale;
864 int bits;
868
874
875typedef void (fz_activity_fn)(fz_context *ctx, void *opaque, fz_activity_reason reason, void *reason_arg);
876
882
884
886{
887 void *user;
888
889 /* If master points to itself, then we are the master context.
890 * If master is NULL, then we are the master context, but we have
891 * been destroyed. We exist just so the count of clones can live
892 * on. Otherwise master points to the master context from which
893 * we were cloned. */
895 /* The number of contexts in this family. 1 for this one, plus
896 * 1 for every context cloned (directly or indirectly) from it. */
898
899 /* Only the master version of this is used! */
901
907
908 /* unshared contexts */
910 uint16_t seed48[7];
911#if FZ_ENABLE_ICC
912 int icc_enabled;
913#endif
914
915 /* TODO: should these be unshared? */
920
921 /* shared contexts */
928};
929
930fz_context *fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, size_t max_store, const char *version);
931
935static inline void
936fz_lock(fz_context *ctx, int lock)
937{
938 fz_lock_debug_lock(ctx, lock);
939 ctx->locks.lock(ctx->locks.user, lock);
940}
941
945static inline void
946fz_unlock(fz_context *ctx, int lock)
947{
948 fz_lock_debug_unlock(ctx, lock);
949 ctx->locks.unlock(ctx->locks.user, lock);
950}
951
952/* Lock-safe reference counting functions */
953
954#define fz_keep_imp(C,P,R) fz_keep_imp_aux((C), (P), (P) ? (R) : NULL)
955#define fz_keep_imp8(C,P,R) fz_keep_imp8_aux((C), (P), (P) ? (R) : NULL)
956#define fz_keep_imp16(C,P,R) fz_keep_imp16_aux((C), (P), (P) ? (R) : NULL)
957
958#define fz_keep_imp_locked(C,P,R) fz_keep_imp_locked_aux((C), (P), (P) ? (R) : NULL)
959#define fz_keep_imp8_locked(C,P,R) fz_keep_imp8_locked_aux((C), (P), (P) ? (R) : NULL)
960
961#define fz_drop_imp(C,P,R) fz_drop_imp_aux((C), (P), (P) ? (R) : NULL)
962#define fz_drop_imp8(C,P,R) fz_drop_imp8_aux((C), (P), (P) ? (R) : NULL)
963#define fz_drop_imp16(C,P,R) fz_drop_imp16_aux((C), (P), (P) ? (R) : NULL)
964
965static inline void *
966fz_keep_imp_aux(fz_context *ctx, void *p, int *refs)
967{
968 if (p)
969 {
971 fz_lock(ctx, FZ_LOCK_ALLOC);
972 if (*refs > 0)
973 {
974 (void)Memento_takeRef(p);
975 ++*refs;
976 }
977 fz_unlock(ctx, FZ_LOCK_ALLOC);
978 }
979 return p;
980}
981
982static inline void *
983fz_keep_imp_locked_aux(fz_context *ctx FZ_UNUSED, void *p, int *refs)
984{
985 if (p)
986 {
988 if (*refs > 0)
989 {
990 (void)Memento_takeRef(p);
991 ++*refs;
992 }
993 }
994 return p;
995}
996
997static inline void *
998fz_keep_imp8_locked_aux(fz_context *ctx FZ_UNUSED, void *p, int8_t *refs)
999{
1000 if (p)
1001 {
1003 if (*refs > 0)
1004 {
1005 (void)Memento_takeRef(p);
1006 ++*refs;
1007 }
1008 }
1009 return p;
1010}
1011
1012static inline void *
1013fz_keep_imp8_aux(fz_context *ctx, void *p, int8_t *refs)
1014{
1015 if (p)
1016 {
1018 fz_lock(ctx, FZ_LOCK_ALLOC);
1019 if (*refs > 0)
1020 {
1021 (void)Memento_takeRef(p);
1022 ++*refs;
1023 }
1024 fz_unlock(ctx, FZ_LOCK_ALLOC);
1025 }
1026 return p;
1027}
1028
1029static inline void *
1030fz_keep_imp16_aux(fz_context *ctx, void *p, int16_t *refs)
1031{
1032 if (p)
1033 {
1035 fz_lock(ctx, FZ_LOCK_ALLOC);
1036 if (*refs > 0)
1037 {
1038 (void)Memento_takeRef(p);
1039 ++*refs;
1040 }
1041 fz_unlock(ctx, FZ_LOCK_ALLOC);
1042 }
1043 return p;
1044}
1045
1046static inline int
1047fz_drop_imp_aux(fz_context *ctx, void *p, int *refs)
1048{
1049 if (p)
1050 {
1051 int drop;
1053 fz_lock(ctx, FZ_LOCK_ALLOC);
1054 if (*refs > 0)
1055 {
1056 (void)Memento_dropIntRef(p);
1057 drop = --*refs == 0;
1058 }
1059 else
1060 drop = 0;
1061 fz_unlock(ctx, FZ_LOCK_ALLOC);
1062 return drop;
1063 }
1064 return 0;
1065}
1066
1067static inline int
1068fz_drop_imp8_aux(fz_context *ctx, void *p, int8_t *refs)
1069{
1070 if (p)
1071 {
1072 int drop;
1074 fz_lock(ctx, FZ_LOCK_ALLOC);
1075 if (*refs > 0)
1076 {
1077 (void)Memento_dropByteRef(p);
1078 drop = --*refs == 0;
1079 }
1080 else
1081 drop = 0;
1082 fz_unlock(ctx, FZ_LOCK_ALLOC);
1083 return drop;
1084 }
1085 return 0;
1086}
1087
1088static inline int
1089fz_drop_imp16_aux(fz_context *ctx, void *p, int16_t *refs)
1090{
1091 if (p)
1092 {
1093 int drop;
1095 fz_lock(ctx, FZ_LOCK_ALLOC);
1096 if (*refs > 0)
1097 {
1098 (void)Memento_dropShortRef(p);
1099 drop = --*refs == 0;
1100 }
1101 else
1102 drop = 0;
1103 fz_unlock(ctx, FZ_LOCK_ALLOC);
1104 return drop;
1105 }
1106 return 0;
1107}
1108
1109#endif
struct fz_glyph_cache fz_glyph_cache
Definition context.h:41
void fz_error_cb(void *user, const char *message)
Definition context.h:417
struct fz_hyph_context fz_hyph_context
Definition context.h:36
void fz_vwarn(fz_context *ctx, const char *fmt, va_list ap)
void fz_rethrow_if(fz_context *ctx, int errcode)
void fz_set_user_context(fz_context *ctx, void *user)
void fz_disable_icc(fz_context *ctx)
void fz_drop_string(fz_context *ctx, fz_string *str)
void fz_flush_warnings(fz_context *ctx)
void fz_tune_image_decode(fz_context *ctx, fz_tune_image_decode_fn *image_decode, void *arg)
void * fz_realloc_no_throw(fz_context *ctx, void *p, size_t size)
FZ_NORETURN void fz_vthrow(fz_context *ctx, int errcode, const char *, va_list ap)
void fz_set_error_callback(fz_context *ctx, fz_error_cb *error_cb, void *user)
void fz_tune_image_decode_fn(void *arg, int w, int h, int l2factor, fz_irect *subarea)
Definition context.h:480
void fz_ignore_error(fz_context *ctx)
void fz_drop_context(fz_context *ctx)
struct fz_font_context fz_font_context
Definition context.h:35
void fz_log_error(fz_context *ctx, const char *str)
fz_string * fz_new_string(fz_context *ctx, const char *str)
struct fz_archive_handler_context fz_archive_handler_context
Definition context.h:43
void fz_load_user_css(fz_context *ctx, const char *filename)
int fz_use_document_css(fz_context *ctx)
void fz_set_warning_callback(fz_context *ctx, fz_warning_cb *warning_cb, void *user)
void fz_set_use_document_css(fz_context *ctx, int use)
int fz_do_always(fz_context *ctx)
#define FZ_JMPBUF_ALIGN
Definition context.h:828
fz_context * fz_clone_context(fz_context *ctx)
void fz_warning_cb(void *user, const char *message)
Definition context.h:424
void fz_lock_debug_unlock(fz_context *ctx, int lock)
const char * fz_user_css(fz_context *ctx)
void fz_activity_fn(fz_context *ctx, void *opaque, fz_activity_reason reason, void *reason_arg)
Definition context.h:875
void fz_enable_icc(fz_context *ctx)
int fz_text_aa_level(fz_context *ctx)
struct fz_tuning_context fz_tuning_context
Definition context.h:39
void * fz_realloc(fz_context *ctx, void *p, size_t size)
void fz_assert_lock_held(fz_context *ctx, int lock)
struct fz_output fz_output
Definition context.h:44
void * fz_realloc_array_imp(fz_context *ctx, void *p, size_t nmemb, size_t size)
int fz_caught(fz_context *ctx)
fz_jmp_buf * fz_push_try(fz_context *ctx)
fz_string * fz_keep_string(fz_context *ctx, fz_string *str)
void fz_set_graphics_min_line_width(fz_context *ctx, float min_line_width)
void fz_log_error_printf(fz_context *ctx, const char *fmt,...) FZ_PRINTFLIKE(2
fz_error_type
Definition context.h:219
@ FZ_ERROR_ARGUMENT
Definition context.h:225
@ FZ_ERROR_FORMAT
Definition context.h:228
@ FZ_ERROR_REPAIRED
Definition context.h:234
@ FZ_ERROR_LIMIT
Definition context.h:226
@ FZ_ERROR_LIBRARY
Definition context.h:224
@ FZ_ERROR_GENERIC
Definition context.h:221
@ FZ_ERROR_ABORT
Definition context.h:233
@ FZ_ERROR_SYNTAX
Definition context.h:229
@ FZ_ERROR_UNSUPPORTED
Definition context.h:227
@ FZ_ERROR_TRYLATER
Definition context.h:232
@ FZ_ERROR_NONE
Definition context.h:220
@ FZ_ERROR_SYSTEM
Definition context.h:223
struct fz_document_handler_context fz_document_handler_context
Definition context.h:42
fz_context * fz_new_context_imp(const fz_alloc_context *alloc, const fz_locks_context *locks, size_t max_store, const char *version)
void fz_rethrow_unless(fz_context *ctx, int errcode)
@ FZ_STORE_UNLIMITED
Definition context.h:313
@ FZ_STORE_DEFAULT
Definition context.h:314
void fz_register_activity_logger(fz_context *ctx, fz_activity_fn *activity, void *opaque)
struct fz_store fz_store
Definition context.h:40
fz_warning_cb * fz_warning_callback(fz_context *ctx, void **user)
void fz_lock_debug_lock(fz_context *ctx, int lock)
FZ_NORETURN void FZ_NORETURN void fz_rethrow(fz_context *ctx)
void fz_report_error(fz_context *ctx)
int fz_tune_image_scale_fn(void *arg, int dst_w, int dst_h, int src_w, int src_h)
Definition context.h:497
const char * fz_convert_error(fz_context *ctx, int *code)
void fz_free(fz_context *ctx, void *p)
int fz_caught_errno(fz_context *ctx)
void * fz_malloc(fz_context *ctx, size_t size)
float fz_graphics_min_line_width(fz_context *ctx)
void const char * fz_caught_message(fz_context *ctx)
void fz_set_user_css(fz_context *ctx, const char *text)
void * fz_malloc_array_imp(fz_context *ctx, size_t nmemb, size_t size)
void * fz_calloc_no_throw(fz_context *ctx, size_t count, size_t size)
struct fz_style_context fz_style_context
Definition context.h:38
fz_error_cb * fz_error_callback(fz_context *ctx, void **user)
void fz_tune_image_rendering(fz_context *ctx, int behavior)
fz_activity_reason
Definition context.h:870
@ FZ_ACTIVITY_NEW_DOC
Definition context.h:871
@ FZ_ACTIVITY_SHUTDOWN
Definition context.h:872
@ FZ_IMAGE_RENDERING_BALANCE
Definition context.h:527
@ FZ_IMAGE_RENDERING_QUALITY
Definition context.h:533
@ FZ_IMAGE_RENDERING_SPEED
Definition context.h:546
void fz_assert_lock_not_held(fz_context *ctx, int lock)
@ FZ_LOCK_GLYPHCACHE
Definition context.h:279
@ FZ_LOCK_FREETYPE
Definition context.h:278
@ FZ_LOCK_MAX
Definition context.h:280
@ FZ_LOCK_ALLOC
Definition context.h:277
void * fz_user_context(fz_context *ctx)
void * fz_malloc_no_throw(fz_context *ctx, size_t size)
int fz_graphics_aa_level(fz_context *ctx)
void fz_tune_image_scale(fz_context *ctx, fz_tune_image_scale_fn *image_scale, void *arg)
struct fz_colorspace_context fz_colorspace_context
Definition context.h:37
void fz_default_error_callback(void *user, const char *message)
void fz_set_aa_level(fz_context *ctx, int bits)
char * fz_strdup(fz_context *ctx, const char *s)
int fz_aa_level(fz_context *ctx)
void * fz_calloc(fz_context *ctx, size_t count, size_t size)
void fz_warn(fz_context *ctx, const char *fmt,...) FZ_PRINTFLIKE(2
FZ_NORETURN void fz_throw(fz_context *ctx, int errcode, const char *,...) FZ_PRINTFLIKE(3
void fz_morph_error(fz_context *ctx, int fromcode, int tocode)
void fz_set_text_aa_level(fz_context *ctx, int bits)
int fz_do_catch(fz_context *ctx)
void fz_set_graphics_aa_level(fz_context *ctx, int bits)
void fz_default_warning_callback(void *user, const char *message)
void void fz_vlog_error_printf(fz_context *ctx, const char *fmt, va_list ap)
void fz_free_aligned(fz_context *ctx, void *p)
int fz_do_try(fz_context *ctx)
void fz_memrnd(fz_context *ctx, uint8_t *block, int len)
void * fz_malloc_aligned(fz_context *ctx, size_t size, int align)
void fz_var_imp(void *)
#define Memento_checkIntPointerOrNull(A)
Definition memento.h:405
#define Memento_dropByteRef(A)
Definition memento.h:393
#define Memento_dropShortRef(A)
Definition memento.h:395
#define Memento_checkShortPointerOrNull(A)
Definition memento.h:404
#define Memento_checkBytePointerOrNull(A)
Definition memento.h:403
#define Memento_dropIntRef(A)
Definition memento.h:397
#define Memento_takeRef(A)
Definition memento.h:398
Definition context.h:860
int text_bits
Definition context.h:865
int vscale
Definition context.h:862
int scale
Definition context.h:863
float min_line_width
Definition context.h:866
int hscale
Definition context.h:861
int bits
Definition context.h:864
Definition context.h:878
fz_activity_fn * activity
Definition context.h:880
void * opaque
Definition context.h:879
Definition context.h:51
void * user
Definition context.h:52
void(* free)(void *, void *)
Definition context.h:55
Definition context.h:886
fz_tuning_context * tuning
Definition context.h:919
fz_colorspace_context * colorspace
Definition context.h:925
fz_activity_context activity
Definition context.h:906
fz_document_handler_context * handler
Definition context.h:916
fz_alloc_context alloc
Definition context.h:902
fz_hyph_context * hyph
Definition context.h:924
fz_glyph_cache * glyph_cache
Definition context.h:927
void * user
Definition context.h:887
fz_error_context error
Definition context.h:904
fz_warn_context warn
Definition context.h:905
fz_archive_handler_context * archive
Definition context.h:917
fz_store * store
Definition context.h:926
uint16_t seed48[7]
Definition context.h:910
fz_output * stddbg
Definition context.h:922
fz_context * master
Definition context.h:894
int context_count
Definition context.h:897
fz_font_context * font
Definition context.h:923
fz_aa_context aa
Definition context.h:909
fz_style_context * style
Definition context.h:918
int next_document_id
Definition context.h:900
fz_locks_context locks
Definition context.h:903
Definition context.h:839
void(* print)(void *user, const char *message)
Definition context.h:847
void * print_user
Definition context.h:846
char message[256]
Definition context.h:848
fz_error_stack_slot * top
Definition context.h:840
int errcode
Definition context.h:844
fz_error_stack_slot * stack_base
Definition context.h:843
fz_error_stack_slot padding
Definition context.h:842
int errnum
Definition context.h:845
fz_error_stack_slot stack[256]
Definition context.h:841
Definition context.h:832
int code
Definition context.h:834
int state
Definition context.h:834
char padding[FZ_JMPBUF_ALIGN-sizeof(int) *2]
Definition context.h:835
fz_jmp_buf buffer
Definition context.h:833
Definition geometry.h:248
Definition context.h:270
void(* unlock)(void *user, int lock)
Definition context.h:273
void * user
Definition context.h:271
void(* lock)(void *user, int lock)
Definition context.h:272
Definition output.h:111
Definition context.h:792
char str[FZ_FLEXIBLE_ARRAY]
Definition context.h:794
int refs
Definition context.h:793
Definition context.h:852
void(* print)(void *user, const char *message)
Definition context.h:854
char message[256]
Definition context.h:856
void * print_user
Definition context.h:853
int count
Definition context.h:855
#define FZ_UNUSED
Definition system.h:278
#define FZ_PRINTFLIKE(F, V)
Definition system.h:288
#define FZ_FLEXIBLE_ARRAY
Definition system.h:46
#define FZ_NORETURN
Definition system.h:269
jmp_buf fz_jmp_buf
Definition system.h:160