diff --git a/poppler/SplashOutputDev.cc b/poppler/SplashOutputDev.cc index 171825f..5728ba6 100644 --- a/poppler/SplashOutputDev.cc +++ b/poppler/SplashOutputDev.cc @@ -4266,7 +4266,20 @@ GBool SplashOutputDev::tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *ca matc[1] = ctm[1]; matc[2] = ctm[2]; matc[3] = ctm[3]; - retValue = splash->drawImage(&tilingBitmapSrc, &imgData, colorMode, gTrue, result_width, result_height, matc, gTrue) == splashOk; + GBool minorAxisZero = matc[1] == 0 && matc[2] == 0; + if (matc[0] > 0 && minorAxisZero && matc[3] > 0) { + // draw the tiles + for (int y = 0; y < imgData.repeatY; ++y) { + for (int x = 0; x < imgData.repeatX; ++x) { + x0 = splashFloor(matc[4]) + x * tBitmap->getWidth(); + y0 = splashFloor(matc[5]) + y * tBitmap->getHeight(); + splash->blitImage(tBitmap, gTrue, x0, y0); + } + } + retValue = gTrue; + } else { + retValue = splash->drawImage(&tilingBitmapSrc, &imgData, colorMode, gTrue, result_width, result_height, matc, gFalse, gTrue) == splashOk; + } delete tBitmap; delete gfx; return retValue; diff --git a/splash/Splash.cc b/splash/Splash.cc index 6a1891e..a014620 100644 --- a/splash/Splash.cc +++ b/splash/Splash.cc @@ -3682,7 +3682,7 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, return splashErrBadArg; } scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h, - scaledWidth, scaledHeight, interpolate); + scaledWidth, scaledHeight, interpolate, tilingPattern); if (scaledImg == NULL) { return splashErrBadArg; } @@ -3720,7 +3720,7 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, return splashErrBadArg; } scaledImg = scaleImage(src, srcData, srcMode, nComps, srcAlpha, w, h, - scaledWidth, scaledHeight, interpolate); + scaledWidth, scaledHeight, interpolate, tilingPattern); if (scaledImg == NULL) { return splashErrBadArg; } @@ -4063,13 +4063,13 @@ static GBool isImageInterpolationRequired(int srcWidth, int srcHeight, SplashBitmap *Splash::scaleImage(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, GBool interpolate) { + int scaledWidth, int scaledHeight, GBool interpolate, GBool tilingPattern) { SplashBitmap *dest; dest = new SplashBitmap(scaledWidth, scaledHeight, 1, srcMode, srcAlpha, gTrue, bitmap->getSeparationList()); if (dest->getDataPtr() != NULL) { - if (scaledHeight < srcHeight) { - if (scaledWidth < srcWidth) { + if (scaledHeight <= srcHeight) { + if (scaledWidth <= srcWidth) { scaleImageYdXd(src, srcData, srcMode, nComps, srcAlpha, srcWidth, srcHeight, scaledWidth, scaledHeight, dest); } else { @@ -4077,11 +4077,11 @@ SplashBitmap *Splash::scaleImage(SplashImageSource src, void *srcData, srcWidth, srcHeight, scaledWidth, scaledHeight, dest); } } else { - if (scaledWidth < srcWidth) { + if (scaledWidth <= srcWidth) { scaleImageYuXd(src, srcData, srcMode, nComps, srcAlpha, srcWidth, srcHeight, scaledWidth, scaledHeight, dest); } else { - if (isImageInterpolationRequired(srcWidth, srcHeight, scaledWidth, scaledHeight, interpolate)) { + if (!tilingPattern && isImageInterpolationRequired(srcWidth, srcHeight, scaledWidth, scaledHeight, interpolate)) { scaleImageYuXuBilinear(src, srcData, srcMode, nComps, srcAlpha, srcWidth, srcHeight, scaledWidth, scaledHeight, dest); } else { @@ -4971,6 +4971,13 @@ void Splash::vertFlipImage(SplashBitmap *img, int width, int height, gfree(lineBuf); } +void Splash::blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest) { + SplashClipResult clipRes = state->clip->testRect(xDest, yDest, xDest + src->getWidth() - 1, yDest + src->getHeight() - 1); + if (clipRes != splashClipAllOutside) { + blitImage(src, srcAlpha, xDest, yDest, clipRes); + } +} + void Splash::blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest, SplashClipResult clipRes) { SplashPipe pipe; diff --git a/splash/Splash.h b/splash/Splash.h index 8bcd1db..cf98e6c 100644 --- a/splash/Splash.h +++ b/splash/Splash.h @@ -232,6 +232,7 @@ public: // zero. SplashError blitTransparent(SplashBitmap *src, int xSrc, int ySrc, int xDest, int yDest, int w, int h); + void blitImage(SplashBitmap *src, GBool srcAlpha, int xDest, int yDest); //----- misc @@ -364,7 +365,7 @@ private: SplashBitmap *scaleImage(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, GBool srcAlpha, int srcWidth, int srcHeight, - int scaledWidth, int scaledHeight, GBool interpolate); + int scaledWidth, int scaledHeight, GBool interpolate, GBool tilingPattern = gFalse); void scaleImageYdXd(SplashImageSource src, void *srcData, SplashColorMode srcMode, int nComps, GBool srcAlpha, int srcWidth, int srcHeight,