X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fcups.git;a=blobdiff_plain;f=pdftops%2FSplashXPathScanner.cxx;h=d5b3048f688f63f077c17518556326696a3ebf38;hp=ea2ad871d353d5df75dfaee1b90707f080330d41;hb=bd7854cb4d663bb0e561eaf5b01bbd47baa71d22;hpb=4400e98de24bd267328aa20d57951fb6678297fe diff --git a/pdftops/SplashXPathScanner.cxx b/pdftops/SplashXPathScanner.cxx index ea2ad871d..d5b3048f6 100644 --- a/pdftops/SplashXPathScanner.cxx +++ b/pdftops/SplashXPathScanner.cxx @@ -186,7 +186,7 @@ GBool SplashXPathScanner::getNextSpan(int y, int *x0, int *x1) { } void SplashXPathScanner::computeIntersections(int y) { - SplashCoord ySegMin, ySegMax, xx0, xx1; + SplashCoord xSegMin, xSegMax, ySegMin, ySegMax, xx0, xx1; SplashXPathSeg *seg; int i, j; @@ -236,19 +236,27 @@ void SplashXPathScanner::computeIntersections(int y) { } else if (seg->flags & splashXPathVert) { xx0 = xx1 = seg->x0; } else { - if (ySegMin <= y) { - // intersection with top edge - xx0 = seg->x0 + ((SplashCoord)y - seg->y0) * seg->dxdy; + if (seg->x0 < seg->x1) { + xSegMin = seg->x0; + xSegMax = seg->x1; } else { - // x coord of segment endpoint with min y coord - xx0 = (seg->flags & splashXPathFlip) ? seg->x1 : seg->x0; + xSegMin = seg->x1; + xSegMax = seg->x0; } - if (ySegMax >= y + 1) { - // intersection with bottom edge - xx1 = seg->x0 + ((SplashCoord)y + 1 - seg->y0) * seg->dxdy; - } else { - // x coord of segment endpoint with max y coord - xx1 = (seg->flags & splashXPathFlip) ? seg->x0 : seg->x1; + // intersection with top edge + xx0 = seg->x0 + ((SplashCoord)y - seg->y0) * seg->dxdy; + // intersection with bottom edge + xx1 = seg->x0 + ((SplashCoord)y + 1 - seg->y0) * seg->dxdy; + // the segment may not actually extend to the top and/or bottom edges + if (xx0 < xSegMin) { + xx0 = xSegMin; + } else if (xx0 > xSegMax) { + xx0 = xSegMax; + } + if (xx1 < xSegMin) { + xx1 = xSegMin; + } else if (xx1 > xSegMax) { + xx1 = xSegMax; } } if (xx0 < xx1) {