summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>2010-06-22 14:54:59 +0000
committerHenry Stiles <henry.stiles@artifex.com>2010-06-22 14:54:59 +0000
commit94b467a15d17b5f4bf5c9caad18f19694ff5d1c5 (patch)
tree32875b97738eb41649b80c3012af3ff3f974c34e
parentfbafc70e7d16e498bae23c28708e1035ef2f6502 (diff)
Erase patterns with the color white instead of filling the pattern
bitmap with 0 or 255. Previously the initialization was only used when anti aliasing was enabled, now initial erasing is done for all colored patterns, eliminating a long standing UMR in the pcl code where the pattern was combined with the destination/source with indeterminate results. The UMR manifested in frequent regression reports in the pcl tests (c321.bin for example), these reports should go away with this change, though (NB) the change only masks the underlying issue. git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11416 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/base/gxpcmap.c59
-rw-r--r--gs/base/gxpcolor.h3
-rw-r--r--gs/psi/zpcolor.c6
3 files changed, 53 insertions, 15 deletions
diff --git a/gs/base/gxpcmap.c b/gs/base/gxpcmap.c
index cf9ac8361..f3b10adcc 100644
--- a/gs/base/gxpcmap.c
+++ b/gs/base/gxpcmap.c
@@ -21,6 +21,7 @@
#include "gsutil.h" /* for gs_next_ids */
#include "gxfixed.h"
#include "gxmatrix.h"
+#include "gspath2.h"
#include "gxcspace.h" /* for gscolor2.h */
#include "gxcolor2.h"
#include "gxdcolor.h"
@@ -347,7 +348,6 @@ pattern_accum_open(gx_device * dev)
int height = pinst->size.y;
int code = 0;
bool mask_open = false;
- int abits;
/*
* C's bizarre coercion rules force us to copy HWResolution in pieces
@@ -435,19 +435,6 @@ pattern_accum_open(gx_device * dev)
code = (*dev_proc(bits, open_device)) ((gx_device *) bits);
gx_device_set_target((gx_device_forward *)padev,
(gx_device *)bits);
- if (pinst->saved) {
- abits = alpha_buffer_bits(pinst->saved);
- if (abits > 1) {
- if (bits->color_info.polarity ==
- GX_CINFO_POLARITY_SUBTRACTIVE) {
- memset(bits->base, 0,
- bits->raster * bits->height);
- } else {
- memset(bits->base, 255,
- bits->raster * bits->height);
- }
- }
- }
}
}
}
@@ -1051,6 +1038,38 @@ gx_pattern_cache_winnow(gx_pattern_cache * pcache,
}
}
+/* blank the pattern accumulator device assumed to be in the graphics
+ state */
+int
+gx_erase_colored_pattern(gs_state *pgs)
+{
+ int code;
+ gx_device_pattern_accum *pdev = (gx_device_pattern_accum *)gs_currentdevice(pgs);
+
+ if ((code = gs_gsave(pgs)) < 0)
+ return code;
+ if ((code = gs_setgray(pgs, 1.0)) >= 0) {
+ gs_rect rect;
+ gx_device_memory *mask;
+ pgs->log_op = lop_default;
+ rect.p.x = 0.0;
+ rect.p.y = 0.0;
+ rect.q.x = (double)pdev->width;
+ rect.q.y = (double)pdev->height;
+
+ /* we don't want the fill rectangle device call to use the
+ mask */
+ mask = pdev->mask;
+ pdev->mask = NULL;
+ code = gs_rectfill(pgs, &rect, 1);
+ /* restore the mask */
+ pdev->mask = mask;
+ if (code < 0)
+ return code;
+ }
+ return gs_grestore(pgs);
+}
+
/* Reload a (non-null) Pattern color into the cache. */
/* *pdc is already set, except for colors.pattern.p_tile and mask.m_tile. */
int
@@ -1095,7 +1114,19 @@ gx_pattern_load(gx_device_color * pdc, const gs_imager_state * pis,
if_debug0('v', "gx_pattern_load: pushing the pdf14 compositor device into this graphics state\n");
if ((code = gs_push_pdf14trans_device(saved)) < 0)
return code;
+ } else {
+ /* For colored patterns we clear the pattern device's
+ background. This is necessary for the anti aliasing code
+ and (unfortunately) it masks a difficult to fix UMR
+ affecting pcl patterns, see bug #690487. Note we have to
+ make a similar change in zpcolor.c where much of this
+ pattern code is duplicated to support high level stream
+ patterns. */
+ if (pinst->template.PaintType == 1)
+ if ((gx_erase_colored_pattern(saved)) < 0)
+ return code;
}
+
code = (*pinst->template.PaintProc)(&pdc->ccolor, saved);
if (code < 0) {
dev_proc(adev, close_device)((gx_device *)adev);
diff --git a/gs/base/gxpcolor.h b/gs/base/gxpcolor.h
index 37a90998c..202ff97b7 100644
--- a/gs/base/gxpcolor.h
+++ b/gs/base/gxpcolor.h
@@ -327,4 +327,7 @@ void tile_rect_trans_simple(int xmin, int ymin, int xmax, int ymax, int px, int
void tile_rect_trans_blend(int xmin, int ymin, int xmax, int ymax, int px, int py, const gx_color_tile *ptile,
gx_pattern_trans_t *fill_trans_buffer);
+/* File a colored pattern with white */
+int gx_erase_colored_pattern(gs_state *pgs);
+
#endif /* gxpcolor_INCLUDED */
diff --git a/gs/psi/zpcolor.c b/gs/psi/zpcolor.c
index b6b29734d..bcea4216e 100644
--- a/gs/psi/zpcolor.c
+++ b/gs/psi/zpcolor.c
@@ -242,7 +242,11 @@ pattern_paint_prepare(i_ctx_t *i_ctx_p)
if_debug0('v', " pushing the pdf14 compositor device into this graphics state\n");
if ((code = gs_push_pdf14trans_device(pgs)) < 0)
return code;
- }
+ } else { /* not transparent */
+ if (pinst->template.PaintType == 1)
+ if ((code = gx_erase_colored_pattern(pgs)) < 0)
+ return code;
+ }
} else {
gs_matrix m;
gs_rect bbox;