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

Unified Diff: src/effects/SkTileImageFilter.cpp

Issue 106933002: Implement srcRect and dstRect functionality in SkBitmapSource. This is required for the "preserveAs… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix nits Created 7 years 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/effects/SkBitmapSource.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 c5eace0b74ddd598311af434bb9128cc30437a82..73e5304adb3db2f8a0a87908a5f3e1b0c0d76030 100644
--- a/src/effects/SkTileImageFilter.cpp
+++ b/src/effects/SkTileImageFilter.cpp
@@ -24,16 +24,24 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S
return false;
}
- int w = SkScalarTruncToInt(fDstRect.width());
- int h = SkScalarTruncToInt(fDstRect.height());
+ SkRect dstRect;
+ ctm.mapRect(&dstRect, fDstRect);
+ int w = SkScalarCeilToInt(dstRect.width());
+ int h = SkScalarCeilToInt(dstRect.height());
if (!fSrcRect.width() || !fSrcRect.height() || !w || !h) {
return false;
}
- SkIRect srcRect;
- fSrcRect.roundOut(&srcRect);
+ SkRect srcRect;
+ ctm.mapRect(&srcRect, fSrcRect);
+ SkIRect srcIRect;
+ srcRect.roundOut(&srcIRect);
SkBitmap subset;
- if (!source.extractSubset(&subset, srcRect)) {
+ SkIRect bounds;
+ source.getBounds(&bounds);
+ if (!srcIRect.intersect(bounds)) {
+ return true;
+ } else if (!source.extractSubset(&subset, srcIRect)) {
return false;
}
@@ -41,8 +49,6 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S
if (NULL == device.get()) {
return false;
}
- SkIRect bounds;
- source.getBounds(&bounds);
SkCanvas canvas(device);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
@@ -50,7 +56,6 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src, const S
SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(subset,
SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode));
paint.setShader(shader);
- SkRect dstRect = fDstRect;
dstRect.offset(SkIntToScalar(localOffset.fX), SkIntToScalar(localOffset.fY));
canvas.drawRect(dstRect, paint);
*dst = device->accessBitmap(false);
« no previous file with comments | « src/effects/SkBitmapSource.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698