From f84a189d5f94250e46d2cbd1a75aba00130e2dd6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 21 Jan 2015 16:42:45 +0100 Subject: 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. --- source/pdf/pdf-op-filter.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'source/pdf/pdf-op-filter.c') diff --git a/source/pdf/pdf-op-filter.c b/source/pdf/pdf-op-filter.c index 17bd3af0..ec08b305 100644 --- a/source/pdf/pdf-op-filter.c +++ b/source/pdf/pdf-op-filter.c @@ -47,21 +47,22 @@ typedef struct pdf_filter_state_s static void insert_resource_name(pdf_csi *csi, pdf_filter_state *state, const char *key, const char *name) { + fz_context *ctx = csi->ctx; pdf_obj *xobj; pdf_obj *obj; if (!state->resources || !name || name[0] == 0) return; - xobj = pdf_dict_gets(csi->rdb, key); - obj = pdf_dict_gets(xobj, name); + xobj = pdf_dict_gets(ctx, csi->rdb, key); + obj = pdf_dict_gets(ctx, xobj, name); - xobj = pdf_dict_gets(state->resources, key); + xobj = pdf_dict_gets(ctx, state->resources, key); if (xobj == NULL) { - xobj = pdf_new_dict(csi->doc, 1); - pdf_dict_puts_drop(state->resources, key, xobj); + xobj = pdf_new_dict(csi->ctx, csi->doc, 1); + pdf_dict_puts_drop(ctx, state->resources, key, xobj); } - pdf_dict_putp(xobj, name, obj); + pdf_dict_putp(ctx, xobj, name, obj); } static void insert_resource(pdf_csi *csi, pdf_filter_state *state, const char *key) @@ -408,7 +409,7 @@ pdf_filter_BDC(pdf_csi *csi, void *state_) { pdf_filter_state *state = (pdf_filter_state *)state_; - insert_resource_name(csi, state, "Properties", pdf_to_name(csi->obj)); + insert_resource_name(csi, state, "Properties", pdf_to_name(csi->ctx, csi->obj)); filter_flush(csi, state, 0); call_op(csi, state, PDF_OP_BDC); @@ -467,7 +468,7 @@ pdf_filter_DP(pdf_csi *csi, void *state_) { pdf_filter_state *state = (pdf_filter_state *)state_; - insert_resource_name(csi, state, "Properties", pdf_to_name(csi->obj)); + insert_resource_name(csi, state, "Properties", pdf_to_name(csi->ctx, csi->obj)); filter_flush(csi, state, 0); call_op(csi, state, PDF_OP_DP); @@ -1085,11 +1086,11 @@ free_processor_filter(pdf_csi *csi, void *state_) static void process_annot(pdf_csi *csi, void *state, pdf_obj *resources, pdf_annot *annot) { - fz_context *ctx = csi->doc->ctx; + fz_context *ctx = csi->ctx; pdf_xobject *xobj = annot->ap; /* Avoid infinite recursion */ - if (xobj == NULL || pdf_mark_obj(xobj->me)) + if (xobj == NULL || pdf_mark_obj(ctx, xobj->me)) return; fz_try(ctx) @@ -1101,7 +1102,7 @@ process_annot(pdf_csi *csi, void *state, pdf_obj *resources, pdf_annot *annot) } fz_always(ctx) { - pdf_unmark_obj(xobj->me); + pdf_unmark_obj(ctx, xobj->me); } fz_catch(ctx) { @@ -1203,7 +1204,7 @@ static const pdf_processor pdf_processor_filter = }; pdf_process * -pdf_process_filter(pdf_process *process, fz_context *ctx, pdf_process *underlying, pdf_obj *resources) +pdf_init_process_filter(fz_context *ctx, pdf_process *process, pdf_process *underlying, pdf_obj *resources) { pdf_filter_state *p = NULL; -- cgit v1.2.3