Commit 7d46ac00 authored by Albert Astals Cid's avatar Albert Astals Cid

Merging SplashXPathScanner.cc changes from xpdf 3.01

parent e34713a2
...@@ -40,53 +40,57 @@ SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, GBool eoA) { ...@@ -40,53 +40,57 @@ SplashXPathScanner::SplashXPathScanner(SplashXPath *xPathA, GBool eoA) {
eo = eoA; eo = eoA;
// compute the bbox // compute the bbox
seg = &xPath->segs[0]; if (xPath->length == 0) {
if (seg->x0 <= seg->x1) { xMin = yMin = 1;
xMinFP = seg->x0; xMax = yMax = 0;
xMaxFP = seg->x1;
} else { } else {
xMinFP = seg->x1; seg = &xPath->segs[0];
xMaxFP = seg->x0; if (seg->x0 <= seg->x1) {
}
if (seg->flags & splashXPathFlip) {
yMinFP = seg->y1;
yMaxFP = seg->y0;
} else {
yMinFP = seg->y0;
yMaxFP = seg->y1;
}
for (i = 1; i < xPath->length; ++i) {
seg = &xPath->segs[i];
if (seg->x0 < xMinFP) {
xMinFP = seg->x0; xMinFP = seg->x0;
} else if (seg->x0 > xMaxFP) {
xMaxFP = seg->x0;
}
if (seg->x1 < xMinFP) {
xMinFP = seg->x1;
} else if (seg->x1 > xMaxFP) {
xMaxFP = seg->x1; xMaxFP = seg->x1;
} else {
xMinFP = seg->x1;
xMaxFP = seg->x0;
} }
if (seg->flags & splashXPathFlip) { if (seg->flags & splashXPathFlip) {
if (seg->y0 > yMaxFP) { yMinFP = seg->y1;
yMaxFP = seg->y0; yMaxFP = seg->y0;
}
} else { } else {
if (seg->y1 > yMaxFP) { yMinFP = seg->y0;
yMaxFP = seg->y1; yMaxFP = seg->y1;
}
for (i = 1; i < xPath->length; ++i) {
seg = &xPath->segs[i];
if (seg->x0 < xMinFP) {
xMinFP = seg->x0;
} else if (seg->x0 > xMaxFP) {
xMaxFP = seg->x0;
}
if (seg->x1 < xMinFP) {
xMinFP = seg->x1;
} else if (seg->x1 > xMaxFP) {
xMaxFP = seg->x1;
}
if (seg->flags & splashXPathFlip) {
if (seg->y0 > yMaxFP) {
yMaxFP = seg->y0;
}
} else {
if (seg->y1 > yMaxFP) {
yMaxFP = seg->y1;
}
} }
} }
xMin = splashFloor(xMinFP);
xMax = splashFloor(xMaxFP);
yMin = splashFloor(yMinFP);
yMax = splashFloor(yMaxFP);
} }
xMin = splashFloor(xMinFP);
xMax = splashFloor(xMaxFP);
yMin = splashFloor(yMinFP);
yMax = splashFloor(yMaxFP);
interY = 0; interY = yMin - 1;
xPathIdx = 0; xPathIdx = 0;
inter = NULL; inter = NULL;
interLen = interSize = 0; interLen = interSize = 0;
computeIntersections(yMin);
} }
SplashXPathScanner::~SplashXPathScanner() { SplashXPathScanner::~SplashXPathScanner() {
...@@ -234,14 +238,14 @@ void SplashXPathScanner::computeIntersections(int y) { ...@@ -234,14 +238,14 @@ void SplashXPathScanner::computeIntersections(int y) {
} else { } else {
if (ySegMin <= y) { if (ySegMin <= y) {
// intersection with top edge // intersection with top edge
xx0 = seg->x0 + (y - seg->y0) * seg->dxdy; xx0 = seg->x0 + ((SplashCoord)y - seg->y0) * seg->dxdy;
} else { } else {
// x coord of segment endpoint with min y coord // x coord of segment endpoint with min y coord
xx0 = (seg->flags & splashXPathFlip) ? seg->x1 : seg->x0; xx0 = (seg->flags & splashXPathFlip) ? seg->x1 : seg->x0;
} }
if (ySegMax >= y + 1) { if (ySegMax >= y + 1) {
// intersection with bottom edge // intersection with bottom edge
xx1 = seg->x0 + (y + 1 - seg->y0) * seg->dxdy; xx1 = seg->x0 + ((SplashCoord)y + 1 - seg->y0) * seg->dxdy;
} else { } else {
// x coord of segment endpoint with max y coord // x coord of segment endpoint with max y coord
xx1 = (seg->flags & splashXPathFlip) ? seg->x0 : seg->x1; xx1 = (seg->flags & splashXPathFlip) ? seg->x0 : seg->x1;
...@@ -254,7 +258,9 @@ void SplashXPathScanner::computeIntersections(int y) { ...@@ -254,7 +258,9 @@ void SplashXPathScanner::computeIntersections(int y) {
inter[interLen].x0 = splashFloor(xx1); inter[interLen].x0 = splashFloor(xx1);
inter[interLen].x1 = splashFloor(xx0); inter[interLen].x1 = splashFloor(xx0);
} }
if (ySegMin <= y && y < ySegMax && !(seg->flags & splashXPathHoriz)) { if (ySegMin <= y &&
(SplashCoord)y < ySegMax &&
!(seg->flags & splashXPathHoriz)) {
inter[interLen].count = eo ? 1 inter[interLen].count = eo ? 1
: (seg->flags & splashXPathFlip) ? 1 : -1; : (seg->flags & splashXPathFlip) ? 1 : -1;
} else { } else {
......
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