diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-08-13 07:14:48 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-08-13 07:14:48 +0000 |
commit | 4b4995cda35627e06c43e25ecbe07c1bc1859bb5 (patch) | |
tree | 143ed02a389bab62f44043a54cbc70f69e312e2f /Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc | |
parent | 00d00899c484b81967558f43c4fe4a896ffdf610 (diff) |
xpdf 4.00
git-svn-id: svn://tug.org/texlive/trunk@45031 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc')
-rw-r--r-- | Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc | 153 |
1 files changed, 77 insertions, 76 deletions
diff --git a/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc b/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc index 6865c574f4e..bf7b802cf0d 100644 --- a/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc +++ b/Build/source/libs/xpdf/xpdf-src/splash/SplashClip.cc @@ -15,6 +15,7 @@ #include <stdlib.h> #include <string.h> #include "gmem.h" +#include "gmempp.h" #include "SplashErrorCodes.h" #include "SplashPath.h" #include "SplashXPath.h" @@ -52,6 +53,8 @@ SplashClip::SplashClip(int hardXMinA, int hardYMinA, eo = NULL; scanners = NULL; length = size = 0; + isSimple = gTrue; + prev = NULL; if ((w = hardXMax + 1) <= 0) { w = 1; } @@ -59,7 +62,7 @@ SplashClip::SplashClip(int hardXMinA, int hardYMinA, } SplashClip::SplashClip(SplashClip *clip) { - int w, i; + int w; hardXMin = clip->hardXMin; hardYMin = clip->hardYMin; @@ -75,17 +78,12 @@ SplashClip::SplashClip(SplashClip *clip) { yMaxI = clip->yMaxI; intBoundsValid = clip->intBoundsValid; intBoundsStrokeAdjust = clip->intBoundsStrokeAdjust; - length = clip->length; - size = clip->size; - paths = (SplashXPath **)gmallocn(size, sizeof(SplashXPath *)); - eo = (Guchar *)gmallocn(size, sizeof(Guchar)); - scanners = (SplashXPathScanner **) - gmallocn(size, sizeof(SplashXPathScanner *)); - for (i = 0; i < length; ++i) { - paths[i] = clip->paths[i]->copy(); - eo[i] = clip->eo[i]; - scanners[i] = new SplashXPathScanner(paths[i], eo[i], yMinI, yMaxI); - } + paths = NULL; + eo = NULL; + scanners = NULL; + length = size = 0; + isSimple = clip->isSimple; + prev = clip; if ((w = splashCeil(xMax)) <= 0) { w = 1; } @@ -96,8 +94,8 @@ SplashClip::~SplashClip() { int i; for (i = 0; i < length; ++i) { - delete paths[i]; delete scanners[i]; + delete paths[i]; } gfree(paths); gfree(eo); @@ -136,6 +134,8 @@ void SplashClip::resetToRect(SplashCoord x0, SplashCoord y0, eo = NULL; scanners = NULL; length = size = 0; + isSimple = gTrue; + prev = NULL; if (x0 < x1) { xMin = x0; @@ -202,11 +202,15 @@ SplashError SplashClip::clipToRect(SplashCoord x0, SplashCoord y0, } SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord *matrix, - SplashCoord flatness, GBool eoA) { + SplashCoord flatness, GBool eoA, + GBool enablePathSimplification, + SplashStrokeAdjustMode strokeAdjust) { SplashXPath *xPath; SplashCoord t; - xPath = new SplashXPath(path, matrix, flatness, gTrue); + xPath = new SplashXPath(path, matrix, flatness, gTrue, + enablePathSimplification, + strokeAdjust); // check for an empty path if (xPath->length == 0) { @@ -218,33 +222,8 @@ SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord *matrix, } // check for a rectangle - if (xPath->length == 4 && - xPath->segs[0].y0 == xPath->segs[0].y1 && - xPath->segs[1].x0 == xPath->segs[1].x1 && - xPath->segs[2].x0 == xPath->segs[2].x1 && - xPath->segs[3].y0 == xPath->segs[3].y1) { - clipToRect(xPath->segs[1].x0, xPath->segs[0].y0, - xPath->segs[2].x0, xPath->segs[3].y0); - delete xPath; - return splashOk; - } - if (xPath->length == 4 && - xPath->segs[0].x0 == xPath->segs[0].x1 && - xPath->segs[1].y0 == xPath->segs[1].y1 && - xPath->segs[2].x0 == xPath->segs[2].x1 && - xPath->segs[3].y0 == xPath->segs[3].y1) { - clipToRect(xPath->segs[0].x0, xPath->segs[1].y0, - xPath->segs[2].x0, xPath->segs[3].y0); - delete xPath; - return splashOk; - } - if (xPath->length == 4 && - xPath->segs[0].x0 == xPath->segs[0].x1 && - xPath->segs[1].x0 == xPath->segs[1].x1 && - xPath->segs[2].y0 == xPath->segs[2].y1 && - xPath->segs[3].y0 == xPath->segs[3].y1) { - clipToRect(xPath->segs[0].x0, xPath->segs[2].y0, - xPath->segs[1].x0, xPath->segs[3].y0); + if (xPath->isRect) { + clipToRect(xPath->rectX0, xPath->rectY0, xPath->rectX1, xPath->rectY1); delete xPath; return splashOk; } @@ -268,13 +247,14 @@ SplashError SplashClip::clipToPath(SplashPath *path, SplashCoord *matrix, scanners[length] = new SplashXPathScanner(xPath, eoA, splashFloor(yMin), splashCeil(yMax) - 1); ++length; + isSimple = gFalse; return splashOk; } SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin, int rectXMax, int rectYMax, - GBool strokeAdjust) { + SplashStrokeAdjustMode strokeAdjust) { // In general, this function tests the rectangle: // x = [rectXMin, rectXMax + 1) (note: coords are ints) // y = [rectYMin, rectYMax + 1) @@ -282,7 +262,7 @@ SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin, // x = [xMin, xMax) (note: coords are fp) // y = [yMin, yMax) - if (strokeAdjust && length == 0) { + if (strokeAdjust != splashStrokeAdjustOff && isSimple) { // special case for stroke adjustment with a simple clipping // rectangle -- the clipping region is: // x = [xMinI, xMaxI + 1) @@ -313,7 +293,7 @@ SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin, (SplashCoord)rectYMin >= yMax) { return splashClipAllOutside; } - if (length == 0 && + if (isSimple && (SplashCoord)rectXMin >= xMin && (SplashCoord)(rectXMax + 1) <= xMax && (SplashCoord)rectYMin >= yMin && @@ -325,9 +305,10 @@ SplashClipResult SplashClip::testRect(int rectXMin, int rectYMin, } void SplashClip::clipSpan(Guchar *line, int y, int x0, int x1, - GBool strokeAdjust) { + SplashStrokeAdjustMode strokeAdjust) { + SplashClip *clip; SplashCoord d; - int x0a, x1a, x, i; + int x0a, x1a, x0b, x1b, x, i; updateIntBounds(strokeAdjust); @@ -360,7 +341,7 @@ void SplashClip::clipSpan(Guchar *line, int y, int x0, int x1, //--- clip to the floating point rectangle // (if stroke adjustment is disabled) - if (!strokeAdjust) { + if (strokeAdjust == splashStrokeAdjustOff) { // clip left edge (xMin) if (x0a == xMinI) { @@ -391,22 +372,31 @@ void SplashClip::clipSpan(Guchar *line, int y, int x0, int x1, } } - if (length == 0) { + if (isSimple) { return; } //--- clip to the paths - for (i = 0; i < length; ++i) { - scanners[i]->getSpan(buf, y, x0a, x1a); - for (x = x0a; x <= x1a; ++x) { - line[x] = mul255(line[x], buf[x]); + for (clip = this; clip; clip = clip->prev) { + for (i = 0; i < clip->length; ++i) { + clip->scanners[i]->getSpan(buf, y, x0a, x1a, &x0b, &x1b); + if (x0a < x0b) { + memset(line + x0a, 0, x0b - x0a); + } + for (x = x0b; x <= x1b; ++x) { + line[x] = mul255(line[x], buf[x]); + } + if (x1b < x1a) { + memset(line + x1b + 1, 0, x1a - x1b); + } } } } GBool SplashClip::clipSpanBinary(Guchar *line, int y, int x0, int x1, - GBool strokeAdjust) { + SplashStrokeAdjustMode strokeAdjust) { + SplashClip *clip; int x0a, x1a, x0b, x1b, x, i; Guchar any; @@ -438,7 +428,7 @@ GBool SplashClip::clipSpanBinary(Guchar *line, int y, int x0, int x1, return gFalse; } - if (length == 0) { + if (isSimple) { for (x = x0a; x <= x1a; ++x) { if (line[x]) { return gTrue; @@ -448,52 +438,63 @@ GBool SplashClip::clipSpanBinary(Guchar *line, int y, int x0, int x1, } any = 0; - for (i = 0; i < length; ++i) { - scanners[i]->getSpanBinary(buf, y, x0a, x1a); - for (x0b = x0a; x0b <= x1a && !buf[x0b]; ++x0b) ; - if (x0a < x0b) { - memset(line + x0a, 0, x0b - x0a); - } - for (x1b = x1a; x1b >= x0b && !buf[x1b]; --x1b) ; - if (x1b < x1a) { - memset(line + x1b + 1, 0, x1a - x1b); - } - for (x = x0b; x <= x1b; ++x) { - line[x] &= buf[x]; - any |= line[x]; + for (clip = this; clip; clip = clip->prev) { + for (i = 0; i < clip->length; ++i) { + clip->scanners[i]->getSpanBinary(buf, y, x0a, x1a, &x0b, &x1b); + if (x0a < x0b) { + memset(line + x0a, 0, x0b - x0a); + } + for (x = x0b; x <= x1b; ++x) { + line[x] &= buf[x]; + any |= line[x]; + } + if (x1b < x1a) { + memset(line + x1b + 1, 0, x1a - x1b); + } } } return any != 0; } -int SplashClip::getXMinI(GBool strokeAdjust) { +int SplashClip::getXMinI(SplashStrokeAdjustMode strokeAdjust) { updateIntBounds(strokeAdjust); return xMinI; } -int SplashClip::getXMaxI(GBool strokeAdjust) { +int SplashClip::getXMaxI(SplashStrokeAdjustMode strokeAdjust) { updateIntBounds(strokeAdjust); return xMaxI; } -int SplashClip::getYMinI(GBool strokeAdjust) { +int SplashClip::getYMinI(SplashStrokeAdjustMode strokeAdjust) { updateIntBounds(strokeAdjust); return yMinI; } -int SplashClip::getYMaxI(GBool strokeAdjust) { +int SplashClip::getYMaxI(SplashStrokeAdjustMode strokeAdjust) { updateIntBounds(strokeAdjust); return yMaxI; } -void SplashClip::updateIntBounds(GBool strokeAdjust) { +int SplashClip::getNumPaths() { + SplashClip *clip; + int n; + + n = 0; + for (clip = this; clip; clip = clip->prev) { + n += clip->length; + } + return n; +} + +void SplashClip::updateIntBounds(SplashStrokeAdjustMode strokeAdjust) { if (intBoundsValid && strokeAdjust == intBoundsStrokeAdjust) { return; } - if (strokeAdjust && length == 0) { - splashStrokeAdjust(xMin, xMax, &xMinI, &xMaxI); - splashStrokeAdjust(yMin, yMax, &yMinI, &yMaxI); + if (strokeAdjust != splashStrokeAdjustOff && isSimple) { + splashStrokeAdjust(xMin, xMax, &xMinI, &xMaxI, strokeAdjust); + splashStrokeAdjust(yMin, yMax, &yMinI, &yMaxI, strokeAdjust); } else { xMinI = splashFloor(xMin); yMinI = splashFloor(yMin); |