From fc5bcdc79a12fb01b6cd07aa142c01ef11430b34 Mon Sep 17 00:00:00 2001 From: Robin Watts <robin.watts@artifex.com> Date: Fri, 13 Dec 2013 16:54:29 +0000 Subject: 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. --- source/fitz/device.c | 10 ++++++++++ source/fitz/document.c | 7 +++++++ source/fitz/svg-device.c | 10 ++++++++++ 3 files changed, 27 insertions(+) (limited to 'source/fitz') 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 @@ -35,6 +35,16 @@ fz_disable_device_hints(fz_device *dev, int hints) dev->hints &= ~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) { 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; -- cgit v1.2.3