summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-08-04 14:52:11 +0100
committerRobin Watts <robin.watts@artifex.com>2017-10-24 15:16:35 +0100
commit38620dea1512581a65350955cebb1028063ce42b (patch)
tree46172be5f2be7af54c974e04932e2bdd06c724bf
parent556a18a855b3641185c982cc31740b5462b3f970 (diff)
downloadmupdf-38620dea1512581a65350955cebb1028063ce42b.tar.xz
Avoid using overprinting routines unnecessarily.
-rw-r--r--source/fitz/draw-affine.c16
-rw-r--r--source/fitz/draw-device.c17
-rw-r--r--source/fitz/draw-imp.h14
-rw-r--r--source/fitz/draw-paint.c10
4 files changed, 36 insertions, 21 deletions
diff --git a/source/fitz/draw-affine.c b/source/fitz/draw-affine.c
index 8c48eb54..db6c2cd5 100644
--- a/source/fitz/draw-affine.c
+++ b/source/fitz/draw-affine.c
@@ -1355,7 +1355,7 @@ static paintfn_t *
fz_paint_affine_lerp(int da, int sa, int fa, int fb, int n, int alpha, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (alpha == 255)
return paint_affine_lerp_N_op;
@@ -1556,7 +1556,7 @@ fallback:
static paintfn_t *
fz_paint_affine_lerp_spots(int da, int sa, int fa, int fb, int dn, int sn, int alpha, const fz_overprint * restrict eop)
{
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (alpha == 255)
return paint_affine_lerp_N_op;
@@ -2484,7 +2484,7 @@ static paintfn_t *
fz_paint_affine_near(int da, int sa, int fa, int fb, int n, int alpha, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (alpha == 255)
return paint_affine_near_N_op;
@@ -2936,7 +2936,7 @@ fallback:
static paintfn_t *
fz_paint_affine_near_spots(int da, int sa, int fa, int fb, int dn, int sn, int alpha, const fz_overprint * restrict eop)
{
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (alpha == 255)
return paint_affine_near_N_op;
@@ -3399,7 +3399,7 @@ static paintfn_t *
fz_paint_affine_color_lerp(int da, int sa, int fa, int fb, int n, int alpha, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
return paint_affine_color_lerp_N_op;
#endif /* FZ_ENABLE_SPOT_RENDERING */
switch (n)
@@ -3425,7 +3425,7 @@ fz_paint_affine_color_lerp(int da, int sa, int fa, int fb, int n, int alpha, con
static paintfn_t *
fz_paint_affine_color_lerp_spots(int da, int sa, int fa, int fb, int dn, int sn, int alpha, const fz_overprint * restrict eop)
{
- if (eop != NULL)
+ if (fz_overprint_required(eop))
return paint_affine_color_lerp_N_op;
return da ? paint_affine_color_lerp_da_N : paint_affine_color_lerp_N;
}
@@ -3522,7 +3522,7 @@ static paintfn_t *
fz_paint_affine_color_near(int da, int sa, int fa, int fb, int n, int alpha, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
return da ? paint_affine_color_near_da_N_op : paint_affine_color_near_N_op;
#endif /* FZ_ENABLE_SPOT_RENDERING */
switch (n)
@@ -3549,7 +3549,7 @@ fz_paint_affine_color_near(int da, int sa, int fa, int fb, int n, int alpha, con
static paintfn_t *
fz_paint_affine_color_near_spots(int da, int sa, int fa, int fb, int dn, int sn, int alpha, const fz_overprint * restrict eop)
{
- if (eop != NULL)
+ if (fz_overprint_required(eop))
return paint_affine_color_near_N_op;
return da ? paint_affine_color_near_da_N : paint_affine_color_near_N;
}
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index bab1c5a6..eba18fb6 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -348,16 +348,16 @@ colors_supported(fz_context *ctx, fz_colorspace *cs, fz_pixmap *dest)
return 0;
}
-static void
+static fz_overprint *
set_op_from_spaces(fz_context *ctx, fz_overprint *op, const fz_pixmap *dest, const fz_colorspace *src, int opm)
{
int dn, sn, i, j, dc;
if (!op)
- return;
+ return NULL;
if (!fz_colorspace_is_subtractive(ctx, src) || !fz_colorspace_is_subtractive(ctx, dest->colorspace))
- return;
+ return NULL;
sn = fz_colorspace_n(ctx, src);
dn = dest->n - dest->alpha;
@@ -438,6 +438,8 @@ set_op_from_spaces(fz_context *ctx, fz_overprint *op, const fz_pixmap *dest, con
if (j == sn)
fz_set_overprint(op, i);
}
+
+ return op;
}
static fz_overprint *
@@ -464,7 +466,7 @@ resolve_color(fz_context *ctx, fz_overprint *op, const float *color, fz_colorspa
fz_convert_separation_colors(ctx, color_params, dest->colorspace, dest->seps, colorfv, colorspace, color);
for (i = 0; i < n; i++)
colorbv[i] = colorfv[i] * 255;
- set_op_from_spaces(ctx, op, dest, colorspace, color_params->opm);
+ op = set_op_from_spaces(ctx, op, dest, colorspace, color_params->opm);
}
else
{
@@ -1389,8 +1391,7 @@ fz_draw_fill_shade(fz_context *ctx, fz_device *devp, fz_shade *shade, const fz_m
if (color_params->op)
{
- eop = &op;
- set_op_from_spaces(ctx, eop, dest, shade->colorspace, 0);
+ eop = set_op_from_spaces(ctx, &op, dest, shade->colorspace, 0);
}
else
eop = NULL;
@@ -1495,7 +1496,7 @@ convert_pixmap_for_painting(fz_context *ctx, fz_pixmap *pixmap, fz_colorspace *m
if (fz_colorspace_is_device_n(ctx, src_cs) && dest->seps)
{
converted = fz_clone_pixmap_area_with_different_seps(ctx, pixmap, NULL, model, dest->seps, color_params, dev->default_cs);
- set_op_from_spaces(ctx, *eop, dest, src_cs, 0);
+ *eop = set_op_from_spaces(ctx, *eop, dest, src_cs, 0);
}
else
{
@@ -1516,7 +1517,7 @@ convert_pixmap_for_painting(fz_context *ctx, fz_pixmap *pixmap, fz_colorspace *m
}
else
{
- set_op_from_spaces(ctx, *eop, dest, src_cs, 0);
+ *eop = set_op_from_spaces(ctx, *eop, dest, src_cs, 0);
}
}
}
diff --git a/source/fitz/draw-imp.h b/source/fitz/draw-imp.h
index 47a429d1..c14947c8 100644
--- a/source/fitz/draw-imp.h
+++ b/source/fitz/draw-imp.h
@@ -126,6 +126,20 @@ static int inline fz_overprint_component(const fz_overprint *op, int i)
return ((op->mask[i>>5]>>(i & 31)) & 1) == 0;
}
+static int inline fz_overprint_required(const fz_overprint *op)
+{
+ int i;
+
+ if (op == NULL)
+ return 0;
+
+ for (i = 0; i < (FZ_MAX_COLORS+31)/32; i++)
+ if (op->mask[i] != 0)
+ return 1;
+
+ return 0;
+}
+
/*
* Scan converter
*/
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c
index 581c2ff9..aaa1c890 100644
--- a/source/fitz/draw-paint.c
+++ b/source/fitz/draw-paint.c
@@ -572,7 +572,7 @@ fz_solid_color_painter_t *
fz_get_solid_color_painter(int n, const byte * restrict color, int da, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (da)
return paint_solid_color_N_da_op;
@@ -1015,7 +1015,7 @@ fz_span_color_painter_t *
fz_get_span_color_painter(int n, int da, const byte * restrict color, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
return da ? paint_span_with_color_N_da_op : paint_span_with_color_N_op;
}
@@ -1990,7 +1990,7 @@ fz_span_painter_t *
fz_get_span_painter(int da, int sa, int n, int alpha, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (alpha == 255)
return paint_span_N_general_op;
@@ -2572,7 +2572,7 @@ static inline void
fz_paint_glyph_alpha(const unsigned char * restrict colorbv, int n, int span, unsigned char * restrict dp, int da, const fz_glyph *glyph, int w, int h, int skip_x, int skip_y, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (da)
fz_paint_glyph_alpha_N_da_op(colorbv, n, span, dp, glyph, w, h, skip_x, skip_y, eop);
@@ -2629,7 +2629,7 @@ static inline void
fz_paint_glyph_solid(const unsigned char * restrict colorbv, int n, int span, unsigned char * restrict dp, int da, const fz_glyph * restrict glyph, int w, int h, int skip_x, int skip_y, const fz_overprint * restrict eop)
{
#ifdef FZ_ENABLE_SPOT_RENDERING
- if (eop != NULL)
+ if (fz_overprint_required(eop))
{
if (da)
fz_paint_glyph_solid_N_da_op(colorbv, n, span, dp, glyph, w, h, skip_x, skip_y, eop);