Raster alignment in display device can not be less than pointer size
"Russell Lang" <[email protected]> Fri, 04 Mar 2005 19:46:10 +1100
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <4228BB02.10661.2EDFA58B@localhost> |
Log Message: The display device row alignment must be equal to or greater than the pointer size, since this is a requirement of the memory devices. Problem noticed on 64-bit builds. Russell Lang [email protected] Ghostgum Software Pty Ltd http://www.ghostgum.com.au/ _______________________________________________ gs-code-review mailing list [email protected] http://www.ghostscript.com/mailman/listinfo/gs-code-review
align1.txt
(application/octet-stream, 2.7 KB)
diff -u -r1.10 gdevdsp.h
--- src/gdevdsp.h 23 Aug 2004 09:57:21 -0000 1.10
+++ src/gdevdsp.h 3 Mar 2005 03:00:58 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2004, Ghostgum Software Pty Ltd. All rights reserved.
+/* Copyright (C) 2001-2005, Ghostgum Software Pty Ltd. All rights reserved.
This software is provided AS-IS with no warranty, either express or
implied.
@@ -128,8 +128,11 @@
} DISPLAY_FORMAT_555;
#define DISPLAY_555_MASK 0x00040000L
-/* Define the row alignment. The default is 4 bytes, so
- * DISPLAY_ROW_ALIGN_DEFAULT is the same as DISPLAY_ROW_ALIGN_4
+/* Define the row alignment, which must be equal to or greater then
+ * the size of a pointer.
+ * The default (DISPLAY_ROW_ALIGN_DEFAULT) is the size of a pointer,
+ * 4 bytes (DISPLAY_ROW_ALIGN_4) on 32-bit systems or 8 bytes
+ * (DISPLAY_ROW_ALIGN_8) on 64-bit systems.
*/
typedef enum {
DISPLAY_ROW_ALIGN_DEFAULT = (0<<20),
diff -u -r1.30 gdevdsp.c
--- src/gdevdsp.c 1 Oct 2004 23:35:02 -0000 1.30
+++ src/gdevdsp.c 3 Mar 2005 03:44:38 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2004, Ghostgum Software Pty Ltd. All rights reserved.
+/* Copyright (C) 2001-2005, Ghostgum Software Pty Ltd. All rights reserved.
This software is provided AS-IS with no warranty, either express or
implied.
@@ -1172,7 +1172,7 @@
private int
display_raster(gx_device_display *dev)
{
- int align = 4;
+ int align = 0;
int bytewidth = dev->width * dev->color_info.depth/8;
switch (dev->nFormat & DISPLAY_ROW_ALIGN_MASK) {
case DISPLAY_ROW_ALIGN_4:
@@ -1191,6 +1191,8 @@
align = 64;
break;
}
+ if (align < ARCH_ALIGN_PTR_MOD)
+ align = ARCH_ALIGN_PTR_MOD;
align -= 1;
bytewidth = (bytewidth + align) & (~align);
return bytewidth;
@@ -1494,6 +1496,7 @@
int bpc; /* bits per component */
int bpp; /* bits per pixel */
int maxvalue;
+ int align;
switch (nFormat & DISPLAY_DEPTH_MASK) {
case DISPLAY_DEPTH_1:
@@ -1520,6 +1523,31 @@
maxvalue = (1 << bpc) - 1;
ddev->devn_params.bitspercomponent = bpc;
+ switch (ddev->nFormat & DISPLAY_ROW_ALIGN_MASK) {
+ case DISPLAY_ROW_ALIGN_DEFAULT:
+ align = ARCH_ALIGN_PTR_MOD;
+ break;
+ case DISPLAY_ROW_ALIGN_4:
+ align = 4;
+ break;
+ case DISPLAY_ROW_ALIGN_8:
+ align = 8;
+ break;
+ case DISPLAY_ROW_ALIGN_16:
+ align = 16;
+ break;
+ case DISPLAY_ROW_ALIGN_32:
+ align = 32;
+ break;
+ case DISPLAY_ROW_ALIGN_64:
+ align = 64;
+ break;
+ default:
+ align = 0; /* not permitted */
+ }
+ if (align < ARCH_ALIGN_PTR_MOD)
+ return_error(gs_error_rangecheck);
+
switch (ddev->nFormat & DISPLAY_ALPHA_MASK) {
case DISPLAY_ALPHA_FIRST:
case DISPLAY_ALPHA_LAST: