diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-12-13 16:54:29 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-01-02 20:04:44 +0000 |
commit | fc5bcdc79a12fb01b6cd07aa142c01ef11430b34 (patch) | |
tree | 547ed060a16453df001ffcb34657de46418872ff /source/fitz | |
parent | 651f13408c67a8392ad93adda079c096d8a6118c (diff) | |
download | mupdf-fc5bcdc79a12fb01b6cd07aa142c01ef11430b34.tar.xz |
Add rebinding for fz_devices and fz_documents
The SVG device needs rebinding as it holds a file. The PDF device needs
to rebind the underlying pdf document.
All documents need to rebind their underlying streams.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/device.c | 10 | ||||
-rw-r--r-- | source/fitz/document.c | 7 | ||||
-rw-r--r-- | source/fitz/svg-device.c | 10 |
3 files changed, 27 insertions, 0 deletions
diff --git a/source/fitz/device.c b/source/fitz/device.c index fa428764..d9249732 100644 --- a/source/fitz/device.c +++ b/source/fitz/device.c @@ -36,6 +36,16 @@ fz_disable_device_hints(fz_device *dev, int hints) } void +fz_rebind_device(fz_device *dev, fz_context *ctx) +{ + if (dev == NULL) + return; + dev->ctx = ctx; + if (dev->rebind) + dev->rebind(dev); +} + +void fz_begin_page(fz_device *dev, const fz_rect *rect, const fz_matrix *ctm) { if (dev->begin_page) diff --git a/source/fitz/document.c b/source/fitz/document.c index 3926255b..a86c2f6e 100644 --- a/source/fitz/document.c +++ b/source/fitz/document.c @@ -102,6 +102,13 @@ fz_close_document(fz_document *doc) doc->close(doc); } +void +fz_rebind_document(fz_document *doc, fz_context *ctx) +{ + if (doc != NULL && doc->rebind != NULL) + doc->rebind(doc, ctx); +} + int fz_needs_password(fz_document *doc) { diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index dd5a2e19..dc248f88 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -1027,6 +1027,15 @@ svg_dev_free_user(fz_device *dev) fz_free(ctx, sdev); } +void svg_rebind(fz_device *dev) +{ + svg_device *sdev = dev->user; + + sdev->ctx = dev->ctx; + fz_rebind_output(sdev->out, sdev->ctx); + fz_rebind_output(sdev->out_store, sdev->ctx); +} + fz_device *fz_new_svg_device(fz_context *ctx, fz_output *out, float page_width, float page_height) { svg_device *sdev = fz_malloc_struct(ctx, svg_device); @@ -1047,6 +1056,7 @@ fz_device *fz_new_svg_device(fz_context *ctx, fz_output *out, float page_width, fz_rethrow(ctx); } + dev->rebind = svg_rebind; dev->free_user = svg_dev_free_user; dev->fill_path = svg_dev_fill_path; |