[gs-cvs] rev 8581 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Mon Mar 3 02:11:28 PST 2008
Author: leonardo
Date: 2008-03-03 02:11:27 -0800 (Mon, 03 Mar 2008)
New Revision: 8581
Modified:
trunk/gs/src/gdevp14.c
trunk/gs/src/gxclimag.c
trunk/gs/src/gxclist.c
trunk/gs/src/gxclpath.c
trunk/gs/src/gxclrect.c
Log:
Fix (clist) : Crop transparencsy commands while clist writing, step 1.
DETAILS :
This is a preparation to the next step.
In general, the behavior doesn't change,
but implementation details differ.
The old code maitains a flag cropping_by_y in the clist writer,
which triggers a cropping of objects by the Y axis.
The old code isn't perfect, because
it first crops by [cdev->cropping_min, cdev->cropping_max],
and then by [0, cdev->height].
In the new code we unite both croppings into a single one.
For doing that we remove the flag, and provide
the right interval [cdev->cropping_min, cdev->cropping_max]
in any case. Initially it is [0, cdev->height},
and it is narrowed when a shading bbox is set.
To restore the initial cropping after the shading
is complete, we maintain 2 new fields
save_croping_min and save_cropping_max.
So now the cropping mechanizm does not depend
on shading, and clients may set a croping when they need.
We'll use this feature in the next patch.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevp14.c
===================================================================
--- trunk/gs/src/gdevp14.c 2008-03-03 04:10:37 UTC (rev 8580)
+++ trunk/gs/src/gdevp14.c 2008-03-03 10:11:27 UTC (rev 8581)
@@ -1797,6 +1797,7 @@
{
gx_device_forward * pdev = (gx_device_forward *)dev;
gx_device * tdev = pdev->target;
+ pdf14_device *ñdev = (pdf14_device *)dev;
int code = 0;
/* The PDF 1.4 compositing devices must have a target */
@@ -1851,6 +1852,7 @@
pdf14_disable_device(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
+ pdf14_device *cdev = (pdf14_device *)dev;
if_debug0('v', "[v]pdf14_disable_device\n");
dev->color_info = pdev->target->color_info;
@@ -2016,7 +2018,6 @@
pdev->procs = dev_proto->procs;
gx_device_fill_in_procs(dev);
check_device_separable((gx_device *)pdev);
-
return code;
}
@@ -2165,8 +2166,9 @@
int code, sbyte, bit, count;
int run_length, startx, current_bit, bit_value;
gx_color_index current_color;
+ pdf14_device *pdev = (pdf14_device *)dev;
- fit_copy(dev, base, sourcex, sraster, id, x, y, w, h);
+ fit_copy(pdev, base, sourcex, sraster, id, x, y, w, h);
line = base + (sourcex >> 3);
sbit = sourcex & 7;
first_bit = 7 - sbit;
Modified: trunk/gs/src/gxclimag.c
===================================================================
--- trunk/gs/src/gxclimag.c 2008-03-03 04:10:37 UTC (rev 8580)
+++ trunk/gs/src/gxclimag.c 2008-03-03 10:11:27 UTC (rev 8581)
@@ -81,7 +81,9 @@
if (depth > 1 && (cdev->disable_mask & clist_disable_copy_alpha) != 0)
return_error(gs_error_unknownerror);
- fit_copy(dev, data, data_x, raster, id, rx, ry, rwidth, rheight);
+ crop_copy(cdev, data, data_x, raster, id, rx, ry, rwidth, rheight);
+ if (rwidth < 0 || rheight < 0)
+ return 0;
y0 = ry; /* must do after fit_copy */
/* If non-trivial clipping & complex clipping disabled, default */
Modified: trunk/gs/src/gxclist.c
===================================================================
--- trunk/gs/src/gxclist.c 2008-03-03 04:10:37 UTC (rev 8580)
+++ trunk/gs/src/gxclist.c 2008-03-03 10:11:27 UTC (rev 8581)
@@ -89,7 +89,7 @@
public_st_device_clist();
/* Forward declarations of driver procedures */
-static dev_proc_open_device(clist_open);
+dev_proc_open_device(clist_open);
static dev_proc_output_page(clist_output_page);
static dev_proc_close_device(clist_close);
static dev_proc_get_band(clist_get_band);
@@ -464,7 +464,8 @@
cdev->undercolor_removal_id = gs_no_id;
cdev->device_halftone_id = gs_no_id;
cdev->image_enum_id = gs_no_id;
- cdev->cropping_by_path = false;
+ cdev->cropping_min = cdev->save_cropping_min = 0;
+ cdev->cropping_max = cdev->save_cropping_max = cdev->height;
return 0;
}
/*
@@ -613,7 +614,7 @@
/* Open the device by initializing the device state and opening the */
/* scratch files. */
-static int
+int
clist_open(gx_device *dev)
{
gx_device_clist_writer * const cdev =
Modified: trunk/gs/src/gxclpath.c
===================================================================
--- trunk/gs/src/gxclpath.c 2008-03-03 04:10:37 UTC (rev 8580)
+++ trunk/gs/src/gxclpath.c 2008-03-03 10:11:27 UTC (rev 8581)
@@ -602,7 +602,8 @@
See comment below about pdcolor == NULL.
*/
code = gx_default_fill_path(dev, pis, ppath, params, pdcolor, pcpath);
- cdev->cropping_by_path = false;
+ cdev->cropping_min = cdev->save_cropping_min;
+ cdev->cropping_max = cdev->save_cropping_max;
return code;
}
if ( (cdev->disable_mask & clist_disable_fill_path) ||
@@ -624,8 +625,7 @@
}
ry = fixed2int(bbox.p.y) - 1;
rheight = fixed2int_ceiling(bbox.q.y) - ry + 1;
- fit_fill_y(dev, ry, rheight);
- fit_fill_h(dev, ry, rheight);
+ crop_fill_y(cdev, ry, rheight);
if (rheight <= 0)
return 0;
}
@@ -642,10 +642,9 @@
Put the clipping path only.
The graphics library will call us again with subdividing
the shading into trapezoids and rectangles.
- Note cropping_by_path is true during such calls. */
- cdev->cropping_by_path = true;
- cdev->cropping_min = ry;
- cdev->cropping_max = ry + rheight;
+ Narrow cropping_min, croping_max for such calls. */
+ cdev->cropping_min = max(ry, cdev->cropping_min);
+ cdev->cropping_max = min(ry + rheight, cdev->cropping_max);
RECT_ENUM_INIT(re, ry, rheight);
do {
RECT_STEP_INIT(re);
Modified: trunk/gs/src/gxclrect.c
===================================================================
--- trunk/gs/src/gxclrect.c 2008-03-03 04:10:37 UTC (rev 8580)
+++ trunk/gs/src/gxclrect.c 2008-03-03 10:11:27 UTC (rev 8581)
@@ -244,7 +244,9 @@
int code;
cmd_rects_enum_t re;
- fit_fill(dev, rx, ry, rwidth, rheight);
+ crop_fill(cdev, rx, ry, rwidth, rheight);
+ if (rwidth < 0 || rheight < 0)
+ return 0;
if (cdev->permanent_error < 0)
return (cdev->permanent_error);
RECT_ENUM_INIT(re, ry, rheight);
@@ -310,21 +312,7 @@
rheight = fixed2int_ceiling(ytop) - ry;
}
}
- if (cdev->cropping_by_path) {
- /* Cropping by Y is necessary when the shading path is smaller than shading.
- In this case the clipping path is written into the path's bands only.
- Thus bands outside the shading path are not clipped,
- but the shading may paint into them, so crop them here.
- */
- if (ry < cdev->cropping_min) {
- rheight = ry + rheight - cdev->cropping_min;
- ry = cdev->cropping_min;
- }
- if (ry + rheight > cdev->cropping_max)
- rheight = cdev->cropping_max - ry;
- }
- fit_fill_y(dev, ry, rheight);
- fit_fill_h(dev, ry, rheight);
+ crop_fill_y(cdev, ry, rheight);
if (rheight < 0)
return 0;
if (cdev->permanent_error < 0)
@@ -464,7 +452,9 @@
int code;
cmd_rects_enum_t re;
- fit_fill(dev, rx, ry, rwidth, rheight);
+ crop_fill(cdev, rx, ry, rwidth, rheight);
+ if (rwidth < 0 || rheight < 0)
+ return 0;
if (cdev->permanent_error < 0)
return (cdev->permanent_error);
RECT_ENUM_INIT(re, ry, rheight);
@@ -916,10 +906,12 @@
cmd_rects_enum_t re;
if (scolors != 0 && scolors[0] != scolors[1]) {
- fit_fill(dev, rx, ry, rwidth, rheight);
+ crop_fill(cdev, rx, ry, rwidth, rheight);
} else {
- fit_copy(dev, sdata, sourcex, sraster, id, rx, ry, rwidth, rheight);
+ crop_copy(cdev, sdata, sourcex, sraster, id, rx, ry, rwidth, rheight);
}
+ if (rwidth < 0 || rheight < 0)
+ return 0;
/*
* On CMYK devices, RasterOps must be executed with complete pixels
* if the operation involves the destination.
More information about the gs-cvs
mailing list