[poppler] poppler/splash: SplashXPath.cc,1.2,1.3

Albert Astals Cid aacid at freedesktop.org
Fri Sep 16 11:00:45 PDT 2005


Update of /cvs/poppler/poppler/splash
In directory gabe:/tmp/cvs-serv473/splash

Modified Files:
	SplashXPath.cc 
Log Message:
SplashXPath.cc merges from xpdf 3.00 -> 3.01


Index: SplashXPath.cc
===================================================================
RCS file: /cvs/poppler/poppler/splash/SplashXPath.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SplashXPath.cc	27 Aug 2005 08:43:43 -0000	1.2
+++ SplashXPath.cc	16 Sep 2005 18:00:43 -0000	1.3
@@ -34,8 +34,7 @@
 			 GBool closeSubpaths) {
   SplashCoord xc, yc, dx, dy, r, x0, y0, x1, y1;
   int quad0, quad1, quad;
-  int i, curSubpath;
-  GBool last;
+  int curSubpath, n, i, j;
 
   segs = NULL;
   length = size = 0;
@@ -93,52 +92,50 @@
 	} else {
 	  quad1 = 3;
 	}
+	n = 0; // make gcc happy
+	if (quad0 == quad1) {
+	  switch (quad0) {
+	  case 0:
+	  case 1: n = path->pts[i-1].x < path->pts[i+1].x ? 0 : 4; break;
+	  case 2:
+	  case 3: n = path->pts[i-1].x > path->pts[i+1].x ? 0 : 4; break;
+	  }
+	} else {
+	  n = (quad1 - quad0) & 3;
+	}
 	x0 = path->pts[i-1].x;
 	y0 = path->pts[i-1].y;
 	x1 = y1 = 0; // make gcc happy
 	quad = quad0;
-	while (1) {
+	for (j = 0; j < n; ++j) {
 	  switch (quad) {
 	  case 0: x1 = xc;     y1 = yc - r; break;
 	  case 1: x1 = xc + r; y1 = yc;     break;
 	  case 2: x1 = xc;     y1 = yc + r; break;
 	  case 3: x1 = xc - r; y1 = yc;     break;
 	  }
-	  last = gFalse;
-	  if (quad == quad1) {
-	    switch (quad) {
-	    case 0: 
-	    case 1: last = path->pts[i+1].x > x0; break;
-	    case 2:
-	    case 3: last = path->pts[i+1].x < x0; break;
-	    }
-	  }
-	  if (last) {
-	    addArc(x0, y0, path->pts[i+1].x, path->pts[i+1].y,
-		   xc, yc, r, quad, flatness,
-		   quad == quad0 && (path->flags[i-1] & splashPathFirst),
-		   (path->flags[i+1] & splashPathLast),
-		   quad == quad0 && !closeSubpaths &&
-		     (path->flags[i-1] & splashPathFirst) &&
-		     !(path->flags[i-1] & splashPathClosed),
-		   !closeSubpaths &&
-		     (path->flags[i+1] & splashPathLast) &&
-		     !(path->flags[i+1] & splashPathClosed));
-	    break;
-	  } else {
-	    addArc(x0, y0, x1, y1,
-		   xc, yc, r, quad, flatness,
-		   quad == quad0 && (path->flags[i-1] & splashPathFirst),
-		   gFalse,
-		   quad == quad0 && !closeSubpaths &&
-		     (path->flags[i-1] & splashPathFirst) &&
-		     !(path->flags[i-1] & splashPathClosed),
-		   gFalse);
-	    x0 = x1;
-	    y0 = y1;
-	    quad = (quad + 1) & 3;
-	  }
+	  addArc(x0, y0, x1, y1,
+		 xc, yc, r, quad, flatness,
+		 quad == quad0 && (path->flags[i-1] & splashPathFirst),
+		 gFalse,
+		 quad == quad0 && !closeSubpaths &&
+		   (path->flags[i-1] & splashPathFirst) &&
+		   !(path->flags[i-1] & splashPathClosed),
+		 gFalse);
+	  x0 = x1;
+	  y0 = y1;
+	  quad = (quad + 1) & 3;
 	}
+	addArc(x0, y0, path->pts[i+1].x, path->pts[i+1].y,
+	       xc, yc, r, quad, flatness,
+	       quad == quad0 && (path->flags[i-1] & splashPathFirst),
+	       (path->flags[i+1] & splashPathLast),
+	       quad == quad0 && !closeSubpaths &&
+	         (path->flags[i-1] & splashPathFirst) &&
+	         !(path->flags[i-1] & splashPathClosed),
+	       !closeSubpaths &&
+	         (path->flags[i+1] & splashPathLast) &&
+	         !(path->flags[i+1] & splashPathClosed));
 	i += 2;
 
       // line segment
@@ -309,8 +306,8 @@
 
     // compute the arc midpoint
     t = (xx0 - xc) * (xx1 - xc) - (yy0 - yc) * (yy1 - yc);
-    xm = splashSqrt(0.5 * (r2 + t));
-    ym = splashSqrt(0.5 * (r2 - t));
+    xm = splashSqrt((SplashCoord)0.5 * (r2 + t));
+    ym = splashSqrt((SplashCoord)0.5 * (r2 - t));
     switch (quad) {
     case 0: xm = xc - xm;  ym = yc - ym;  break;
     case 1: xm = xc + xm;  ym = yc - ym;  break;
@@ -320,8 +317,8 @@
 
     // compute distance from midpoint of straight segment to midpoint
     // of arc
-    dx = 0.5 * (xx0 + xx1) - xm;
-    dy = 0.5 * (yy0 + yy1) - ym;
+    dx = (SplashCoord)0.5 * (xx0 + xx1) - xm;
+    dy = (SplashCoord)0.5 * (yy0 + yy1) - ym;
 
     // if the arc is flat enough, or no more subdivisions are allowed,
     // add the straight line segment
@@ -376,7 +373,7 @@
     segs[length].flags |= splashXPathVert;
   } else {
     segs[length].dxdy = (x1 - x0) / (y1 - y0);
-    segs[length].dydx = 1 / segs[length].dxdy;
+    segs[length].dydx = (SplashCoord)1 / segs[length].dxdy;
   }
   if (y0 > y1) {
     segs[length].flags |= splashXPathFlip;



More information about the poppler mailing list