summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-page.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-06-25 17:50:39 +0100
committerRobin Watts <robin.watts@artifex.com>2013-06-25 18:28:42 +0100
commita9e56e9f94515c109a912a50b4bc80466a11b075 (patch)
tree92d31f23c2c56e86867ff23aa6fbd95ca3251e43 /source/pdf/pdf-page.c
parent148e6b9dae3900f1acd053df10bc41f06be5c507 (diff)
downloadmupdf-a9e56e9f94515c109a912a50b4bc80466a11b075.tar.xz
Rework storing internal flags in PDF objects.
Before we render a page we need to evaluate whether we need transparency or not. To establish this, we recursively walk the resources looking for certain markers (blend modes, alpha levels, smasks etc). To avoid doing this repeatedly we'd like to stash the results somewhere. Currently we write a '.useBM' entry into the top level dictionary object, but with the recent changes to support incremental update this is not ideal - it has the effect of forcing all resources into the new section of the xref. So we avoid that horrible hack and use a different one; we make use of the new flags word in the pdf_obj structure. 1 bit is used to indicate whether we have stashed a (boolean) value here, and another bit is used to indicate what that value was.
Diffstat (limited to 'source/pdf/pdf-page.c')
-rw-r--r--source/pdf/pdf-page.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index 12e38b5f..82c7aa5c 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -8,27 +8,6 @@ struct info
pdf_obj *rotate;
};
-static void
-put_marker_bool(pdf_document *doc, pdf_obj *rdb, char *marker, int val)
-{
- pdf_obj *tmp;
- fz_context *ctx = doc->ctx;
-
- tmp = pdf_new_bool(doc, val);
- fz_try(ctx)
- {
- pdf_dict_puts(rdb, marker, tmp);
- }
- fz_always(ctx)
- {
- pdf_drop_obj(tmp);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
-}
-
typedef struct pdf_page_load_s pdf_page_load;
struct pdf_page_load_s
@@ -240,9 +219,8 @@ pdf_resources_use_blending(pdf_document *doc, pdf_obj *rdb)
return 0;
/* Have we been here before and stashed an answer? */
- obj = pdf_dict_gets(rdb, ".useBM");
- if (obj)
- return pdf_to_bool(obj);
+ if (pdf_obj_stashed(rdb, &useBM))
+ return useBM;
/* stop on cyclic resource dependencies */
if (pdf_obj_mark(rdb))
@@ -282,7 +260,7 @@ found:
fz_rethrow(ctx);
}
- put_marker_bool(doc, rdb, ".useBM", useBM);
+ pdf_obj_stash(rdb, useBM);
return useBM;
}