diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-05-25 12:00:21 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-05-25 12:28:00 +0200 |
commit | 32599868df1b3ecd553a0c1bc3e2521dd11b288a (patch) | |
tree | 31ea9a6e6c42ed560e19f3d8b655d2f29286d786 /source/fitz | |
parent | f01a11057f3352330bacd411160db1c2a032a1dc (diff) | |
download | mupdf-32599868df1b3ecd553a0c1bc3e2521dd11b288a.tar.xz |
Replace broken FZ_IGNORE_IMAGE hints with other mechanisms.
Add an option to the structured text device to preserve images.
If the PDF processor does not have ops to process images, then skip
loading them in the interpreter if possible. If the device does not
have any image callbacks, then don't set the image processing ops in
the run device.
This accomplishes the same effect as the device hints were intended
to do, but without needing to expose them to the PDF interpreter
which may not even have a device since we now have multiple PDF op
processors.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/list-device.c | 12 | ||||
-rw-r--r-- | source/fitz/stext-device.c | 14 | ||||
-rw-r--r-- | source/fitz/test-device.c | 1 |
3 files changed, 12 insertions, 15 deletions
diff --git a/source/fitz/list-device.c b/source/fitz/list-device.c index 49a93c20..6580b93c 100644 --- a/source/fitz/list-device.c +++ b/source/fitz/list-device.c @@ -1646,20 +1646,16 @@ visible: fz_ignore_text(ctx, dev, *(fz_text **)node, &trans_ctm); break; case FZ_CMD_FILL_SHADE: - if ((dev->hints & FZ_IGNORE_SHADE) == 0) - fz_fill_shade(ctx, dev, *(fz_shade **)node, &trans_ctm, alpha); + fz_fill_shade(ctx, dev, *(fz_shade **)node, &trans_ctm, alpha); break; case FZ_CMD_FILL_IMAGE: - if ((dev->hints & FZ_IGNORE_IMAGE) == 0) - fz_fill_image(ctx, dev, *(fz_image **)node, &trans_ctm, alpha); + fz_fill_image(ctx, dev, *(fz_image **)node, &trans_ctm, alpha); break; case FZ_CMD_FILL_IMAGE_MASK: - if ((dev->hints & FZ_IGNORE_IMAGE) == 0) - fz_fill_image_mask(ctx, dev, *(fz_image **)node, &trans_ctm, colorspace, color, alpha); + fz_fill_image_mask(ctx, dev, *(fz_image **)node, &trans_ctm, colorspace, color, alpha); break; case FZ_CMD_CLIP_IMAGE_MASK: - if ((dev->hints & FZ_IGNORE_IMAGE) == 0) - fz_clip_image_mask(ctx, dev, *(fz_image **)node, &trans_ctm, &trans_rect); + fz_clip_image_mask(ctx, dev, *(fz_image **)node, &trans_ctm, &trans_rect); break; case FZ_CMD_POP_CLIP: fz_pop_clip(ctx, dev); diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 0890043f..78755595 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -1095,6 +1095,8 @@ fz_parse_stext_options(fz_context *ctx, fz_stext_options *opts, const char *stri opts->flags |= FZ_STEXT_PRESERVE_LIGATURES; if (fz_has_option(ctx, string, "preserve-whitespace", &val) && fz_option_eq(val, "yes")) opts->flags |= FZ_STEXT_PRESERVE_WHITESPACE; + if (fz_has_option(ctx, string, "preserve-images", &val) && fz_option_eq(val, "yes")) + opts->flags |= FZ_STEXT_PRESERVE_IMAGES; return opts; } @@ -1104,8 +1106,6 @@ fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page, { fz_stext_device *dev = fz_new_derived_device(ctx, fz_stext_device); - dev->super.hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE; - dev->super.close_device = fz_stext_close_device; dev->super.drop_device = fz_stext_drop_device; @@ -1114,16 +1114,18 @@ fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page, dev->super.clip_text = fz_stext_clip_text; dev->super.clip_stroke_text = fz_stext_clip_stroke_text; dev->super.ignore_text = fz_stext_ignore_text; - dev->super.fill_image = fz_stext_fill_image; - dev->super.fill_image_mask = fz_stext_fill_image_mask; + + if (opts && (opts->flags & FZ_STEXT_PRESERVE_IMAGES)) + { + dev->super.fill_image = fz_stext_fill_image; + dev->super.fill_image_mask = fz_stext_fill_image_mask; + } dev->sheet = sheet; dev->page = page; dev->spans = NULL; dev->cur_span = NULL; dev->lastchar = ' '; - if (opts) - dev->flags = opts->flags; return (fz_device*)dev; } diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c index f12a294b..38dc331b 100644 --- a/source/fitz/test-device.c +++ b/source/fitz/test-device.c @@ -53,7 +53,6 @@ fz_test_color(fz_context *ctx, fz_test_device *t, fz_colorspace *colorspace, con t->resolved = 1; if (t->passthrough == NULL) { - t->super.hints |= FZ_IGNORE_IMAGE; fz_throw(ctx, FZ_ERROR_ABORT, "Page found as color; stopping interpretation"); } } |