summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vrhel <michael.vrhel@artifex.com>2017-08-07 18:57:46 -0700
committerRobin Watts <robin.watts@artifex.com>2017-10-24 15:16:36 +0100
commit5bc368de9feb7d12c124e2d0712e2d7314420c44 (patch)
tree9a2841d082ab3133cb6abdfa7bdd932b865782d2
parent38620dea1512581a65350955cebb1028063ce42b (diff)
downloadmupdf-5bc368de9feb7d12c124e2d0712e2d7314420c44.tar.xz
Make sure shades use proper "default" color space.
Fixes some issues in Altona test file.
-rw-r--r--include/mupdf/fitz/shade.h5
-rw-r--r--source/fitz/draw-device.c7
-rw-r--r--source/fitz/draw-mesh.c17
-rw-r--r--source/fitz/stext-device.c2
-rw-r--r--source/fitz/svg-device.c2
5 files changed, 20 insertions, 13 deletions
diff --git a/include/mupdf/fitz/shade.h b/include/mupdf/fitz/shade.h
index 5604e762..24cb4cb2 100644
--- a/include/mupdf/fitz/shade.h
+++ b/include/mupdf/fitz/shade.h
@@ -122,6 +122,9 @@ fz_rect *fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
shade: The shade to paint.
+ override_cs: NULL, or colorspace to override the shades
+ inbuilt colorspace.
+
ctm: The transform to apply.
dest: The pixmap to render into.
@@ -133,7 +136,7 @@ fz_rect *fz_bound_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm,
op: NULL, or pointer to overprint bitmap.
*/
-void fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap *dest, const fz_color_params *color_params, const fz_irect *bbox, const fz_overprint *op);
+void fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *override_cs, const fz_matrix *ctm, fz_pixmap *dest, const fz_color_params *color_params, const fz_irect *bbox, const fz_overprint *op);
/*
* Handy routine for processing mesh based shades
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index eba18fb6..99894ac3 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -1299,6 +1299,7 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
fz_draw_state *state = &dev->stack[dev->top];
fz_overprint op = { { 0 } };
fz_overprint *eop;
+ fz_colorspace *colorspace = fz_default_colorspace(ctx, dev->default_cs, shade->colorspace);
if (dev->top == 0 && dev->resolve_spots)
state = push_group_for_separations(ctx, dev, color_params, dev->default_cs);
@@ -1348,7 +1349,7 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
cp = &local_cp;
}
- eop = resolve_color(ctx, &op, shade->background, fz_default_colorspace(ctx, dev->default_cs, shade->colorspace), alpha, cp, colorbv, state->dest);
+ eop = resolve_color(ctx, &op, shade->background, colorspace, alpha, cp, colorbv, state->dest);
n = dest->n;
if (eop)
@@ -1391,12 +1392,12 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
if (color_params->op)
{
- eop = set_op_from_spaces(ctx, &op, dest, shade->colorspace, 0);
+ eop = set_op_from_spaces(ctx, &op, dest, colorspace, 0);
}
else
eop = NULL;
- fz_paint_shade(ctx, shade, &ctm, dest, color_params, &bbox, eop);
+ fz_paint_shade(ctx, shade, colorspace, &ctm, dest, color_params, &bbox, eop);
if (shape)
fz_clear_pixmap_rect_with_value(ctx, shape, 255, &bbox);
diff --git a/source/fitz/draw-mesh.c b/source/fitz/draw-mesh.c
index eaca9c64..90838709 100644
--- a/source/fitz/draw-mesh.c
+++ b/source/fitz/draw-mesh.c
@@ -211,7 +211,7 @@ do_paint_tri(fz_context *ctx, void *arg, fz_vertex *av, fz_vertex *bv, fz_vertex
}
void
-fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap *dest, const fz_color_params *color_params, const fz_irect *bbox, const fz_overprint *op)
+fz_paint_shade(fz_context *ctx, fz_shade *shade, fz_colorspace *colorspace, const fz_matrix *ctm, fz_pixmap *dest, const fz_color_params *color_params, const fz_irect *bbox, const fz_overprint *op)
{
unsigned char clut[256][FZ_MAX_COLORS];
fz_pixmap *temp = NULL;
@@ -224,6 +224,9 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap
fz_var(temp);
fz_var(conv);
+ if (colorspace == NULL)
+ colorspace = shade->colorspace;
+
fz_try(ctx)
{
fz_concat(&local_ctm, &shade->matrix, ctm);
@@ -244,7 +247,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap
ptd.shade = shade;
ptd.bbox = bbox;
- fz_init_cached_color_converter(ctx, &ptd.cc, NULL, temp->colorspace, shade->colorspace, color_params);
+ fz_init_cached_color_converter(ctx, &ptd.cc, NULL, temp->colorspace, colorspace, color_params);
fz_process_shade(ctx, shade, &local_ctm, prepare_mesh_vertex, &do_paint_tri, &ptd);
if (shade->use_function)
@@ -254,7 +257,7 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap
* we need to render it in deviceN before painting it
* to the destination. If not, we are free to render it
* direct to the target. */
- if (fz_colorspace_is_device_n(ctx, shade->colorspace))
+ if (fz_colorspace_is_device_n(ctx, colorspace))
{
/* We've drawn it as greyscale, with the values being
* the input to the function. Now make DevN version
@@ -268,10 +271,10 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap
unsigned char *s = temp->samples;
unsigned char *d;
int hh = temp->h;
- int n = fz_colorspace_n(ctx, shade->colorspace);
+ int n = fz_colorspace_n(ctx, colorspace);
/* alpha = 1 here for the same reason as earlier */
- conv = fz_new_pixmap_with_bbox(ctx, shade->colorspace, bbox, NULL, 1);
+ conv = fz_new_pixmap_with_bbox(ctx, colorspace, bbox, NULL, 1);
d = conv->samples;
while (hh--)
{
@@ -303,10 +306,10 @@ fz_paint_shade(fz_context *ctx, fz_shade *shade, const fz_matrix *ctm, fz_pixmap
int hh = temp->h;
fz_color_converter cc;
- int cn = fz_colorspace_n(ctx, shade->colorspace);
+ int cn = fz_colorspace_n(ctx, colorspace);
int m = dest->n - dest->alpha;
int n = fz_colorspace_n(ctx, dest->colorspace);
- fz_find_color_converter(ctx, &cc, NULL, dest->colorspace, shade->colorspace, color_params);
+ fz_find_color_converter(ctx, &cc, NULL, dest->colorspace, colorspace, color_params);
for (i = 0; i < 256; i++)
{
cc.convert(ctx, &cc, color, shade->function[i]);
diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c
index b2bd7a8f..069caa9f 100644
--- a/source/fitz/stext-device.c
+++ b/source/fitz/stext-device.c
@@ -603,7 +603,7 @@ fz_new_image_from_shade(fz_context *ctx, fz_shade *shade, fz_matrix *in_out_ctm,
fz_fill_pixmap_with_color(ctx, pix, shade->colorspace, shade->background, color_params);
else
fz_clear_pixmap(ctx, pix);
- fz_paint_shade(ctx, shade, &ctm, pix, color_params, &bbox, NULL);
+ fz_paint_shade(ctx, shade, NULL, &ctm, pix, color_params, &bbox, NULL);
img = fz_new_image_from_pixmap(ctx, pix, NULL);
}
fz_always(ctx)
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index 3860b5c5..7c8dfd50 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -921,7 +921,7 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
fz_try(ctx)
{
- fz_paint_shade(ctx, shade, ctm, pix, color_params, &bbox, NULL);
+ fz_paint_shade(ctx, shade, NULL, ctm, pix, color_params, &bbox, NULL);
buf = fz_new_buffer_from_pixmap_as_png(ctx, pix, color_params);
if (alpha != 1.0f)
fz_write_printf(ctx, out, "<g opacity=\"%g\">\n", alpha);