summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/cbz.h51
-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
-rw-r--r--include/mupdf/html.h6
-rw-r--r--include/mupdf/img.h51
-rw-r--r--include/mupdf/pdf/annot.h50
-rw-r--r--include/mupdf/pdf/appearance.h20
-rw-r--r--include/mupdf/pdf/cmap.h4
-rw-r--r--include/mupdf/pdf/crypt.h36
-rw-r--r--include/mupdf/pdf/document.h50
-rw-r--r--include/mupdf/pdf/event.h28
-rw-r--r--include/mupdf/pdf/field.h36
-rw-r--r--include/mupdf/pdf/font.h18
-rw-r--r--include/mupdf/pdf/javascript.h6
-rw-r--r--include/mupdf/pdf/object.h180
-rw-r--r--include/mupdf/pdf/output-pdf.h6
-rw-r--r--include/mupdf/pdf/page.h32
-rw-r--r--include/mupdf/pdf/parse.h16
-rw-r--r--include/mupdf/pdf/resource.h26
-rw-r--r--include/mupdf/pdf/widget.h28
-rw-r--r--include/mupdf/pdf/xref.h86
-rw-r--r--include/mupdf/tiff.h51
-rw-r--r--include/mupdf/xps.h115
54 files changed, 675 insertions, 831 deletions
diff --git a/include/mupdf/cbz.h b/include/mupdf/cbz.h
deleted file mode 100644
index 5c0f9a66..00000000
--- a/include/mupdf/cbz.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef MUPDF_CBZ_H
-#define MUPDF_CBZ_H
-
-#include "mupdf/fitz.h"
-
-typedef struct cbz_document_s cbz_document;
-typedef struct cbz_page_s cbz_page;
-
-/*
- cbz_open_document: Open a document.
-
- Open a document for reading so the library is able to locate
- objects and pages inside the file.
-
- The returned cbz_document should be used when calling most
- other functions. Note that it wraps the context, so those
- functions implicitly get access to the global state in
- context.
-
- filename: a path to a file as it would be given to open(2).
-*/
-cbz_document *cbz_open_document(fz_context *ctx, const char *filename);
-
-/*
- cbz_open_document_with_stream: Opens a document.
-
- Same as cbz_open_document, but takes a stream instead of a
- filename to locate the document to open. Increments the
- reference count of the stream. See fz_open_file,
- fz_open_file_w or fz_open_fd for opening a stream, and
- fz_close for closing an open stream.
-*/
-cbz_document *cbz_open_document_with_stream(fz_context *ctx, fz_stream *file);
-
-/*
- cbz_close_document: Closes and frees an opened document.
-
- The resource store in the context associated with cbz_document
- is emptied.
-
- Does not throw exceptions.
-*/
-void cbz_close_document(cbz_document *doc);
-
-int cbz_count_pages(cbz_document *doc);
-cbz_page *cbz_load_page(cbz_document *doc, int number);
-fz_rect *cbz_bound_page(cbz_document *doc, cbz_page *page, fz_rect *rect);
-void cbz_free_page(cbz_document *doc, cbz_page *page);
-void cbz_run_page(cbz_document *doc, cbz_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
-
-#endif
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.
diff --git a/include/mupdf/html.h b/include/mupdf/html.h
index 86fea924..8003b83d 100644
--- a/include/mupdf/html.h
+++ b/include/mupdf/html.h
@@ -165,7 +165,7 @@ struct fz_html_flow_s
fz_css_rule *fz_parse_css(fz_context *ctx, fz_css_rule *chain, const char *source, const char *file);
fz_css_property *fz_parse_css_properties(fz_context *ctx, const char *source);
-void fz_free_css(fz_context *ctx, fz_css_rule *rule);
+void fz_drop_css(fz_context *ctx, fz_css_rule *rule);
void fz_match_css(fz_context *ctx, fz_css_match *match, fz_css_rule *rule, fz_xml *node);
@@ -179,11 +179,11 @@ float fz_from_css_number_scale(fz_css_number number, float scale, float em, floa
fz_html_font_set *fz_new_html_font_set(fz_context *ctx);
fz_font *fz_load_html_font(fz_context *ctx, fz_html_font_set *set,
const char *family, const char *variant, const char *style, const char *weight);
-void fz_free_html_font_set(fz_context *ctx, fz_html_font_set *htx);
+void fz_drop_html_font_set(fz_context *ctx, fz_html_font_set *htx);
fz_html *fz_parse_html(fz_context *ctx, fz_html_font_set *htx, fz_archive *zip, const char *base_uri, fz_buffer *buf, const char *user_css);
void fz_layout_html(fz_context *ctx, fz_html *box, float w, float h, float em);
void fz_draw_html(fz_context *ctx, fz_html *box, float page_top, float page_bot, fz_device *dev, const fz_matrix *ctm);
-void fz_free_html(fz_context *ctx, fz_html *box);
+void fz_drop_html(fz_context *ctx, fz_html *box);
#endif
diff --git a/include/mupdf/img.h b/include/mupdf/img.h
deleted file mode 100644
index 4c10b0d3..00000000
--- a/include/mupdf/img.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef MUIMAGE_H
-#define MUIMAGE_H
-
-#include "mupdf/fitz.h"
-
-typedef struct image_document_s image_document;
-typedef struct image_page_s image_page;
-
-/*
- image_open_document: Open a document.
-
- Open a document for reading so the library is able to locate
- objects and pages inside the file.
-
- The returned image_document should be used when calling most
- other functions. Note that it wraps the context, so those
- functions implicitly get access to the global state in
- context.
-
- filename: a path to a file as it would be given to open(2).
-*/
-image_document *image_open_document(fz_context *ctx, const char *filename);
-
-/*
- image_open_document_with_stream: Opens a document.
-
- Same as image_open_document, but takes a stream instead of a
- filename to locate the document to open. Increments the
- reference count of the stream. See fz_open_file,
- fz_open_file_w or fz_open_fd for opening a stream, and
- fz_close for closing an open stream.
-*/
-image_document *image_open_document_with_stream(fz_context *ctx, fz_stream *file);
-
-/*
- image_close_document: Closes and frees an opened document.
-
- The resource store in the context associated with image_document
- is emptied.
-
- Does not throw exceptions.
-*/
-void image_close_document(image_document *doc);
-
-int image_count_pages(image_document *doc);
-image_page *image_load_page(image_document *doc, int number);
-fz_rect *image_bound_page(image_document *doc, image_page *page, fz_rect *rect);
-void image_free_page(image_document *doc, image_page *page);
-void image_run_page(image_document *doc, image_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
-
-#endif
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h
index e3243186..a6959f32 100644
--- a/include/mupdf/pdf/annot.h
+++ b/include/mupdf/pdf/annot.h
@@ -20,26 +20,26 @@ enum
Does not throw exceptions.
*/
-pdf_annot *pdf_first_annot(pdf_document *doc, pdf_page *page);
+pdf_annot *pdf_first_annot(fz_context *ctx, pdf_page *page);
/*
pdf_next_annot: Return the next annotation on a page.
Does not throw exceptions.
*/
-pdf_annot *pdf_next_annot(pdf_document *doc, pdf_annot *annot);
+pdf_annot *pdf_next_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot);
/*
pdf_bound_annot: Return the rectangle for an annotation on a page.
Does not throw exceptions.
*/
-fz_rect *pdf_bound_annot(pdf_document *doc, pdf_annot *annot, fz_rect *rect);
+fz_rect *pdf_bound_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot, fz_rect *rect);
/*
pdf_annot_type: Return the type of an annotation
*/
-fz_annot_type pdf_annot_type(pdf_annot *annot);
+fz_annot_type pdf_annot_type(fz_context *ctx, pdf_annot *annot);
/*
pdf_run_annot: Interpret an annotation and render it on a device.
@@ -53,7 +53,7 @@ fz_annot_type pdf_annot_type(pdf_annot *annot);
ctm: A transformation matrix applied to the objects on the page,
e.g. to scale or rotate the page contents as desired.
*/
-void pdf_run_annot(pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
+void pdf_run_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
struct pdf_annot_s
{
@@ -70,69 +70,69 @@ struct pdf_annot_s
int widget_type;
};
-fz_link_dest pdf_parse_link_dest(pdf_document *doc, fz_link_kind kind, pdf_obj *dest);
-fz_link_dest pdf_parse_action(pdf_document *doc, pdf_obj *action);
-pdf_obj *pdf_lookup_dest(pdf_document *doc, pdf_obj *needle);
-pdf_obj *pdf_lookup_name(pdf_document *doc, char *which, pdf_obj *needle);
-pdf_obj *pdf_load_name_tree(pdf_document *doc, char *which);
+fz_link_dest pdf_parse_link_dest(fz_context *ctx, pdf_document *doc, fz_link_kind kind, pdf_obj *dest);
+fz_link_dest pdf_parse_action(fz_context *ctx, pdf_document *doc, pdf_obj *action);
+pdf_obj *pdf_lookup_dest(fz_context *ctx, pdf_document *doc, pdf_obj *needle);
+pdf_obj *pdf_lookup_name(fz_context *ctx, pdf_document *doc, char *which, pdf_obj *needle);
+pdf_obj *pdf_load_name_tree(fz_context *ctx, pdf_document *doc, char *which);
-fz_link *pdf_load_link_annots(pdf_document *, pdf_obj *annots, const fz_matrix *page_ctm);
+fz_link *pdf_load_link_annots(fz_context *ctx, pdf_document *, pdf_obj *annots, const fz_matrix *page_ctm);
-void pdf_transform_annot(pdf_annot *annot);
-void pdf_load_annots(pdf_document *, pdf_page *page, pdf_obj *annots);
-void pdf_update_annot(pdf_document *, pdf_annot *annot);
-void pdf_free_annot(fz_context *ctx, pdf_annot *link);
+void pdf_transform_annot(fz_context *ctx, pdf_annot *annot);
+void pdf_load_annots(fz_context *ctx, pdf_document *, pdf_page *page, pdf_obj *annots);
+void pdf_update_annot(fz_context *ctx, pdf_document *, pdf_annot *annot);
+void pdf_drop_annot(fz_context *ctx, pdf_annot *link);
/*
pdf_create_annot: create a new annotation of the specified type on the
specified page. The returned pdf_annot structure is owned by the page
and does not need to be freed.
*/
-pdf_annot *pdf_create_annot(pdf_document *doc, pdf_page *page, fz_annot_type type);
+pdf_annot *pdf_create_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_annot_type type);
/*
pdf_delete_annot: delete an annotation
*/
-void pdf_delete_annot(pdf_document *doc, pdf_page *page, pdf_annot *annot);
+void pdf_delete_annot(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_annot *annot);
/*
pdf_set_markup_annot_quadpoints: set the quadpoints for a text-markup annotation.
*/
-void pdf_set_markup_annot_quadpoints(pdf_document *doc, pdf_annot *annot, fz_point *qp, int n);
+void pdf_set_markup_annot_quadpoints(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *qp, int n);
/*
pdf_set_ink_annot_list: set the details of an ink annotation. All the points of the multiple arcs
are carried in a single array, with the counts for each arc held in a secondary array.
*/
-void pdf_set_ink_annot_list(pdf_document *doc, pdf_annot *annot, fz_point *pts, int *counts, int ncount, float color[3], float thickness);
+void pdf_set_ink_annot_list(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pts, int *counts, int ncount, float color[3], float thickness);
/*
pdf_set_text_annot_position: set the position on page for a text (sticky note) annotation.
*/
-void pdf_set_text_annot_position(pdf_document *doc, pdf_annot *annot, fz_point pt);
+void pdf_set_text_annot_position(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point pt);
/*
pdf_set_annot_contents: set the contents of an annotation.
*/
-void pdf_set_annot_contents(pdf_document *doc, pdf_annot *annot, char *text);
+void pdf_set_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot, char *text);
/*
pdf_annot_contents: return the contents of an annotation.
*/
-char *pdf_annot_contents(pdf_document *doc, pdf_annot *annot);
+char *pdf_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
/*
pdf_set_free_text_details: set the position, text, font and color for a free text annotation.
Only base 14 fonts are supported and are specified by name.
*/
-void pdf_set_free_text_details(pdf_document *doc, pdf_annot *annot, fz_point *pos, char *text, char *font_name, float font_size, float color[3]);
+void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pos, char *text, char *font_name, float font_size, float color[3]);
-fz_annot_type pdf_annot_obj_type(pdf_obj *obj);
+fz_annot_type pdf_annot_obj_type(fz_context *ctx, pdf_obj *obj);
/*
pdf_poll_changed_annot: enumerate the changed annotations recoreded
by a call to pdf_update_page.
*/
-pdf_annot *pdf_poll_changed_annot(pdf_document *idoc, pdf_page *page);
+pdf_annot *pdf_poll_changed_annot(fz_context *ctx, pdf_document *idoc, pdf_page *page);
#endif
diff --git a/include/mupdf/pdf/appearance.h b/include/mupdf/pdf/appearance.h
index 3cdfb103..ddf64516 100644
--- a/include/mupdf/pdf/appearance.h
+++ b/include/mupdf/pdf/appearance.h
@@ -13,30 +13,30 @@ void pdf_da_info_fin(fz_context *ctx, pdf_da_info *di);
void pdf_parse_da(fz_context *ctx, char *da, pdf_da_info *di);
void pdf_fzbuf_print_da(fz_context *ctx, fz_buffer *fzbuf, pdf_da_info *di);
-void pdf_update_text_appearance(pdf_document *doc, pdf_obj *obj, char *eventValue);
-void pdf_update_combobox_appearance(pdf_document *doc, pdf_obj *obj);
-void pdf_update_pushbutton_appearance(pdf_document *doc, pdf_obj *obj);
-void pdf_update_text_markup_appearance(pdf_document *doc, pdf_annot *annot, fz_annot_type type);
-void pdf_update_ink_appearance(pdf_document *doc, pdf_annot *annot);
-void pdf_update_text_annot_appearance(pdf_document *doc, pdf_annot *annot);
+void pdf_update_text_appearance(fz_context *ctx, pdf_document *doc, pdf_obj *obj, char *eventValue);
+void pdf_update_combobox_appearance(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+void pdf_update_text_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_annot_type type);
+void pdf_update_ink_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
+void pdf_update_text_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
/*
pdf_update_free_text_annot_appearance: update the appearance stream for a free text
annotation, basing it on the annoations rectangle and contents.
*/
-void pdf_update_free_text_annot_appearance(pdf_document *doc, pdf_annot *annot);
+void pdf_update_free_text_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
/*
pdf_set_annot_appearance: update the appearance of an annotation based
on a display list.
*/
-void pdf_set_annot_appearance(pdf_document *doc, pdf_annot *annot, fz_rect *rect, fz_display_list *disp_list);
+void pdf_set_annot_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_rect *rect, fz_display_list *disp_list);
/*
fz_set_markup_appearance: set the appearance stream of a text markup annotations, basing it on
its QuadPoints array
*/
-void pdf_set_markup_appearance(pdf_document *doc, pdf_annot *annot, float color[3], float alpha, float line_thickness, float line_height);
+void pdf_set_markup_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot, float color[3], float alpha, float line_thickness, float line_height);
-void pdf_set_signature_appearance(pdf_document *doc, pdf_annot *annot, char *name, char *dn, char *date);
+void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot, char *name, char *dn, char *date);
#endif
diff --git a/include/mupdf/pdf/cmap.h b/include/mupdf/pdf/cmap.h
index b4080b8e..e17ebbaa 100644
--- a/include/mupdf/pdf/cmap.h
+++ b/include/mupdf/pdf/cmap.h
@@ -58,7 +58,7 @@ struct pdf_cmap_s
pdf_cmap *pdf_new_cmap(fz_context *ctx);
pdf_cmap *pdf_keep_cmap(fz_context *ctx, pdf_cmap *cmap);
void pdf_drop_cmap(fz_context *ctx, pdf_cmap *cmap);
-void pdf_free_cmap_imp(fz_context *ctx, fz_storable *cmap);
+void pdf_drop_cmap_imp(fz_context *ctx, fz_storable *cmap);
unsigned int pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap);
int pdf_cmap_wmode(fz_context *ctx, pdf_cmap *cmap);
@@ -79,7 +79,7 @@ pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes);
pdf_cmap *pdf_load_cmap(fz_context *ctx, fz_stream *file);
pdf_cmap *pdf_load_system_cmap(fz_context *ctx, char *name);
pdf_cmap *pdf_load_builtin_cmap(fz_context *ctx, char *name);
-pdf_cmap *pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *ref);
+pdf_cmap *pdf_load_embedded_cmap(fz_context *ctx, pdf_document *doc, pdf_obj *ref);
#ifndef NDEBUG
void pdf_print_cmap(fz_context *ctx, pdf_cmap *cmap);
diff --git a/include/mupdf/pdf/crypt.h b/include/mupdf/pdf/crypt.h
index 9e3c4c94..30a74ec0 100644
--- a/include/mupdf/pdf/crypt.h
+++ b/include/mupdf/pdf/crypt.h
@@ -6,21 +6,21 @@
*/
pdf_crypt *pdf_new_crypt(fz_context *ctx, pdf_obj *enc, pdf_obj *id);
-void pdf_free_crypt(fz_context *ctx, pdf_crypt *crypt);
+void pdf_drop_crypt(fz_context *ctx, pdf_crypt *crypt);
void pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, pdf_obj *obj, int num, int gen);
void pdf_crypt_buffer(fz_context *ctx, pdf_crypt *crypt, fz_buffer *buf, int num, int gen);
-fz_stream *pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, int num, int gen);
-fz_stream *pdf_open_crypt_with_filter(fz_stream *chain, pdf_crypt *crypt, char *name, int num, int gen);
+fz_stream *pdf_open_crypt(fz_context *ctx, fz_stream *chain, pdf_crypt *crypt, int num, int gen);
+fz_stream *pdf_open_crypt_with_filter(fz_context *ctx, fz_stream *chain, pdf_crypt *crypt, char *name, int num, int gen);
-int pdf_crypt_version(pdf_document *doc);
-int pdf_crypt_revision(pdf_document *doc);
-char *pdf_crypt_method(pdf_document *doc);
-int pdf_crypt_length(pdf_document *doc);
-unsigned char *pdf_crypt_key(pdf_document *doc);
+int pdf_crypt_version(fz_context *ctx, pdf_document *doc);
+int pdf_crypt_revision(fz_context *ctx, pdf_document *doc);
+char *pdf_crypt_method(fz_context *ctx, pdf_document *doc);
+int pdf_crypt_length(fz_context *ctx, pdf_document *doc);
+unsigned char *pdf_crypt_key(fz_context *ctx, pdf_document *doc);
#ifndef NDEBUG
-void pdf_print_crypt(pdf_crypt *crypt);
+void pdf_print_crypt(fz_context *ctx, pdf_crypt *crypt);
#endif
typedef struct pdf_designated_name_s
@@ -33,33 +33,33 @@ typedef struct pdf_designated_name_s
}
pdf_designated_name;
-void pdf_free_designated_name(pdf_designated_name *dn);
+void pdf_drop_designated_name(fz_context *ctx, pdf_designated_name *dn);
pdf_signer *pdf_read_pfx(fz_context *ctx, const char *sigfile, const char *password);
-pdf_signer *pdf_keep_signer(pdf_signer *signer);
-void pdf_drop_signer(pdf_signer *signer);
-pdf_designated_name *pdf_signer_designated_name(pdf_signer *signer);
-void pdf_write_digest(pdf_document *doc, char *filename, pdf_obj *byte_range, int digest_offset, int digest_length, pdf_signer *signer);
+pdf_signer *pdf_keep_signer(fz_context *ctx, pdf_signer *signer);
+void pdf_drop_signer(fz_context *ctx, pdf_signer *signer);
+pdf_designated_name *pdf_signer_designated_name(fz_context *ctx, pdf_signer *signer);
+void pdf_write_digest(fz_context *ctx, pdf_document *doc, char *filename, pdf_obj *byte_range, int digest_offset, int digest_length, pdf_signer *signer);
/*
pdf_signature_widget_byte_range: retrieve the byte range for a signature widget
*/
-int pdf_signature_widget_byte_range(pdf_document *doc, pdf_widget *widget, int (*byte_range)[2]);
+int pdf_signature_widget_byte_range(fz_context *ctx, pdf_document *doc, pdf_widget *widget, int (*byte_range)[2]);
/*
pdf_signature_widget_contents: retrieve the contents for a signature widget
*/
-int pdf_signature_widget_contents(pdf_document *doc, pdf_widget *widget, char **contents);
+int pdf_signature_widget_contents(fz_context *ctx, pdf_document *doc, pdf_widget *widget, char **contents);
/*
pdf_check_signature: check a signature's certificate chain and digest
*/
-int pdf_check_signature(pdf_document *doc, pdf_widget *widget, char *file, char *ebuf, int ebufsize);
+int pdf_check_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget, char *file, char *ebuf, int ebufsize);
/*
pdf_sign_signature: sign a signature form field
*/
-void pdf_sign_signature(pdf_document *doc, pdf_widget *widget, const char *sigfile, const char *password);
+void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget, const char *sigfile, const char *password);
#endif
diff --git a/include/mupdf/pdf/document.h b/include/mupdf/pdf/document.h
index c9851a47..f8fc23ca 100644
--- a/include/mupdf/pdf/document.h
+++ b/include/mupdf/pdf/document.h
@@ -21,7 +21,6 @@ enum
struct pdf_lexbuf_s
{
- fz_context *ctx;
int size;
int base_size;
int len;
@@ -54,7 +53,7 @@ typedef struct pdf_doc_event_s pdf_doc_event;
pdf_doc_event_cb: the type of function via which the app receives
document events.
*/
-typedef void (pdf_doc_event_cb)(pdf_doc_event *event, void *data);
+typedef void (pdf_doc_event_cb)(fz_context *ctx, pdf_document *doc, pdf_doc_event *event, void *data);
/*
pdf_open_document: Open a PDF document.
@@ -82,7 +81,7 @@ pdf_document *pdf_open_document(fz_context *ctx, const char *filename);
filename to locate the PDF document to open. Increments the
reference count of the stream. See fz_open_file,
fz_open_file_w or fz_open_fd for opening a stream, and
- fz_close for closing an open stream.
+ fz_drop_stream for closing an open stream.
*/
pdf_document *pdf_open_document_with_stream(fz_context *ctx, fz_stream *file);
@@ -97,16 +96,16 @@ pdf_document *pdf_open_document_no_run_with_stream(fz_context *ctx, fz_stream *f
Does not throw exceptions.
*/
-void pdf_close_document(pdf_document *doc);
+void pdf_close_document(fz_context *ctx, pdf_document *doc);
/*
pdf_specific: down-cast an fz_document to a pdf_document.
Returns NULL if underlying document is not PDF
*/
-pdf_document *pdf_specifics(fz_document *doc);
+pdf_document *pdf_specifics(fz_context *ctx, fz_document *doc);
-int pdf_needs_password(pdf_document *doc);
-int pdf_authenticate_password(pdf_document *doc, const char *pw);
+int pdf_needs_password(fz_context *ctx, pdf_document *doc);
+int pdf_authenticate_password(fz_context *ctx, pdf_document *doc, const char *pw);
enum
{
@@ -121,14 +120,14 @@ enum
PDF_DEFAULT_PERM_FLAGS = 0xfffc
};
-int pdf_has_permission(pdf_document *doc, int p);
+int pdf_has_permission(fz_context *ctx, pdf_document *doc, int p);
/*
Metadata interface.
*/
-int pdf_meta(pdf_document *doc, int key, void *ptr, int size);
+int pdf_meta(fz_context *ctx, pdf_document *doc, int key, void *ptr, int size);
-fz_outline *pdf_load_outline(pdf_document *doc);
+fz_outline *pdf_load_outline(fz_context *ctx, pdf_document *doc);
typedef struct pdf_ocg_entry_s pdf_ocg_entry;
@@ -160,24 +159,13 @@ struct pdf_ocg_descriptor_s
a call to pdf_update_page would not reliably be able to report all changed
areas.
*/
-void pdf_update_page(pdf_document *doc, pdf_page *page);
+void pdf_update_page(fz_context *ctx, pdf_document *doc, pdf_page *page);
/*
Determine whether changes have been made since the
document was opened or last saved.
*/
-int pdf_has_unsaved_changes(pdf_document *doc);
-
-typedef struct pdf_obj_read_state_s pdf_obj_read_state;
-
-struct pdf_obj_read_state_s
-{
- int offset;
- int num;
- int numofs;
- int gen;
- int genofs;
-};
+int pdf_has_unsaved_changes(fz_context *ctx, pdf_document *doc);
typedef struct pdf_signer_s pdf_signer;
@@ -200,7 +188,6 @@ struct pdf_document_s
{
fz_document super;
- fz_context *ctx;
fz_stream *file;
int version;
@@ -213,6 +200,7 @@ struct pdf_document_s
int max_xref_len;
int num_xref_sections;
pdf_xref *xref_sections;
+ int *xref_index;
int xref_altered;
int freeze_updates;
int has_xref_streams;
@@ -279,7 +267,7 @@ struct pdf_document_s
int dirty;
pdf_unsaved_sig *unsaved_sigs;
- void (*update_appearance)(pdf_document *doc, pdf_annot *annot);
+ void (*update_appearance)(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
pdf_doc_event_cb *event_cb;
void *event_cb_data;
@@ -298,17 +286,17 @@ struct pdf_document_s
*/
pdf_document *pdf_create_document(fz_context *ctx);
-pdf_page *pdf_create_page(pdf_document *doc, fz_rect rect, int res, int rotate);
+pdf_page *pdf_create_page(fz_context *ctx, pdf_document *doc, fz_rect rect, int res, int rotate);
-void pdf_insert_page(pdf_document *doc, pdf_page *page, int at);
+void pdf_insert_page(fz_context *ctx, pdf_document *doc, pdf_page *page, int at);
-void pdf_delete_page(pdf_document *doc, int number);
+void pdf_delete_page(fz_context *ctx, pdf_document *doc, int number);
-void pdf_delete_page_range(pdf_document *doc, int start, int end);
+void pdf_delete_page_range(fz_context *ctx, pdf_document *doc, int start, int end);
-fz_device *pdf_page_write(pdf_document *doc, pdf_page *page);
+fz_device *pdf_page_write(fz_context *ctx, pdf_document *doc, pdf_page *page);
-void pdf_finish_edit(pdf_document *doc);
+void pdf_finish_edit(fz_context *ctx, pdf_document *doc);
int pdf_recognize(fz_context *doc, const char *magic);
diff --git a/include/mupdf/pdf/event.h b/include/mupdf/pdf/event.h
index c2adf057..6e16ab33 100644
--- a/include/mupdf/pdf/event.h
+++ b/include/mupdf/pdf/event.h
@@ -57,7 +57,7 @@ void pdf_init_ui_pointer_event(pdf_ui_event *event, int type, float x, float y);
passing the events that make up a drag, if the down event isn't
accepted then don't send the move events or the up event.
*/
-int pdf_pass_event(pdf_document *doc, pdf_page *page, pdf_ui_event *ui_event);
+int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_event *ui_event);
struct pdf_doc_event_s
{
@@ -79,7 +79,7 @@ enum
pdf_set_doc_event_callback: set the function via which to receive
document events.
*/
-void pdf_set_doc_event_callback(pdf_document *doc, pdf_doc_event_cb *event_cb, void *data);
+void pdf_set_doc_event_callback(fz_context *ctx, pdf_document *doc, pdf_doc_event_cb *event_cb, void *data);
/*
The various types of document events
@@ -141,13 +141,13 @@ enum
structire are owned by mupdf and need not be freed by the
caller.
*/
-pdf_alert_event *pdf_access_alert_event(pdf_doc_event *event);
+pdf_alert_event *pdf_access_alert_event(fz_context *ctx, pdf_doc_event *event);
/*
pdf_access_exec_menu_item_event: access the details of am execMenuItem
event, which consists of just the name of the menu item
*/
-char *pdf_access_exec_menu_item_event(pdf_doc_event *event);
+char *pdf_access_exec_menu_item_event(fz_context *ctx, pdf_doc_event *event);
/*
pdf_submit_event: details of a submit event. The app should submit
@@ -167,7 +167,7 @@ typedef struct
The returned pointer and all data referred to by the structure are
owned by mupdf and need not be freed by the caller.
*/
-pdf_submit_event *pdf_access_submit_event(pdf_doc_event *event);
+pdf_submit_event *pdf_access_submit_event(fz_context *ctx, pdf_doc_event *event);
/*
pdf_launch_url_event: details of a launch-url event. The app should
@@ -184,7 +184,7 @@ typedef struct
event. The returned pointer and all data referred to by the structure
are owned by mupdf and need not be freed by the caller.
*/
-pdf_launch_url_event *pdf_access_launch_url_event(pdf_doc_event *event);
+pdf_launch_url_event *pdf_access_launch_url_event(fz_context *ctx, pdf_doc_event *event);
/*
pdf_mail_doc_event: details of a mail_doc event. The app should save
@@ -204,13 +204,13 @@ typedef struct
/*
pdf_acccess_mail_doc_event: access the details of a mail-doc event.
*/
-pdf_mail_doc_event *pdf_access_mail_doc_event(pdf_doc_event *event);
-
-void pdf_event_issue_alert(pdf_document *doc, pdf_alert_event *event);
-void pdf_event_issue_print(pdf_document *doc);
-void pdf_event_issue_exec_menu_item(pdf_document *doc, char *item);
-void pdf_event_issue_exec_dialog(pdf_document *doc);
-void pdf_event_issue_launch_url(pdf_document *doc, char *url, int new_frame);
-void pdf_event_issue_mail_doc(pdf_document *doc, pdf_mail_doc_event *event);
+pdf_mail_doc_event *pdf_access_mail_doc_event(fz_context *ctx, pdf_doc_event *event);
+
+void pdf_event_issue_alert(fz_context *ctx, pdf_document *doc, pdf_alert_event *event);
+void pdf_event_issue_print(fz_context *ctx, pdf_document *doc);
+void pdf_event_issue_exec_menu_item(fz_context *ctx, pdf_document *doc, char *item);
+void pdf_event_issue_exec_dialog(fz_context *ctx, pdf_document *doc);
+void pdf_event_issue_launch_url(fz_context *ctx, pdf_document *doc, char *url, int new_frame);
+void pdf_event_issue_mail_doc(fz_context *ctx, pdf_document *doc, pdf_mail_doc_event *event);
#endif
diff --git a/include/mupdf/pdf/field.h b/include/mupdf/pdf/field.h
index f0aa70ff..272e14be 100644
--- a/include/mupdf/pdf/field.h
+++ b/include/mupdf/pdf/field.h
@@ -33,23 +33,23 @@ enum
Ff_CommitOnSelCHange = 1 << (27-1),
};
-char *pdf_get_string_or_stream(pdf_document *doc, pdf_obj *obj);
-pdf_obj *pdf_get_inheritable(pdf_document *doc, pdf_obj *obj, char *key);
-int pdf_get_field_flags(pdf_document *doc, pdf_obj *obj);
-int pdf_field_type(pdf_document *doc, pdf_obj *field);
-void pdf_set_field_type(pdf_document *doc, pdf_obj *obj, int type);
-char *pdf_field_value(pdf_document *doc, pdf_obj *field);
-int pdf_field_set_value(pdf_document *doc, pdf_obj *field, char *text);
-char *pdf_field_border_style(pdf_document *doc, pdf_obj *field);
-void pdf_field_set_border_style(pdf_document *doc, pdf_obj *field, char *text);
-void pdf_field_set_button_caption(pdf_document *doc, pdf_obj *field, char *text);
-void pdf_field_set_fill_color(pdf_document *doc, pdf_obj *field, pdf_obj *col);
-void pdf_field_set_text_color(pdf_document *doc, pdf_obj *field, pdf_obj *col);
-void pdf_signature_set_value(pdf_document *doc, pdf_obj *field, pdf_signer *signer);
-int pdf_field_display(pdf_document *doc, pdf_obj *field);
-char *pdf_field_name(pdf_document *doc, pdf_obj *field);
-void pdf_field_set_display(pdf_document *doc, pdf_obj *field, int d);
-pdf_obj *pdf_lookup_field(pdf_obj *form, char *name);
-void pdf_field_reset(pdf_document *doc, pdf_obj *field);
+char *pdf_get_string_or_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+pdf_obj *pdf_get_inheritable(fz_context *ctx, pdf_document *doc, pdf_obj *obj, char *key);
+int pdf_get_field_flags(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+int pdf_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *field);
+void pdf_set_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj, int type);
+char *pdf_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *field);
+int pdf_field_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, char *text);
+char *pdf_field_border_style(fz_context *ctx, pdf_document *doc, pdf_obj *field);
+void pdf_field_set_border_style(fz_context *ctx, pdf_document *doc, pdf_obj *field, char *text);
+void pdf_field_set_button_caption(fz_context *ctx, pdf_document *doc, pdf_obj *field, char *text);
+void pdf_field_set_fill_color(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_obj *col);
+void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_obj *col);
+void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_signer *signer);
+int pdf_field_display(fz_context *ctx, pdf_document *doc, pdf_obj *field);
+char *pdf_field_name(fz_context *ctx, pdf_document *doc, pdf_obj *field);
+void pdf_field_set_display(fz_context *ctx, pdf_document *doc, pdf_obj *field, int d);
+pdf_obj *pdf_lookup_field(fz_context *ctx, pdf_obj *form, char *name);
+void pdf_field_reset(fz_context *ctx, pdf_document *doc, pdf_obj *field);
#endif
diff --git a/include/mupdf/pdf/font.h b/include/mupdf/pdf/font.h
index c1576483..7697053f 100644
--- a/include/mupdf/pdf/font.h
+++ b/include/mupdf/pdf/font.h
@@ -99,18 +99,18 @@ void pdf_end_vmtx(fz_context *ctx, pdf_font_desc *font);
pdf_hmtx pdf_lookup_hmtx(fz_context *ctx, pdf_font_desc *font, int cid);
pdf_vmtx pdf_lookup_vmtx(fz_context *ctx, pdf_font_desc *font, int cid);
-void pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, pdf_obj *cmapstm);
+void pdf_load_to_unicode(fz_context *ctx, pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, pdf_obj *cmapstm);
int pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid);
-unsigned char *pdf_lookup_builtin_font(const char *name, unsigned int *len);
-unsigned char *pdf_lookup_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len);
-unsigned char *pdf_lookup_substitute_cjk_font(int ros, int serif, int wmode, unsigned int *len, int *index);
+unsigned char *pdf_lookup_builtin_font(fz_context *ctx, const char *name, unsigned int *len);
+unsigned char *pdf_lookup_substitute_font(fz_context *ctx, int mono, int serif, int bold, int italic, unsigned int *len);
+unsigned char *pdf_lookup_substitute_cjk_font(fz_context *ctx, int ros, int serif, int wmode, unsigned int *len, int *index);
-pdf_font_desc *pdf_load_type3_font(pdf_document *doc, pdf_obj *rdb, pdf_obj *obj);
-void pdf_load_type3_glyphs(pdf_document *doc, pdf_font_desc *fontdesc, int nestedDepth);
-pdf_font_desc *pdf_load_font(pdf_document *doc, pdf_obj *rdb, pdf_obj *obj, int nestedDepth);
-pdf_font_desc *pdf_load_hail_mary_font(pdf_document *doc);
+pdf_font_desc *pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *obj);
+void pdf_load_type3_glyphs(fz_context *ctx, pdf_document *doc, pdf_font_desc *fontdesc, int nestedDepth);
+pdf_font_desc *pdf_load_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *obj, int nestedDepth);
+pdf_font_desc *pdf_load_hail_mary_font(fz_context *ctx, pdf_document *doc);
pdf_font_desc *pdf_new_font_desc(fz_context *ctx);
pdf_font_desc *pdf_keep_font(fz_context *ctx, pdf_font_desc *fontdesc);
@@ -123,6 +123,6 @@ void pdf_print_font(fz_context *ctx, pdf_font_desc *fontdesc);
fz_rect *pdf_measure_text(fz_context *ctx, pdf_font_desc *fontdesc, unsigned char *buf, int len, fz_rect *rect);
float pdf_text_stride(fz_context *ctx, pdf_font_desc *fontdesc, float fontsize, unsigned char *buf, int len, float room, int *count);
-void pdf_run_glyph(pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, const fz_matrix *ctm, void *gstate, int nestedDepth);
+void pdf_run_glyph(fz_context *ctx, pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, const fz_matrix *ctm, void *gstate, int nestedDepth);
#endif
diff --git a/include/mupdf/pdf/javascript.h b/include/mupdf/pdf/javascript.h
index ba8af4d6..a9a9213a 100644
--- a/include/mupdf/pdf/javascript.h
+++ b/include/mupdf/pdf/javascript.h
@@ -8,9 +8,9 @@ typedef struct pdf_js_event_s
int rc;
} pdf_js_event;
-void pdf_enable_js(pdf_document *doc);
-void pdf_disable_js(pdf_document *doc);
-int pdf_js_supported(pdf_document *doc);
+void pdf_enable_js(fz_context *ctx, pdf_document *doc);
+void pdf_disable_js(fz_context *ctx, pdf_document *doc);
+int pdf_js_supported(fz_context *ctx, pdf_document *doc);
void pdf_js_setup_event(pdf_js *js, pdf_js_event *e);
pdf_js_event *pdf_js_get_event(pdf_js *js);
diff --git a/include/mupdf/pdf/object.h b/include/mupdf/pdf/object.h
index c8417224..bcb4ab56 100644
--- a/include/mupdf/pdf/object.h
+++ b/include/mupdf/pdf/object.h
@@ -11,92 +11,92 @@ typedef struct pdf_document_s pdf_document;
typedef struct pdf_obj_s pdf_obj;
-pdf_obj *pdf_new_null(pdf_document *doc);
-pdf_obj *pdf_new_bool(pdf_document *doc, int b);
-pdf_obj *pdf_new_int(pdf_document *doc, int i);
-pdf_obj *pdf_new_real(pdf_document *doc, float f);
-pdf_obj *pdf_new_name(pdf_document *doc, const char *str);
-pdf_obj *pdf_new_string(pdf_document *doc, const char *str, int len);
-pdf_obj *pdf_new_indirect(pdf_document *doc, int num, int gen);
-pdf_obj *pdf_new_array(pdf_document *doc, int initialcap);
-pdf_obj *pdf_new_dict(pdf_document *doc, int initialcap);
-pdf_obj *pdf_new_rect(pdf_document *doc, const fz_rect *rect);
-pdf_obj *pdf_new_matrix(pdf_document *doc, const fz_matrix *mtx);
-pdf_obj *pdf_copy_array(pdf_obj *array);
-pdf_obj *pdf_copy_dict(pdf_obj *dict);
-
-pdf_obj *pdf_new_obj_from_str(pdf_document *doc, const char *src);
-
-pdf_obj *pdf_keep_obj(pdf_obj *obj);
-void pdf_drop_obj(pdf_obj *obj);
+pdf_obj *pdf_new_null(fz_context *ctx, pdf_document *doc);
+pdf_obj *pdf_new_bool(fz_context *ctx, pdf_document *doc, int b);
+pdf_obj *pdf_new_int(fz_context *ctx, pdf_document *doc, int i);
+pdf_obj *pdf_new_real(fz_context *ctx, pdf_document *doc, float f);
+pdf_obj *pdf_new_name(fz_context *ctx, pdf_document *doc, const char *str);
+pdf_obj *pdf_new_string(fz_context *ctx, pdf_document *doc, const char *str, int len);
+pdf_obj *pdf_new_indirect(fz_context *ctx, pdf_document *doc, int num, int gen);
+pdf_obj *pdf_new_array(fz_context *ctx, pdf_document *doc, int initialcap);
+pdf_obj *pdf_new_dict(fz_context *ctx, pdf_document *doc, int initialcap);
+pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, const fz_rect *rect);
+pdf_obj *pdf_new_matrix(fz_context *ctx, pdf_document *doc, const fz_matrix *mtx);
+pdf_obj *pdf_copy_array(fz_context *ctx, pdf_obj *array);
+pdf_obj *pdf_copy_dict(fz_context *ctx, pdf_obj *dict);
+
+pdf_obj *pdf_new_obj_from_str(fz_context *ctx, pdf_document *doc, const char *src);
+
+pdf_obj *pdf_keep_obj(fz_context *ctx, pdf_obj *obj);
+void pdf_drop_obj(fz_context *ctx, pdf_obj *obj);
/* type queries */
-int pdf_is_null(pdf_obj *obj);
-int pdf_is_bool(pdf_obj *obj);
-int pdf_is_int(pdf_obj *obj);
-int pdf_is_real(pdf_obj *obj);
-int pdf_is_number(pdf_obj *obj);
-int pdf_is_name(pdf_obj *obj);
-int pdf_is_string(pdf_obj *obj);
-int pdf_is_array(pdf_obj *obj);
-int pdf_is_dict(pdf_obj *obj);
-int pdf_is_indirect(pdf_obj *obj);
-int pdf_is_stream(pdf_document *doc, int num, int gen);
-
-int pdf_objcmp(pdf_obj *a, pdf_obj *b);
+int pdf_is_null(fz_context *ctx, pdf_obj *obj);
+int pdf_is_bool(fz_context *ctx, pdf_obj *obj);
+int pdf_is_int(fz_context *ctx, pdf_obj *obj);
+int pdf_is_real(fz_context *ctx, pdf_obj *obj);
+int pdf_is_number(fz_context *ctx, pdf_obj *obj);
+int pdf_is_name(fz_context *ctx, pdf_obj *obj);
+int pdf_is_string(fz_context *ctx, pdf_obj *obj);
+int pdf_is_array(fz_context *ctx, pdf_obj *obj);
+int pdf_is_dict(fz_context *ctx, pdf_obj *obj);
+int pdf_is_indirect(fz_context *ctx, pdf_obj *obj);
+int pdf_is_stream(fz_context *ctx, pdf_document *doc, int num, int gen);
+
+int pdf_objcmp(fz_context *ctx, pdf_obj *a, pdf_obj *b);
/* obj marking and unmarking functions - to avoid infinite recursions. */
-int pdf_obj_marked(pdf_obj *obj);
-int pdf_mark_obj(pdf_obj *obj);
-void pdf_unmark_obj(pdf_obj *obj);
+int pdf_obj_marked(fz_context *ctx, pdf_obj *obj);
+int pdf_mark_obj(fz_context *ctx, pdf_obj *obj);
+void pdf_unmark_obj(fz_context *ctx, pdf_obj *obj);
/* obj memo functions - allows us to secretly remember "a memo" (a bool) in
* an object, and to read back whether there was a memo, and if so, what it
* was. */
-void pdf_set_obj_memo(pdf_obj *obj, int memo);
-int pdf_obj_memo(pdf_obj *obj, int *memo);
+void pdf_set_obj_memo(fz_context *ctx, pdf_obj *obj, int memo);
+int pdf_obj_memo(fz_context *ctx, pdf_obj *obj, int *memo);
/* obj dirty bit support. */
-int pdf_obj_is_dirty(pdf_obj *obj);
-void pdf_dirty_obj(pdf_obj *obj);
-void pdf_clean_obj(pdf_obj *obj);
+int pdf_obj_is_dirty(fz_context *ctx, pdf_obj *obj);
+void pdf_dirty_obj(fz_context *ctx, pdf_obj *obj);
+void pdf_clean_obj(fz_context *ctx, pdf_obj *obj);
/* safe, silent failure, no error reporting on type mismatches */
-int pdf_to_bool(pdf_obj *obj);
-int pdf_to_int(pdf_obj *obj);
-float pdf_to_real(pdf_obj *obj);
-char *pdf_to_name(pdf_obj *obj);
-char *pdf_to_str_buf(pdf_obj *obj);
-pdf_obj *pdf_to_dict(pdf_obj *obj);
-int pdf_to_str_len(pdf_obj *obj);
-int pdf_to_num(pdf_obj *obj);
-int pdf_to_gen(pdf_obj *obj);
-
-int pdf_array_len(pdf_obj *array);
-pdf_obj *pdf_array_get(pdf_obj *array, int i);
-void pdf_array_put(pdf_obj *array, int i, pdf_obj *obj);
-void pdf_array_push(pdf_obj *array, pdf_obj *obj);
-void pdf_array_push_drop(pdf_obj *array, pdf_obj *obj);
-void pdf_array_insert(pdf_obj *array, pdf_obj *obj, int index);
-void pdf_array_insert_drop(pdf_obj *array, pdf_obj *obj, int index);
-void pdf_array_delete(pdf_obj *array, int index);
-int pdf_array_contains(pdf_obj *array, pdf_obj *obj);
-
-int pdf_dict_len(pdf_obj *dict);
-pdf_obj *pdf_dict_get_key(pdf_obj *dict, int idx);
-pdf_obj *pdf_dict_get_val(pdf_obj *dict, int idx);
-pdf_obj *pdf_dict_get(pdf_obj *dict, pdf_obj *key);
-pdf_obj *pdf_dict_gets(pdf_obj *dict, const char *key);
-pdf_obj *pdf_dict_getp(pdf_obj *dict, const char *key);
-pdf_obj *pdf_dict_getsa(pdf_obj *dict, const char *key, const char *abbrev);
-void pdf_dict_put(pdf_obj *dict, pdf_obj *key, pdf_obj *val);
-void pdf_dict_puts(pdf_obj *dict, const char *key, pdf_obj *val);
-void pdf_dict_puts_drop(pdf_obj *dict, const char *key, pdf_obj *val);
-void pdf_dict_putp(pdf_obj *dict, const char *key, pdf_obj *val);
-void pdf_dict_putp_drop(pdf_obj *dict, const char *key, pdf_obj *val);
-void pdf_dict_del(pdf_obj *dict, pdf_obj *key);
-void pdf_dict_dels(pdf_obj *dict, const char *key);
-void pdf_sort_dict(pdf_obj *dict);
+int pdf_to_bool(fz_context *ctx, pdf_obj *obj);
+int pdf_to_int(fz_context *ctx, pdf_obj *obj);
+float pdf_to_real(fz_context *ctx, pdf_obj *obj);
+char *pdf_to_name(fz_context *ctx, pdf_obj *obj);
+char *pdf_to_str_buf(fz_context *ctx, pdf_obj *obj);
+pdf_obj *pdf_to_dict(fz_context *ctx, pdf_obj *obj);
+int pdf_to_str_len(fz_context *ctx, pdf_obj *obj);
+int pdf_to_num(fz_context *ctx, pdf_obj *obj);
+int pdf_to_gen(fz_context *ctx, pdf_obj *obj);
+
+int pdf_array_len(fz_context *ctx, pdf_obj *array);
+pdf_obj *pdf_array_get(fz_context *ctx, pdf_obj *array, int i);
+void pdf_array_put(fz_context *ctx, pdf_obj *array, int i, pdf_obj *obj);
+void pdf_array_push(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
+void pdf_array_push_drop(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
+void pdf_array_insert(fz_context *ctx, pdf_obj *array, pdf_obj *obj, int index);
+void pdf_array_insert_drop(fz_context *ctx, pdf_obj *array, pdf_obj *obj, int index);
+void pdf_array_delete(fz_context *ctx, pdf_obj *array, int index);
+int pdf_array_contains(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
+
+int pdf_dict_len(fz_context *ctx, pdf_obj *dict);
+pdf_obj *pdf_dict_get_key(fz_context *ctx, pdf_obj *dict, int idx);
+pdf_obj *pdf_dict_get_val(fz_context *ctx, pdf_obj *dict, int idx);
+pdf_obj *pdf_dict_get(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
+pdf_obj *pdf_dict_gets(fz_context *ctx, pdf_obj *dict, const char *key);
+pdf_obj *pdf_dict_getp(fz_context *ctx, pdf_obj *dict, const char *key);
+pdf_obj *pdf_dict_getsa(fz_context *ctx, pdf_obj *dict, const char *key, const char *abbrev);
+void pdf_dict_put(fz_context *ctx, pdf_obj *dict, pdf_obj *key, pdf_obj *val);
+void pdf_dict_puts(fz_context *ctx, pdf_obj *dict, const char *key, pdf_obj *val);
+void pdf_dict_puts_drop(fz_context *ctx, pdf_obj *dict, const char *key, pdf_obj *val);
+void pdf_dict_putp(fz_context *ctx, pdf_obj *dict, const char *key, pdf_obj *val);
+void pdf_dict_putp_drop(fz_context *ctx, pdf_obj *dict, const char *key, pdf_obj *val);
+void pdf_dict_del(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
+void pdf_dict_dels(fz_context *ctx, pdf_obj *dict, const char *key);
+void pdf_sort_dict(fz_context *ctx, pdf_obj *dict);
/*
Recurse through the object structure setting the node's parent_num to num.
@@ -104,32 +104,32 @@ void pdf_sort_dict(pdf_obj *dict);
The whole containing hierarchy is moved to the incremental xref section, so
to be later written out as an incremental file update.
*/
-void pdf_set_obj_parent(pdf_obj *obj, int num);
+void pdf_set_obj_parent(fz_context *ctx, pdf_obj *obj, int num);
-int pdf_obj_refs(pdf_obj *ref);
+int pdf_obj_refs(fz_context *ctx, pdf_obj *ref);
-int pdf_obj_parent_num(pdf_obj *obj);
+int pdf_obj_parent_num(fz_context *ctx, pdf_obj *obj);
-int pdf_sprint_obj(char *s, int n, pdf_obj *obj, int tight);
-int pdf_fprint_obj(FILE *fp, pdf_obj *obj, int tight);
-int pdf_output_obj(fz_output *out, pdf_obj *obj, int tight);
+int pdf_sprint_obj(fz_context *ctx, char *s, int n, pdf_obj *obj, int tight);
+int pdf_fprint_obj(fz_context *ctx, FILE *fp, pdf_obj *obj, int tight);
+int pdf_output_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight);
#ifndef NDEBUG
-void pdf_print_obj(pdf_obj *obj);
-void pdf_print_ref(pdf_obj *obj);
+void pdf_print_obj(fz_context *ctx, pdf_obj *obj);
+void pdf_print_ref(fz_context *ctx, pdf_obj *obj);
#endif
-char *pdf_to_utf8(pdf_document *doc, pdf_obj *src);
-unsigned short *pdf_to_ucs2(pdf_document *doc, pdf_obj *src);
-pdf_obj *pdf_to_utf8_name(pdf_document *doc, pdf_obj *src);
-char *pdf_from_ucs2(pdf_document *doc, unsigned short *str);
-void pdf_to_ucs2_buf(unsigned short *buffer, pdf_obj *src);
+char *pdf_to_utf8(fz_context *ctx, pdf_document *doc, pdf_obj *src);
+unsigned short *pdf_to_ucs2(fz_context *ctx, pdf_document *doc, pdf_obj *src);
+pdf_obj *pdf_to_utf8_name(fz_context *ctx, pdf_document *doc, pdf_obj *src);
+char *pdf_from_ucs2(fz_context *ctx, pdf_document *doc, unsigned short *str);
+void pdf_to_ucs2_buf(fz_context *ctx, unsigned short *buffer, pdf_obj *src);
fz_rect *pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *rect);
fz_matrix *pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *mat);
-pdf_document *pdf_get_indirect_document(pdf_obj *obj);
-void pdf_set_str_len(pdf_obj *obj, int newlen);
-void pdf_set_int(pdf_obj *obj, int i);
+pdf_document *pdf_get_indirect_document(fz_context *ctx, pdf_obj *obj);
+void pdf_set_str_len(fz_context *ctx, pdf_obj *obj, int newlen);
+void pdf_set_int(fz_context *ctx, pdf_obj *obj, int i);
#endif
diff --git a/include/mupdf/pdf/output-pdf.h b/include/mupdf/pdf/output-pdf.h
index fe7e4b5a..c823b201 100644
--- a/include/mupdf/pdf/output-pdf.h
+++ b/include/mupdf/pdf/output-pdf.h
@@ -6,13 +6,13 @@
new pdf content. WARNING: this device is work in progress. It doesn't
currently support all rendering cases.
*/
-fz_device *pdf_new_pdf_device(pdf_document *doc, pdf_obj *contents, pdf_obj *resources, const fz_matrix *ctm);
+fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, pdf_obj *contents, pdf_obj *resources, const fz_matrix *ctm);
/*
pdf_write_document: Write out the document to a file with all changes finalised.
*/
-void pdf_write_document(pdf_document *doc, char *filename, fz_write_options *opts);
+void pdf_write_document(fz_context *ctx, pdf_document *doc, char *filename, fz_write_options *opts);
-void pdf_localise_page_resources(pdf_document *doc);
+void pdf_localise_page_resources(fz_context *ctx, pdf_document *doc);
#endif
diff --git a/include/mupdf/pdf/page.h b/include/mupdf/pdf/page.h
index c1b690b6..ab4a8ce3 100644
--- a/include/mupdf/pdf/page.h
+++ b/include/mupdf/pdf/page.h
@@ -1,9 +1,9 @@
#ifndef MUPDF_PDF_PAGE_H
#define MUPDF_PDF_PAGE_H
-int pdf_lookup_page_number(pdf_document *doc, pdf_obj *pageobj);
-int pdf_count_pages(pdf_document *doc);
-pdf_obj *pdf_lookup_page_obj(pdf_document *doc, int needle);
+int pdf_lookup_page_number(fz_context *ctx, pdf_document *doc, pdf_obj *pageobj);
+int pdf_count_pages(fz_context *ctx, pdf_document *doc);
+pdf_obj *pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle);
/*
pdf_load_page: Load a page and its resources.
@@ -15,9 +15,9 @@ pdf_obj *pdf_lookup_page_obj(pdf_document *doc, int needle);
number: page number, where 0 is the first page of the document.
*/
-pdf_page *pdf_load_page(pdf_document *doc, int number);
+pdf_page *pdf_load_page(fz_context *ctx, pdf_document *doc, int number);
-fz_link *pdf_load_links(pdf_document *doc, pdf_page *page);
+fz_link *pdf_load_links(fz_context *ctx, pdf_page *page);
/*
pdf_bound_page: Determine the size of a page.
@@ -29,14 +29,7 @@ fz_link *pdf_load_links(pdf_document *doc, pdf_page *page);
Does not throw exceptions.
*/
-fz_rect *pdf_bound_page(pdf_document *doc, pdf_page *page, fz_rect *);
-
-/*
- pdf_free_page: Frees a page and its resources.
-
- Does not throw exceptions.
-*/
-void pdf_free_page(pdf_document *doc, pdf_page *page);
+fz_rect *pdf_bound_page(fz_context *ctx, pdf_page *page, fz_rect *);
/*
pdf_run_page: Interpret a loaded page and render it on a device.
@@ -48,7 +41,7 @@ void pdf_free_page(pdf_document *doc, pdf_page *page);
ctm: A transformation matrix applied to the objects on the page,
e.g. to scale or rotate the page contents as desired.
*/
-void pdf_run_page(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
+void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
/*
pdf_run_page: Interpret a loaded page and render it on a device.
@@ -63,7 +56,7 @@ void pdf_run_page(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_ma
cookie: A pointer to an optional fz_cookie structure that can be used
to track progress, collect errors etc.
*/
-void pdf_run_page_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie);
+void pdf_run_page_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie);
/*
pdf_run_page_contents: Interpret a loaded page and render it on a device.
@@ -76,7 +69,7 @@ void pdf_run_page_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev,
ctm: A transformation matrix applied to the objects on the page,
e.g. to scale or rotate the page contents as desired.
*/
-void pdf_run_page_contents(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
+void pdf_run_page_contents(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
/*
pdf_clean_page_contents: Clean a loaded pages rendering operations.
@@ -92,12 +85,12 @@ void pdf_run_page_contents(pdf_document *doc, pdf_page *page, fz_device *dev, co
cookie: A pointer to an optional fz_cookie structure that can be used
to track progress, collect errors etc.
*/
-void pdf_clean_page_contents(pdf_document *doc, pdf_page *page, fz_cookie *cookie);
+void pdf_clean_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_cookie *cookie);
/*
Presentation interface.
*/
-fz_transition *pdf_page_presentation(pdf_document *doc, pdf_page *page, float *duration);
+fz_transition *pdf_page_presentation(fz_context *ctx, pdf_page *page, float *duration);
/*
* Page tree, pages and related objects
@@ -105,6 +98,9 @@ fz_transition *pdf_page_presentation(pdf_document *doc, pdf_page *page, float *d
struct pdf_page_s
{
+ fz_page super;
+ pdf_document *doc;
+
fz_matrix ctm; /* calculated from mediabox and rotate */
fz_rect mediabox;
int rotate;
diff --git a/include/mupdf/pdf/parse.h b/include/mupdf/pdf/parse.h
index 625ebfca..23584029 100644
--- a/include/mupdf/pdf/parse.h
+++ b/include/mupdf/pdf/parse.h
@@ -20,16 +20,16 @@ typedef enum
} pdf_token;
void pdf_lexbuf_init(fz_context *ctx, pdf_lexbuf *lexbuf, int size);
-void pdf_lexbuf_fin(pdf_lexbuf *lexbuf);
-ptrdiff_t pdf_lexbuf_grow(pdf_lexbuf *lexbuf);
+void pdf_lexbuf_fin(fz_context *ctx, pdf_lexbuf *lexbuf);
+ptrdiff_t pdf_lexbuf_grow(fz_context *ctx, pdf_lexbuf *lexbuf);
-pdf_token pdf_lex(fz_stream *f, pdf_lexbuf *lexbuf);
-pdf_token pdf_lex_no_string(fz_stream *f, pdf_lexbuf *lexbuf);
+pdf_token pdf_lex(fz_context *ctx, fz_stream *f, pdf_lexbuf *lexbuf);
+pdf_token pdf_lex_no_string(fz_context *ctx, fz_stream *f, pdf_lexbuf *lexbuf);
-pdf_obj *pdf_parse_array(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
-pdf_obj *pdf_parse_dict(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
-pdf_obj *pdf_parse_stm_obj(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
-pdf_obj *pdf_parse_ind_obj(pdf_document *doc, fz_stream *f, pdf_lexbuf *buf, int *num, int *gen, int *stm_ofs, int *try_repair);
+pdf_obj *pdf_parse_array(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
+pdf_obj *pdf_parse_dict(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
+pdf_obj *pdf_parse_stm_obj(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
+pdf_obj *pdf_parse_ind_obj(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf, int *num, int *gen, int *stm_ofs, int *try_repair);
/*
pdf_print_token: print a lexed token to a buffer, growing if necessary
diff --git a/include/mupdf/pdf/resource.h b/include/mupdf/pdf/resource.h
index 0b090705..fb542f59 100644
--- a/include/mupdf/pdf/resource.h
+++ b/include/mupdf/pdf/resource.h
@@ -5,24 +5,24 @@
* PDF interface to store
*/
void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, unsigned int itemsize);
-void *pdf_find_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key);
-void pdf_remove_item(fz_context *ctx, fz_store_free_fn *free, pdf_obj *key);
+void *pdf_find_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
+void pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
/*
* Functions, Colorspaces, Shadings and Images
*/
-fz_function *pdf_load_function(pdf_document *doc, pdf_obj *ref, int in, int out);
+fz_function *pdf_load_function(fz_context *ctx, pdf_document *doc, pdf_obj *ref, int in, int out);
-fz_colorspace *pdf_load_colorspace(pdf_document *doc, pdf_obj *obj);
-int pdf_is_tint_colorspace(fz_colorspace *cs);
+fz_colorspace *pdf_load_colorspace(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+int pdf_is_tint_colorspace(fz_context *ctx, fz_colorspace *cs);
-fz_shade *pdf_load_shading(pdf_document *doc, pdf_obj *obj);
+fz_shade *pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
-fz_image *pdf_load_inline_image(pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, fz_stream *file);
+fz_image *pdf_load_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, fz_stream *file);
int pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict);
-fz_image *pdf_load_image(pdf_document *doc, pdf_obj *obj);
+fz_image *pdf_load_image(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
/*
* Pattern
@@ -42,7 +42,7 @@ struct pdf_pattern_s
pdf_obj *contents;
};
-pdf_pattern *pdf_load_pattern(pdf_document *doc, pdf_obj *obj);
+pdf_pattern *pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
pdf_pattern *pdf_keep_pattern(fz_context *ctx, pdf_pattern *pat);
void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat);
@@ -67,12 +67,12 @@ struct pdf_xobject_s
int iteration;
};
-pdf_xobject *pdf_load_xobject(pdf_document *doc, pdf_obj *obj);
-pdf_obj *pdf_new_xobject(pdf_document *doc, const fz_rect *bbox, const fz_matrix *mat);
+pdf_xobject *pdf_load_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+pdf_obj *pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const fz_matrix *mat);
pdf_xobject *pdf_keep_xobject(fz_context *ctx, pdf_xobject *xobj);
void pdf_drop_xobject(fz_context *ctx, pdf_xobject *xobj);
-void pdf_update_xobject_contents(pdf_document *doc, pdf_xobject *form, fz_buffer *buffer);
+void pdf_update_xobject_contents(fz_context *ctx, pdf_document *doc, pdf_xobject *form, fz_buffer *buffer);
-void pdf_update_appearance(pdf_document *doc, pdf_annot *annot);
+void pdf_update_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
#endif
diff --git a/include/mupdf/pdf/widget.h b/include/mupdf/pdf/widget.h
index 9f2745cc..45441e55 100644
--- a/include/mupdf/pdf/widget.h
+++ b/include/mupdf/pdf/widget.h
@@ -37,22 +37,22 @@ enum
widget, e.g., to collect the text for a text widget, rather than
routing key strokes through pdf_pass_event.
*/
-pdf_widget *pdf_focused_widget(pdf_document *doc);
+pdf_widget *pdf_focused_widget(fz_context *ctx, pdf_document *doc);
/*
pdf_first_widget: get first widget when enumerating
*/
-pdf_widget *pdf_first_widget(pdf_document *doc, pdf_page *page);
+pdf_widget *pdf_first_widget(fz_context *ctx, pdf_document *doc, pdf_page *page);
/*
pdf_next_widget: get next widget when enumerating
*/
-pdf_widget *pdf_next_widget(pdf_widget *previous);
+pdf_widget *pdf_next_widget(fz_context *ctx, pdf_widget *previous);
/*
pdf_create_widget: create a new widget of a specific type
*/
-pdf_widget *pdf_create_widget(pdf_document *doc, pdf_page *page, int type, char *fieldname);
+pdf_widget *pdf_create_widget(fz_context *ctx, pdf_document *doc, pdf_page *page, int type, char *fieldname);
/*
pdf_widget_get_type: find out the type of a widget.
@@ -60,37 +60,37 @@ pdf_widget *pdf_create_widget(pdf_document *doc, pdf_page *page, int type, char
The type determines what widget subclass the widget
can safely be cast to.
*/
-int pdf_widget_get_type(pdf_widget *widget);
+int pdf_widget_get_type(fz_context *ctx, pdf_widget *widget);
/*
pdf_bound_widget: get the bounding box of a widget.
*/
-fz_rect *pdf_bound_widget(pdf_widget *widget, fz_rect *);
+fz_rect *pdf_bound_widget(fz_context *ctx, pdf_widget *widget, fz_rect *);
/*
pdf_text_widget_text: Get the text currently displayed in
a text widget.
*/
-char *pdf_text_widget_text(pdf_document *doc, pdf_widget *tw);
+char *pdf_text_widget_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
/*
pdf_widget_text_max_len: get the maximum number of
characters permitted in a text widget
*/
-int pdf_text_widget_max_len(pdf_document *doc, pdf_widget *tw);
+int pdf_text_widget_max_len(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
/*
pdf_text_widget_content_type: get the type of content
required by a text widget
*/
-int pdf_text_widget_content_type(pdf_document *doc, pdf_widget *tw);
+int pdf_text_widget_content_type(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
/*
pdf_text_widget_set_text: Update the text of a text widget.
The text is first validated and accepted only if it passes. The
function returns whether validation passed.
*/
-int pdf_text_widget_set_text(pdf_document *doc, pdf_widget *tw, char *text);
+int pdf_text_widget_set_text(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *text);
/*
pdf_choice_widget_options: get the list of options for a list
@@ -98,13 +98,13 @@ int pdf_text_widget_set_text(pdf_document *doc, pdf_widget *tw, char *text);
names within the supplied array. Should first be called with a
NULL array to find out how big the array should be.
*/
-int pdf_choice_widget_options(pdf_document *doc, pdf_widget *tw, char *opts[]);
+int pdf_choice_widget_options(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[]);
/*
pdf_choice_widget_is_multiselect: returns whether a list box or
combo box supports selection of multiple options
*/
-int pdf_choice_widget_is_multiselect(pdf_document *doc, pdf_widget *tw);
+int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_document *doc, pdf_widget *tw);
/*
pdf_choice_widget_value: get the value of a choice widget.
@@ -113,13 +113,13 @@ int pdf_choice_widget_is_multiselect(pdf_document *doc, pdf_widget *tw);
with NULL as the array to find out how big the array need to
be. The filled in elements should not be freed by the caller.
*/
-int pdf_choice_widget_value(pdf_document *doc, pdf_widget *tw, char *opts[]);
+int pdf_choice_widget_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, char *opts[]);
/*
pdf_widget_set_value: set the value of a choice widget. The
caller should pass the number of options selected and an
array of their names
*/
-void pdf_choice_widget_set_value(pdf_document *doc, pdf_widget *tw, int n, char *opts[]);
+void pdf_choice_widget_set_value(fz_context *ctx, pdf_document *doc, pdf_widget *tw, int n, char *opts[]);
#endif
diff --git a/include/mupdf/pdf/xref.h b/include/mupdf/pdf/xref.h
index 70826314..c41b0291 100644
--- a/include/mupdf/pdf/xref.h
+++ b/include/mupdf/pdf/xref.h
@@ -4,17 +4,17 @@
/*
pdf_create_object: Allocate a slot in the xref table and return a fresh unused object number.
*/
-int pdf_create_object(pdf_document *doc);
+int pdf_create_object(fz_context *ctx, pdf_document *doc);
/*
pdf_delete_object: Remove object from xref table, marking the slot as free.
*/
-void pdf_delete_object(pdf_document *doc, int num);
+void pdf_delete_object(fz_context *ctx, pdf_document *doc, int num);
/*
pdf_update_object: Replace object in xref table with the passed in object.
*/
-void pdf_update_object(pdf_document *doc, int num, pdf_obj *obj);
+void pdf_update_object(fz_context *ctx, pdf_document *doc, int num, pdf_obj *obj);
/*
pdf_update_stream: Replace stream contents for object in xref table with the passed in buffer.
@@ -24,7 +24,7 @@ void pdf_update_object(pdf_document *doc, int num, pdf_obj *obj);
the stream dictionary. If storing deflated data, make sure to set the
/Filter value to /FlateDecode.
*/
-void pdf_update_stream(pdf_document *doc, int num, fz_buffer *buf);
+void pdf_update_stream(fz_context *ctx, pdf_document *doc, int num, fz_buffer *buf);
/*
* xref and object / stream api
@@ -66,48 +66,48 @@ struct pdf_xref_s
pdf_obj *pre_repair_trailer;
};
-void pdf_cache_object(pdf_document *doc, int num, int gen);
+pdf_xref_entry *pdf_cache_object(fz_context *ctx, pdf_document *doc, int num, int gen);
-int pdf_count_objects(pdf_document *doc);
-pdf_obj *pdf_resolve_indirect(pdf_obj *ref);
-pdf_obj *pdf_load_object(pdf_document *doc, int num, int gen);
+int pdf_count_objects(fz_context *ctx, pdf_document *doc);
+pdf_obj *pdf_resolve_indirect(fz_context *ctx, pdf_obj *ref);
+pdf_obj *pdf_load_object(fz_context *ctx, pdf_document *doc, int num, int gen);
-fz_buffer *pdf_load_raw_stream(pdf_document *doc, int num, int gen);
-fz_buffer *pdf_load_stream(pdf_document *doc, int num, int gen);
-fz_stream *pdf_open_raw_stream(pdf_document *doc, int num, int gen);
-fz_stream *pdf_open_stream(pdf_document *doc, int num, int gen);
+fz_buffer *pdf_load_raw_stream(fz_context *ctx, pdf_document *doc, int num, int gen);
+fz_buffer *pdf_load_stream(fz_context *ctx, pdf_document *doc, int num, int gen);
+fz_stream *pdf_open_raw_stream(fz_context *ctx, pdf_document *doc, int num, int gen);
+fz_stream *pdf_open_stream(fz_context *ctx, pdf_document *doc, int num, int gen);
-fz_stream *pdf_open_inline_stream(pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *chain, fz_compression_params *params);
-fz_compressed_buffer *pdf_load_compressed_stream(pdf_document *doc, int num, int gen);
-void pdf_load_compressed_inline_image(pdf_document *doc, pdf_obj *dict, int length, fz_stream *cstm, int indexed, fz_image *image);
-fz_stream *pdf_open_stream_with_offset(pdf_document *doc, int num, int gen, pdf_obj *dict, int stm_ofs);
+fz_stream *pdf_open_inline_stream(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj, int length, fz_stream *chain, fz_compression_params *params);
+fz_compressed_buffer *pdf_load_compressed_stream(fz_context *ctx, pdf_document *doc, int num, int gen);
+void pdf_load_compressed_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int length, fz_stream *cstm, int indexed, fz_image *image);
+fz_stream *pdf_open_stream_with_offset(fz_context *ctx, pdf_document *doc, int num, int gen, pdf_obj *dict, int stm_ofs);
fz_stream *pdf_open_compressed_stream(fz_context *ctx, fz_compressed_buffer *);
-fz_stream *pdf_open_contents_stream(pdf_document *doc, pdf_obj *obj);
-fz_buffer *pdf_load_raw_renumbered_stream(pdf_document *doc, int num, int gen, int orig_num, int orig_gen);
-fz_buffer *pdf_load_renumbered_stream(pdf_document *doc, int num, int gen, int orig_num, int orig_gen, int *truncated);
-fz_stream *pdf_open_raw_renumbered_stream(pdf_document *doc, int num, int gen, int orig_num, int orig_gen);
-
-pdf_obj *pdf_trailer(pdf_document *doc);
-void pdf_set_populating_xref_trailer(pdf_document *doc, pdf_obj *trailer);
-int pdf_xref_len(pdf_document *doc);
-pdf_xref_entry *pdf_get_populating_xref_entry(pdf_document *doc, int i);
-pdf_xref_entry *pdf_get_xref_entry(pdf_document *doc, int i);
-void pdf_replace_xref(pdf_document *doc, pdf_xref_entry *entries, int n);
-void pdf_xref_ensure_incremental_object(pdf_document *doc, int num);
-int pdf_xref_is_incremental(pdf_document *doc, int num);
-
-void pdf_repair_xref(pdf_document *doc, pdf_lexbuf *buf);
-void pdf_repair_obj_stms(pdf_document *doc);
-pdf_obj *pdf_new_ref(pdf_document *doc, pdf_obj *obj);
-void pdf_ensure_solid_xref(pdf_document *doc, int num);
-void pdf_mark_xref(pdf_document *doc);
-void pdf_clear_xref(pdf_document *doc);
-void pdf_clear_xref_to_mark(pdf_document *doc);
-
-int pdf_repair_obj(pdf_document *doc, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, pdf_obj **encrypt, pdf_obj **id, pdf_obj **page, int *tmpofs);
-
-pdf_obj *pdf_progressive_advance(pdf_document *doc, int pagenum);
-
-void pdf_print_xref(pdf_document *);
+fz_stream *pdf_open_contents_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+fz_buffer *pdf_load_raw_renumbered_stream(fz_context *ctx, pdf_document *doc, int num, int gen, int orig_num, int orig_gen);
+fz_buffer *pdf_load_renumbered_stream(fz_context *ctx, pdf_document *doc, int num, int gen, int orig_num, int orig_gen, int *truncated);
+fz_stream *pdf_open_raw_renumbered_stream(fz_context *ctx, pdf_document *doc, int num, int gen, int orig_num, int orig_gen);
+
+pdf_obj *pdf_trailer(fz_context *ctx, pdf_document *doc);
+void pdf_set_populating_xref_trailer(fz_context *ctx, pdf_document *doc, pdf_obj *trailer);
+int pdf_xref_len(fz_context *ctx, pdf_document *doc);
+pdf_xref_entry *pdf_get_populating_xref_entry(fz_context *ctx, pdf_document *doc, int i);
+pdf_xref_entry *pdf_get_xref_entry(fz_context *ctx, pdf_document *doc, int i);
+void pdf_replace_xref(fz_context *ctx, pdf_document *doc, pdf_xref_entry *entries, int n);
+void pdf_xref_ensure_incremental_object(fz_context *ctx, pdf_document *doc, int num);
+int pdf_xref_is_incremental(fz_context *ctx, pdf_document *doc, int num);
+
+void pdf_repair_xref(fz_context *ctx, pdf_document *doc);
+void pdf_repair_obj_stms(fz_context *ctx, pdf_document *doc);
+pdf_obj *pdf_new_ref(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
+void pdf_ensure_solid_xref(fz_context *ctx, pdf_document *doc, int num);
+void pdf_mark_xref(fz_context *ctx, pdf_document *doc);
+void pdf_clear_xref(fz_context *ctx, pdf_document *doc);
+void pdf_clear_xref_to_mark(fz_context *ctx, pdf_document *doc);
+
+int pdf_repair_obj(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf, int *stmofsp, int *stmlenp, pdf_obj **encrypt, pdf_obj **id, pdf_obj **page, int *tmpofs);
+
+pdf_obj *pdf_progressive_advance(fz_context *ctx, pdf_document *doc, int pagenum);
+
+void pdf_print_xref(fz_context *ctx, pdf_document *);
#endif
diff --git a/include/mupdf/tiff.h b/include/mupdf/tiff.h
deleted file mode 100644
index 1304e4b2..00000000
--- a/include/mupdf/tiff.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef MUPDF_TIFF_H
-#define MUPDF_TIFF_H
-
-#include "mupdf/fitz.h"
-
-typedef struct tiff_document_s tiff_document;
-typedef struct tiff_page_s tiff_page;
-
-/*
- tiff_open_document: Open a document.
-
- Open a document for reading so the library is able to locate
- objects and pages inside the file.
-
- The returned tiff_document should be used when calling most
- other functions. Note that it wraps the context, so those
- functions implicitly get access to the global state in
- context.
-
- filename: a path to a file as it would be given to open(2).
-*/
-tiff_document *tiff_open_document(fz_context *ctx, const char *filename);
-
-/*
- tiff_open_document_with_stream: Opens a document.
-
- Same as tiff_open_document, but takes a stream instead of a
- filename to locate the document to open. Increments the
- reference count of the stream. See fz_open_file,
- fz_open_file_w or fz_open_fd for opening a stream, and
- fz_close for closing an open stream.
-*/
-tiff_document *tiff_open_document_with_stream(fz_context *ctx, fz_stream *file);
-
-/*
- tiff_close_document: Closes and frees an opened document.
-
- The resource store in the context associated with tiff_document
- is emptied.
-
- Does not throw exceptions.
-*/
-void tiff_close_document(tiff_document *doc);
-
-int tiff_count_pages(tiff_document *doc);
-tiff_page *tiff_load_page(tiff_document *doc, int number);
-fz_rect *tiff_bound_page(tiff_document *doc, tiff_page *page, fz_rect *rect);
-void tiff_free_page(tiff_document *doc, tiff_page *page);
-void tiff_run_page(tiff_document *doc, tiff_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
-
-#endif
diff --git a/include/mupdf/xps.h b/include/mupdf/xps.h
index 48574931..13c8eea0 100644
--- a/include/mupdf/xps.h
+++ b/include/mupdf/xps.h
@@ -28,7 +28,7 @@ xps_document *xps_open_document(fz_context *ctx, const char *filename);
filename to locate the document to open. Increments the
reference count of the stream. See fz_open_file,
fz_open_file_w or fz_open_fd for opening a stream, and
- fz_close for closing an open stream.
+ fz_drop_stream for closing an open stream.
*/
xps_document *xps_open_document_with_stream(fz_context *ctx, fz_stream *file);
@@ -40,16 +40,12 @@ xps_document *xps_open_document_with_stream(fz_context *ctx, fz_stream *file);
Does not throw exceptions.
*/
-void xps_close_document(xps_document *doc);
+void xps_close_document(fz_context *ctx, xps_document *doc);
-int xps_count_pages(xps_document *doc);
-xps_page *xps_load_page(xps_document *doc, int number);
-fz_rect *xps_bound_page(xps_document *doc, xps_page *page, fz_rect *rect);
-void xps_run_page(xps_document *doc, xps_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
-fz_link *xps_load_links(xps_document *doc, xps_page *page);
-void xps_free_page(xps_document *doc, xps_page *page);
-
-fz_outline *xps_load_outline(xps_document *doc);
+int xps_count_pages(fz_context *ctx, xps_document *doc);
+xps_page *xps_load_page(fz_context *ctx, xps_document *doc, int number);
+fz_outline *xps_load_outline(fz_context *ctx, xps_document *doc);
+void xps_run_page(fz_context *ctx, xps_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
/* xps-internal.h */
@@ -58,9 +54,9 @@ fz_outline *xps_load_outline(xps_document *doc);
*/
int xps_strcasecmp(char *a, char *b);
-void xps_resolve_url(char *output, char *base_uri, char *path, int output_size);
-int xps_url_is_remote(char *path);
-char *xps_parse_point(char *s_in, float *x, float *y);
+void xps_resolve_url(fz_context *ctx, xps_document *doc, char *output, char *base_uri, char *path, int output_size);
+int xps_url_is_remote(fz_context *ctx, xps_document *doc, char *path);
+char *xps_parse_point(fz_context *ctx, xps_document *doc, char *s_in, float *x, float *y);
/*
* Container parts.
@@ -75,15 +71,16 @@ struct xps_part_s
unsigned char *data;
};
-int xps_has_part(xps_document *doc, char *partname);
-xps_part *xps_read_part(xps_document *doc, char *partname);
-void xps_free_part(xps_document *doc, xps_part *part);
+int xps_has_part(fz_context *ctx, xps_document *doc, char *partname);
+xps_part *xps_read_part(fz_context *ctx, xps_document *doc, char *partname);
+void xps_drop_part(fz_context *ctx, xps_document *doc, xps_part *part);
/*
* Document structure.
*/
typedef struct xps_fixdoc_s xps_fixdoc;
+typedef struct xps_fixpage_s xps_fixpage;
typedef struct xps_target_s xps_target;
struct xps_fixdoc_s
@@ -93,16 +90,23 @@ struct xps_fixdoc_s
xps_fixdoc *next;
};
-struct xps_page_s
+struct xps_fixpage_s
{
char *name;
int number;
int width;
int height;
- fz_xml *root;
int links_resolved;
fz_link *links;
- xps_page *next;
+ xps_fixpage *next;
+};
+
+struct xps_page_s
+{
+ fz_page super;
+ xps_document *doc;
+ xps_fixpage *fix;
+ fz_xml *root;
};
struct xps_target_s
@@ -112,12 +116,12 @@ struct xps_target_s
xps_target *next;
};
-void xps_read_page_list(xps_document *doc);
-void xps_print_page_list(xps_document *doc);
-void xps_free_page_list(xps_document *doc);
+void xps_read_page_list(fz_context *ctx, xps_document *doc);
+void xps_print_page_list(fz_context *ctx, xps_document *doc);
+void xps_drop_page_list(fz_context *ctx, xps_document *doc);
-int xps_lookup_link_target(xps_document *doc, char *target_uri);
-void xps_add_link(xps_document *doc, const fz_rect *area, char *base_uri, char *target_uri);
+int xps_lookup_link_target(fz_context *ctx, xps_document *doc, char *target_uri);
+void xps_add_link(fz_context *ctx, xps_document *doc, const fz_rect *area, char *base_uri, char *target_uri);
/*
* Images, fonts, and colorspaces.
@@ -144,12 +148,12 @@ void xps_identify_font_encoding(fz_font *font, int idx, int *pid, int *eid);
void xps_select_font_encoding(fz_font *font, int idx);
int xps_encode_font_char(fz_font *font, int key);
-void xps_measure_font_glyph(xps_document *doc, fz_font *font, int gid, xps_glyph_metrics *mtx);
+void xps_measure_font_glyph(fz_context *ctx, xps_document *doc, fz_font *font, int gid, xps_glyph_metrics *mtx);
-void xps_print_path(xps_document *doc);
+void xps_print_path(fz_context *ctx, xps_document *doc);
-void xps_parse_color(xps_document *doc, char *base_uri, char *hexstring, fz_colorspace **csp, float *samples);
-void xps_set_color(xps_document *doc, fz_colorspace *colorspace, float *samples);
+void xps_parse_color(fz_context *ctx, xps_document *doc, char *base_uri, char *hexstring, fz_colorspace **csp, float *samples);
+void xps_set_color(fz_context *ctx, xps_document *doc, fz_colorspace *colorspace, float *samples);
/*
* Resource dictionaries.
@@ -167,41 +171,41 @@ struct xps_resource_s
xps_resource *parent; /* up to the previous dict in the stack */
};
-xps_resource * xps_parse_resource_dictionary(xps_document *doc, char *base_uri, fz_xml *root);
-void xps_free_resource_dictionary(xps_document *doc, xps_resource *dict);
-void xps_resolve_resource_reference(xps_document *doc, xps_resource *dict, char **attp, fz_xml **tagp, char **urip);
+xps_resource * xps_parse_resource_dictionary(fz_context *ctx, xps_document *doc, char *base_uri, fz_xml *root);
+void xps_drop_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *dict);
+void xps_resolve_resource_reference(fz_context *ctx, xps_document *doc, xps_resource *dict, char **attp, fz_xml **tagp, char **urip);
-void xps_print_resource_dictionary(xps_resource *dict);
+void xps_print_resource_dictionary(fz_context *ctx, xps_document *doc, xps_resource *dict);
/*
* Fixed page/graphics parsing.
*/
-void xps_parse_fixed_page(xps_document *doc, const fz_matrix *ctm, xps_page *page);
-void xps_parse_canvas(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_path(xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_glyphs(xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_solid_color_brush(xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_image_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_visual_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_linear_gradient_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_radial_gradient_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_fixed_page(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_page *page);
+void xps_parse_canvas(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_path(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_glyphs(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_solid_color_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_image_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_visual_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_linear_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_radial_gradient_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_tiling_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *root, void(*func)(xps_document*, const fz_matrix *, const fz_rect *, char*, xps_resource*, fz_xml*, void*), void *user);
+void xps_parse_tiling_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *root, void(*func)(fz_context *ctx, xps_document*, const fz_matrix *, const fz_rect *, char*, xps_resource*, fz_xml*, void*), void *user);
-void xps_parse_matrix_transform(xps_document *doc, fz_xml *root, fz_matrix *matrix);
-void xps_parse_render_transform(xps_document *doc, char *text, fz_matrix *matrix);
-void xps_parse_rectangle(xps_document *doc, char *text, fz_rect *rect);
+void xps_parse_matrix_transform(fz_context *ctx, xps_document *doc, fz_xml *root, fz_matrix *matrix);
+void xps_parse_render_transform(fz_context *ctx, xps_document *doc, char *text, fz_matrix *matrix);
+void xps_parse_rectangle(fz_context *ctx, xps_document *doc, char *text, fz_rect *rect);
-void xps_begin_opacity(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
-void xps_end_opacity(xps_document *doc, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
+void xps_begin_opacity(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
+void xps_end_opacity(fz_context *ctx, xps_document *doc, char *base_uri, xps_resource *dict, char *opacity_att, fz_xml *opacity_mask_tag);
-void xps_parse_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_parse_element(xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_brush(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
+void xps_parse_element(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, const fz_rect *area, char *base_uri, xps_resource *dict, fz_xml *node);
-void xps_clip(xps_document *doc, const fz_matrix *ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag);
+void xps_clip(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, xps_resource *dict, char *clip_att, fz_xml *clip_tag);
-fz_xml *xps_lookup_alternate_content(fz_xml *node);
+fz_xml *xps_lookup_alternate_content(fz_context *ctx, xps_document *doc, fz_xml *node);
/*
* The interpreter context.
@@ -220,14 +224,13 @@ struct xps_entry_s
struct xps_document_s
{
fz_document super;
- fz_context *ctx;
fz_archive *zip;
char *start_part; /* fixed document sequence */
xps_fixdoc *first_fixdoc; /* first fixed document */
xps_fixdoc *last_fixdoc; /* last fixed document */
- xps_page *first_page; /* first page of document */
- xps_page *last_page; /* last page of document */
+ xps_fixpage *first_page; /* first page of document */
+ xps_fixpage *last_page; /* last page of document */
int page_count;
xps_target *target; /* link targets */
@@ -248,11 +251,11 @@ struct xps_document_s
float alpha;
/* Current device */
- fz_cookie *cookie;
fz_device *dev;
+ fz_cookie *cookie;
/* Current page we are loading */
- xps_page *current_page;
+ xps_fixpage *current_page;
};
#endif