[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1556-gd8f0530

[email protected] (Ray Johnston)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, master has been updated
       via  d8f05309d5e54b6e75c2b78af9c0bcf5f62b493c (commit)
      from  ff856d0c44ce7d3f4d204f4a405857a6a6672a80 (commit)

----------------------------------------------------------------------
commit d8f05309d5e54b6e75c2b78af9c0bcf5f62b493c
Author: Ray Johnston <[email protected]>
Date:   Wed Aug 7 10:24:49 2019 -0700

    Bug 701308: Fix clip transpose logic that resulted in garbled output.
    
    This seems like it should have showed up earlier, but when the clip
    rectangle list was transposed, the _t1 and _s1 clip_fill_rectangle_
    functions were confused about the coordinates being sent to the target
    device fill_rectangle.
    
    Also during debug, I found that if the clip list consisted of more than
    a single rectangle, clip_get_clipping_box was only using the first rect,
    rather than accumulating the outer_box for the entire list.

diff --git a/base/gxclip.c b/base/gxclip.c
index fbce42c..47a1996 100644
--- a/base/gxclip.c
+++ b/base/gxclip.c
@@ -491,7 +491,7 @@ clip_fill_rectangle_t1(gx_device * dev, int x, int y, int w, int h,
         INCR(in_y);
         if (x >= rptr->xmin && xe <= rptr->xmax) {
             INCR(in);
-            return dev_proc(tdev, fill_rectangle)(tdev, x, y, w, h, color);
+            return dev_proc(tdev, fill_rectangle)(tdev, y, x, w, h, color);
         }
         else if ((rptr->prev == 0 || rptr->prev->ymax != rptr->ymax) &&
                  (rptr->next == 0 || rptr->next->ymax != rptr->ymax)
@@ -503,7 +503,7 @@ clip_fill_rectangle_t1(gx_device * dev, int x, int y, int w, int h,
                 xe = rptr->xmax;
             if (x >= xe)
                  return 0;
-            return dev_proc(tdev, fill_rectangle)(tdev, y, x, h, xe - x, color);
+            return dev_proc(tdev, fill_rectangle)(tdev, y, x, w, xe - x, color);
         }
     }
     ccdata.tdev = tdev;
@@ -565,7 +565,7 @@ clip_fill_rectangle_s1(gx_device * dev, int x, int y, int w, int h,
     h -= y;
     if (w <= 0 || h <= 0)
         return 0;
-    return dev_proc(tdev, fill_rectangle)(tdev, y, x, h, w, color);
+    return dev_proc(tdev, fill_rectangle)(tdev, x, y, w, h, color);
 }
 static int
 clip_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
@@ -1423,10 +1423,35 @@ clip_get_clipping_box(gx_device * dev, gs_fixed_rect * pbox)
                 cbox.q.y = int2fixed(rdev->list.single.ymax);
             } else {
                 /* The head and tail elements are dummies.... */
-                cbox.p.x = int2fixed(rdev->list.xmin);
-                cbox.p.y = int2fixed(rdev->list.head->next->ymin);
-                cbox.q.x = int2fixed(rdev->list.xmax);
-                cbox.q.y = int2fixed(rdev->list.tail->prev->ymax);
+                gx_clip_rect *curr = rdev->list.head->next;
+
+                cbox.p.x = cbox.p.y = max_int;
+                cbox.q.x = cbox.q.y = min_int;
+                /* scan the list for the outer bbox */
+                while (curr->next != NULL) {	/* stop before tail */
+                    if (curr->xmin < cbox.p.x)
+                        cbox.p.x = curr->xmin;
+                    if (curr->xmax > cbox.q.x)
+                        cbox.q.x = curr->xmax;
+                    if (curr->ymin < cbox.p.y)
+                        cbox.p.y = curr->ymin;
+                    if (curr->ymax > cbox.q.y)
+                        cbox.q.y = curr->ymax;
+                    curr = curr->next;
+                }
+                cbox.p.x = int2fixed(cbox.p.x);
+                cbox.q.x = int2fixed(cbox.q.x);
+                cbox.p.y = int2fixed(cbox.p.y);
+                cbox.q.y = int2fixed(cbox.q.y);
+            }
+            if (rdev->list.transpose) {
+                fixed temp = cbox.p.x;
+
+                cbox.p.x = cbox.p.y;
+                cbox.p.y = temp;
+                temp = cbox.q.x;
+                cbox.q.x = cbox.q.y;
+                cbox.q.y = temp;
             }
             rect_intersect(tbox, cbox);
         }


Summary of changes:
 base/gxclip.c | 39 ++++++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.