[gs-cvs] rev 8659 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Wed Apr 23 07:06:12 PDT 2008
Author: leonardo
Date: 2008-04-23 07:06:11 -0700 (Wed, 23 Apr 2008)
New Revision: 8659
Modified:
trunk/gs/src/gsimage.c
trunk/gs/src/gsptype1.h
trunk/gs/src/gxacpath.c
trunk/gs/src/gximask.c
Log:
Fix (graphics) : Convert imagemask into a clipping path when painting a big pattern.
DETAILS :
Bug 689440 "PostScript file generates infinitely large temp file".
In the past we implemented a conversion of imagemask intoi a clipping path
for a faster painting a shading color. Now we do same for big type 1 patterns.
1. Enhanced the condition in gximask.c for passing big patterns.
2. In gximask.c filter out degenerate rectangles,
which can't be painted with gx_device_color_fill_rectangle.
3. Set a pure black color in gsimage.c,
because patterns can't convert with gx_device_black.
4. In gxacpath.c added the default copy_mono method
to the clip list accumulator device in order to handle
imagemask with the pure color set by (3).
5. In gximask.c added a proper setup of device width and height
to clip list accummulator, because gx_default_copy_mono needs them.
6. In gximask.c gx_device_retain is now called on errors.
The old code does not call it, and we think it caused memory leaks
in some rare cases.
This patch changes the behavior with shadings, because the old code paints
imagemask with the shading color to clip list accummulator.
The new code does with pure black, so that now the clipping is not
restricted with the shading area or the shading BBox.
But we believe that the final result should be same
and the performance should be some faster.
Note we keep the call to gx_dc_pattern2_clip_with_bbox_simple
in gx_image_fill_masked_end rather now it is always idle.
Doing so for the case if this change will need undoing for shadings.
The new code doesn't use the writing of big patterns into clist,
which was done with recent revision 8655.
That change appears unneccessary for this particular bug.
However we want to keep it in HEAD branch because it may be useful
for further impeovements when imagemask produces a too big clipping list.
This patch causes a minor raster difference with Bug688396.pdf .
Delaying it for better times.
EXPECTED DIFFERENCES :
Bug688396.pdf - a minoe raster difference.
Modified: trunk/gs/src/gsimage.c
===================================================================
--- trunk/gs/src/gsimage.c 2008-04-23 00:30:10 UTC (rev 8658)
+++ trunk/gs/src/gsimage.c 2008-04-23 14:06:11 UTC (rev 8659)
@@ -194,6 +194,7 @@
gx_clip_path *pcpath;
int code = gx_effective_clip_path(pgs, &pcpath);
gx_device *dev2 = dev;
+ gx_device_color dc_temp, *pdevc = pgs->dev_color;
if (code < 0)
return code;
@@ -219,9 +220,13 @@
if (code < 0)
return code;
}
+ if (dev2 != dev) {
+ set_nonclient_dev_color(&dc_temp, 1);
+ pdevc = &dc_temp;
+ }
}
code = gx_device_begin_typed_image(dev2, (const gs_imager_state *)pgs,
- NULL, pic, NULL, pgs->dev_color, pcpath, pgs->memory, ppie);
+ NULL, pic, NULL, pdevc, pcpath, pgs->memory, ppie);
if (code < 0)
return code;
code = is_image_visible(pic, pgs, pcpath);
Modified: trunk/gs/src/gsptype1.h
===================================================================
--- trunk/gs/src/gsptype1.h 2008-04-23 00:30:10 UTC (rev 8658)
+++ trunk/gs/src/gsptype1.h 2008-04-23 14:06:11 UTC (rev 8659)
@@ -24,6 +24,10 @@
# define gx_device_color_DEFINED
typedef struct gx_device_color_s gx_device_color;
#endif
+#ifndef gs_color_space_DEFINED
+# define gs_color_space_DEFINED
+typedef struct gs_color_space_s gs_color_space;
+#endif
/* ---------------- Types and structures ---------------- */
Modified: trunk/gs/src/gxacpath.c
===================================================================
--- trunk/gs/src/gxacpath.c 2008-04-23 00:30:10 UTC (rev 8658)
+++ trunk/gs/src/gxacpath.c 2008-04-23 14:06:11 UTC (rev 8659)
@@ -63,6 +63,7 @@
NULL,
accum_fill_rectangle,
NULL,
+ gx_default_copy_mono,
NULL,
NULL,
NULL,
@@ -77,7 +78,6 @@
NULL,
NULL,
NULL,
- NULL,
gx_default_fill_path,
gx_default_stroke_path,
gx_default_fill_mask,
Modified: trunk/gs/src/gximask.c
===================================================================
--- trunk/gs/src/gximask.c 2008-04-23 00:30:10 UTC (rev 8658)
+++ trunk/gs/src/gximask.c 2008-04-23 14:06:11 UTC (rev 8659)
@@ -35,7 +35,7 @@
gx_image_fill_masked_start(gx_device *dev, const gx_device_color *pdevc, const gx_clip_path *pcpath,
gs_memory_t *mem, gx_device **cdev)
{
- if (gx_dc_is_pattern2_color(pdevc)) {
+ if (gx_dc_is_pattern2_color(pdevc) || gx_dc_is_pattern1_color_clist_based(pdevc)) {
if (!dev_proc(dev, pattern_manage)(dev, gs_no_id, NULL, pattern_manage__can_accum)) {
extern_st(st_device_cpath_accum);
gx_device_cpath_accum *pcdev = gs_alloc_struct(mem,
@@ -48,6 +48,8 @@
gx_cpath_outer_box(pcpath, &cbox);
gx_cpath_accum_set_cbox(pcdev, &cbox);
pcdev->rc.memory = mem;
+ pcdev->width = dev->width; /* For gx_default_copy_mono. */
+ pcdev->height = dev->height; /* For gx_default_copy_mono. */
gx_device_retain((gx_device *)pcdev, true);
*cdev = (gx_device *)pcdev;
}
@@ -69,7 +71,7 @@
if (code >= 0)
code = gx_dc_pattern2_clip_with_bbox_simple(pdevc, tdev, &cpath);
gx_make_clip_device_on_stack(&cdev, &cpath, tdev);
- if (code >= 0) {
+ if (code >= 0 && pcdev->bbox.p.x < pcdev->bbox.q.x) {
code1 = gx_device_color_fill_rectangle(pdevc,
pcdev->bbox.p.x, pcdev->bbox.p.y,
pcdev->bbox.q.x - pcdev->bbox.p.x,
@@ -77,8 +79,8 @@
(gx_device *)&cdev, lop_default, 0);
if (code == 0)
code = code1;
- gx_device_retain((gx_device *)pcdev, false);
}
+ gx_device_retain((gx_device *)pcdev, false);
gx_cpath_free(&cpath, "s_image_cleanup");
return code;
}
More information about the gs-cvs
mailing list