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

Unified Diff: src/effects/SkMorphologyImageFilter.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/SkMergeImageFilter.cpp ('k') | src/effects/SkOffsetImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMorphologyImageFilter.cpp
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 0d00c359d85656694559ad25690dd10d0588f873..1f8bca111f899afde3902374ad042b51a47e40f5 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -167,7 +167,8 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source, const SkMatrix& ctm,
SkBitmap* dst, SkIPoint* offset) {
SkBitmap src = source;
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offset)) {
+ SkIPoint srcOffset = SkIPoint::Make(0, 0);
+ if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, &srcOffset)) {
return false;
}
@@ -177,6 +178,7 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
SkIRect bounds;
src.getBounds(&bounds);
+ bounds.offset(srcOffset);
if (!this->applyCropRect(&bounds, ctm)) {
return false;
}
@@ -201,8 +203,8 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
if (width == 0 && height == 0) {
src.extractSubset(dst, bounds);
- offset->fX += bounds.left();
- offset->fY += bounds.top();
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
@@ -212,6 +214,9 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
return false;
}
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
+ bounds.offset(-srcOffset);
if (width > 0 && height > 0) {
erodeX(src, &temp, width, bounds);
SkIRect tmpBounds = SkIRect::MakeWH(bounds.width(), bounds.height());
@@ -221,8 +226,6 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
} else if (height > 0) {
erodeY(src, dst, height, bounds);
}
- offset->fX += bounds.left();
- offset->fY += bounds.top();
return true;
}
@@ -230,7 +233,8 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
const SkBitmap& source, const SkMatrix& ctm,
SkBitmap* dst, SkIPoint* offset) {
SkBitmap src = source;
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offset)) {
+ SkIPoint srcOffset = SkIPoint::Make(0, 0);
+ if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, &srcOffset)) {
return false;
}
if (src.config() != SkBitmap::kARGB_8888_Config) {
@@ -239,6 +243,7 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
SkIRect bounds;
src.getBounds(&bounds);
+ bounds.offset(srcOffset);
if (!this->applyCropRect(&bounds, ctm)) {
return false;
}
@@ -263,8 +268,8 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
if (width == 0 && height == 0) {
src.extractSubset(dst, bounds);
- offset->fX += bounds.left();
- offset->fY += bounds.top();
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
@@ -274,6 +279,9 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
return false;
}
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
+ bounds.offset(-srcOffset);
if (width > 0 && height > 0) {
dilateX(src, &temp, width, bounds);
SkIRect tmpBounds = SkIRect::MakeWH(bounds.width(), bounds.height());
@@ -283,8 +291,6 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
} else if (height > 0) {
dilateY(src, dst, height, bounds);
}
- offset->fX += bounds.left();
- offset->fY += bounds.top();
return true;
}
@@ -580,16 +586,16 @@ bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, cons
if (width == 0 && height == 0) {
src.extractSubset(result, bounds);
- offset->fX += bounds.left();
- offset->fY += bounds.top();
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
if (!apply_morphology(input, bounds, GrMorphologyEffect::kDilate_MorphologyType, radius(), result)) {
return false;
}
- offset->fX += bounds.left();
- offset->fY += bounds.top();
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
@@ -613,16 +619,16 @@ bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
if (width == 0 && height == 0) {
src.extractSubset(result, bounds);
- offset->fX += bounds.left();
- offset->fY += bounds.top();
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
if (!apply_morphology(input, bounds, GrMorphologyEffect::kErode_MorphologyType, radius(), result)) {
return false;
}
- offset->fX += bounds.left();
- offset->fY += bounds.top();
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
« no previous file with comments | « src/effects/SkMergeImageFilter.cpp ('k') | src/effects/SkOffsetImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698