From 3f9d9ffbb30220b9592072a6dde5e4d440ab2e15 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Tue, 31 May 2016 14:53:38 +0100 Subject: Update test device with passthrough option. Update the test device so it can be used 'wrapping' another device. In particular, it can be used to wrap the display list device so that we can evaluate 'color or not' while building the display list rather than having to rerun the display list afterwards. Also, give improved control over whether we test every pixel of images/shadings. --- include/mupdf/fitz/device.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/mupdf/fitz/device.h b/include/mupdf/fitz/device.h index caa01cb2..d0a8f0ed 100644 --- a/include/mupdf/fitz/device.h +++ b/include/mupdf/fitz/device.h @@ -296,11 +296,39 @@ fz_device *fz_new_bbox_device(fz_context *ctx, fz_rect *rectp); Currently only tests for the presence of non-grayscale colors. + is_color: Possible values returned: + 0: Definitely greyscale + 1: Probably color (all colors were grey, but there + were images or shadings in a non grey colorspace). + 2: Definitely color + threshold: The difference from grayscale that will be tolerated. Typical values to use are either 0 (be exact) and 0.02 (allow an imperceptible amount of slop). + + options: A set of bitfield options, from the FZ_TEST_OPT set. + + passthrough: A device to pass all calls through to, or NULL. + If set, then the test device can both test and pass through to + an underlying device (like, say, the display list device). This + means that a display list can be created and at the end we'll + know if it's color or not. + + In the absence of a passthrough device, the device will throw + an exception to stop page interpretation when color is found. */ -fz_device *fz_new_test_device(fz_context *ctx, int *is_color, float threshold); +fz_device *fz_new_test_device(fz_context *ctx, int *is_color, float threshold, int options, fz_device *passthrough); + +enum +{ + /* If set, test every pixel of images exhaustively. + * If clear, just look at colorspaces for images. */ + FZ_TEST_OPT_IMAGES = 1, + + /* If set, test every pixel of shadings. */ + /* If clear, just look at colorspaces for shadings. */ + FZ_TEST_OPT_SHADINGS = 2 +}; /* fz_new_draw_device: Create a device to draw on a pixmap. -- cgit v1.2.3