summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/pdf/resource.h6
-rw-r--r--source/pdf/pdf-appearance.c10
-rw-r--r--source/pdf/pdf-op-run.c4
-rw-r--r--source/pdf/pdf-page.c2
-rw-r--r--source/pdf/pdf-xobject.c25
5 files changed, 19 insertions, 28 deletions
diff --git a/include/mupdf/pdf/resource.h b/include/mupdf/pdf/resource.h
index c417635e..f42e3644 100644
--- a/include/mupdf/pdf/resource.h
+++ b/include/mupdf/pdf/resource.h
@@ -91,6 +91,7 @@ struct pdf_xobject_s
{
fz_storable storable;
pdf_obj *obj;
+ pdf_document *document;
fz_matrix matrix;
fz_rect bbox;
@@ -98,9 +99,6 @@ struct pdf_xobject_s
int knockout;
int transparency;
fz_colorspace *colorspace;
- pdf_document *document;
- pdf_obj *resources;
- pdf_obj *contents;
int iteration;
};
@@ -112,4 +110,6 @@ void pdf_update_xobject_contents(fz_context *ctx, pdf_document *doc, pdf_xobject
void pdf_update_appearance(fz_context *ctx, pdf_document *doc, pdf_annot *annot);
+pdf_obj *pdf_xobject_resources(fz_context *ctx, pdf_xobject *xobj);
+
#endif
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index e2690c0c..6e03cb2b 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -778,7 +778,7 @@ static int get_matrix(fz_context *ctx, pdf_document *doc, pdf_xobject *form, int
pdf_lexbuf lbuf;
fz_stream *str;
- str = pdf_open_stream(ctx, doc, pdf_to_num(ctx, form->contents));
+ str = pdf_open_stream(ctx, doc, pdf_to_num(ctx, form->obj));
pdf_lexbuf_init(ctx, &lbuf, PDF_LEXBUF_SMALL);
@@ -824,7 +824,7 @@ static int get_matrix(fz_context *ctx, pdf_document *doc, pdf_xobject *form, int
if (found)
{
fz_rect bbox;
- pdf_to_rect(ctx, pdf_dict_get(ctx, form->contents, PDF_NAME_BBox), &bbox);
+ pdf_to_rect(ctx, pdf_dict_get(ctx, form->obj, PDF_NAME_BBox), &bbox);
switch (q)
{
@@ -1005,7 +1005,7 @@ static pdf_xobject *load_or_create_form(fz_context *ctx, pdf_document *doc, pdf_
pdf_update_xobject_contents(ctx, doc, form, fzbuf);
}
- copy_resources(ctx, form->resources, pdf_get_inheritable(ctx, doc, obj, PDF_NAME_DR));
+ copy_resources(ctx, pdf_xobject_resources(ctx, form), pdf_get_inheritable(ctx, doc, obj, PDF_NAME_DR));
}
fz_always(ctx)
{
@@ -1041,7 +1041,7 @@ static void update_marked_content(fz_context *ctx, pdf_document *doc, pdf_xobjec
int first = 1;
newbuf = fz_new_buffer(ctx, 0);
- str_outer = pdf_open_stream(ctx, doc, pdf_to_num(ctx, form->contents));
+ str_outer = pdf_open_stream(ctx, doc, pdf_to_num(ctx, form->obj));
len = fz_buffer_storage(ctx, fzbuf, &buf);
str_inner = fz_open_memory(ctx, buf, len);
@@ -1504,7 +1504,7 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob
clip.x1 -= btotal;
clip.y1 -= btotal;
- get_font_info(ctx, doc, form->resources, da, &font_rec);
+ get_font_info(ctx, doc, pdf_xobject_resources(ctx, form), da, &font_rec);
measure_text(ctx, doc, &font_rec, &fz_identity, text, &bounds);
fz_translate(&mat, (rect.x1 - bounds.x1)/2, (rect.y1 - bounds.y1)/2);
fzbuf_print_text(ctx, fzbuf, &clip, NULL, &font_rec, &mat, text);
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index de3e8bdc..b529125a 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -1282,11 +1282,11 @@ pdf_run_xobject(fz_context *ctx, pdf_run_processor *proc, pdf_xobject *xobj, pdf
/* run contents */
- resources = xobj->resources;
+ resources = pdf_xobject_resources(ctx, xobj);
if (!resources)
resources = page_resources;
- pdf_process_contents(ctx, (pdf_processor*)pr, xobj->document, resources, xobj->contents, NULL);
+ pdf_process_contents(ctx, (pdf_processor*)pr, xobj->document, resources, xobj->obj, NULL);
}
fz_always(ctx)
{
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index cc2a4798..e3b68378 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -608,7 +608,7 @@ pdf_load_page(fz_context *ctx, pdf_document *doc, int number)
else if (pdf_name_eq(ctx, pdf_dict_getp(ctx, pageobj, "Group/S"), PDF_NAME_Transparency))
page->transparency = 1;
for (annot = page->annots; annot && !page->transparency; annot = annot->next)
- if (annot->ap && pdf_resources_use_blending(ctx, annot->ap->resources))
+ if (annot->ap && pdf_resources_use_blending(ctx, pdf_xobject_resources(ctx, annot->ap)))
page->transparency = 1;
}
fz_catch(ctx)
diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c
index d684ee90..78d736e2 100644
--- a/source/pdf/pdf-xobject.c
+++ b/source/pdf/pdf-xobject.c
@@ -19,8 +19,6 @@ pdf_drop_xobject_imp(fz_context *ctx, fz_storable *xobj_)
if (xobj->colorspace)
fz_drop_colorspace(ctx, xobj->colorspace);
- pdf_drop_obj(ctx, xobj->resources);
- pdf_drop_obj(ctx, xobj->contents);
pdf_drop_obj(ctx, xobj->obj);
fz_free(ctx, xobj);
}
@@ -33,6 +31,12 @@ pdf_xobject_size(pdf_xobject *xobj)
return sizeof(*xobj) + (xobj->colorspace ? xobj->colorspace->size : 0);
}
+pdf_obj *
+pdf_xobject_resources(fz_context *ctx, pdf_xobject *xobj)
+{
+ return pdf_dict_get(ctx, xobj->obj, PDF_NAME_Resources);
+}
+
pdf_xobject *
pdf_load_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
{
@@ -47,8 +51,6 @@ pdf_load_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
form = fz_malloc_struct(ctx, pdf_xobject);
FZ_INIT_STORABLE(form, 1, pdf_drop_xobject_imp);
form->document = doc;
- form->resources = NULL;
- form->contents = NULL;
form->colorspace = NULL;
form->obj = NULL;
form->iteration = 0;
@@ -96,12 +98,6 @@ pdf_load_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
}
}
}
-
- form->resources = pdf_dict_get(ctx, dict, PDF_NAME_Resources);
- if (form->resources)
- pdf_keep_obj(ctx, form->resources);
-
- form->contents = pdf_keep_obj(ctx, dict);
}
fz_catch(ctx)
{
@@ -109,6 +105,7 @@ pdf_load_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
pdf_drop_xobject(ctx, form);
fz_rethrow(ctx);
}
+
form->obj = pdf_keep_obj(ctx, dict);
return form;
@@ -151,8 +148,6 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
form = fz_malloc_struct(ctx, pdf_xobject);
FZ_INIT_STORABLE(form, 1, pdf_drop_xobject_imp);
form->document = doc;
- form->resources = NULL;
- form->contents = NULL;
form->colorspace = NULL;
form->obj = NULL;
form->iteration = 0;
@@ -165,9 +160,6 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
form->knockout = 0;
form->transparency = 0;
- form->resources = res;
- res = NULL;
-
idict_num = pdf_create_object(ctx, doc);
pdf_update_object(ctx, doc, idict_num, dict);
idict = pdf_new_indirect(ctx, doc, idict_num, 0);
@@ -176,7 +168,6 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
pdf_store_item(ctx, idict, form, pdf_xobject_size(form));
- form->contents = pdf_keep_obj(ctx, idict);
form->obj = pdf_keep_obj(ctx, idict);
pdf_drop_xobject(ctx, form);
@@ -196,6 +187,6 @@ pdf_new_xobject(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const f
void pdf_update_xobject_contents(fz_context *ctx, pdf_document *doc, pdf_xobject *form, fz_buffer *buffer)
{
- pdf_update_stream(ctx, doc, form->contents, buffer, 0);
+ pdf_update_stream(ctx, doc, form->obj, buffer, 0);
form->iteration ++;
}