Commit 09c9ff67 authored by Albert Astals Cid's avatar Albert Astals Cid

SplashXPath.cc merges from xpdf 3.00 -> 3.01

parent 0555ba86
2005-09-16 Albert Astals Cid <aacid@kde.org>
* splash/: Some merges from xpdf 3.01
2005-09-16 Albert Astals Cid <aacid@kde.org>
* configure.ac
* splash/SplashFTFontEngine.[cc|h]
......
......@@ -34,8 +34,7 @@ SplashXPath::SplashXPath(SplashPath *path, SplashCoord flatness,
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 @@ SplashXPath::SplashXPath(SplashPath *path, SplashCoord flatness,
} 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 @@ void SplashXPath::addArc(SplashCoord x0, SplashCoord y0,
// 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 @@ void SplashXPath::addArc(SplashCoord x0, SplashCoord y0,
// 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 @@ void SplashXPath::addSegment(SplashCoord x0, SplashCoord y0,
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment