[poppler] 2 commits - poppler/CurlPDFDocBuilder.cc poppler/Gfx.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Mon Nov 22 11:21:58 PST 2010


 poppler/CurlPDFDocBuilder.cc |    2 -
 poppler/Gfx.cc               |   71 ++++++++++++++++++++-----------------------
 2 files changed, 35 insertions(+), 38 deletions(-)

New commits:
commit 6a17cc89eda52f08cbacbf9bfaaeda22cf041e82
Author: Thomas Freitag <Thomas.Freitag at alfa.de>
Date:   Mon Nov 22 19:20:56 2010 +0000

    Improve rendering of radial shadings
    
    Improves the duck rendering in bug 22098

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 825d98c..6b80e90 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -2733,6 +2733,27 @@ void Gfx::doAxialShFill(GfxAxialShading *shading) {
   }
 }
 
+static inline void getShadingColorRadialHelper(double t0, double t1, double t, GfxRadialShading *shading, GfxColor *color)
+{
+  if (t0 < t1) {
+    if (t < t0) {
+      shading->getColor(t0, color);
+    } else if (t > t1) {
+      shading->getColor(t1, color);
+    } else {
+      shading->getColor(t, color);
+    }
+  } else {
+    if (t > t0) {
+      shading->getColor(t0, color);
+    } else if (t < t1) {
+      shading->getColor(t1, color);
+    } else {
+      shading->getColor(t, color);
+    }
+  }
+}
+
 void Gfx::doRadialShFill(GfxRadialShading *shading) {
   double xMin, yMin, xMax, yMax;
   double x0, y0, r0, x1, y1, r1, t0, t1;
@@ -2885,13 +2906,7 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
   xa = x0 + sa * (x1 - x0);
   ya = y0 + sa * (y1 - y0);
   ra = r0 + sa * (r1 - r0);
-  if (ta < t0) {
-    shading->getColor(t0, &colorA);
-  } else if (ta > t1) {
-    shading->getColor(t1, &colorA);
-  } else {
-    shading->getColor(ta, &colorA);
-  }
+  getShadingColorRadialHelper(t0, t1, ta, shading, &colorA);
 
   needExtend = !out->radialShadedSupportExtend(state, shading);
 
@@ -2907,42 +2922,24 @@ void Gfx::doRadialShFill(GfxRadialShading *shading) {
     ib = radialMaxSplits;
     sb = sMax;
     tb = t0 + sb * (t1 - t0);
-    if (tb < t0) {
-      shading->getColor(t0, &colorB);
-    } else if (tb > t1) {
-      shading->getColor(t1, &colorB);
-    } else {
-      shading->getColor(tb, &colorB);
-    }
+    getShadingColorRadialHelper(t0, t1, tb, shading, &colorB);
     while (ib - ia > 1) {
       if (isSameGfxColor(colorB, colorA, nComps, radialColorDelta) && ib < radialMaxSplits) {
-	// 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);
-	if (tc < t0) {
-	  shading->getColor(t0, &colorC);
-	} else if (tc > t1) {
-	  shading->getColor(t1, &colorC);
-	} else {
-	  shading->getColor(tc, &colorC);
-	}
-	if (isSameGfxColor(colorC, colorA, nComps, radialColorDelta))
-	  break;
+        // 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;
       }
       ib = (ia + ib) / 2;
       sb = sMin + ((double)ib / (double)radialMaxSplits) * (sMax - sMin);
       tb = t0 + sb * (t1 - t0);
-      if (tb < t0) {
-	shading->getColor(t0, &colorB);
-      } else if (tb > t1) {
-	shading->getColor(t1, &colorB);
-      } else {
-	shading->getColor(tb, &colorB);
-      }
+      getShadingColorRadialHelper(t0, t1, tb, shading, &colorB);
     }
 
     // compute center and radius of the circle
commit 9093adede4f9ad6fb2962dcefcb09c1d8c357715
Author: Albert Astals Cid <aacid at kde.org>
Date:   Sun Nov 21 23:49:12 2010 +0000

    pedantic ;

diff --git a/poppler/CurlPDFDocBuilder.cc b/poppler/CurlPDFDocBuilder.cc
index 948cd7a..5b02b14 100644
--- a/poppler/CurlPDFDocBuilder.cc
+++ b/poppler/CurlPDFDocBuilder.cc
@@ -43,5 +43,5 @@ GBool CurlPDFDocBuilder::supports(const GooString &uri)
   } else {
     return gFalse;
   }
-};
+}
 


More information about the poppler mailing list