[gs-cvs] rev 8279 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Wed Oct 10 01:59:39 PDT 2007


Author: leonardo
Date: 2007-10-10 01:59:39 -0700 (Wed, 10 Oct 2007)
New Revision: 8279

Modified:
   trunk/gs/src/gdevp14.c
Log:
Fix (pdf14 device) : Don't allocate transparency buffer for bands that appear outside the transparency bounding box.

DETAILS :

This is an optimization, which should be algorithmically equivalent.

For bands outside the transparency bounding box the old code
allocated a zero length buffer and performed fake operations with it.

The main change is gdevp14.c ln 550.
Others prevent an access to the buffer when it is not allocated.

Note that in some cases the new check is excessive
because (width <= 0 || height <= 0) normally means no buffer.
We check for (buf->data == NULL) anyway to simplify the sefity proof
and documentation.

EXPECTED DIFFERENCES :

None,


Modified: trunk/gs/src/gdevp14.c
===================================================================
--- trunk/gs/src/gdevp14.c	2007-10-10 08:12:49 UTC (rev 8278)
+++ trunk/gs/src/gdevp14.c	2007-10-10 08:59:39 UTC (rev 8279)
@@ -547,7 +547,7 @@
     result->rowstride = rowstride;
     result->transfer_fn = NULL;
     
-    if (height < 0) {
+    if (height <= 0) {
 	/* Empty clipping - will skip all drawings. */
 	result->planestride = 0;
 	result->data = 0;
@@ -598,7 +598,8 @@
     }
     if_debug3('v', "[v]base buf: %d x %d, %d channels\n",
 	      buf->rect.q.x, buf->rect.q.y, buf->n_chan);
-    memset(buf->data, 0, buf->planestride * buf->n_planes);
+    if (buf->data != NULL)
+	memset(buf->data, 0, buf->planestride * buf->n_planes);
     buf->saved = NULL;
     result->stack = buf;
     result->maskbuf = NULL;
@@ -675,6 +676,9 @@
     buf->saved = tos;
     ctx->stack = buf;
 
+    if (buf->data == NULL)
+	return 0;
+
     backdrop = pdf14_find_backdrop_buf(ctx);
     if (backdrop == NULL) {
 	memset(buf->data, 0, buf->planestride * (buf->n_chan +
@@ -905,7 +909,8 @@
 
     buf->saved = ctx->stack;
     ctx->stack = buf;
-    memset(buf->data, 0, buf->planestride * buf->n_chan);
+    if (buf->data != NULL)
+	memset(buf->data, 0, buf->planestride * buf->n_chan);
     return 0;
 }
 
@@ -1090,8 +1095,11 @@
     int code;
     int y;
 
-	file = fopen ("c:\\temp\\tmp.png", "wb");
+    if (buf->data == NULL)
+	return 0;
 
+    file = fopen ("c:\\temp\\tmp.png", "wb");
+
     if_debug0('v', "[v]pnga_output_page\n");
 
     if (row == 0 || png_ptr == 0 || info_ptr == 0) {
@@ -1205,7 +1213,7 @@
     dump_planar_rgba(pdev->memory, buf);
 #endif
 
-    if (width <= 0 || height <= 0)
+    if (width <= 0 || height <= 0 || buf->data == NULL)
 	return 0;
 
 #if 0
@@ -1353,6 +1361,10 @@
     int num_sep = pseparations->num_separations++;
 
     if_debug0('v', "[v]pdf14_cmykspot_put_image\n");
+
+    if (width <= 0 || height <= 0 || buf->data == NULL)
+	return 0;
+
     /*
      * The process color model for the PDF 1.4 compositor device is CMYK plus
      * spot colors.  The target device may have only some of these colorants due
@@ -1458,6 +1470,9 @@
 
     if_debug0('v', "[v]pdf14_custom_put_image\n");
 
+    if (width <= 0 || height <= 0 || buf->data == NULL)
+	return 0;
+
     /* Send pixel data to the target device. */
     for (y = 0; y < height; y++) {
 	for (x = 0; x < width; x++) {
@@ -2245,6 +2260,9 @@
     byte shape = 0; /* Quiet compiler. */
     byte src_alpha;
 
+    if (buf->data == NULL)
+	return 0;
+
     /* NB: gx_color_index is 4 or 8 bytes */
     if (sizeof(color) <= sizeof(ulong))
 	if_debug7('v', "[v]pdf14_mark_fill_rectangle, (%d, %d), %d x %d color = %lx  bm %d, nc %d,\n", 
@@ -2336,6 +2354,9 @@
     byte opacity;
     bool additive = pdev->ctx->additive;
 
+    if (buf->data == NULL)
+	return 0;
+
     if (sizeof(color) <= sizeof(ulong))
 	if_debug6('v', "[v]pdf14_mark_fill_rectangle_ko_simple, (%d, %d), %d x %d color = %lx, nc %d,\n", 
 		    x, y, w, h, (ulong)color, num_chan);



More information about the gs-cvs mailing list