diff options
author | Robin Watts <robin.watts@artifex.com> | 2014-09-01 19:09:36 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-09-01 19:26:35 +0100 |
commit | 7d726b34666e5547a93f64f1dc1f161c5517e473 (patch) | |
tree | f12880769bedd4e6baca30c05382b47449d128c2 /source | |
parent | 7662af082b44f8164d1adadc5688f30d888e6a63 (diff) | |
download | mupdf-7d726b34666e5547a93f64f1dc1f161c5517e473.tar.xz |
Performance improvement for test-device.
When we detect that a page is color, set the ignore image hint
to avoid us loading future images. The overhead on loading
images is not generally huge, except for JPEG2000 ones, which
currently require decoding at load time. This therefore saves
lots of time for such files.
Also, a tiny tweak to ignore page components with 0 alpha.
Diffstat (limited to 'source')
-rw-r--r-- | source/fitz/test-device.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c index d4193c43..0b37e1ad 100644 --- a/source/fitz/test-device.c +++ b/source/fitz/test-device.c @@ -35,14 +35,20 @@ fz_test_color(fz_device *dev, fz_colorspace *colorspace, const float *color) if (colorspace == fz_device_rgb(ctx)) { if (is_rgb_color(t->threshold, color[0], color[1], color[2])) + { *t->is_color = 1; + dev->hints |= FZ_IGNORE_IMAGE; + } } else { float rgb[3]; fz_convert_color(ctx, fz_device_rgb(ctx), rgb, colorspace, color); if (is_rgb_color(t->threshold, rgb[0], rgb[1], rgb[2])) + { *t->is_color = 1; + dev->hints |= FZ_IGNORE_IMAGE; + } } } } @@ -51,28 +57,32 @@ static void fz_test_fill_path(fz_device *dev, fz_path *path, int even_odd, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_test_color(dev, colorspace, color); + if (alpha != 0.0f) + fz_test_color(dev, colorspace, color); } static void fz_test_stroke_path(fz_device *dev, fz_path *path, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_test_color(dev, colorspace, color); + if (alpha != 0.0f) + fz_test_color(dev, colorspace, color); } static void fz_test_fill_text(fz_device *dev, fz_text *text, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_test_color(dev, colorspace, color); + if (alpha != 0.0f) + fz_test_color(dev, colorspace, color); } static void fz_test_stroke_text(fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_test_color(dev, colorspace, color); + if (alpha != 0.0f) + fz_test_color(dev, colorspace, color); } struct shadearg @@ -139,6 +149,7 @@ fz_test_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float if (is_rgb_color_u8(threshold_u8, s[0], s[1], s[2])) { *t->is_color = 1; + dev->hints |= FZ_IGNORE_IMAGE; break; } s += 4; @@ -147,7 +158,7 @@ fz_test_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float else { fz_color_converter cc; - int n = pix->n-1; + unsigned int n = (unsigned int)pix->n-1; fz_init_cached_color_converter(ctx, &cc, fz_device_rgb(ctx), pix->colorspace); for (i = 0; i < count; i++) @@ -164,6 +175,7 @@ fz_test_fill_image(fz_device *dev, fz_image *image, const fz_matrix *ctm, float if (is_rgb_color(t->threshold, ds[0], ds[1], ds[2])) { *t->is_color = 1; + dev->hints |= FZ_IGNORE_IMAGE; break; } } |