summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2023-01-31 14:31:43 +0000
committerRobin Watts <Robin.Watts@artifex.com>2023-02-07 17:22:19 +0000
commitae5f49271305465c6b00259e9382c4940906db6c (patch)
tree79f00ddbf03d6e92fc6e26f4ff4ff739b9a7f435
parent71d572e6b72d209b99f34b311298d51eac32fbb1 (diff)
downloadghostpdl-alphabits_fix_test.tar.gz
Bug 706368: alphabits device declares invalid width/height.alphabits_fix_test
We now assume that every device will give a true width and height (or set them to zero), so that callers can clip graphic operations to the extent of the device that is being called. The alphabits device was breaking this, and giving a much smaller width/height than was really the case. This caused us to incorrectly clip.
-rw-r--r--base/gdevddrw.c6
-rw-r--r--base/gspaint.c9
2 files changed, 9 insertions, 6 deletions
diff --git a/base/gdevddrw.c b/base/gdevddrw.c
index 347c6c252..07c9c0159 100644
--- a/base/gdevddrw.c
+++ b/base/gdevddrw.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2022 Artifex Software, Inc.
+/* Copyright (C) 2001-2023 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -427,7 +427,7 @@ gx_default_fill_trapezoid(gx_device * dev, const gs_fixed_edge * left,
/* Some devices init max->width to be int_max, which overflows when converted to fixed. */
int dw = dev->width > max_int_in_fixed ? max_int_in_fixed : dev->width;
if (ytop < 0)
- return 0;
+ return 0;
if (ybot < 0)
ybot = 0;
dw = int2fixed(dw);
@@ -447,7 +447,7 @@ gx_default_fill_trapezoid(gx_device * dev, const gs_fixed_edge * left,
/* Some devices init max->height to be int_max, which overflows when converted to fixed. */
int dh = dev->height > max_int_in_fixed ? max_int_in_fixed : dev->height;
if (ytop < 0)
- return 0;
+ return 0;
if (ybot < 0)
ybot = 0;
dh = int2fixed(dh);
diff --git a/base/gspaint.c b/base/gspaint.c
index d67ef36bc..b3500c1d5 100644
--- a/base/gspaint.c
+++ b/base/gspaint.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2022 Artifex Software, Inc.
+/* Copyright (C) 2001-2023 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -208,6 +208,7 @@ alpha_buffer_init(gs_gstate * pgs, fixed extra_x, fixed extra_y, int alpha_bits,
gs_fixed_rect bbox;
gs_int_rect ibox;
uint width, raster, band_space;
+ uint dev_width, dev_height;
uint height, height2;
gs_log2_scale_point log2_scale;
gs_memory_t *mem;
@@ -223,6 +224,7 @@ alpha_buffer_init(gs_gstate * pgs, fixed extra_x, fixed extra_y, int alpha_bits,
if ((ibox.q.y <= ibox.p.y) || (ibox.q.x <= ibox.p.x))
return 2;
width = (ibox.q.x - ibox.p.x) << log2_scale.x;
+ dev_width = ibox.q.x << log2_scale.x;
raster = bitmap_raster(width);
band_space = raster << log2_scale.y;
height2 = (ibox.q.y - ibox.p.y);
@@ -232,6 +234,7 @@ alpha_buffer_init(gs_gstate * pgs, fixed extra_x, fixed extra_y, int alpha_bits,
if (height > height2)
height = height2;
height <<= log2_scale.y;
+ dev_height = ibox.q.y << log2_scale.y;
mem = pgs->memory;
mdev = gs_alloc_struct(mem, gx_device_memory, &st_device_memory,
"alpha_buffer_init");
@@ -244,8 +247,8 @@ alpha_buffer_init(gs_gstate * pgs, fixed extra_x, fixed extra_y, int alpha_bits,
}
gs_make_mem_abuf_device(mdev, mem, dev, &log2_scale,
alpha_bits, ibox.p.x << log2_scale.x, devn);
- mdev->width = width;
- mdev->height = height;
+ mdev->width = dev_width;
+ mdev->height = dev_height;
mdev->bitmap_memory = mem;
if ((*dev_proc(mdev, open_device)) ((gx_device *) mdev) < 0) {
/* No room for bits, punt. */