Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: src/effects/SkTileImageFilter.cpp

Issue 1570133003: Fix SkTileImageFilter when srcRect is a superset of bitmap bounds. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix 100-col issues Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698