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

Unified Diff: src/core/SkImageFilter.cpp

Issue 23011012: Implement correct clipping for image filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Add morphology to the list of ignored tests Created 6 years, 10 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/SkCanvas.cpp ('k') | src/effects/SkBitmapSource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 9b7e5e488f5789f4323a6f7e1fd4e5ed94ee4a47..384f2dce6be9d26cb15db21347c5ec09fa164d94 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -106,7 +106,7 @@ bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src,
}
bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst) {
+ SkIRect* dst) const {
SkASSERT(&src);
SkASSERT(dst);
return this->onFilterBounds(src, ctm, dst);
@@ -210,8 +210,28 @@ bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const {
}
bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
- SkIRect* dst) {
- *dst = src;
+ SkIRect* dst) const {
+ if (fInputCount < 1) {
+ return false;
+ }
+
+ SkIRect bounds;
+ for (int i = 0; i < fInputCount; ++i) {
+ SkImageFilter* filter = this->getInput(i);
+ SkIRect rect = src;
+ if (filter && !filter->filterBounds(src, ctm, &rect)) {
+ return false;
+ }
+ if (0 == i) {
+ bounds = rect;
+ } else {
+ bounds.join(rect);
+ }
+ }
+
+ // don't modify dst until now, so we don't accidentally change it in the
+ // loop, but then return false on the next filter.
+ *dst = bounds;
return true;
}
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/effects/SkBitmapSource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698