diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-01-21 16:42:45 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-02-17 18:05:39 +0100 |
commit | f84a189d5f94250e46d2cbd1a75aba00130e2dd6 (patch) | |
tree | 8ee614ab90de1baa8941f91ae4946ed5c2e70721 /source/pdf/pdf-run.c | |
parent | 681039767f2ccc72e236246178893eb0989169c9 (diff) | |
download | mupdf-f84a189d5f94250e46d2cbd1a75aba00130e2dd6.tar.xz |
Add ctx parameter and remove embedded contexts for API regularity.
Purge several embedded contexts:
Remove embedded context in fz_output.
Remove embedded context in fz_stream.
Remove embedded context in fz_device.
Remove fz_rebind_stream (since it is no longer necessary).
Remove embedded context in svg_device.
Remove embedded context in XML parser.
Add ctx argument to fz_document functions.
Remove embedded context in fz_document.
Remove embedded context in pdf_document.
Remove embedded context in pdf_obj.
Make fz_page independent of fz_document in the interface.
We shouldn't need to pass the document to all functions handling a page.
If a page is tied to the source document, it's redundant; otherwise it's
just pointless.
Fix reference counting oddity in fz_new_image_from_pixmap.
Diffstat (limited to 'source/pdf/pdf-run.c')
-rw-r--r-- | source/pdf/pdf-run.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/source/pdf/pdf-run.c b/source/pdf/pdf-run.c index d52d8282..e6f3d5b9 100644 --- a/source/pdf/pdf-run.c +++ b/source/pdf/pdf-run.c @@ -1,19 +1,19 @@ #include "pdf-interpret-imp.h" static void -pdf_run_annot_with_usage(pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) +pdf_run_annot_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) { fz_matrix local_ctm; pdf_process process; fz_concat(&local_ctm, &page->ctm, ctm); - pdf_process_run(&process, dev, &local_ctm, event, NULL, 0); + pdf_init_process_run(ctx, &process, dev, &local_ctm, event, NULL, 0); - pdf_process_annot(doc, page, annot, &process, cookie); + pdf_process_annot(ctx, doc, page, annot, &process, cookie); } -static void pdf_run_page_contents_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) +static void pdf_run_page_contents_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) { fz_matrix local_ctm; pdf_process process; @@ -23,67 +23,70 @@ static void pdf_run_page_contents_with_usage(pdf_document *doc, pdf_page *page, if (page->transparency) { fz_rect mediabox = page->mediabox; - fz_begin_group(dev, fz_transform_rect(&mediabox, &local_ctm), 1, 0, 0, 1); + fz_begin_group(ctx, dev, fz_transform_rect(&mediabox, &local_ctm), 1, 0, 0, 1); } - pdf_process_run(&process, dev, &local_ctm, event, NULL, 0); + pdf_init_process_run(ctx, &process, dev, &local_ctm, event, NULL, 0); - pdf_process_stream_object(doc, page->contents, &process, page->resources, cookie); + pdf_process_stream_object(ctx, doc, page->contents, &process, page->resources, cookie); if (page->transparency) - fz_end_group(dev); + fz_end_group(ctx, dev); } -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) { - fz_context *ctx = doc->ctx; - int nocache = !!(dev->hints & FZ_NO_CACHE); + pdf_document *doc = page->doc; + int nocache; + nocache = !!(dev->hints & FZ_NO_CACHE); if (nocache) - pdf_mark_xref(doc); + pdf_mark_xref(ctx, doc); + fz_try(ctx) { - pdf_run_page_contents_with_usage(doc, page, dev, ctm, "View", cookie); + pdf_run_page_contents_with_usage(ctx, doc, page, dev, ctm, "View", cookie); } fz_always(ctx) { if (nocache) - pdf_clear_xref_to_mark(doc); + pdf_clear_xref_to_mark(ctx, doc); } fz_catch(ctx) { fz_rethrow(ctx); } if (page->incomplete & PDF_PAGE_INCOMPLETE_CONTENTS) - fz_throw(doc->ctx, FZ_ERROR_TRYLATER, "incomplete rendering"); + fz_throw(ctx, FZ_ERROR_TRYLATER, "incomplete rendering"); } -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) { - fz_context *ctx = doc->ctx; - int nocache = !!(dev->hints & FZ_NO_CACHE); + pdf_document *doc = page->doc; + int nocache; + nocache = !!(dev->hints & FZ_NO_CACHE); if (nocache) - pdf_mark_xref(doc); + pdf_mark_xref(ctx, doc); fz_try(ctx) { - pdf_run_annot_with_usage(doc, page, annot, dev, ctm, "View", cookie); + pdf_run_annot_with_usage(ctx, doc, page, annot, dev, ctm, "View", cookie); } fz_always(ctx) { if (nocache) - pdf_clear_xref_to_mark(doc); + pdf_clear_xref_to_mark(ctx, doc); } fz_catch(ctx) { fz_rethrow(ctx); } if (page->incomplete & PDF_PAGE_INCOMPLETE_ANNOTS) - fz_throw(doc->ctx, FZ_ERROR_TRYLATER, "incomplete rendering"); + fz_throw(ctx, FZ_ERROR_TRYLATER, "incomplete rendering"); } -static void pdf_run_page_annots_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) +static void pdf_run_page_annots_with_usage(fz_context *ctx, pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) { pdf_annot *annot; @@ -105,52 +108,51 @@ static void pdf_run_page_annots_with_usage(pdf_document *doc, pdf_page *page, fz cookie->progress++; } - pdf_run_annot_with_usage(doc, page, annot, dev, ctm, event, cookie); + pdf_run_annot_with_usage(ctx, doc, page, annot, dev, ctm, event, cookie); } } void -pdf_run_page_with_usage(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, char *event, fz_cookie *cookie) +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) { - fz_context *ctx = doc->ctx; int nocache = !!(dev->hints & FZ_NO_CACHE); if (nocache) - pdf_mark_xref(doc); + pdf_mark_xref(ctx, doc); fz_try(ctx) { - pdf_run_page_contents_with_usage(doc, page, dev, ctm, event, cookie); - pdf_run_page_annots_with_usage(doc, page, dev, ctm, event, cookie); + pdf_run_page_contents_with_usage(ctx, doc, page, dev, ctm, event, cookie); + pdf_run_page_annots_with_usage(ctx, doc, page, dev, ctm, event, cookie); } fz_always(ctx) { if (nocache) - pdf_clear_xref_to_mark(doc); + pdf_clear_xref_to_mark(ctx, doc); } fz_catch(ctx) { fz_rethrow(ctx); } if (page->incomplete) - fz_throw(doc->ctx, FZ_ERROR_TRYLATER, "incomplete rendering"); + fz_throw(ctx, FZ_ERROR_TRYLATER, "incomplete rendering"); } void -pdf_run_page(pdf_document *doc, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) +pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie) { - pdf_run_page_with_usage(doc, page, dev, ctm, "View", cookie); + pdf_document *doc = page->doc; + pdf_run_page_with_usage(ctx, doc, page, dev, ctm, "View", cookie); } void -pdf_run_glyph(pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, const fz_matrix *ctm, void *gstate, int nested_depth) +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 nested_depth) { - fz_context *ctx = doc->ctx; pdf_process process; if (nested_depth > 10) fz_throw(ctx, FZ_ERROR_GENERIC, "Too many nestings of Type3 glyphs"); - pdf_process_run(&process, dev, ctm, "View", gstate, nested_depth+1); + pdf_init_process_run(ctx, &process, dev, ctm, "View", gstate, nested_depth+1); - pdf_process_glyph(doc, resources, contents, &process); + pdf_process_glyph(ctx, doc, resources, contents, &process); } |