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

Unified Diff: src/effects/SkTileImageFilter.cpp

Issue 112803004: Make SkImageFilter crop rects relative to the primitive origin, instead of relative to their parent (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Updated to ToT Created 6 years, 12 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/effects/SkRectShaderImageFilter.cpp ('k') | src/effects/SkXfermodeImageFilter.cpp » ('j') | 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 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;
}
« no previous file with comments | « src/effects/SkRectShaderImageFilter.cpp ('k') | src/effects/SkXfermodeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698