summaryrefslogtreecommitdiff
path: root/source/fitz/test-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz/test-device.c')
-rw-r--r--source/fitz/test-device.c82
1 files changed, 47 insertions, 35 deletions
diff --git a/source/fitz/test-device.c b/source/fitz/test-device.c
index 38dc331b..aa6631a8 100644
--- a/source/fitz/test-device.c
+++ b/source/fitz/test-device.c
@@ -29,7 +29,7 @@ is_rgb_color_u8(int threshold_u8, int r, int g, int b)
}
static void
-fz_test_color(fz_context *ctx, fz_test_device *t, fz_colorspace *colorspace, const float *color)
+fz_test_color(fz_context *ctx, fz_test_device *t, fz_colorspace *colorspace, const float *color, const fz_color_params *color_params)
{
if (!*t->is_color && colorspace && colorspace != fz_device_gray(ctx))
{
@@ -46,7 +46,7 @@ fz_test_color(fz_context *ctx, fz_test_device *t, fz_colorspace *colorspace, con
else
{
float rgb[3];
- fz_convert_color(ctx, fz_device_rgb(ctx), rgb, colorspace, color);
+ fz_convert_color(ctx, color_params, NULL, fz_device_rgb(ctx), rgb, colorspace, color);
if (is_rgb_color(t->threshold, rgb[0], rgb[1], rgb[2]))
{
*t->is_color = 2;
@@ -62,68 +62,73 @@ fz_test_color(fz_context *ctx, fz_test_device *t, fz_colorspace *colorspace, con
static void
fz_test_fill_path(fz_context *ctx, fz_device *dev_, const fz_path *path, int even_odd, const fz_matrix *ctm,
- fz_colorspace *colorspace, const float *color, float alpha)
+ fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
- if (dev->resolved == 0)
+ if (dev->resolved == 0 && alpha != 0.0f)
{
- if (alpha != 0.0f)
- fz_test_color(ctx, dev, colorspace, color);
+ if (color_params == NULL)
+ color_params = fz_default_color_params(ctx);
+ fz_test_color(ctx, dev, colorspace, color, color_params);
}
if (dev->passthrough)
- fz_fill_path(ctx, dev->passthrough, path, even_odd, ctm, colorspace, color, alpha);
+ fz_fill_path(ctx, dev->passthrough, path, even_odd, ctm, colorspace, color, alpha, color_params);
}
static void
fz_test_stroke_path(fz_context *ctx, fz_device *dev_, const fz_path *path, const fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha)
+ const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
- if (dev->resolved == 0)
+ if (dev->resolved == 0 && alpha != 0.0f)
{
- if (alpha != 0.0f)
- fz_test_color(ctx, dev, colorspace, color);
+ if (color_params == NULL)
+ color_params = fz_default_color_params(ctx);
+ fz_test_color(ctx, dev, colorspace, color, color_params);
}
if (dev->passthrough)
- fz_stroke_path(ctx, dev->passthrough, path, stroke, ctm, colorspace, color, alpha);
+ fz_stroke_path(ctx, dev->passthrough, path, stroke, ctm, colorspace, color, alpha, color_params);
}
static void
fz_test_fill_text(fz_context *ctx, fz_device *dev_, const fz_text *text, const fz_matrix *ctm,
- fz_colorspace *colorspace, const float *color, float alpha)
+ fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
- if (dev->resolved == 0)
+ if (dev->resolved == 0 && alpha != 0.0f)
{
- if (alpha != 0.0f)
- fz_test_color(ctx, dev, colorspace, color);
+ if (color_params == NULL)
+ color_params = fz_default_color_params(ctx);
+ fz_test_color(ctx, dev, colorspace, color, color_params);
}
if (dev->passthrough)
- fz_fill_text(ctx, dev->passthrough, text, ctm, colorspace, color, alpha);
+ fz_fill_text(ctx, dev->passthrough, text, ctm, colorspace, color, alpha, color_params);
}
static void
fz_test_stroke_text(fz_context *ctx, fz_device *dev_, const fz_text *text, const fz_stroke_state *stroke,
- const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha)
+ const fz_matrix *ctm, fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
- if (dev->resolved == 0)
+ if (dev->resolved == 0 && alpha != 0.0f)
{
- if (alpha != 0.0f)
- fz_test_color(ctx, dev, colorspace, color);
+ if (color_params == NULL)
+ color_params = fz_default_color_params(ctx);
+ fz_test_color(ctx, dev, colorspace, color, color_params);
}
if (dev->passthrough)
- fz_stroke_text(ctx, dev->passthrough, text, stroke, ctm, colorspace, color, alpha);
+ fz_stroke_text(ctx, dev->passthrough, text, stroke, ctm, colorspace, color, alpha, color_params);
}
struct shadearg
{
fz_test_device *dev;
fz_shade *shade;
+ const fz_color_params *color_params;
};
static void
@@ -133,14 +138,17 @@ prepare_vertex(fz_context *ctx, void *arg_, fz_vertex *v, const float *color)
fz_test_device *dev = arg->dev;
fz_shade *shade = arg->shade;
if (!shade->use_function)
- fz_test_color(ctx, dev, shade->colorspace, color);
+ fz_test_color(ctx, dev, shade->colorspace, color, arg->color_params);
}
static void
-fz_test_fill_shade(fz_context *ctx, fz_device *dev_, fz_shade *shade, const fz_matrix *ctm, float alpha)
+fz_test_fill_shade(fz_context *ctx, fz_device *dev_, fz_shade *shade, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
+ if (color_params == NULL)
+ color_params = fz_default_color_params(ctx);
+
if (dev->resolved == 0)
{
if ((dev->options & FZ_TEST_OPT_SHADINGS) == 0)
@@ -161,23 +169,24 @@ fz_test_fill_shade(fz_context *ctx, fz_device *dev_, fz_shade *shade, const fz_m
{
int i;
for (i = 0; i < 256; i++)
- fz_test_color(ctx, dev, shade->colorspace, shade->function[i]);
+ fz_test_color(ctx, dev, shade->colorspace, shade->function[i], color_params);
}
else
{
struct shadearg arg;
arg.dev = dev;
arg.shade = shade;
+ arg.color_params = color_params;
fz_process_shade(ctx, shade, ctm, prepare_vertex, NULL, &arg);
}
}
}
if (dev->passthrough)
- fz_fill_shade(ctx, dev->passthrough, shade, ctm, alpha);
+ fz_fill_shade(ctx, dev->passthrough, shade, ctm, alpha, color_params);
}
static void
-fz_test_fill_image(fz_context *ctx, fz_device *dev_, fz_image *image, const fz_matrix *ctm, float alpha)
+fz_test_fill_image(fz_context *ctx, fz_device *dev_, fz_image *image, const fz_matrix *ctm, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
@@ -231,7 +240,7 @@ fz_test_fill_image(fz_context *ctx, fz_device *dev_, fz_image *image, const fz_m
fz_color_converter cc;
unsigned int n = (unsigned int)image->n;
- fz_init_cached_color_converter(ctx, &cc, fz_device_rgb(ctx), image->colorspace);
+ fz_init_cached_color_converter(ctx, &cc, NULL, fz_device_rgb(ctx), image->colorspace, color_params);
for (i = 0; i < count; i++)
{
float cs[FZ_MAX_COLORS];
@@ -299,7 +308,7 @@ fz_test_fill_image(fz_context *ctx, fz_device *dev_, fz_image *image, const fz_m
fz_color_converter cc;
unsigned int n = (unsigned int)pix->n-1;
- fz_init_cached_color_converter(ctx, &cc, fz_device_rgb(ctx), pix->colorspace);
+ fz_init_cached_color_converter(ctx, &cc, NULL, fz_device_rgb(ctx), pix->colorspace, color_params);
while (h--)
{
for (i = 0; i < count; i++)
@@ -336,22 +345,25 @@ fz_test_fill_image(fz_context *ctx, fz_device *dev_, fz_image *image, const fz_m
break;
}
if (dev->passthrough)
- fz_fill_image(ctx, dev->passthrough, image, ctm, alpha);
+ fz_fill_image(ctx, dev->passthrough, image, ctm, alpha, color_params);
}
static void
fz_test_fill_image_mask(fz_context *ctx, fz_device *dev_, fz_image *image, const fz_matrix *ctm,
- fz_colorspace *colorspace, const float *color, float alpha)
+ fz_colorspace *colorspace, const float *color, float alpha, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
+ if (color_params == NULL)
+ color_params = fz_default_color_params(ctx);
+
if (dev->resolved == 0)
{
/* We assume that at least some of the image pixels are non-zero */
- fz_test_color(ctx, dev, colorspace, color);
+ fz_test_color(ctx, dev, colorspace, color, color_params);
}
if (dev->passthrough)
- fz_fill_image_mask(ctx, dev->passthrough, image, ctm, colorspace, color, alpha);
+ fz_fill_image_mask(ctx, dev->passthrough, image, ctm, colorspace, color, alpha, color_params);
}
static void
@@ -411,11 +423,11 @@ fz_test_pop_clip(fz_context *ctx, fz_device *dev_)
}
static void
-fz_test_begin_mask(fz_context *ctx, fz_device *dev_, const fz_rect *rect, int luminosity, fz_colorspace *cs, const float *bc)
+fz_test_begin_mask(fz_context *ctx, fz_device *dev_, const fz_rect *rect, int luminosity, fz_colorspace *cs, const float *bc, const fz_color_params *color_params)
{
fz_test_device *dev = (fz_test_device*)dev_;
- fz_begin_mask(ctx, dev->passthrough, rect, luminosity, cs, bc);
+ fz_begin_mask(ctx, dev->passthrough, rect, luminosity, cs, bc, color_params);
}
static void