Index: src/effects/SkTileImageFilter.cpp |
diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp |
index 8d158013879a7bf23097c75a2ce241f49816bad6..ca4c15d4191900fc644cdb3961096bcb8b4bf125 100644 |
--- a/src/effects/SkTileImageFilter.cpp |
+++ b/src/effects/SkTileImageFilter.cpp |
@@ -54,15 +54,31 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
srcRect.roundOut(&srcIRect); |
srcIRect.offset(-srcOffset); |
SkBitmap subset; |
- SkIRect bounds; |
- source.getBounds(&bounds); |
+ SkIRect srcBounds; |
+ source.getBounds(&srcBounds); |
- if (!srcIRect.intersect(bounds)) { |
+ if (!SkIRect::Intersects(srcIRect, srcBounds)) { |
offset->fX = offset->fY = 0; |
return true; |
- } else if (!source.extractSubset(&subset, srcIRect)) { |
- return false; |
} |
+ if (srcBounds.contains(srcIRect)) { |
+ if (!source.extractSubset(&subset, srcIRect)) { |
+ return false; |
+ } |
+ } else { |
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(srcIRect.width(), |
+ srcIRect.height(), |
+ kPossible_TileUsage)); |
+ if (!device) { |
+ return false; |
+ } |
+ SkCanvas canvas(device); |
+ canvas.drawBitmap(src, SkIntToScalar(srcOffset.x()), |
+ SkIntToScalar(srcOffset.y())); |
+ subset = device->accessBitmap(false); |
+ } |
+ SkASSERT(subset.width() == srcIRect.width()); |
+ SkASSERT(subset.height() == srcIRect.height()); |
SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(w, h)); |
if (nullptr == device.get()) { |
@@ -72,12 +88,8 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, |
SkPaint paint; |
paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
- SkMatrix shaderMatrix; |
- shaderMatrix.setTranslate(SkIntToScalar(srcOffset.fX), |
- SkIntToScalar(srcOffset.fY)); |
SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset, |
- SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode, |
- &shaderMatrix)); |
+ SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode)); |
paint.setShader(shader); |
canvas.translate(-dstRect.fLeft, -dstRect.fTop); |
canvas.drawRect(dstRect, paint); |