[poppler] poppler/Gfx.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Dec 23 07:57:02 PST 2010


 poppler/Gfx.cc |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

New commits:
commit 0294d6e50691a3e40fad0d6e4fa9056944a91efd
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date:   Thu Dec 23 15:56:32 2010 +0000

    Be more correct when drawing radial shadings
    
    Fixes 32349

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 6b80e90..09c5381 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2924,17 +2924,24 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
     tb = t0 + sb * (t1 - t0);
     getShadingColorRadialHelper(t0, t1, tb, shading, &colorB);
     while (ib - ia > 1) {
-      if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta) && ib < radialMaxSplits) {
+      if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta)) {
         // The shading is not necessarily lineal so having two points with the
         // same color does not mean all the areas in between have the same color too
-        // Do another bisection to be a bit more sure we are not doing something wrong
-        GfxColor colorC;
-        int ic = (ia + ib) / 2;
-        double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - sMin);
-        double tc = t0 + sc * (t1 - t0);
-        getShadingColorRadialHelper(t0, t1, tc, shading, &colorC);
-        if (isSameGfxColor(colorC, colorA, nComps, radialColorDelta))
-          break;
+        int ic = ia + 1;
+        for (; ic <= ib; ic++) {
+          GfxColor colorC;
+          const double sc = sMin + ((double)ic / (double)radialMaxSplits) * (sMax - sMin);
+          const double tc = t0 + sc * (t1 - t0);
+          getShadingColorRadialHelper(t0, t1, tc, shading, &colorC);
+          if (!isSameGfxColor(colorC, colorA, nComps, radialColorDelta)) {
+            break;
+          }
+        }
+        ib = (ic > ia + 1) ? ic - 1 : ia + 1;
+        sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin);
+        tb = t0 + sb * (t1 - t0);
+        getShadingColorRadialHelper(t0, t1, tb, shading, &colorB);
+        break;
       }
       ib = (ia + ib) / 2;
       sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin);


More information about the poppler mailing list