summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz
diff options
context:
space:
mode:
Diffstat (limited to 'include/mupdf/fitz')
-rw-r--r--include/mupdf/fitz/annotation.h8
-rw-r--r--include/mupdf/fitz/colorspace.h11
-rw-r--r--include/mupdf/fitz/compressed-buffer.h2
-rw-r--r--include/mupdf/fitz/context.h38
-rw-r--r--include/mupdf/fitz/device.h113
-rw-r--r--include/mupdf/fitz/display-list.h4
-rw-r--r--include/mupdf/fitz/document.h117
-rw-r--r--include/mupdf/fitz/filter.h30
-rw-r--r--include/mupdf/fitz/font.h4
-rw-r--r--include/mupdf/fitz/function.h6
-rw-r--r--include/mupdf/fitz/glyph-cache.h2
-rw-r--r--include/mupdf/fitz/hash.h2
-rw-r--r--include/mupdf/fitz/image.h4
-rw-r--r--include/mupdf/fitz/link.h2
-rw-r--r--include/mupdf/fitz/meta.h2
-rw-r--r--include/mupdf/fitz/outline.h4
-rw-r--r--include/mupdf/fitz/output-pcl.h4
-rw-r--r--include/mupdf/fitz/output-png.h10
-rw-r--r--include/mupdf/fitz/output-pnm.h8
-rw-r--r--include/mupdf/fitz/output-pwg.h8
-rw-r--r--include/mupdf/fitz/output.h47
-rw-r--r--include/mupdf/fitz/path.h10
-rw-r--r--include/mupdf/fitz/pixmap.h17
-rw-r--r--include/mupdf/fitz/shade.h17
-rw-r--r--include/mupdf/fitz/store.h24
-rw-r--r--include/mupdf/fitz/stream.h88
-rw-r--r--include/mupdf/fitz/structured-text.h8
-rw-r--r--include/mupdf/fitz/text.h6
-rw-r--r--include/mupdf/fitz/transition.h2
-rw-r--r--include/mupdf/fitz/tree.h2
-rw-r--r--include/mupdf/fitz/unzip.h4
-rw-r--r--include/mupdf/fitz/write-document.h2
-rw-r--r--include/mupdf/fitz/xml.h4
33 files changed, 310 insertions, 300 deletions
diff --git a/include/mupdf/fitz/annotation.h b/include/mupdf/fitz/annotation.h
index 13f955e4..122777de 100644
--- a/include/mupdf/fitz/annotation.h
+++ b/include/mupdf/fitz/annotation.h
@@ -38,27 +38,27 @@ typedef enum
/*
fz_get_annot_type: return the type of an annotation
*/
-fz_annot_type fz_get_annot_type(fz_annot *annot);
+fz_annot_type fz_get_annot_type(fz_context *ctx, fz_annot *annot);
/*
fz_first_annot: Return a pointer to the first annotation on a page.
Does not throw exceptions.
*/
-fz_annot *fz_first_annot(fz_document *doc, fz_page *page);
+fz_annot *fz_first_annot(fz_context *ctx, fz_page *page);
/*
fz_next_annot: Return a pointer to the next annotation on a page.
Does not throw exceptions.
*/
-fz_annot *fz_next_annot(fz_document *doc, fz_annot *annot);
+fz_annot *fz_next_annot(fz_context *ctx, fz_page *page, fz_annot *annot);
/*
fz_bound_annot: Return the bounding rectangle of the annotation.
Does not throw exceptions.
*/
-fz_rect *fz_bound_annot(fz_document *doc, fz_annot *annot, fz_rect *rect);
+fz_rect *fz_bound_annot(fz_context *ctx, fz_page *page, fz_annot *annot, fz_rect *rect);
#endif
diff --git a/include/mupdf/fitz/colorspace.h b/include/mupdf/fitz/colorspace.h
index 1572211f..b1b82999 100644
--- a/include/mupdf/fitz/colorspace.h
+++ b/include/mupdf/fitz/colorspace.h
@@ -26,7 +26,7 @@ fz_colorspace *fz_lookup_device_colorspace(fz_context *ctx, char *name);
fz_colorspace_is_indexed: Return true, iff a given colorspace is
indexed.
*/
-int fz_colorspace_is_indexed(fz_colorspace *cs);
+int fz_colorspace_is_indexed(fz_context *ctx, fz_colorspace *cs);
/*
fz_device_gray: Get colorspace representing device specific gray.
@@ -84,7 +84,7 @@ fz_colorspace *fz_new_colorspace(fz_context *ctx, char *name, int n);
fz_colorspace *fz_new_indexed_colorspace(fz_context *ctx, fz_colorspace *base, int high, unsigned char *lookup);
fz_colorspace *fz_keep_colorspace(fz_context *ctx, fz_colorspace *colorspace);
void fz_drop_colorspace(fz_context *ctx, fz_colorspace *colorspace);
-void fz_free_colorspace_imp(fz_context *ctx, fz_storable *colorspace);
+void fz_drop_colorspace_imp(fz_context *ctx, fz_storable *colorspace);
void fz_convert_color(fz_context *ctx, fz_colorspace *dsts, float *dstv, fz_colorspace *srcs, const float *srcv);
@@ -100,16 +100,15 @@ typedef struct fz_color_converter_s fz_color_converter;
*/
struct fz_color_converter_s
{
- void (*convert)(fz_color_converter *, float *, const float *);
- fz_context *ctx;
+ void (*convert)(fz_context *, fz_color_converter *, float *, const float *);
fz_colorspace *ds;
fz_colorspace *ss;
void *opaque;
};
-void fz_lookup_color_converter(fz_color_converter *cc, fz_context *ctx, fz_colorspace *ds, fz_colorspace *ss);
+void fz_lookup_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ds, fz_colorspace *ss);
void fz_init_cached_color_converter(fz_context *ctx, fz_color_converter *cc, fz_colorspace *ds, fz_colorspace *ss);
-void fz_fin_cached_color_converter(fz_color_converter *cc);
+void fz_fin_cached_color_converter(fz_context *ctx, fz_color_converter *cc);
#endif
diff --git a/include/mupdf/fitz/compressed-buffer.h b/include/mupdf/fitz/compressed-buffer.h
index 384a7744..5139b90d 100644
--- a/include/mupdf/fitz/compressed-buffer.h
+++ b/include/mupdf/fitz/compressed-buffer.h
@@ -76,6 +76,6 @@ struct fz_compressed_buffer_s
fz_buffer *buffer;
};
-void fz_free_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf);
+void fz_drop_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf);
#endif
diff --git a/include/mupdf/fitz/context.h b/include/mupdf/fitz/context.h
index dc134511..f694bc39 100644
--- a/include/mupdf/fitz/context.h
+++ b/include/mupdf/fitz/context.h
@@ -131,7 +131,7 @@ enum {
The global state contains an exception stack, resource store,
etc. Most functions in MuPDF take a context argument to be
- able to reference the global state. See fz_free_context for
+ able to reference the global state. See fz_drop_context for
freeing an allocated context.
alloc: Supply a custom memory allocator through a set of
@@ -176,7 +176,7 @@ fz_context *fz_new_context_imp(fz_alloc_context *alloc, fz_locks_context *locks,
fz_context *fz_clone_context(fz_context *ctx);
/*
- fz_free_context: Free a context and its global state.
+ fz_drop_context: Free a context and its global state.
The context and all of its global state is freed, and any
buffered warnings are flushed (see fz_flush_warnings). If NULL
@@ -184,7 +184,7 @@ fz_context *fz_clone_context(fz_context *ctx);
Does not throw exceptions.
*/
-void fz_free_context(fz_context *ctx);
+void fz_drop_context(fz_context *ctx);
/*
fz_aa_level: Get the number of bits of antialiasing we are
@@ -410,7 +410,7 @@ struct fz_warn_context_s
fz_context *fz_clone_context_internal(fz_context *ctx);
void fz_new_aa_context(fz_context *ctx);
-void fz_free_aa_context(fz_context *ctx);
+void fz_drop_aa_context(fz_context *ctx);
void fz_copy_aa_context(fz_context *dst, fz_context *src);
void fz_new_document_handler_context(fz_context *ctx);
@@ -457,4 +457,34 @@ fz_unlock(fz_context *ctx, int lock)
ctx->locks->unlock(ctx->locks->user, lock);
}
+static inline void *
+fz_keep_imp(fz_context *ctx, void *p, int *refs)
+{
+ if (p)
+ {
+ fz_lock(ctx, FZ_LOCK_ALLOC);
+ if (*refs > 0)
+ ++*refs;
+ fz_unlock(ctx, FZ_LOCK_ALLOC);
+ }
+ return p;
+}
+
+static inline int
+fz_drop_imp(fz_context *ctx, void *p, int *refs)
+{
+ if (p)
+ {
+ int drop;
+ fz_lock(ctx, FZ_LOCK_ALLOC);
+ if (*refs > 0)
+ drop = --*refs == 0;
+ else
+ drop = 0;
+ fz_unlock(ctx, FZ_LOCK_ALLOC);
+ return drop;
+ }
+ return 0;
+}
+
#endif
diff --git a/include/mupdf/fitz/device.h b/include/mupdf/fitz/device.h
index ef27cd5d..e8098502 100644
--- a/include/mupdf/fitz/device.h
+++ b/include/mupdf/fitz/device.h
@@ -99,40 +99,36 @@ struct fz_device_s
int hints;
int flags;
- void *user;
- void (*free_user)(fz_device *);
- fz_context *ctx;
+ void (*drop_imp)(fz_context *, fz_device *);
- void (*rebind)(fz_device *);
+ void (*begin_page)(fz_context *, fz_device *, const fz_rect *rect, const fz_matrix *ctm);
+ void (*end_page)(fz_context *, fz_device *);
- void (*begin_page)(fz_device *, const fz_rect *rect, const fz_matrix *ctm);
- void (*end_page)(fz_device *);
+ void (*fill_path)(fz_context *, fz_device *, fz_path *, int even_odd, const fz_matrix *, fz_colorspace *, float *color, float alpha);
+ void (*stroke_path)(fz_context *, fz_device *, fz_path *, fz_stroke_state *, const fz_matrix *, fz_colorspace *, float *color, float alpha);
+ void (*clip_path)(fz_context *, fz_device *, fz_path *, const fz_rect *rect, int even_odd, const fz_matrix *);
+ void (*clip_stroke_path)(fz_context *, fz_device *, fz_path *, const fz_rect *rect, fz_stroke_state *, const fz_matrix *);
- void (*fill_path)(fz_device *, fz_path *, int even_odd, const fz_matrix *, fz_colorspace *, float *color, float alpha);
- void (*stroke_path)(fz_device *, fz_path *, fz_stroke_state *, const fz_matrix *, fz_colorspace *, float *color, float alpha);
- void (*clip_path)(fz_device *, fz_path *, const fz_rect *rect, int even_odd, const fz_matrix *);
- void (*clip_stroke_path)(fz_device *, fz_path *, const fz_rect *rect, fz_stroke_state *, const fz_matrix *);
+ void (*fill_text)(fz_context *, fz_device *, fz_text *, const fz_matrix *, fz_colorspace *, float *color, float alpha);
+ void (*stroke_text)(fz_context *, fz_device *, fz_text *, fz_stroke_state *, const fz_matrix *, fz_colorspace *, float *color, float alpha);
+ void (*clip_text)(fz_context *, fz_device *, fz_text *, const fz_matrix *, int accumulate);
+ void (*clip_stroke_text)(fz_context *, fz_device *, fz_text *, fz_stroke_state *, const fz_matrix *);
+ void (*ignore_text)(fz_context *, fz_device *, fz_text *, const fz_matrix *);
- void (*fill_text)(fz_device *, fz_text *, const fz_matrix *, fz_colorspace *, float *color, float alpha);
- void (*stroke_text)(fz_device *, fz_text *, fz_stroke_state *, const fz_matrix *, fz_colorspace *, float *color, float alpha);
- void (*clip_text)(fz_device *, fz_text *, const fz_matrix *, int accumulate);
- void (*clip_stroke_text)(fz_device *, fz_text *, fz_stroke_state *, const fz_matrix *);
- void (*ignore_text)(fz_device *, fz_text *, const fz_matrix *);
+ void (*fill_shade)(fz_context *, fz_device *, fz_shade *shd, const fz_matrix *ctm, float alpha);
+ void (*fill_image)(fz_context *, fz_device *, fz_image *img, const fz_matrix *ctm, float alpha);
+ void (*fill_image_mask)(fz_context *, fz_device *, fz_image *img, const fz_matrix *ctm, fz_colorspace *, float *color, float alpha);
+ void (*clip_image_mask)(fz_context *, fz_device *, fz_image *img, const fz_rect *rect, const fz_matrix *ctm);
- void (*fill_shade)(fz_device *, fz_shade *shd, const fz_matrix *ctm, float alpha);
- void (*fill_image)(fz_device *, fz_image *img, const fz_matrix *ctm, float alpha);
- void (*fill_image_mask)(fz_device *, fz_image *img, const fz_matrix *ctm, fz_colorspace *, float *color, float alpha);
- void (*clip_image_mask)(fz_device *, fz_image *img, const fz_rect *rect, const fz_matrix *ctm);
+ void (*pop_clip)(fz_context *, fz_device *);
- void (*pop_clip)(fz_device *);
+ void (*begin_mask)(fz_context *, fz_device *, const fz_rect *, int luminosity, fz_colorspace *, float *bc);
+ void (*end_mask)(fz_context *, fz_device *);
+ void (*begin_group)(fz_context *, fz_device *, const fz_rect *, int isolated, int knockout, int blendmode, float alpha);
+ void (*end_group)(fz_context *, fz_device *);
- void (*begin_mask)(fz_device *, const fz_rect *, int luminosity, fz_colorspace *, float *bc);
- void (*end_mask)(fz_device *);
- void (*begin_group)(fz_device *, const fz_rect *, int isolated, int knockout, int blendmode, float alpha);
- void (*end_group)(fz_device *);
-
- int (*begin_tile)(fz_device *, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id);
- void (*end_tile)(fz_device *);
+ int (*begin_tile)(fz_context *, fz_device *, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id);
+ void (*end_tile)(fz_context *, fz_device *);
int error_depth;
char errmess[256];
@@ -143,37 +139,36 @@ struct fz_device_s
fz_rect scissor_accumulator;
};
-void fz_rebind_device(fz_device *dev, fz_context *ctx);
-void fz_begin_page(fz_device *dev, const fz_rect *rect, const fz_matrix *ctm);
-void fz_end_page(fz_device *dev);
-void fz_fill_path(fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
-void fz_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
-void fz_clip_path(fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm);
-void fz_clip_stroke_path(fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm);
-void fz_fill_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
-void fz_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
-void fz_clip_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate);
-void fz_clip_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm);
-void fz_ignore_text(fz_device *dev, fz_text *text, const fz_matrix *ctm);
-void fz_pop_clip(fz_device *dev);
-void fz_fill_shade(fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha);
-void fz_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha);
-void fz_fill_image_mask(fz_device *dev, fz_image *image, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
-void fz_clip_image_mask(fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm);
-void fz_begin_mask(fz_device *dev, const fz_rect *area, int luminosity, fz_colorspace *colorspace, float *bc);
-void fz_end_mask(fz_device *dev);
-void fz_begin_group(fz_device *dev, const fz_rect *area, int isolated, int knockout, int blendmode, float alpha);
-void fz_end_group(fz_device *dev);
-void fz_begin_tile(fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm);
-int fz_begin_tile_id(fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id);
-void fz_end_tile(fz_device *dev);
-
-fz_device *fz_new_device(fz_context *ctx, void *user);
+void fz_begin_page(fz_context *ctx, fz_device *dev, const fz_rect *rect, const fz_matrix *ctm);
+void fz_end_page(fz_context *ctx, fz_device *dev);
+void fz_fill_path(fz_context *ctx, fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
+void fz_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
+void fz_clip_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, int even_odd, const fz_matrix *ctm);
+void fz_clip_stroke_path(fz_context *ctx, fz_device *dev, fz_path *path, const fz_rect *rect, fz_stroke_state *stroke, const fz_matrix *ctm);
+void fz_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
+void fz_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
+void fz_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate);
+void fz_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm);
+void fz_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm);
+void fz_pop_clip(fz_context *ctx, fz_device *dev);
+void fz_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha);
+void fz_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha);
+void fz_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha);
+void fz_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_rect *rect, const fz_matrix *ctm);
+void fz_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *area, int luminosity, fz_colorspace *colorspace, float *bc);
+void fz_end_mask(fz_context *ctx, fz_device *dev);
+void fz_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *area, int isolated, int knockout, int blendmode, float alpha);
+void fz_end_group(fz_context *ctx, fz_device *dev);
+void fz_begin_tile(fz_context *ctx, fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm);
+int fz_begin_tile_id(fz_context *ctx, fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id);
+void fz_end_tile(fz_context *ctx, fz_device *dev);
+
+void *fz_new_device(fz_context *ctx, int size);
/*
- fz_free_device: Free a devices of any type and its resources.
+ fz_drop_device: Free a devices of any type and its resources.
*/
-void fz_free_device(fz_device *dev);
+void fz_drop_device(fz_context *ctx, fz_device *dev);
/*
fz_enable_device_hints : Enable hints in a device.
@@ -185,7 +180,7 @@ void fz_free_device(fz_device *dev);
to tell it to ignore shadings. For this you would enable the
FZ_IGNORE_SHADE hint.
*/
-void fz_enable_device_hints(fz_device *dev, int hints);
+void fz_enable_device_hints(fz_context *ctx, fz_device *dev, int hints);
/*
fz_disable_device_hints : Disable hints in a device.
@@ -197,7 +192,7 @@ void fz_enable_device_hints(fz_device *dev, int hints);
enable the capturing of image data too. For this you would disable
the FZ_IGNORE_IMAGE hint.
*/
-void fz_disable_device_hints(fz_device *dev, int hints);
+void fz_disable_device_hints(fz_context *ctx, fz_device *dev, int hints);
enum
{
@@ -304,7 +299,7 @@ fz_device *fz_new_test_device(fz_context *ctx, int *is_color, float threshold);
for how to obtain a pixmap. The pixmap is not cleared by the
draw device, see fz_clear_pixmap* for how to clear it prior to
calling fz_new_draw_device. Free the device by calling
- fz_free_device.
+ fz_drop_device.
*/
fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest);
@@ -315,7 +310,7 @@ fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest);
for how to obtain a pixmap. The pixmap is not cleared by the
draw device, see fz_clear_pixmap* for how to clear it prior to
calling fz_new_draw_device. Free the device by calling
- fz_free_device.
+ fz_drop_device.
clip: Bounding box to restrict any marking operations of the
draw device.
diff --git a/include/mupdf/fitz/display-list.h b/include/mupdf/fitz/display-list.h
index 080ca5b5..85346624 100644
--- a/include/mupdf/fitz/display-list.h
+++ b/include/mupdf/fitz/display-list.h
@@ -40,7 +40,7 @@ fz_display_list *fz_new_display_list(fz_context *ctx);
display list can later be reused to render a page many times
without having to re-interpret the page from the document file
for each rendering. Once the device is no longer needed, free
- it with fz_free_device.
+ it with fz_drop_device.
list: A display list that the list device takes ownership of.
*/
@@ -71,7 +71,7 @@ fz_device *fz_new_list_device(fz_context *ctx, fz_display_list *list);
progress information back to the caller. The fields inside
cookie are continually updated while the page is being run.
*/
-void fz_run_display_list(fz_display_list *list, fz_device *dev, const fz_matrix *ctm, const fz_rect *area, fz_cookie *cookie);
+void fz_run_display_list(fz_context *ctx, fz_display_list *list, fz_device *dev, const fz_matrix *ctm, const fz_rect *area, fz_cookie *cookie);
/*
fz_keep_display_list: Keep a reference to a display list.
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index c6df79bb..d19b3661 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -20,28 +20,44 @@ typedef struct fz_annot_s fz_annot;
// TODO: move out of this interface (it's pdf specific)
typedef struct fz_write_options_s fz_write_options;
-typedef void (fz_document_close_fn)(fz_document *doc);
-typedef int (fz_document_needs_password_fn)(fz_document *doc);
-typedef int (fz_document_authenticate_password_fn)(fz_document *doc, const char *password);
-typedef fz_outline *(fz_document_load_outline_fn)(fz_document *doc);
-typedef void (fz_document_layout_fn)(fz_document *doc, float w, float h, float em);
-typedef int (fz_document_count_pages_fn)(fz_document *doc);
-typedef fz_page *(fz_document_load_page_fn)(fz_document *doc, int number);
-typedef fz_link *(fz_document_load_links_fn)(fz_document *doc, fz_page *page);
-typedef fz_rect *(fz_document_bound_page_fn)(fz_document *doc, fz_page *page, fz_rect *);
-typedef void (fz_document_run_page_contents_fn)(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
-typedef void (fz_document_run_annot_fn)(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
-typedef void (fz_document_free_page_fn)(fz_document *doc, fz_page *page);
-typedef int (fz_document_meta_fn)(fz_document *doc, int key, void *ptr, int size);
-typedef fz_transition *(fz_document_page_presentation_fn)(fz_document *doc, fz_page *page, float *duration);
-typedef fz_annot *(fz_document_first_annot_fn)(fz_document *doc, fz_page *page);
-typedef fz_annot *(fz_document_next_annot_fn)(fz_document *doc, fz_annot *annot);
-typedef fz_rect *(fz_document_bound_annot_fn)(fz_document *doc, fz_annot *annot, fz_rect *rect);
-typedef void (fz_document_write_fn)(fz_document *doc, char *filename, fz_write_options *opts);
-typedef void (fz_document_rebind_fn)(fz_document *doc, fz_context *ctx);
+typedef void (fz_document_close_fn)(fz_context *ctx, fz_document *doc);
+typedef int (fz_document_needs_password_fn)(fz_context *ctx, fz_document *doc);
+typedef int (fz_document_authenticate_password_fn)(fz_context *ctx, fz_document *doc, const char *password);
+typedef fz_outline *(fz_document_load_outline_fn)(fz_context *ctx, fz_document *doc);
+typedef void (fz_document_layout_fn)(fz_context *ctx, fz_document *doc, float w, float h, float em);
+typedef int (fz_document_count_pages_fn)(fz_context *ctx, fz_document *doc);
+typedef fz_page *(fz_document_load_page_fn)(fz_context *ctx, fz_document *doc, int number);
+typedef int (fz_document_meta_fn)(fz_context *ctx, fz_document *doc, int key, void *ptr, int size);
+typedef void (fz_document_write_fn)(fz_context *ctx, fz_document *doc, char *filename, fz_write_options *opts);
+
+typedef fz_link *(fz_page_load_links_fn)(fz_context *ctx, fz_page *page);
+typedef fz_rect *(fz_page_bound_page_fn)(fz_context *ctx, fz_page *page, fz_rect *);
+typedef void (fz_page_run_page_contents_fn)(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+typedef void (fz_page_drop_page_imp_fn)(fz_context *ctx, fz_page *page);
+typedef fz_transition *(fz_page_page_presentation_fn)(fz_context *ctx, fz_page *page, float *duration);
+
+typedef fz_annot *(fz_page_first_annot_fn)(fz_context *ctx, fz_page *page);
+typedef fz_annot *(fz_page_next_annot_fn)(fz_context *ctx, fz_page *page, fz_annot *annot);
+typedef fz_rect *(fz_page_bound_annot_fn)(fz_context *ctx, fz_page *page, fz_annot *annot, fz_rect *rect);
+typedef void (fz_page_run_annot_fn)(fz_context *ctx, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+
+struct fz_page_s
+{
+ int refs;
+ fz_page_drop_page_imp_fn *drop_page_imp;
+ fz_page_bound_page_fn *bound_page;
+ fz_page_run_page_contents_fn *run_page_contents;
+ fz_page_load_links_fn *load_links;
+ fz_page_first_annot_fn *first_annot;
+ fz_page_next_annot_fn *next_annot;
+ fz_page_bound_annot_fn *bound_annot;
+ fz_page_run_annot_fn *run_annot;
+ fz_page_page_presentation_fn *page_presentation;
+};
struct fz_document_s
{
+ int refs;
fz_document_close_fn *close;
fz_document_needs_password_fn *needs_password;
fz_document_authenticate_password_fn *authenticate_password;
@@ -49,18 +65,8 @@ struct fz_document_s
fz_document_layout_fn *layout;
fz_document_count_pages_fn *count_pages;
fz_document_load_page_fn *load_page;
- fz_document_load_links_fn *load_links;
- fz_document_bound_page_fn *bound_page;
- fz_document_run_page_contents_fn *run_page_contents;
- fz_document_run_annot_fn *run_annot;
- fz_document_free_page_fn *free_page;
fz_document_meta_fn *meta;
- fz_document_page_presentation_fn *page_presentation;
- fz_document_first_annot_fn *first_annot;
- fz_document_next_annot_fn *next_annot;
- fz_document_bound_annot_fn *bound_annot;
fz_document_write_fn *write;
- fz_document_rebind_fn *rebind;
};
typedef fz_document *(fz_document_open_fn)(fz_context *ctx, const char *filename);
@@ -115,14 +121,22 @@ fz_document *fz_open_document(fz_context *ctx, const char *filename);
fz_document *fz_open_document_with_stream(fz_context *ctx, const char *magic, fz_stream *stream);
/*
- fz_close_document: Close and free an open document.
+ fz_new_document: Create and initialize a document struct.
+*/
+void *fz_new_document(fz_context *ctx, int size);
+
+/*
+ fz_drop_document: Release an open document.
The resource store in the context associated with fz_document
- is emptied, and any allocations for the document are freed.
+ is emptied, and any allocations for the document are freed when
+ the last reference is dropped.
Does not throw exceptions.
*/
-void fz_close_document(fz_document *doc);
+void fz_drop_document(fz_context *ctx, fz_document *doc);
+
+fz_document *fz_keep_document(fz_context *ctx, fz_document *doc);
/*
fz_needs_password: Check if a document is encrypted with a
@@ -130,7 +144,7 @@ void fz_close_document(fz_document *doc);
Does not throw exceptions.
*/
-int fz_needs_password(fz_document *doc);
+int fz_needs_password(fz_context *ctx, fz_document *doc);
/*
fz_authenticate_password: Test if the given password can
@@ -142,14 +156,14 @@ int fz_needs_password(fz_document *doc);
Does not throw exceptions.
*/
-int fz_authenticate_password(fz_document *doc, const char *password);
+int fz_authenticate_password(fz_context *ctx, fz_document *doc, const char *password);
/*
fz_load_outline: Load the hierarchical document outline.
- Should be freed by fz_free_outline.
+ Should be freed by fz_drop_outline.
*/
-fz_outline *fz_load_outline(fz_document *doc);
+fz_outline *fz_load_outline(fz_context *ctx, fz_document *doc);
/*
fz_layout_document: Layout reflowable document types.
@@ -157,25 +171,25 @@ fz_outline *fz_load_outline(fz_document *doc);
w, h: Page size in points.
em: Default font size in points.
*/
-void fz_layout_document(fz_document *doc, float w, float h, float em);
+void fz_layout_document(fz_context *ctx, fz_document *doc, float w, float h, float em);
/*
fz_count_pages: Return the number of pages in document
May return 0 for documents with no pages.
*/
-int fz_count_pages(fz_document *doc);
+int fz_count_pages(fz_context *ctx, fz_document *doc);
/*
fz_load_page: Load a page.
After fz_load_page is it possible to retrieve the size of the
page using fz_bound_page, or to render the page using
- fz_run_page_*. Free the page by calling fz_free_page.
+ fz_run_page_*. Free the page by calling fz_drop_page.
number: page number, 0 is the first page of the document.
*/
-fz_page *fz_load_page(fz_document *doc, int number);
+fz_page *fz_load_page(fz_context *ctx, fz_document *doc, int number);
/*
fz_load_links: Load the list of links for a page.
@@ -187,14 +201,19 @@ fz_page *fz_load_page(fz_document *doc, int number);
page: Page obtained from fz_load_page.
*/
-fz_link *fz_load_links(fz_document *doc, fz_page *page);
+fz_link *fz_load_links(fz_context *ctx, fz_page *page);
+
+/*
+ fz_new_page: Create and initialize a page struct.
+*/
+void *fz_new_page(fz_context *ctx, int size);
/*
fz_bound_page: Determine the size of a page at 72 dpi.
Does not throw exceptions.
*/
-fz_rect *fz_bound_page(fz_document *doc, fz_page *page, fz_rect *rect);
+fz_rect *fz_bound_page(fz_context *ctx, fz_page *page, fz_rect *rect);
/*
fz_run_page: Run a page through a device.
@@ -215,7 +234,7 @@ fz_rect *fz_bound_page(fz_document *doc, fz_page *page, fz_rect *rect);
fields inside cookie are continually updated while the page is
rendering.
*/
-void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+void fz_run_page(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
/*
fz_run_page_contents: Run a page through a device. Just the main
@@ -237,7 +256,7 @@ void fz_run_page(fz_document *doc, fz_page *page, fz_device *dev, const fz_matri
fields inside cookie are continually updated while the page is
rendering.
*/
-void fz_run_page_contents(fz_document *doc, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+void fz_run_page_contents(fz_context *ctx, fz_page *page, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
/*
fz_run_annot: Run an annotation through a device.
@@ -260,14 +279,14 @@ void fz_run_page_contents(fz_document *doc, fz_page *page, fz_device *dev, const
fields inside cookie are continually updated while the page is
rendering.
*/
-void fz_run_annot(fz_document *doc, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
+void fz_run_annot(fz_context *ctx, fz_page *page, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
/*
- fz_free_page: Free a loaded page.
+ fz_drop_page: Free a loaded page.
Does not throw exceptions.
*/
-void fz_free_page(fz_document *doc, fz_page *page);
+void fz_drop_page(fz_context *ctx, fz_page *page);
/*
fz_page_presentation: Get the presentation details for a given page.
@@ -280,8 +299,6 @@ void fz_free_page(fz_document *doc, fz_page *page);
Does not throw exceptions.
*/
-fz_transition *fz_page_presentation(fz_document *doc, fz_page *page, float *duration);
-
-void fz_rebind_document(fz_document *doc, fz_context *ctx);
+fz_transition *fz_page_presentation(fz_context *ctx, fz_page *page, float *duration);
#endif
diff --git a/include/mupdf/fitz/filter.h b/include/mupdf/fitz/filter.h
index d8a6729f..f200d8c1 100644
--- a/include/mupdf/fitz/filter.h
+++ b/include/mupdf/fitz/filter.h
@@ -9,25 +9,25 @@
typedef struct fz_jbig2_globals_s fz_jbig2_globals;
-fz_stream *fz_open_copy(fz_stream *chain);
-fz_stream *fz_open_null(fz_stream *chain, int len, int offset);
+fz_stream *fz_open_copy(fz_context *ctx, fz_stream *chain);
+fz_stream *fz_open_null(fz_context *ctx, fz_stream *chain, int len, int offset);
fz_stream *fz_open_concat(fz_context *ctx, int max, int pad);
-void fz_concat_push(fz_stream *concat, fz_stream *chain); /* Ownership of chain is passed in */
-fz_stream *fz_open_arc4(fz_stream *chain, unsigned char *key, unsigned keylen);
-fz_stream *fz_open_aesd(fz_stream *chain, unsigned char *key, unsigned keylen);
-fz_stream *fz_open_a85d(fz_stream *chain);
-fz_stream *fz_open_ahxd(fz_stream *chain);
-fz_stream *fz_open_rld(fz_stream *chain);
-fz_stream *fz_open_dctd(fz_stream *chain, int color_transform, int l2factor, fz_stream *jpegtables);
-fz_stream *fz_open_faxd(fz_stream *chain,
+void fz_concat_push(fz_context *ctx, fz_stream *concat, fz_stream *chain); /* Ownership of chain is passed in */
+fz_stream *fz_open_arc4(fz_context *ctx, fz_stream *chain, unsigned char *key, unsigned keylen);
+fz_stream *fz_open_aesd(fz_context *ctx, fz_stream *chain, unsigned char *key, unsigned keylen);
+fz_stream *fz_open_a85d(fz_context *ctx, fz_stream *chain);
+fz_stream *fz_open_ahxd(fz_context *ctx, fz_stream *chain);
+fz_stream *fz_open_rld(fz_context *ctx, fz_stream *chain);
+fz_stream *fz_open_dctd(fz_context *ctx, fz_stream *chain, int color_transform, int l2factor, fz_stream *jpegtables);
+fz_stream *fz_open_faxd(fz_context *ctx, fz_stream *chain,
int k, int end_of_line, int encoded_byte_align,
int columns, int rows, int end_of_block, int black_is_1);
-fz_stream *fz_open_flated(fz_stream *chain, int window_bits);
-fz_stream *fz_open_lzwd(fz_stream *chain, int early_change);
-fz_stream *fz_open_predict(fz_stream *chain, int predictor, int columns, int colors, int bpc);
-fz_stream *fz_open_jbig2d(fz_stream *chain, fz_jbig2_globals *globals);
+fz_stream *fz_open_flated(fz_context *ctx, fz_stream *chain, int window_bits);
+fz_stream *fz_open_lzwd(fz_context *ctx, fz_stream *chain, int early_change);
+fz_stream *fz_open_predict(fz_context *ctx, fz_stream *chain, int predictor, int columns, int colors, int bpc);
+fz_stream *fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals);
fz_jbig2_globals *fz_load_jbig2_globals(fz_context *ctx, unsigned char *data, int size);
-void fz_free_jbig2_globals_imp(fz_context *ctx, fz_storable *globals);
+void fz_drop_jbig2_globals_imp(fz_context *ctx, fz_storable *globals);
#endif
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index a36909d1..6c02bc60 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -46,8 +46,8 @@ struct fz_font_s
float *t3widths; /* has 256 entries if used */
char *t3flags; /* has 256 entries if used */
void *t3doc; /* a pdf_document for the callback */
- void (*t3run)(void *doc, void *resources, fz_buffer *contents, struct fz_device_s *dev, const fz_matrix *ctm, void *gstate, int nestedDepth);
- void (*t3freeres)(void *doc, void *resources);
+ void (*t3run)(fz_context *ctx, void *doc, void *resources, fz_buffer *contents, struct fz_device_s *dev, const fz_matrix *ctm, void *gstate, int nestedDepth);
+ void (*t3freeres)(fz_context *ctx, void *doc, void *resources);
fz_rect bbox; /* font bbox is used only for t3 fonts */
diff --git a/include/mupdf/fitz/function.h b/include/mupdf/fitz/function.h
index b623172c..005cef3f 100644
--- a/include/mupdf/fitz/function.h
+++ b/include/mupdf/fitz/function.h
@@ -15,9 +15,9 @@ typedef struct fz_function_s fz_function;
void fz_eval_function(fz_context *ctx, fz_function *func, const float *in, int inlen, float *out, int outlen);
fz_function *fz_keep_function(fz_context *ctx, fz_function *func);
void fz_drop_function(fz_context *ctx, fz_function *func);
-unsigned int fz_function_size(fz_function *func);
+unsigned int fz_function_size(fz_context *ctx, fz_function *func);
#ifndef NDEBUG
-void pdf_debug_function(fz_function *func);
+void pdf_debug_function(fz_context *ctx, fz_function *func);
#endif
enum
@@ -34,7 +34,7 @@ struct fz_function_s
int n; /* number of output values */
void (*evaluate)(fz_context *ctx, fz_function *func, const float *in, float *out);
#ifndef NDEBUG
- void (*debug)(fz_function *func);
+ void (*debug)(fz_context *ctx, fz_function *func);
#endif
};
diff --git a/include/mupdf/fitz/glyph-cache.h b/include/mupdf/fitz/glyph-cache.h
index 96413702..28fcf416 100644
--- a/include/mupdf/fitz/glyph-cache.h
+++ b/include/mupdf/fitz/glyph-cache.h
@@ -33,6 +33,6 @@ fz_pixmap *fz_render_stroked_glyph_pixmap(fz_context *ctx, fz_font*, int, fz_mat
void fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nestedDepth);
void fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nestedDepth);
void fz_dump_glyph_cache_stats(fz_context *ctx);
-float fz_subpixel_adjust(fz_matrix *ctm, fz_matrix *subpix_ctm, unsigned char *qe, unsigned char *qf);
+float fz_subpixel_adjust(fz_context *ctx, fz_matrix *ctm, fz_matrix *subpix_ctm, unsigned char *qe, unsigned char *qf);
#endif
diff --git a/include/mupdf/fitz/hash.h b/include/mupdf/fitz/hash.h
index f70e9693..c56c9d13 100644
--- a/include/mupdf/fitz/hash.h
+++ b/include/mupdf/fitz/hash.h
@@ -12,7 +12,7 @@ typedef struct fz_hash_table_s fz_hash_table;
fz_hash_table *fz_new_hash_table(fz_context *ctx, int initialsize, int keylen, int lock);
void fz_empty_hash(fz_context *ctx, fz_hash_table *table);
-void fz_free_hash(fz_context *ctx, fz_hash_table *table);
+void fz_drop_hash(fz_context *ctx, fz_hash_table *table);
void *fz_hash_find(fz_context *ctx, fz_hash_table *table, const void *key);
void *fz_hash_insert(fz_context *ctx, fz_hash_table *table, const void *key, void *val);
diff --git a/include/mupdf/fitz/image.h b/include/mupdf/fitz/image.h
index 42b45508..3d40cb1d 100644
--- a/include/mupdf/fitz/image.h
+++ b/include/mupdf/fitz/image.h
@@ -57,7 +57,7 @@ fz_image *fz_new_image_from_pixmap(fz_context *ctx, fz_pixmap *pixmap, fz_image
fz_image *fz_new_image_from_data(fz_context *ctx, unsigned char *data, int len);
fz_image *fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer);
fz_pixmap *fz_image_get_pixmap(fz_context *ctx, fz_image *image, int w, int h);
-void fz_free_image(fz_context *ctx, fz_storable *image);
+void fz_drop_image_imp(fz_context *ctx, fz_storable *image);
fz_pixmap *fz_decomp_image_from_stream(fz_context *ctx, fz_stream *stm, fz_image *image, int indexed, int l2factor, int native_l2factor);
fz_pixmap *fz_expand_indexed_pixmap(fz_context *ctx, fz_pixmap *src);
@@ -93,4 +93,6 @@ void fz_load_jxr_info(fz_context *ctx, unsigned char *data, int size, int *w, in
int fz_load_tiff_subimage_count(fz_context *ctx, unsigned char *buf, int len);
fz_pixmap *fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, int len, int subimage);
+void fz_image_get_sanitised_res(fz_image *image, int *xres, int *yres);
+
#endif
diff --git a/include/mupdf/fitz/link.h b/include/mupdf/fitz/link.h
index 47648a4c..586a5aa2 100644
--- a/include/mupdf/fitz/link.h
+++ b/include/mupdf/fitz/link.h
@@ -173,6 +173,6 @@ fz_link *fz_keep_link(fz_context *ctx, fz_link *link);
*/
void fz_drop_link(fz_context *ctx, fz_link *link);
-void fz_free_link_dest(fz_context *ctx, fz_link_dest *dest);
+void fz_drop_link_dest(fz_context *ctx, fz_link_dest *dest);
#endif
diff --git a/include/mupdf/fitz/meta.h b/include/mupdf/fitz/meta.h
index 456d708d..8075c3c6 100644
--- a/include/mupdf/fitz/meta.h
+++ b/include/mupdf/fitz/meta.h
@@ -30,7 +30,7 @@
always means "unknown operation for this document". In general
FZ_META_OK should be used to indicate successful operation.
*/
-int fz_meta(fz_document *doc, int key, void *ptr, int size);
+int fz_meta(fz_context *ctx, fz_document *doc, int key, void *ptr, int size);
enum
{
diff --git a/include/mupdf/fitz/outline.h b/include/mupdf/fitz/outline.h
index 48718be7..6a3ca81a 100644
--- a/include/mupdf/fitz/outline.h
+++ b/include/mupdf/fitz/outline.h
@@ -55,12 +55,12 @@ void fz_print_outline_xml(fz_context *ctx, fz_output *out, fz_outline *outline);
void fz_print_outline(fz_context *ctx, fz_output *out, fz_outline *outline);
/*
- fz_free_outline: Free hierarchical outline.
+ fz_drop_outline: Free hierarchical outline.
Free an outline obtained from fz_load_outline.
Does not throw exceptions.
*/
-void fz_free_outline(fz_context *ctx, fz_outline *outline);
+void fz_drop_outline(fz_context *ctx, fz_outline *outline);
#endif
diff --git a/include/mupdf/fitz/output-pcl.h b/include/mupdf/fitz/output-pcl.h
index 215c3883..778b31fb 100644
--- a/include/mupdf/fitz/output-pcl.h
+++ b/include/mupdf/fitz/output-pcl.h
@@ -89,9 +89,9 @@ void fz_pcl_preset(fz_context *ctx, fz_pcl_options *opts, const char *preset);
*/
void fz_pcl_option(fz_context *ctx, fz_pcl_options *opts, const char *option, int val);
-void fz_output_pcl(fz_output *out, const fz_pixmap *pixmap, fz_pcl_options *pcl);
+void fz_output_pcl(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, fz_pcl_options *pcl);
-void fz_output_pcl_bitmap(fz_output *out, const fz_bitmap *bitmap, fz_pcl_options *pcl);
+void fz_output_pcl_bitmap(fz_context *ctx, fz_output *out, const fz_bitmap *bitmap, fz_pcl_options *pcl);
void fz_write_pcl(fz_context *ctx, fz_pixmap *pixmap, char *filename, int append, fz_pcl_options *pcl);
diff --git a/include/mupdf/fitz/output-png.h b/include/mupdf/fitz/output-png.h
index 55c9a3fa..63c167e9 100644
--- a/include/mupdf/fitz/output-png.h
+++ b/include/mupdf/fitz/output-png.h
@@ -20,7 +20,7 @@ void fz_write_png(fz_context *ctx, fz_pixmap *pixmap, char *filename, int saveal
/*
Output a pixmap to an output stream as a png.
*/
-void fz_output_png(fz_output *out, const fz_pixmap *pixmap, int savealpha);
+void fz_output_png(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, int savealpha);
/*
Get an image as a png in a buffer.
@@ -31,10 +31,8 @@ fz_buffer *fz_new_png_from_pixmap(fz_context *ctx, fz_pixmap *pixmap);
typedef struct fz_png_output_context_s fz_png_output_context;
-fz_png_output_context *fz_output_png_header(fz_output *out, int w, int h, int n, int savealpha);
-
-void fz_output_png_band(fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *samples, int savealpha, fz_png_output_context *poc);
-
-void fz_output_png_trailer(fz_output *out, fz_png_output_context *poc);
+fz_png_output_context *fz_output_png_header(fz_context *ctx, fz_output *out, int w, int h, int n, int savealpha);
+void fz_output_png_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *samples, int savealpha, fz_png_output_context *poc);
+void fz_output_png_trailer(fz_context *ctx, fz_output *out, fz_png_output_context *poc);
#endif
diff --git a/include/mupdf/fitz/output-pnm.h b/include/mupdf/fitz/output-pnm.h
index 0c949a68..54e8355c 100644
--- a/include/mupdf/fitz/output-pnm.h
+++ b/include/mupdf/fitz/output-pnm.h
@@ -14,8 +14,8 @@
*/
void fz_write_pnm(fz_context *ctx, fz_pixmap *pixmap, char *filename);
-void fz_output_pnm_header(fz_output *out, int w, int h, int n);
-void fz_output_pnm_band(fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *p);
+void fz_output_pnm_header(fz_context *ctx, fz_output *out, int w, int h, int n);
+void fz_output_pnm_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *p);
/*
fz_write_pam: Save a pixmap as a pam
@@ -24,8 +24,8 @@ void fz_output_pnm_band(fz_output *out, int w, int h, int n, int band, int bandh
*/
void fz_write_pam(fz_context *ctx, fz_pixmap *pixmap, char *filename, int savealpha);
-void fz_output_pam_header(fz_output *out, int w, int h, int n, int savealpha);
-void fz_output_pam_band(fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *sp, int savealpha);
+void fz_output_pam_header(fz_context *ctx, fz_output *out, int w, int h, int n, int savealpha);
+void fz_output_pam_band(fz_context *ctx, fz_output *out, int w, int h, int n, int band, int bandheight, unsigned char *sp, int savealpha);
/*
fz_write_pbm: Save a bitmap as a pbm
diff --git a/include/mupdf/fitz/output-pwg.h b/include/mupdf/fitz/output-pwg.h
index 6d5758e4..d2bb4a1f 100644
--- a/include/mupdf/fitz/output-pwg.h
+++ b/include/mupdf/fitz/output-pwg.h
@@ -78,21 +78,21 @@ void fz_write_pwg_bitmap(fz_context *ctx, fz_bitmap *bitmap, char *filename, int
/*
Output a pixmap to an output stream as a pwg raster.
*/
-void fz_output_pwg(fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg);
+void fz_output_pwg(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg);
/*
Output the file header to a pwg stream, ready for pages to follow it.
*/
-void fz_output_pwg_file_header(fz_output *out);
+void fz_output_pwg_file_header(fz_context *ctx, fz_output *out);
/*
Output a page to a pwg stream to follow a header, or other pages.
*/
-void fz_output_pwg_page(fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg);
+void fz_output_pwg_page(fz_context *ctx, fz_output *out, const fz_pixmap *pixmap, const fz_pwg_options *pwg);
/*
Output a bitmap page to a pwg stream to follow a header, or other pages.
*/
-void fz_output_pwg_bitmap_page(fz_output *out, const fz_bitmap *bitmap, const fz_pwg_options *pwg);
+void fz_output_pwg_bitmap_page(fz_context *ctx, fz_output *out, const fz_bitmap *bitmap, const fz_pwg_options *pwg);
#endif
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h
index 5bbf3d92..ea87a2ff 100644
--- a/include/mupdf/fitz/output.h
+++ b/include/mupdf/fitz/output.h
@@ -11,21 +11,12 @@
*/
typedef struct fz_output_s fz_output;
-struct fz_output_s
-{
- fz_context *ctx;
- void *opaque;
- int (*printf)(fz_output *, const char *, va_list ap);
- int (*write)(fz_output *, const void *, int n);
- void (*close)(fz_output *);
-};
-
/*
fz_new_output_with_file: Open an output stream onto a FILE *.
The stream does NOT take ownership of the FILE *.
*/
-fz_output *fz_new_output_with_file(fz_context *, FILE *);
+fz_output *fz_new_output_with_file(fz_context *, FILE *, int close);
/*
fz_new_output_to_filename: Open an output stream to a filename.
@@ -42,35 +33,33 @@ fz_output *fz_new_output_with_buffer(fz_context *, fz_buffer *);
/*
fz_printf: fprintf equivalent for output streams.
*/
-int fz_printf(fz_output *, const char *, ...);
+int fz_printf(fz_context *, fz_output *, const char *, ...);
/*
fz_puts: fputs equivalent for output streams.
*/
-int fz_puts(fz_output *, const char *);
+int fz_puts(fz_context *, fz_output *, const char *);
/*
fz_write: fwrite equivalent for output streams.
*/
-int fz_write(fz_output *out, const void *data, int len);
+int fz_write(fz_context *, fz_output *out, const void *data, int len);
/*
fz_putc: putc equivalent for output streams.
*/
-void fz_putc(fz_output *out, char c);
+void fz_putc(fz_context *, fz_output *out, char c);
/*
- fz_close_output: Close a previously opened fz_output stream.
+ fz_drop_output: Close a previously opened fz_output stream.
Note: whether or not this closes the underlying output method is
method dependent. FILE * streams created by fz_new_output_with_file
are NOT closed.
*/
-void fz_close_output(fz_output *);
-
-void fz_rebind_output(fz_output *, fz_context *ctx);
+void fz_drop_output(fz_context *, fz_output *);
-static inline int fz_write_int32be(fz_output *out, int x)
+static inline int fz_write_int32be(fz_context *ctx, fz_output *out, int x)
{
char data[4];
@@ -79,18 +68,24 @@ static inline int fz_write_int32be(fz_output *out, int x)
data[2] = x>>8;
data[3] = x;
- return fz_write(out, data, 4);
+ return fz_write(ctx, out, data, 4);
}
static inline void
-fz_write_byte(fz_output *out, int x)
+fz_write_byte(fz_context *ctx, fz_output *out, int x)
{
char data = x;
- fz_write(out, &data, 1);
+ fz_write(ctx, out, &data, 1);
}
/*
+ fz_vfprintf: Our customised vfprintf routine. Same supported
+ format specifiers as for fz_vsnprintf.
+*/
+int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap);
+
+/*
fz_vsnprintf: Our customised vsnprintf routine. Takes %c, %d, %o, %s, %x, as usual.
Modifiers are not supported except for zero-padding ints (e.g. %02d, %03o, %04x, etc).
%f and %g both output in "as short as possible hopefully lossless non-exponent" form,
@@ -100,14 +95,6 @@ fz_write_byte(fz_output *out, int x)
%q and %( output escaped strings in C/PDF syntax.
*/
int fz_vsnprintf(char *buffer, int space, const char *fmt, va_list args);
-
-/*
- fz_vfprintf: Our customised vfprintf routine. Same supported
- format specifiers as for fz_vsnprintf.
-*/
-int fz_vfprintf(fz_context *ctx, FILE *file, const char *fmt, va_list ap);
-
-
int fz_snprintf(char *buffer, int space, const char *fmt, ...);
#endif
diff --git a/include/mupdf/fitz/path.h b/include/mupdf/fitz/path.h
index 9b32b8d3..23dc0838 100644
--- a/include/mupdf/fitz/path.h
+++ b/include/mupdf/fitz/path.h
@@ -43,6 +43,7 @@ typedef enum fz_linejoin_e
struct fz_path_s
{
+ int refs;
int cmd_len, cmd_cap;
unsigned char *cmds;
int coord_len, coord_cap;
@@ -65,6 +66,10 @@ struct fz_stroke_state_s
};
fz_path *fz_new_path(fz_context *ctx);
+fz_path *fz_keep_path(fz_context *ctx, fz_path *path);
+void fz_drop_path(fz_context *ctx, fz_path *path);
+void fz_trim_path(fz_context *ctx, fz_path *path);
+
fz_point fz_currentpoint(fz_context *ctx, fz_path *path);
void fz_moveto(fz_context*, fz_path*, float x, float y);
void fz_lineto(fz_context*, fz_path*, float x, float y);
@@ -72,14 +77,11 @@ void fz_curveto(fz_context*,fz_path*, float, float, float, float, float, float);
void fz_curvetov(fz_context*,fz_path*, float, float, float, float);
void fz_curvetoy(fz_context*,fz_path*, float, float, float, float);
void fz_closepath(fz_context*,fz_path*);
-void fz_free_path(fz_context *ctx, fz_path *path);
void fz_transform_path(fz_context *ctx, fz_path *path, const fz_matrix *transform);
-fz_path *fz_clone_path(fz_context *ctx, fz_path *old);
-
fz_rect *fz_bound_path(fz_context *ctx, fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r);
-fz_rect *fz_adjust_rect_for_stroke(fz_rect *r, const fz_stroke_state *stroke, const fz_matrix *ctm);
+fz_rect *fz_adjust_rect_for_stroke(fz_context *ctx, fz_rect *r, const fz_stroke_state *stroke, const fz_matrix *ctm);
extern const fz_stroke_state fz_default_stroke_state;
diff --git a/include/mupdf/fitz/pixmap.h b/include/mupdf/fitz/pixmap.h
index 800effd0..d169ea8e 100644
--- a/include/mupdf/fitz/pixmap.h
+++ b/include/mupdf/fitz/pixmap.h
@@ -207,7 +207,7 @@ void fz_tint_pixmap(fz_context *ctx, fz_pixmap *pix, int r, int g, int b);
Does not throw exceptions.
*/
-void fz_invert_pixmap_rect(fz_pixmap *image, const fz_irect *rect);
+void fz_invert_pixmap_rect(fz_context *ctx, fz_pixmap *image, const fz_irect *rect);
/*
fz_gamma_pixmap: Apply gamma correction to a pixmap. All components
@@ -267,8 +267,7 @@ void fz_convert_pixmap(fz_context *ctx, fz_pixmap *dst, fz_pixmap *src);
free_samples: Is zero when an application has provided its own
buffer for pixel data through fz_new_pixmap_with_bbox_and_data.
- If not zero the buffer will be freed when fz_drop_pixmap is
- called for the pixmap.
+ If non-zero the buffer will be freed along with the the pixmap.
*/
struct fz_pixmap_s
{
@@ -281,7 +280,7 @@ struct fz_pixmap_s
int free_samples;
};
-void fz_free_pixmap_imp(fz_context *ctx, fz_storable *pix);
+void fz_drop_pixmap_imp(fz_context *ctx, fz_storable *pix);
void fz_copy_pixmap_rect(fz_context *ctx, fz_pixmap *dest, fz_pixmap *src, const fz_irect *r);
void fz_premultiply_pixmap(fz_context *ctx, fz_pixmap *pix);
@@ -293,21 +292,21 @@ fz_pixmap *fz_scale_pixmap(fz_context *ctx, fz_pixmap *src, float x, float y, fl
typedef struct fz_scale_cache_s fz_scale_cache;
fz_scale_cache *fz_new_scale_cache(fz_context *ctx);
-void fz_free_scale_cache(fz_context *ctx, fz_scale_cache *cache);
+void fz_drop_scale_cache(fz_context *ctx, fz_scale_cache *cache);
fz_pixmap *fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float w, float h, const fz_irect *clip, fz_scale_cache *cache_x, fz_scale_cache *cache_y);
void fz_subsample_pixmap(fz_context *ctx, fz_pixmap *tile, int factor);
fz_irect *fz_pixmap_bbox_no_ctx(fz_pixmap *src, fz_irect *bbox);
-void fz_decode_tile(fz_pixmap *pix, float *decode);
-void fz_decode_indexed_tile(fz_pixmap *pix, float *decode, int maxval);
-void fz_unpack_tile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale);
+void fz_decode_tile(fz_context *ctx, fz_pixmap *pix, float *decode);
+void fz_decode_indexed_tile(fz_context *ctx, fz_pixmap *pix, float *decode, int maxval);
+void fz_unpack_tile(fz_context *ctx, fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale);
/*
fz_md5_pixmap: Return the md5 digest for a pixmap
*/
-void fz_md5_pixmap(fz_pixmap *pixmap, unsigned char digest[16]);
+void fz_md5_pixmap(fz_context *ctx, fz_pixmap *pixmap, unsigned char digest[16]);
fz_pixmap *fz_new_pixmap_from_8bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
fz_pixmap *fz_new_pixmap_from_1bpp_data(fz_context *ctx, int x, int y, int w, int h, unsigned char *sp, int span);
diff --git a/include/mupdf/fitz/shade.h b/include/mupdf/fitz/shade.h
index 3cd43bd7..55e8767b 100644
--- a/include/mupdf/fitz/shade.h
+++ b/include/mupdf/fitz/shade.h
@@ -74,7 +74,7 @@ struct fz_shade_s
fz_shade *fz_keep_shade(fz_context *ctx, fz_shade *shade);
void fz_drop_shade(fz_context *ctx, fz_shade *shade);
-void fz_free_shade_imp(fz_context *ctx, fz_storable *shade);
+void fz_drop_shade_imp(fz_context *ctx, fz_storable *shade);
fz_rect *fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_rect *r);
void fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap *dest, const fz_irect *bbox);
@@ -90,19 +90,8 @@ struct fz_vertex_s
float c[FZ_MAX_COLORS];
};
-typedef struct fz_mesh_processor_s fz_mesh_processor;
-
-typedef void (fz_mesh_prepare_fn)(void *arg, fz_vertex *v, const float *c);
-typedef void (fz_mesh_process_fn)(void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv);
-
-struct fz_mesh_processor_s {
- fz_context *ctx;
- fz_shade *shade;
- fz_mesh_prepare_fn *prepare;
- fz_mesh_process_fn *process;
- void *process_arg;
- int ncomp;
-};
+typedef void (fz_mesh_prepare_fn)(fz_context *ctx, void *arg, fz_vertex *v, const float *c);
+typedef void (fz_mesh_process_fn)(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex *cv);
void fz_process_mesh(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
fz_mesh_prepare_fn *prepare, fz_mesh_process_fn *process, void *process_arg);
diff --git a/include/mupdf/fitz/store.h b/include/mupdf/fitz/store.h
index f954e3b8..49e3cc17 100644
--- a/include/mupdf/fitz/store.h
+++ b/include/mupdf/fitz/store.h
@@ -27,16 +27,16 @@
typedef struct fz_storable_s fz_storable;
-typedef void (fz_store_free_fn)(fz_context *, fz_storable *);
+typedef void (fz_store_drop_fn)(fz_context *, fz_storable *);
struct fz_storable_s {
int refs;
- fz_store_free_fn *free;
+ fz_store_drop_fn *drop;
};
-#define FZ_INIT_STORABLE(S_,RC,FREE) \
+#define FZ_INIT_STORABLE(S_,RC,DROP) \
do { fz_storable *S = &(S_)->storable; S->refs = (RC); \
- S->free = (FREE); \
+ S->drop = (DROP); \
} while (0)
void *fz_keep_storable(fz_context *, fz_storable *);
@@ -62,7 +62,7 @@ typedef struct fz_store_hash_s fz_store_hash;
struct fz_store_hash_s
{
- fz_store_free_fn *free;
+ fz_store_drop_fn *drop;
union
{
struct
@@ -88,12 +88,12 @@ typedef struct fz_store_type_s fz_store_type;
struct fz_store_type_s
{
- int (*make_hash_key)(fz_store_hash *, void *);
+ int (*make_hash_key)(fz_context *ctx, fz_store_hash *, void *);
void *(*keep_key)(fz_context *,void *);
void (*drop_key)(fz_context *,void *);
- int (*cmp_key)(void *, void *);
+ int (*cmp_key)(fz_context *ctx, void *, void *);
#ifndef NDEBUG
- void (*debug)(FILE *, void *);
+ void (*debug)(fz_context *ctx, FILE *, void *);
#endif
};
@@ -138,7 +138,7 @@ void *fz_store_item(fz_context *ctx, void *key, void *val, unsigned int itemsize
/*
fz_find_item: Find an item within the store.
- free: The function used to free the value (to ensure we get a value
+ drop: The function used to free the value (to ensure we get a value
of the correct type).
key: The key to use to index the item.
@@ -148,21 +148,21 @@ void *fz_store_item(fz_context *ctx, void *key, void *val, unsigned int itemsize
Returns NULL for not found, otherwise returns a pointer to the value
indexed by key to which a reference has been taken.
*/
-void *fz_find_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type *type);
+void *fz_find_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type);
/*
fz_remove_item: Remove an item from the store.
If an item indexed by the given key exists in the store, remove it.
- free: The function used to free the value (to ensure we get a value
+ drop: The function used to free the value (to ensure we get a value
of the correct type).
key: The key to use to find the item to remove.
type: Functions used to manipulate the key.
*/
-void fz_remove_item(fz_context *ctx, fz_store_free_fn *free, void *key, fz_store_type *type);
+void fz_remove_item(fz_context *ctx, fz_store_drop_fn *drop, void *key, fz_store_type *type);
/*
fz_empty_store: Evict everything from the store.
diff --git a/include/mupdf/fitz/stream.h b/include/mupdf/fitz/stream.h
index fb3ef932..610192c6 100644
--- a/include/mupdf/fitz/stream.h
+++ b/include/mupdf/fitz/stream.h
@@ -10,7 +10,7 @@
directions.
Streams are reference counted, so references must be dropped
- by a call to fz_close.
+ by a call to fz_drop_stream.
Only the data between rp and wp is valid.
*/
@@ -88,10 +88,10 @@ fz_stream *fz_open_buffer(fz_context *ctx, fz_buffer *buf);
Returns pointer to newly created stream. May throw exceptions on
failure to allocate.
*/
-fz_stream *fz_open_leecher(fz_stream *chain, fz_buffer *buf);
+fz_stream *fz_open_leecher(fz_context *ctx, fz_stream *chain, fz_buffer *buf);
/*
- fz_close: Close an open stream.
+ fz_drop_stream: Close an open stream.
Drops a reference for the stream. Once no references remain
the stream will be closed, as will any file descriptor the
@@ -99,12 +99,12 @@ fz_stream *fz_open_leecher(fz_stream *chain, fz_buffer *buf);
Does not throw exceptions.
*/
-void fz_close(fz_stream *stm);
+void fz_drop_stream(fz_context *ctx, fz_stream *stm);
/*
fz_tell: return the current reading position within a stream
*/
-int fz_tell(fz_stream *stm);
+int fz_tell(fz_context *ctx, fz_stream *stm);
/*
fz_seek: Seek within a stream.
@@ -115,7 +115,7 @@ int fz_tell(fz_stream *stm);
whence: From where the offset is measured (see fseek).
*/
-void fz_seek(fz_stream *stm, int offset, int whence);
+void fz_seek(fz_context *ctx, fz_stream *stm, int offset, int whence);
/*
fz_read: Read from a stream into a given data block.
@@ -128,7 +128,7 @@ void fz_seek(fz_stream *stm, int offset, int whence);
Returns the number of bytes read. May throw exceptions.
*/
-int fz_read(fz_stream *stm, unsigned char *data, int len);
+int fz_read(fz_context *ctx, fz_stream *stm, unsigned char *data, int len);
/*
fz_read_all: Read all of a stream into a buffer.
@@ -140,7 +140,7 @@ int fz_read(fz_stream *stm, unsigned char *data, int len);
Returns a buffer created from reading from the stream. May throw
exceptions on failure to allocate.
*/
-fz_buffer *fz_read_all(fz_stream *stm, int initial);
+fz_buffer *fz_read_all(fz_context *ctx, fz_stream *stm, int initial);
/*
fz_read_file: Read all the contents of a file into a buffer.
@@ -153,19 +153,15 @@ enum
FZ_STREAM_META_LENGTH = 2
};
-int fz_stream_meta(fz_stream *stm, int key, int size, void *ptr);
+int fz_stream_meta(fz_context *ctx, fz_stream *stm, int key, int size, void *ptr);
-void fz_rebind_stream(fz_stream *stm, fz_context *ctx);
-
-typedef int (fz_stream_next_fn)(fz_stream *stm, int max);
+typedef int (fz_stream_next_fn)(fz_context *ctx, fz_stream *stm, int max);
typedef void (fz_stream_close_fn)(fz_context *ctx, void *state);
-typedef void (fz_stream_seek_fn)(fz_stream *stm, int offset, int whence);
-typedef int (fz_stream_meta_fn)(fz_stream *stm, int key, int size, void *ptr);
-typedef fz_stream *(fz_stream_rebind_fn)(fz_stream *stm);
+typedef void (fz_stream_seek_fn)(fz_context *ctx, fz_stream *stm, int offset, int whence);
+typedef int (fz_stream_meta_fn)(fz_context *ctx, fz_stream *stm, int key, int size, void *ptr);
struct fz_stream_s
{
- fz_context *ctx;
int refs;
int error;
int eof;
@@ -178,15 +174,11 @@ struct fz_stream_s
fz_stream_close_fn *close;
fz_stream_seek_fn *seek;
fz_stream_meta_fn *meta;
- fz_stream_rebind_fn *rebind;
};
-fz_stream *fz_new_stream(fz_context *ctx,
- void *state,
- fz_stream_next_fn *next,
- fz_stream_close_fn *close,
- fz_stream_rebind_fn *rebind);
-fz_stream *fz_keep_stream(fz_stream *stm);
+fz_stream *fz_new_stream(fz_context *ctx, void *state, fz_stream_next_fn *next, fz_stream_close_fn *close);
+
+fz_stream *fz_keep_stream(fz_context *ctx, fz_stream *stm);
/*
fz_read_best: Attempt to read a stream into a buffer. If truncated
@@ -201,9 +193,9 @@ fz_stream *fz_keep_stream(fz_stream *stm);
Returns a buffer created from reading from the stream.
*/
-fz_buffer *fz_read_best(fz_stream *stm, int initial, int *truncated);
+fz_buffer *fz_read_best(fz_context *ctx, fz_stream *stm, int initial, int *truncated);
-void fz_read_line(fz_stream *stm, char *buf, int max);
+void fz_read_line(fz_context *ctx, fz_stream *stm, char *buf, int max);
/*
fz_available: Ask how many bytes are available immediately from
@@ -220,21 +212,21 @@ void fz_read_line(fz_stream *stm, char *buf, int max);
if we have hit EOF. The number of bytes returned here need have
no relation to max (could be larger, could be smaller).
*/
-static inline int fz_available(fz_stream *stm, int max)
+static inline int fz_available(fz_context *ctx, fz_stream *stm, int max)
{
int len = stm->wp - stm->rp;
int c = EOF;
if (len)
return len;
- fz_try(stm->ctx)
+ fz_try(ctx)
{
- c = stm->next(stm, max);
+ c = stm->next(ctx, stm, max);
}
- fz_catch(stm->ctx)
+ fz_catch(ctx)
{
- fz_rethrow_if(stm->ctx, FZ_ERROR_TRYLATER);
- fz_warn(stm->ctx, "read error; treating as end of file");
+ fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
+ fz_warn(ctx, "read error; treating as end of file");
stm->error = 1;
c = EOF;
}
@@ -247,20 +239,20 @@ static inline int fz_available(fz_stream *stm, int max)
return stm->wp - stm->rp;
}
-static inline int fz_read_byte(fz_stream *stm)
+static inline int fz_read_byte(fz_context *ctx, fz_stream *stm)
{
int c = EOF;
if (stm->rp != stm->wp)
return *stm->rp++;
- fz_try(stm->ctx)
+ fz_try(ctx)
{
- c = stm->next(stm, 1);
+ c = stm->next(ctx, stm, 1);
}
- fz_catch(stm->ctx)
+ fz_catch(ctx)
{
- fz_rethrow_if(stm->ctx, FZ_ERROR_TRYLATER);
- fz_warn(stm->ctx, "read error; treating as end of file");
+ fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
+ fz_warn(ctx, "read error; treating as end of file");
stm->error = 1;
c = EOF;
}
@@ -269,36 +261,36 @@ static inline int fz_read_byte(fz_stream *stm)
return c;
}
-static inline int fz_peek_byte(fz_stream *stm)
+static inline int fz_peek_byte(fz_context *ctx, fz_stream *stm)
{
int c;
if (stm->rp != stm->wp)
return *stm->rp;
- c = stm->next(stm, 1);
+ c = stm->next(ctx, stm, 1);
if (c != EOF)
stm->rp--;
return c;
}
-static inline void fz_unread_byte(fz_stream *stm)
+static inline void fz_unread_byte(fz_context *ctx, fz_stream *stm)
{
stm->rp--;
}
-static inline int fz_is_eof(fz_stream *stm)
+static inline int fz_is_eof(fz_context *ctx, fz_stream *stm)
{
if (stm->rp == stm->wp)
{
if (stm->eof)
return 1;
- return fz_peek_byte(stm) == EOF;
+ return fz_peek_byte(ctx, stm) == EOF;
}
return 0;
}
-static inline unsigned int fz_read_bits(fz_stream *stm, int n)
+static inline unsigned int fz_read_bits(fz_context *ctx, fz_stream *stm, int n)
{
unsigned int x;
@@ -315,13 +307,13 @@ static inline unsigned int fz_read_bits(fz_stream *stm, int n)
while (n > 8)
{
- x = (x << 8) | fz_read_byte(stm);
+ x = (x << 8) | fz_read_byte(ctx, stm);
n -= 8;
}
if (n > 0)
{
- stm->bits = fz_read_byte(stm);
+ stm->bits = fz_read_byte(ctx, stm);
stm->avail = 8 - n;
x = (x << n) | (stm->bits >> stm->avail);
}
@@ -330,14 +322,14 @@ static inline unsigned int fz_read_bits(fz_stream *stm, int n)
return x;
}
-static inline void fz_sync_bits(fz_stream *stm)
+static inline void fz_sync_bits(fz_context *ctx, fz_stream *stm)
{
stm->avail = 0;
}
-static inline int fz_is_eof_bits(fz_stream *stm)
+static inline int fz_is_eof_bits(fz_context *ctx, fz_stream *stm)
{
- return fz_is_eof(stm) && (stm->avail == 0 || stm->bits == EOF);
+ return fz_is_eof(ctx, stm) && (stm->avail == 0 || stm->bits == EOF);
}
#endif
diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h
index f325bf21..df34a678 100644
--- a/include/mupdf/fitz/structured-text.h
+++ b/include/mupdf/fitz/structured-text.h
@@ -176,7 +176,7 @@ struct fz_char_and_box_s
fz_rect bbox;
};
-fz_char_and_box *fz_text_char_at(fz_char_and_box *cab, fz_text_page *page, int idx);
+fz_char_and_box *fz_text_char_at(fz_context *ctx, fz_char_and_box *cab, fz_text_page *page, int idx);
/*
fz_text_char_bbox: Return the bbox of a text char. Calculated from
@@ -192,7 +192,7 @@ fz_char_and_box *fz_text_char_at(fz_char_and_box *cab, fz_text_page *page, int i
Does not throw exceptions
*/
-fz_rect *fz_text_char_bbox(fz_rect *bbox, fz_text_span *span, int idx);
+fz_rect *fz_text_char_bbox(fz_context *ctx, fz_rect *bbox, fz_text_span *span, int idx);
/*
fz_new_text_sheet: Create an empty style sheet.
@@ -202,7 +202,7 @@ fz_rect *fz_text_char_bbox(fz_rect *bbox, fz_text_span *span, int idx);
is used.
*/
fz_text_sheet *fz_new_text_sheet(fz_context *ctx);
-void fz_free_text_sheet(fz_context *ctx, fz_text_sheet *sheet);
+void fz_drop_text_sheet(fz_context *ctx, fz_text_sheet *sheet);
/*
fz_new_text_page: Create an empty text page.
@@ -211,7 +211,7 @@ void fz_free_text_sheet(fz_context *ctx, fz_text_sheet *sheet);
lines and spans of text on the page.
*/
fz_text_page *fz_new_text_page(fz_context *ctx);
-void fz_free_text_page(fz_context *ctx, fz_text_page *page);
+void fz_drop_text_page(fz_context *ctx, fz_text_page *page);
void fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page);
diff --git a/include/mupdf/fitz/text.h b/include/mupdf/fitz/text.h
index 13cc02ab..eb2ad12e 100644
--- a/include/mupdf/fitz/text.h
+++ b/include/mupdf/fitz/text.h
@@ -30,6 +30,7 @@ struct fz_text_item_s
struct fz_text_s
{
+ int refs;
fz_font *font;
fz_matrix trm;
int wmode;
@@ -38,10 +39,11 @@ struct fz_text_s
};
fz_text *fz_new_text(fz_context *ctx, fz_font *face, const fz_matrix *trm, int wmode);
+fz_text *fz_keep_text(fz_context *ctx, fz_text *text);
+void fz_drop_text(fz_context *ctx, fz_text *text);
+
void fz_add_text(fz_context *ctx, fz_text *text, int gid, int ucs, float x, float y);
-void fz_free_text(fz_context *ctx, fz_text *text);
fz_rect *fz_bound_text(fz_context *ctx, fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r);
-fz_text *fz_clone_text(fz_context *ctx, fz_text *old);
void fz_print_text(fz_context *ctx, FILE *out, fz_text*);
#endif
diff --git a/include/mupdf/fitz/transition.h b/include/mupdf/fitz/transition.h
index 3c778528..65d170d5 100644
--- a/include/mupdf/fitz/transition.h
+++ b/include/mupdf/fitz/transition.h
@@ -49,6 +49,6 @@ struct fz_transition_s
Returns 1 if successfully generated a frame.
*/
-int fz_generate_transition(fz_pixmap *tpix, fz_pixmap *opix, fz_pixmap *npix, int time, fz_transition *trans);
+int fz_generate_transition(fz_context *ctx, fz_pixmap *tpix, fz_pixmap *opix, fz_pixmap *npix, int time, fz_transition *trans);
#endif
diff --git a/include/mupdf/fitz/tree.h b/include/mupdf/fitz/tree.h
index f2cc4848..0b299e27 100644
--- a/include/mupdf/fitz/tree.h
+++ b/include/mupdf/fitz/tree.h
@@ -17,7 +17,7 @@ void *fz_tree_lookup(fz_context *ctx, fz_tree *node, const char *key);
*/
fz_tree *fz_tree_insert(fz_context *ctx, fz_tree *root, const char *key, void *value);
-void fz_free_tree(fz_context *ctx, fz_tree *node, void (*freefunc)(fz_context *ctx, void *value));
+void fz_drop_tree(fz_context *ctx, fz_tree *node, void (*dropfunc)(fz_context *ctx, void *value));
void fz_debug_tree(fz_context *ctx, fz_tree *root);
diff --git a/include/mupdf/fitz/unzip.h b/include/mupdf/fitz/unzip.h
index dd9fb856..b19ffbd9 100644
--- a/include/mupdf/fitz/unzip.h
+++ b/include/mupdf/fitz/unzip.h
@@ -14,9 +14,7 @@ fz_archive *fz_open_archive_with_stream(fz_context *ctx, fz_stream *file);
int fz_has_archive_entry(fz_context *ctx, fz_archive *zip, const char *name);
fz_stream *fz_open_archive_entry(fz_context *ctx, fz_archive *zip, const char *entry);
fz_buffer *fz_read_archive_entry(fz_context *ctx, fz_archive *zip, const char *entry);
-void fz_close_archive(fz_context *ctx, fz_archive *ar);
-
-void fz_rebind_archive(fz_archive *zip, fz_context *ctx);
+void fz_drop_archive(fz_context *ctx, fz_archive *ar);
int fz_count_archive_entries(fz_context *ctx, fz_archive *zip);
const char *fz_list_archive_entry(fz_context *ctx, fz_archive *zip, int idx);
diff --git a/include/mupdf/fitz/write-document.h b/include/mupdf/fitz/write-document.h
index 56b9ef76..82cd2f5d 100644
--- a/include/mupdf/fitz/write-document.h
+++ b/include/mupdf/fitz/write-document.h
@@ -53,6 +53,6 @@ enum
May throw exceptions.
*/
-void fz_write_document(fz_document *doc, char *filename, fz_write_options *opts);
+void fz_write_document(fz_context *ctx, fz_document *doc, char *filename, fz_write_options *opts);
#endif
diff --git a/include/mupdf/fitz/xml.h b/include/mupdf/fitz/xml.h
index 8006fa07..7e226f71 100644
--- a/include/mupdf/fitz/xml.h
+++ b/include/mupdf/fitz/xml.h
@@ -60,9 +60,9 @@ char *fz_xml_att(fz_xml *item, const char *att);
char *fz_xml_text(fz_xml *item);
/*
- fz_free_xml: Free the XML node and all its children and siblings.
+ fz_drop_xml: Free the XML node and all its children and siblings.
*/
-void fz_free_xml(fz_context *doc, fz_xml *item);
+void fz_drop_xml(fz_context *doc, fz_xml *item);
/*
fz_detach_xml: Detach a node from the tree, unlinking it from its parent.