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

Unified Diff: src/effects/SkOffsetImageFilter.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/SkMorphologyImageFilter.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkOffsetImageFilter.cpp
diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp
index 59318e3915c1ea86c5acb28e9846d6b0c1669fb2..61f68f7afedb9f4a205b88cace0ac9de6cf17f13 100644
--- a/src/effects/SkOffsetImageFilter.cpp
+++ b/src/effects/SkOffsetImageFilter.cpp
@@ -16,32 +16,33 @@
bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
const SkMatrix& matrix,
SkBitmap* result,
- SkIPoint* loc) {
+ SkIPoint* offset) {
SkImageFilter* input = getInput(0);
SkBitmap src = source;
+ SkIPoint srcOffset = SkIPoint::Make(0, 0);
#ifdef SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION
if (false) {
#else
if (!cropRectIsSet()) {
#endif
- if (input && !input->filterImage(proxy, source, matrix, &src, loc)) {
+ if (input && !input->filterImage(proxy, source, matrix, &src, &srcOffset)) {
return false;
}
SkVector vec;
matrix.mapVectors(&vec, &fOffset, 1);
- loc->fX += SkScalarRoundToInt(vec.fX);
- loc->fY += SkScalarRoundToInt(vec.fY);
+ offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX);
+ offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY);
*result = src;
} else {
- SkIPoint srcOffset = SkIPoint::Make(0, 0);
if (input && !input->filterImage(proxy, source, matrix, &src, &srcOffset)) {
return false;
}
SkIRect bounds;
src.getBounds(&bounds);
+ bounds.offset(srcOffset);
if (!applyCropRect(&bounds, matrix)) {
return false;
@@ -54,10 +55,12 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source,
SkCanvas canvas(device);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
- canvas.drawBitmap(src, fOffset.fX - bounds.left(), fOffset.fY - bounds.top(), &paint);
+ canvas.translate(SkIntToScalar(srcOffset.fX - bounds.fLeft),
+ SkIntToScalar(srcOffset.fY - bounds.fTop));
+ canvas.drawBitmap(src, fOffset.x(), fOffset.y(), &paint);
*result = device->accessBitmap(false);
- loc->fX += bounds.left();
- loc->fY += bounds.top();
+ offset->fX = bounds.fLeft;
+ offset->fY = bounds.fTop;
}
return true;
}
« no previous file with comments | « src/effects/SkMorphologyImageFilter.cpp ('k') | src/effects/SkPictureImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698