diff options
author | Robin Watts <robin.watts@artifex.com> | 2013-04-23 18:55:26 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2013-04-26 14:42:51 +0100 |
commit | c06007db0978041d6b60125929d0ca412f36e18e (patch) | |
tree | b2aec4da0a6205175b77c4485ab57deb9fe9c0e2 /fitz | |
parent | bbf2da4a518d02d83fd939fd716f09f4daa2546a (diff) | |
download | mupdf-c06007db0978041d6b60125929d0ca412f36e18e.tar.xz |
Hint enabling/disabling for devices.
Add configuration functions to control the hints set on a given device.
Use this to set whether image data is captured or not in the text
extraction process.
Also update the display list device to respect the device hints during
playback.
Diffstat (limited to 'fitz')
-rw-r--r-- | fitz/dev_list.c | 20 | ||||
-rw-r--r-- | fitz/dev_text.c | 12 | ||||
-rw-r--r-- | fitz/fitz-internal.h | 4 | ||||
-rw-r--r-- | fitz/fitz.h | 31 |
4 files changed, 56 insertions, 11 deletions
diff --git a/fitz/dev_list.c b/fitz/dev_list.c index 69542677..bd96381d 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -744,20 +744,26 @@ visible: fz_ignore_text(dev, node->item.text, &ctm); break; case FZ_CMD_FILL_SHADE: - fz_fill_shade(dev, node->item.shade, &ctm, node->alpha); + if ((dev->hints & FZ_IGNORE_SHADE) == 0) + fz_fill_shade(dev, node->item.shade, &ctm, node->alpha); break; case FZ_CMD_FILL_IMAGE: - fz_fill_image(dev, node->item.image, &ctm, node->alpha); + if ((dev->hints & FZ_IGNORE_IMAGE) == 0) + fz_fill_image(dev, node->item.image, &ctm, node->alpha); break; case FZ_CMD_FILL_IMAGE_MASK: - fz_fill_image_mask(dev, node->item.image, &ctm, - node->colorspace, node->color, node->alpha); + if ((dev->hints & FZ_IGNORE_IMAGE) == 0) + fz_fill_image_mask(dev, node->item.image, &ctm, + node->colorspace, node->color, node->alpha); break; case FZ_CMD_CLIP_IMAGE_MASK: { - fz_rect rect = node->rect; - fz_transform_rect(&rect, top_ctm); - fz_clip_image_mask(dev, node->item.image, &rect, &ctm); + if ((dev->hints & FZ_IGNORE_IMAGE) == 0) + { + fz_rect rect = node->rect; + fz_transform_rect(&rect, top_ctm); + fz_clip_image_mask(dev, node->item.image, &rect, &ctm); + } break; } case FZ_CMD_POP_CLIP: diff --git a/fitz/dev_text.c b/fitz/dev_text.c index baa8f78b..2df5ad38 100644 --- a/fitz/dev_text.c +++ b/fitz/dev_text.c @@ -912,6 +912,18 @@ fz_new_text_device(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) return dev; } +void +fz_enable_device_hints(fz_device *dev, int hints) +{ + dev->hints |= hints; +} + +void +fz_disable_device_hints(fz_device *dev, int hints) +{ + dev->hints &= ~hints; +} + /* XML, HTML and plain-text output */ static int font_is_bold(fz_font *font) diff --git a/fitz/fitz-internal.h b/fitz/fitz-internal.h index e5f3c0fa..60407b88 100644 --- a/fitz/fitz-internal.h +++ b/fitz/fitz-internal.h @@ -1468,10 +1468,6 @@ fz_device *fz_new_draw_device_type3(fz_context *ctx, fz_pixmap *dest); enum { - /* Hints */ - FZ_IGNORE_IMAGE = 1, - FZ_IGNORE_SHADE = 2, - /* Flags */ FZ_DEVFLAG_MASK = 1, FZ_DEVFLAG_COLOR = 2, diff --git a/fitz/fitz.h b/fitz/fitz.h index d3a554f4..b298877a 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -1839,6 +1839,37 @@ fz_device *fz_new_draw_device(fz_context *ctx, fz_pixmap *dest); fz_device *fz_new_draw_device_with_bbox(fz_context *ctx, fz_pixmap *dest, const fz_irect *clip); /* + fz_enable_device_hints : Enable hints in a device. + + hints: mask of hints to enable. + + For example: By default the draw device renders shadings. For some + purposes (perhaps rendering fast low quality thumbnails) you may want + to tell it to ignore shadings. For this you would enable the + FZ_IGNORE_SHADE hint. +*/ +void fz_enable_device_hints(fz_device *dev, int hints); + +/* + fz_disable_device_hints : Disable hints in a device. + + hints: mask of hints to disable. + + For example: By default the text extraction device ignores images. + For some purposes however (such as extracting HTML) you may want to + enable the capturing of image data too. For this you would disable + the FZ_IGNORE_IMAGE hint. +*/ +void fz_disable_device_hints(fz_device *dev, int hints); + +enum +{ + /* Hints */ + FZ_IGNORE_IMAGE = 1, + FZ_IGNORE_SHADE = 2, +}; + +/* Text extraction device: Used for searching, format conversion etc. (In development - Subject to change in future versions) |