diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-object.c | 23 | ||||
-rw-r--r-- | source/pdf/pdf-page.c | 28 |
2 files changed, 25 insertions, 26 deletions
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c index a6b3f1ac..aa20b79e 100644 --- a/source/pdf/pdf-object.c +++ b/source/pdf/pdf-object.c @@ -22,7 +22,9 @@ struct keyval enum { PDF_FLAGS_MARKED = 1, - PDF_FLAGS_SORTED = 2 + PDF_FLAGS_SORTED = 2, + PDF_FLAGS_STASH = 4, + PDF_FLAGS_STASH_BOOL = 8 }; struct pdf_obj_s @@ -1188,6 +1190,25 @@ pdf_obj_unmark(pdf_obj *obj) obj->flags &= ~PDF_FLAGS_MARKED; } +void +pdf_obj_stash(pdf_obj *obj, int stash) +{ + obj->flags |= PDF_FLAGS_STASH; + if (stash) + obj->flags |= PDF_FLAGS_STASH_BOOL; + else + obj->flags &= ~PDF_FLAGS_STASH_BOOL; +} + +int +pdf_obj_stashed(pdf_obj *obj, int *stash) +{ + if (!(obj->flags & PDF_FLAGS_STASH)) + return 0; + *stash = !!(obj->flags & PDF_FLAGS_STASH_BOOL); + return 1; +} + static void pdf_free_array(pdf_obj *obj) { 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; } |