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/pdf | |
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/pdf')
-rw-r--r-- | source/pdf/pdf-device.c | 9 | ||||
-rw-r--r-- | source/pdf/pdf-xref.c | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index 39c19627..633d9975 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -1277,6 +1277,14 @@ pdf_dev_free_user(fz_device *dev) fz_free(ctx, pdev); } +static void +pdf_dev_rebind(fz_device *dev) +{ + pdf_device *pdev = dev->user; + + fz_rebind_document((fz_document *)pdev->doc, dev->ctx); +} + fz_device *pdf_new_pdf_device(pdf_document *doc, pdf_obj *contents, pdf_obj *resources, const fz_matrix *ctm) { fz_context *ctx = doc->ctx; @@ -1313,6 +1321,7 @@ fz_device *pdf_new_pdf_device(pdf_document *doc, pdf_obj *contents, pdf_obj *res fz_rethrow(ctx); } + dev->rebind = pdf_dev_rebind; dev->free_user = pdf_dev_free_user; dev->fill_path = pdf_dev_fill_path; diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index a71dc1cf..523dd1f3 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -1941,6 +1941,13 @@ pdf_page_presentation(pdf_document *doc, pdf_page *page, float *duration) return &page->transition; } +static void +pdf_rebind(pdf_document *doc, fz_context *ctx) +{ + doc->ctx = ctx; + fz_rebind_stream(doc->file, ctx); +} + /* Initializers for the fz_document interface. @@ -1973,6 +1980,7 @@ pdf_new_document(fz_context *ctx, fz_stream *file) doc->super.meta = (void*)pdf_meta; doc->super.page_presentation = (void*)pdf_page_presentation; doc->super.write = (void*)pdf_write_document; + doc->super.rebind = (void*)pdf_rebind; pdf_lexbuf_init(ctx, &doc->lexbuf.base, PDF_LEXBUF_LARGE); doc->file = fz_keep_stream(file); |