summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-07-08 12:04:35 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-07-08 17:21:24 +0200
commit10d6eaa73164b58c91ae8a4537b8a8589038a01d (patch)
tree5b739b0c2202b42a9079ee3ecbd98c3d3b09b124 /include/mupdf/fitz
parentb53e7a42f7cc9756ed9fa1fed313271e3ae67855 (diff)
downloadmupdf-10d6eaa73164b58c91ae8a4537b8a8589038a01d.tar.xz
Separate close and drop functionality for devices and writers.
Closing a device or writer may throw exceptions, but much of the foreign language bindings (JNI and JS) depend on drop to never throw an exception (exceptions in finalizers are bad).
Diffstat (limited to 'include/mupdf/fitz')
-rw-r--r--include/mupdf/fitz/device.h9
-rw-r--r--include/mupdf/fitz/document.h12
-rw-r--r--include/mupdf/fitz/unzip.h1
-rw-r--r--include/mupdf/fitz/writer.h3
4 files changed, 14 insertions, 11 deletions
diff --git a/include/mupdf/fitz/device.h b/include/mupdf/fitz/device.h
index 172081fe..57e61ad0 100644
--- a/include/mupdf/fitz/device.h
+++ b/include/mupdf/fitz/device.h
@@ -102,7 +102,8 @@ struct fz_device_s
int hints;
int flags;
- void (*close)(fz_context *, fz_device *);
+ void (*close_device)(fz_context *, fz_device *);
+ void (*drop_device)(fz_context *, fz_device *);
void (*fill_path)(fz_context *, fz_device *, const fz_path *, int even_odd, const fz_matrix *, fz_colorspace *, const float *color, float alpha);
void (*stroke_path)(fz_context *, fz_device *, const fz_path *, const fz_stroke_state *, const fz_matrix *, fz_colorspace *, const float *color, float alpha);
@@ -168,14 +169,14 @@ void fz_render_flags(fz_context *ctx, fz_device *dev, int set, int clear);
void *fz_new_device(fz_context *ctx, int size);
/*
- fz_close_device: Flush any pending output and free internal memory.
- This is called implicitly on fz_drop_device, so it's only useful for
- garbage collected language bindings.
+ fz_close_device: Signal the end of input, and flush any buffered output.
+ This is NOT called implicitly on fz_drop_device.
*/
void fz_close_device(fz_context *ctx, fz_device *dev);
/*
fz_drop_device: Free a devices of any type and its resources.
+ Don't forget to call fz_close_device before dropping the device, or you may get incomplete output!
*/
void fz_drop_device(fz_context *ctx, fz_device *dev);
diff --git a/include/mupdf/fitz/document.h b/include/mupdf/fitz/document.h
index 889b66b1..f1a4a74f 100644
--- a/include/mupdf/fitz/document.h
+++ b/include/mupdf/fitz/document.h
@@ -26,7 +26,7 @@ typedef enum
}
fz_permission;
-typedef void (fz_document_close_fn)(fz_context *ctx, fz_document *doc);
+typedef void (fz_document_drop_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 int (fz_document_has_permission_fn)(fz_context *ctx, fz_document *doc, fz_permission permission);
@@ -39,7 +39,7 @@ typedef int (fz_document_lookup_metadata_fn)(fz_context *ctx, fz_document *doc,
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 void (fz_page_drop_page_fn)(fz_context *ctx, fz_page *page);
typedef fz_transition *(fz_page_page_presentation_fn)(fz_context *ctx, fz_page *page, fz_transition *transition, float *duration);
typedef fz_annot *(fz_page_first_annot_fn)(fz_context *ctx, fz_page *page);
@@ -49,7 +49,7 @@ typedef int (fz_page_separation_disabled_fn)(fz_context *ctx, fz_page *page, int
typedef int (fz_page_count_separations_fn)(fz_context *ctx, fz_page *page);
typedef const char *(fz_page_get_separation_fn)(fz_context *ctx, fz_page *page, int separation, uint32_t *rgb, uint32_t *cmyk);
-typedef void (fz_annot_drop_imp_fn)(fz_context *ctx, fz_annot *annot);
+typedef void (fz_annot_drop_fn)(fz_context *ctx, fz_annot *annot);
typedef fz_annot *(fz_annot_next_fn)(fz_context *ctx, fz_annot *annot);
typedef fz_rect *(fz_annot_bound_fn)(fz_context *ctx, fz_annot *annot, fz_rect *rect);
typedef void (fz_annot_run_fn)(fz_context *ctx, fz_annot *annot, fz_device *dev, const fz_matrix *transform, fz_cookie *cookie);
@@ -57,7 +57,7 @@ typedef void (fz_annot_run_fn)(fz_context *ctx, fz_annot *annot, fz_device *dev,
struct fz_annot_s
{
int refs;
- fz_annot_drop_imp_fn *drop_annot_imp;
+ fz_annot_drop_fn *drop_annot;
fz_annot_bound_fn *bound_annot;
fz_annot_run_fn *run_annot;
fz_annot_next_fn *next_annot;
@@ -66,7 +66,7 @@ struct fz_annot_s
struct fz_page_s
{
int refs;
- fz_page_drop_page_imp_fn *drop_page_imp;
+ fz_page_drop_page_fn *drop_page;
fz_page_bound_page_fn *bound_page;
fz_page_run_page_contents_fn *run_page_contents;
fz_page_load_links_fn *load_links;
@@ -81,7 +81,7 @@ struct fz_page_s
struct fz_document_s
{
int refs;
- fz_document_close_fn *close;
+ fz_document_drop_fn *drop_document;
fz_document_needs_password_fn *needs_password;
fz_document_authenticate_password_fn *authenticate_password;
fz_document_has_permission_fn *has_permission;
diff --git a/include/mupdf/fitz/unzip.h b/include/mupdf/fitz/unzip.h
index 64b2b94b..c6295b90 100644
--- a/include/mupdf/fitz/unzip.h
+++ b/include/mupdf/fitz/unzip.h
@@ -23,6 +23,7 @@ typedef struct fz_zip_writer_s fz_zip_writer;
fz_zip_writer *fz_new_zip_writer(fz_context *ctx, const char *filename);
void fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buffer *buf, int compress);
+void fz_close_zip_writer(fz_context *ctx, fz_zip_writer *zip);
void fz_drop_zip_writer(fz_context *ctx, fz_zip_writer *zip);
#endif
diff --git a/include/mupdf/fitz/writer.h b/include/mupdf/fitz/writer.h
index 6f0f47be..069cc7a5 100644
--- a/include/mupdf/fitz/writer.h
+++ b/include/mupdf/fitz/writer.h
@@ -13,7 +13,8 @@ struct fz_document_writer_s
{
fz_device *(*begin_page)(fz_context *ctx, fz_document_writer *wri, const fz_rect *mediabox);
void (*end_page)(fz_context *ctx, fz_document_writer *wri, fz_device *dev);
- void (*close)(fz_context *ctx, fz_document_writer *wri);
+ void (*close_writer)(fz_context *ctx, fz_document_writer *wri);
+ void (*drop_writer)(fz_context *ctx, fz_document_writer *wri);
};
int fz_has_option(fz_context *ctx, const char *opts, const char *key, const char **val);