diff options
author | Igor Melichev <igor.melichev@artifex.com> | 2007-08-31 19:09:47 +0000 |
---|---|---|
committer | Igor Melichev <igor.melichev@artifex.com> | 2007-08-31 19:09:47 +0000 |
commit | 697b446b612356f4b3ba315a116ec08b61b7574a (patch) | |
tree | 21e58ccf1d6219bddcb5b4dde419d3e829192d0d | |
parent | e7de387482fdd1396ccf11586b83e9093e37d98c (diff) |
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.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@8225 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/src/gdevbbox.c | 4 | ||||
-rw-r--r-- | gs/src/gdevdbit.c | 4 | ||||
-rw-r--r-- | gs/src/gxccache.c | 4 | ||||
-rw-r--r-- | gs/src/gxclip.c | 24 | ||||
-rw-r--r-- | gs/src/gxclrast.c | 4 | ||||
-rw-r--r-- | gs/src/gxcpath.h | 5 | ||||
-rw-r--r-- | gs/src/gxfill.c | 8 | ||||
-rw-r--r-- | gs/src/gximask.c | 4 | ||||
-rw-r--r-- | gs/src/gxipixel.c | 5 | ||||
-rw-r--r-- | gs/src/gxstroke.c | 4 |
10 files changed, 30 insertions, 36 deletions
diff --git a/gs/src/gdevbbox.c b/gs/src/gdevbbox.c index 7153a6d36..eb8188116 100644 --- a/gs/src/gdevbbox.c +++ b/gs/src/gdevbbox.c @@ -1076,9 +1076,7 @@ bbox_image_plane_data(gx_image_enum_common_t * info, 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, diff --git a/gs/src/gdevdbit.c b/gs/src/gdevdbit.c index b8454718e..bbe97116d 100644 --- a/gs/src/gdevdbit.c +++ b/gs/src/gdevdbit.c @@ -319,10 +319,8 @@ gx_default_fill_mask(gx_device * orig_dev, 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) { diff --git a/gs/src/gxccache.c b/gs/src/gxccache.c index 549bce399..f130a8415 100644 --- a/gs/src/gxccache.c +++ b/gs/src/gxccache.c @@ -315,10 +315,8 @@ gx_image_cached_char(register gs_show_enum * penum, register cached_char * cc) 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); diff --git a/gs/src/gxclip.c b/gs/src/gxclip.c index 311d956ca..eb61f6397 100644 --- a/gs/src/gxclip.c +++ b/gs/src/gxclip.c @@ -108,14 +108,26 @@ private const gx_device_clip gs_clip_device = /* 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 diff --git a/gs/src/gxclrast.c b/gs/src/gxclrast.c index cbdb6dc9a..306dd9d15 100644 --- a/gs/src/gxclrast.c +++ b/gs/src/gxclrast.c @@ -1423,9 +1423,7 @@ idata: data_size = 0; 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) diff --git a/gs/src/gxcpath.h b/gs/src/gxcpath.h index 21fe67ccf..458987e99 100644 --- a/gs/src/gxcpath.h +++ b/gs/src/gxcpath.h @@ -108,8 +108,9 @@ extern_st(st_device_clip); 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,\ diff --git a/gs/src/gxfill.c b/gs/src/gxfill.c index 5d84d3bca..d202f30c9 100644 --- a/gs/src/gxfill.c +++ b/gs/src/gxfill.c @@ -383,10 +383,8 @@ gx_general_fill_path(gx_device * pdev, const gs_imager_state * pis, */ 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 @@ gx_default_fill_path(gx_device * pdev, const gs_imager_state * pis, 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) diff --git a/gs/src/gximask.c b/gs/src/gximask.c index 1d7defe41..802036d4e 100644 --- a/gs/src/gximask.c +++ b/gs/src/gximask.c @@ -70,9 +70,7 @@ gx_image_fill_masked_end(gx_device *dev, gx_device *tdev, const gx_device_color 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, diff --git a/gs/src/gxipixel.c b/gs/src/gxipixel.c index 5aa49e6d7..5cb38fd39 100644 --- a/gs/src/gxipixel.c +++ b/gs/src/gxipixel.c @@ -589,10 +589,7 @@ gx_image_enum_begin(gx_device * dev, const gs_imager_state * pis, 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. */ diff --git a/gs/src/gxstroke.c b/gs/src/gxstroke.c index 6c13144df..c6729ed81 100644 --- a/gs/src/gxstroke.c +++ b/gs/src/gxstroke.c @@ -437,11 +437,9 @@ gx_stroke_path_only_aux(gx_path * ppath, gx_path * to_path, gx_device * pdev, * 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; |