[gs-cvs] rev 8225 - trunk/gs/src
leonardo at ghostscript.com
leonardo at ghostscript.com
Fri Aug 31 12:09:48 PDT 2007
Author: leonardo
Date: 2007-08-31 12:09:47 -0700 (Fri, 31 Aug 2007)
New Revision: 8225
Modified:
trunk/gs/src/gdevbbox.c
trunk/gs/src/gdevdbit.c
trunk/gs/src/gxccache.c
trunk/gs/src/gxclip.c
trunk/gs/src/gxclrast.c
trunk/gs/src/gxcpath.h
trunk/gs/src/gxfill.c
trunk/gs/src/gximask.c
trunk/gs/src/gxipixel.c
trunk/gs/src/gxstroke.c
Log:
Fix (graphics library) : Distinguish two methods gx_make_clip_device_on_stack, gx_make_clip_device_in_heap.
DETAILS :
This is a preparation for fixing the bug 689365
"Clipper device may have a wrong HWResolution",
step 2.
This change is algorithmically equivalent.
1. Drop tx, ty,arguments, because they always zero.
2. There are 2 different cases in code:
allocation on stack or in heap.
Now we define them explicitely.
3. Adding the 'target' argument,
and adjust reference counters inside the "in heap" method.
The call to open_device is moved inside the methods.
Note that the old code in some cases calls open_device
after doing some settings (2 occurances in gxfill.c).
The new code does before that.
We belirvr it is algorithmically equivalent,
because we checked open_device against using the
data being set there.
EXPECTED DIFFERENCES :
None.
Modified: trunk/gs/src/gdevbbox.c
===================================================================
--- trunk/gs/src/gdevbbox.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gdevbbox.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -1076,9 +1076,7 @@
fixed x0 = float2fixed(corners[0].x), y0 = float2fixed(corners[0].y);
fixed bx2 = float2fixed(corners[2].x) - x0, by2 = float2fixed(corners[2].y) - y0;
- gx_make_clip_translate_device(&cdev, pcpath, 0, 0, NULL);
- cdev.target = dev;
- (*dev_proc(&cdev, open_device)) ((gx_device *) & cdev);
+ gx_make_clip_device_on_stack(&cdev, pcpath, dev);
set_nonclient_dev_color(&devc, bdev->black); /* any non-white color will do */
bdev->target = NULL;
gx_default_fill_triangle((gx_device *) & cdev, x0, y0,
Modified: trunk/gs/src/gdevdbit.c
===================================================================
--- trunk/gs/src/gdevdbit.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gdevdbit.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -319,10 +319,8 @@
gx_device_clip cdev;
if (pcpath != 0) {
- gx_make_clip_translate_device(&cdev, pcpath, 0, 0, NULL);
- cdev.target = orig_dev;
+ gx_make_clip_device_on_stack(&cdev, pcpath, orig_dev);
dev = (gx_device *) & cdev;
- (*dev_proc(dev, open_device)) (dev);
} else
dev = orig_dev;
if (depth > 1) {
Modified: trunk/gs/src/gxccache.c
===================================================================
--- trunk/gs/src/gxccache.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxccache.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -315,10 +315,8 @@
code = gx_effective_clip_path(pgs, &pcpath);
if (code < 0)
return code;
- gx_make_clip_translate_device(&cdev, pcpath, 0, 0, NULL);
- cdev.target = imaging_dev;
+ gx_make_clip_device_on_stack(&cdev, pcpath, imaging_dev);
imaging_dev = (gx_device *) & cdev;
- (*dev_proc(imaging_dev, open_device)) (imaging_dev);
if_debug0('K', "[K](clipping)\n");
}
gx_set_dev_color(pgs);
Modified: trunk/gs/src/gxclip.c
===================================================================
--- trunk/gs/src/gxclip.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxclip.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -108,15 +108,27 @@
/* Make a clipping device. */
void
-gx_make_clip_translate_device(gx_device_clip * dev, const gx_clip_path *pcpath,
- int tx, int ty, gs_memory_t *mem)
+gx_make_clip_device_on_stack(gx_device_clip * dev, const gx_clip_path *pcpath, gx_device *target)
{
- gx_device_init((gx_device *)dev, (const gx_device *)&gs_clip_device,
- mem, true);
+ gx_device_init((gx_device *)dev, (const gx_device *)&gs_clip_device, NULL, true);
dev->list = *gx_cpath_list(pcpath);
- dev->translation.x = tx;
- dev->translation.y = ty;
+ dev->translation.x = 0;
+ dev->translation.y = 0;
+ dev->target = target;
+ (*dev_proc(dev, open_device)) ((gx_device *)dev);
}
+void
+gx_make_clip_device_in_heap(gx_device_clip * dev, const gx_clip_path *pcpath, gx_device *target,
+ gs_memory_t *mem)
+{
+ gx_device_init((gx_device *)dev, (const gx_device *)&gs_clip_device, mem, true);
+ dev->list = *gx_cpath_list(pcpath);
+ dev->translation.x = 0;
+ dev->translation.y = 0;
+ gx_device_set_target((gx_device_forward *)dev, target);
+ gx_device_retain((gx_device *)dev, true); /* will free explicitly */
+ (*dev_proc(dev, open_device)) ((gx_device *)dev);
+}
/* Define debugging statistics for the clipping loops. */
#ifdef DEBUG
struct stats_clip_s {
Modified: trunk/gs/src/gxclrast.c
===================================================================
--- trunk/gs/src/gxclrast.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxclrast.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -1423,9 +1423,7 @@
gx_device *ttdev = tdev;
if (pcpath != NULL && !clipper_dev_open) {
- gx_make_clip_translate_device(&clipper_dev, pcpath, 0, 0, NULL);
- clipper_dev.target = tdev;
- (*dev_proc(&clipper_dev, open_device))((gx_device *)&clipper_dev);
+ gx_make_clip_device_on_stack(&clipper_dev, pcpath, tdev);
clipper_dev_open = true;
}
if (clipper_dev_open)
Modified: trunk/gs/src/gxcpath.h
===================================================================
--- trunk/gs/src/gxcpath.h 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxcpath.h 2007-08-31 19:09:47 UTC (rev 8225)
@@ -108,8 +108,9 @@
gs_public_st_composite_use_final(st_device_clip, gx_device_clip,\
"gx_device_clip", device_clip_enum_ptrs, device_clip_reloc_ptrs,\
gx_device_finalize)
-void gx_make_clip_translate_device(gx_device_clip * dev, const gx_clip_path *pcpath,
- int tx, int ty, gs_memory_t *mem);
+void gx_make_clip_device_on_stack(gx_device_clip * dev, const gx_clip_path *pcpath, gx_device *target);
+void gx_make_clip_device_in_heap(gx_device_clip * dev, const gx_clip_path *pcpath, gx_device *target,
+ gs_memory_t *mem);
#define clip_rect_print(ch, str, ar)\
if_debug7(ch, "[%c]%s 0x%lx: (%d,%d),(%d,%d)\n", ch, str, (ulong)ar,\
Modified: trunk/gs/src/gxfill.c
===================================================================
--- trunk/gs/src/gxfill.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxfill.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -383,10 +383,8 @@
*/
if (pcpath) {
dev = (gx_device *) & cdev;
- gx_make_clip_translate_device(&cdev, pcpath, 0, 0, NULL);
- cdev.target = save_dev;
+ gx_make_clip_device_on_stack(&cdev, pcpath, save_dev);
cdev.max_fill_band = save_dev->max_fill_band;
- (*dev_proc(dev, open_device)) (dev);
}
}
/*
@@ -644,15 +642,13 @@
code = (*dev_proc(pdev, fill_path))(pdev, pis, ppath, params, NULL, pcpath1);
dev = pdev;
} else {
- gx_make_clip_translate_device(&cdev, pcpath1, 0, 0, NULL);
+ gx_make_clip_device_on_stack(&cdev, pcpath1, pdev);
cdev.HWResolution[0] = pdev->HWResolution[0];
cdev.HWResolution[1] = pdev->HWResolution[1];
- cdev.target = pdev;
dev = (gx_device *)&cdev;
if ((*dev_proc(pdev, pattern_manage))(pdev,
gs_no_id, NULL, pattern_manage__shading_area) > 0)
set_dev_proc(&cdev, fill_path, pass_shading_area_through_clip_path_device);
- (*dev_proc(dev, open_device))(dev);
code = 0;
}
if (code >= 0)
Modified: trunk/gs/src/gximask.c
===================================================================
--- trunk/gs/src/gximask.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gximask.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -70,9 +70,7 @@
if (code >= 0)
code = gx_dc_pattern2_clip_with_bbox(pdevc, tdev, &cpath_with_shading_bbox, &pcpath1);
if (code >= 0) {
- gx_make_clip_translate_device(&cdev, pcpath1, 0, 0, NULL);
- cdev.target = tdev;
- (*dev_proc(&cdev, open_device)) ((gx_device *) & cdev);
+ gx_make_clip_device_on_stack(&cdev, pcpath1, tdev);
code1 = gx_device_color_fill_rectangle(pdevc,
pcdev->bbox.p.x, pcdev->bbox.p.y,
pcdev->bbox.q.x - pcdev->bbox.p.x,
Modified: trunk/gs/src/gxipixel.c
===================================================================
--- trunk/gs/src/gxipixel.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxipixel.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -589,10 +589,7 @@
false);
return_error(gs_error_VMerror);
}
- gx_make_clip_translate_device(cdev, pcpath, 0, 0, mem);
- gx_device_retain((gx_device *)cdev, true); /* will free explicitly */
- gx_device_set_target((gx_device_forward *)cdev, dev);
- (*dev_proc(cdev, open_device)) ((gx_device *) cdev);
+ gx_make_clip_device_in_heap(cdev, pcpath, dev, mem);
penum->clip_dev = cdev;
}
if (penum->use_rop) { /* Set up the RasterOp source device. */
Modified: trunk/gs/src/gxstroke.c
===================================================================
--- trunk/gs/src/gxstroke.c 2007-08-31 17:22:21 UTC (rev 8224)
+++ trunk/gs/src/gxstroke.c 2007-08-31 19:09:47 UTC (rev 8225)
@@ -437,11 +437,9 @@
* If there is a clipping path, set up a clipping device.
*/
if (pcpath) {
- gx_make_clip_translate_device(&cdev, pcpath, 0, 0, NULL);
- cdev.target = dev;
+ gx_make_clip_device_on_stack(&cdev, pcpath, dev);
cdev.max_fill_band = dev->max_fill_band;
dev = (gx_device *) & cdev;
- (*dev_proc(dev, open_device)) (dev);
}
}
fill_params.rule = gx_rule_winding_number;
More information about the gs-cvs
mailing list