Index: src/effects/SkTileImageFilter.cpp |
diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp |
index 73e5304adb3db2f8a0a87908a5f3e1b0c0d76030..08dfec4493d51d34de9f889a4953ddbb75d604a1 100644 |
--- a/src/effects/SkTileImageFilter.cpp |
+++ b/src/effects/SkTileImageFilter.cpp |
@@ -19,15 +19,17 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S |
SkBitmap* dst, SkIPoint* offset) { |
SkBitmap source = src; |
SkImageFilter* input = getInput(0); |
- SkIPoint localOffset = SkIPoint::Make(0, 0); |
- if (input && !input->filterImage(proxy, src, ctm, &source, &localOffset)) { |
+ SkIPoint srcOffset = SkIPoint::Make(0, 0); |
+ if (input && !input->filterImage(proxy, src, ctm, &source, &srcOffset)) { |
return false; |
} |
SkRect dstRect; |
ctm.mapRect(&dstRect, fDstRect); |
- int w = SkScalarCeilToInt(dstRect.width()); |
- int h = SkScalarCeilToInt(dstRect.height()); |
+ SkIRect dstIRect; |
+ dstRect.roundOut(&dstIRect); |
+ int w = dstIRect.width(); |
+ int h = dstIRect.height(); |
if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) { |
return false; |
} |
@@ -36,10 +38,13 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S |
ctm.mapRect(&srcRect, fSrcRect); |
SkIRect srcIRect; |
srcRect.roundOut(&srcIRect); |
+ srcIRect.offset(-srcOffset); |
SkBitmap subset; |
SkIRect bounds; |
source.getBounds(&bounds); |
+ |
if (!srcIRect.intersect(bounds)) { |
+ offset->fX = offset->fY = 0; |
return true; |
} else if (!source.extractSubset(&subset, srcIRect)) { |
return false; |
@@ -55,10 +60,16 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S |
SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset, |
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)); |
+ SkMatrix shaderMatrix; |
+ shaderMatrix.setTranslate(SkIntToScalar(srcOffset.fX), |
+ SkIntToScalar(srcOffset.fY)); |
+ shader->setLocalMatrix(shaderMatrix); |
paint.setShader(shader); |
- dstRect.offset(SkIntToScalar(localOffset.fX), SkIntToScalar(localOffset.fY)); |
+ canvas.translate(-dstRect.fLeft, -dstRect.fTop); |
canvas.drawRect(dstRect, paint); |
*dst = device->accessBitmap(false); |
+ offset->fX = dstIRect.fLeft; |
+ offset->fY = dstIRect.fTop; |
return true; |
} |