diff options
author | Ray Johnston <ray.johnston@artifex.com> | 1999-04-02 07:39:50 +0000 |
---|---|---|
committer | Ray Johnston <ray.johnston@artifex.com> | 1999-04-02 07:39:50 +0000 |
commit | d8abcd6dda0c16ec723e00fbea84fe59a63c2203 (patch) | |
tree | 481ee9bca90189240ab03acb24deb8f16a3a5bb0 /gs/src | |
parent | 2a5e8c4a4862e044917e4e83e5ebae72e8c2fc7d (diff) |
Add a check for parallelograms that are rectangles.
git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@796 06663e23-700e-0410-b217-a244a6096597
Diffstat (limited to 'gs/src')
-rw-r--r-- | gs/src/gdevddrw.c | 36 | ||||
-rw-r--r-- | gs/src/gxclpath.c | 15 |
2 files changed, 27 insertions, 24 deletions
diff --git a/gs/src/gdevddrw.c b/gs/src/gdevddrw.c index ba2ffcb27..01782d877 100644 --- a/gs/src/gdevddrw.c +++ b/gs/src/gdevddrw.c @@ -23,6 +23,7 @@ #include "gx.h" #include "gpcheck.h" #include "gserrors.h" +#include "gsrect.h" #include "gxfixed.h" #include "gxmatrix.h" #include "gxdcolor.h" @@ -234,38 +235,32 @@ gx_default_fill_parallelogram(gx_device * dev, { fixed t; fixed qx, qy, ym; - dev_proc_fill_trapezoid((*fill_trapezoid)); gs_fixed_edge left, right; int code; - /* Ensure ay >= 0, by >= 0. */ - if (ay < 0) - px += ax, py += ay, ax = -ax, ay = -ay; - if (by < 0) - px += bx, py += by, bx = -bx, by = -by; - qx = px + ax + bx; /* Make a special fast check for rectangles. */ - if ((ay | bx) == 0 || (by | ax) == 0) { /* If a point falls exactly on the middle of a pixel, */ - /* we must round it down, not up. */ - int rx = fixed2int_pixround(px); - int ry = fixed2int_pixround(py); - - /* Exactly one of (ax,bx) and one of (ay,by) is non-zero. */ - int w = fixed2int_pixround(qx) - rx; - - if (w < 0) - rx += w, w = -w; - return gx_fill_rectangle_device_rop(rx, ry, w, - fixed2int_pixround(py + ay + by) - ry, - pdevc, dev, lop); + if (PARALLELOGRAM_IS_RECT(ax, ay, bx, by)) { + gs_int_rect r; + + INT_RECT_FROM_PARALLELOGRAM(&r, px, py, ax, ay, bx, by); + return gx_fill_rectangle_device_rop(r.p.x, r.p.y, r.q.x - r.p.x, + r.q.y - r.p.y, pdevc, dev, lop); } /* * Not a rectangle. Ensure that the 'a' line is to the left of * the 'b' line. Testing ax <= bx is neither sufficient nor * necessary: in general, we need to compare the slopes. */ + /* Ensure ay >= 0, by >= 0. */ + if (ay < 0) + px += ax, py += ay, ax = -ax, ay = -ay; + if (by < 0) + px += bx, py += by, bx = -bx, by = -by; + qx = px + ax + bx; + #define swap(r, s) (t = r, r = s, s = t) + if ((ax ^ bx) < 0) { /* In this case, the test ax <= bx is sufficient. */ if (ax > bx) swap(ax, bx), swap(ay, by); @@ -346,7 +341,6 @@ gx_default_fill_triangle(gx_device * dev, { fixed t; fixed ym; - dev_proc_fill_trapezoid((*fill_trapezoid)) = dev_proc(dev, fill_trapezoid); gs_fixed_edge left, right; diff --git a/gs/src/gxclpath.c b/gs/src/gxclpath.c index f82193046..23082bb7e 100644 --- a/gs/src/gxclpath.c +++ b/gs/src/gxclpath.c @@ -28,6 +28,7 @@ #include "gxcldev.h" #include "gxclpath.h" #include "gxcolor2.h" +#include "gxdcolor.h" #include "gxpaint.h" /* for gx_fill/stroke_params */ #include "gzpath.h" #include "gzcpath.h" @@ -712,9 +713,10 @@ clist_stroke_path(gx_device * dev, const gs_imager_state * pis, gx_path * ppath, } /* - * Fill_parallelogram and fill_triangle aren't very efficient. This - * isn't important right now, since they are only used for smooth - * shading. + * Fill_parallelogram and fill_triangle aren't very efficient. This isn't + * important right now, since the non-degenerate case is only used for + * smooth shading. However, the rectangular case of fill_parallelogram is + * sometimes used for images, so its performance does matter. */ private int @@ -774,6 +776,13 @@ clist_fill_parallelogram(gx_device *dev, fixed px, fixed py, gs_fixed_point pts[3]; int code; + if (PARALLELOGRAM_IS_RECT(ax, ay, bx, by)) { + gs_int_rect r; + + INT_RECT_FROM_PARALLELOGRAM(&r, px, py, ax, ay, bx, by); + return gx_fill_rectangle_device_rop(r.p.x, r.p.y, r.q.x - r.p.x, + r.q.y - r.p.y, pdcolor, dev, lop); + } if ( (cdev->disable_mask & clist_disable_fill_path) || gs_debug_c(',') ) { |