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

leonardo at ghostscript.com leonardo at ghostscript.com
Fri Aug 11 10:50:37 PDT 2006


Author: leonardo
Date: 2006-08-11 10:50:36 -0700 (Fri, 11 Aug 2006)
New Revision: 6986

Modified:
   trunk/gs/src/gdevpdfd.c
Log:
Fix (pdfwrite) : A stronger condition for skipping the initial fill with a white color.

DETAILS :

Bug 688641 "pdfwrite is_in_page is broken, leads to spurious transparency".

The old code skept any number initial fills with a white color.
The new code skips only if the filling box is entire page.
Also the condition about nested streams (sbstack_depth == 0) was wrong for ps2write.

EXPECTED DIFFERENCES :

FIG3.eps


Modified: trunk/gs/src/gdevpdfd.c
===================================================================
--- trunk/gs/src/gdevpdfd.c	2006-08-11 13:09:34 UTC (rev 6985)
+++ trunk/gs/src/gdevpdfd.c	2006-08-11 17:50:36 UTC (rev 6986)
@@ -42,12 +42,14 @@
 			gx_color_index color)
 {
     gx_device_pdf *pdev = (gx_device_pdf *) dev;
+    int bottom = (pdev->ResourcesBeforeUsage ? 1 : 0);
     int code;
 
     /* Make a special check for the initial fill with white, */
     /* which shouldn't cause the page to be opened. */
-    if (color == pdev->white && !is_in_page(pdev))
-	return 0;
+    if (color == pdev->white && !is_in_page(pdev) && pdev->sbstack_depth == bottom)
+	if (x == 0 && y == 0 && w == pdev->width && h == pdev->height)
+	    return 0;
     code = pdf_open_page(pdev, PDF_IN_STREAM);
     if (code < 0)
 	return code;
@@ -444,6 +446,7 @@
 /*
  * Prepare a fill with a color anc a clipping path.
  * Return 1 if there is nothing to paint.
+ * Changes *box to the clipping box.
  */
 private int
 prepare_fill_with_clip(gx_device_pdf *pdev, const gs_imager_state * pis,
@@ -451,14 +454,16 @@
 	      const gx_drawing_color * pdcolor, const gx_clip_path * pcpath)
 {
     bool new_clip;
+    int bottom = (pdev->ResourcesBeforeUsage ? 1 : 0);
+    gs_fixed_rect cbox;
     int code;
 
     /*
      * Check for an empty clipping path.
      */
     if (pcpath) {
-	gx_cpath_outer_box(pcpath, box);
-	if (box->p.x >= box->q.x || box->p.y >= box->q.y)
+	gx_cpath_outer_box(pcpath, &cbox);
+	if (cbox.p.x >= cbox.q.x || cbox.p.y >= cbox.q.y)
 	    return 1;		/* empty clipping path */
     }
     if (gx_dc_is_pure(pdcolor)) {
@@ -467,9 +472,14 @@
 	 * which shouldn't cause the page to be opened.
 	 */
 	if (gx_dc_pure_color(pdcolor) == pdev->white && 
-		!is_in_page(pdev) && pdev->sbstack_depth == 0)
-	    return 1;
+		!is_in_page(pdev) && pdev->sbstack_depth == bottom) {
+	    if (box->p.x == 0 && box->p.y == 0 && 
+		    box->q.x == int2fixed(pdev->width) && 
+		    box->q.y == int2fixed(pdev->height)) /* See gs_fillpage */
+		return 1;
+        }
     }
+    *box = cbox;
     new_clip = pdf_must_put_clip_path(pdev, pcpath);
     if (have_path || pdev->context == PDF_IN_NONE || new_clip) {
 	if (new_clip)
@@ -1055,7 +1065,7 @@
      * drawing anything.
      */
     bool have_path;
-    gs_fixed_rect box = {{0, 0}, {0, 0}};
+    gs_fixed_rect box = {{0, 0}, {0, 0}}, box1;
 
     have_path = !gx_path_is_void(ppath);
     if (!have_path && !pdev->vg_initial_set) {
@@ -1064,6 +1074,12 @@
 	pdf_reset_graphics(pdev);
 	return 0;
     }
+    if (have_path) {
+	code = gx_path_bbox(ppath, &box);
+	if (code < 0)
+	    return code;
+    }
+    box1 = box;
 
     code = prepare_fill_with_clip(pdev, pis, &box, have_path, pdcolor, pcpath);
     if (code == gs_error_rangecheck) {
@@ -1206,11 +1222,7 @@
 	double scale;
 	gs_matrix smat;
 	gs_matrix *psmat = NULL;
-	gs_fixed_rect box1;
 
-	code = gx_path_bbox(ppath, &box1);
-	if (code < 0)
-	    return code;
 	if (pcpath) {
  	    rect_intersect(box1, box);
  	    if (box1.p.x > box1.q.x || box1.p.y > box1.q.y)
@@ -1383,7 +1395,7 @@
     const gx_clip_path *pcpath)
 {
     int code;
-    gs_fixed_rect box1 = *rect, box = {{0, 0}, {0, 0}};
+    gs_fixed_rect box1 = *rect, box = box1;
     gx_device_pdf *pdev = (gx_device_pdf *) dev;
     double scale;
     gs_matrix smat;



More information about the gs-cvs mailing list