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

Unified Diff: src/effects/SkMorphologyImageFilter.cpp

Issue 137053003: Apply the CTM to filter parameters for 4 pixel-moving filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Revert changes to SkBlurImageFilter.h, SkDropShadowImageFilter.h; use local SkVector var instead Created 6 years, 11 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
« gm/imagefiltersscaled.cpp ('K') | « src/effects/SkDropShadowImageFilter.cpp ('k') | no next file » | 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 1f8bca111f899afde3902374ad042b51a47e40f5..240be2f5f480007a573c0f86f605d4fb2dffb0be 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -194,15 +194,21 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- int width = radius().width();
- int height = radius().height();
+ SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
+ SkIntToScalar(this->radius().height()));
+ ctm.mapVectors(&radius, 1);
+ int width = SkScalarFloorToInt(radius.fX);
+ int height = SkScalarFloorToInt(radius.fY);
if (width < 0 || height < 0) {
return false;
}
+ SkIRect srcBounds = bounds;
+ srcBounds.offset(-srcOffset);
+
if (width == 0 && height == 0) {
- src.extractSubset(dst, bounds);
+ src.extractSubset(dst, srcBounds);
offset->fX = bounds.left();
offset->fY = bounds.top();
return true;
@@ -214,18 +220,17 @@ 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());
+ erodeX(src, &temp, width, srcBounds);
+ SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height());
erodeY(temp, dst, height, tmpBounds);
} else if (width > 0) {
- erodeX(src, dst, width, bounds);
+ erodeX(src, dst, width, srcBounds);
} else if (height > 0) {
- erodeY(src, dst, height, bounds);
+ erodeY(src, dst, height, srcBounds);
}
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
@@ -259,15 +264,21 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy,
return false;
}
- int width = radius().width();
- int height = radius().height();
+ SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
+ SkIntToScalar(this->radius().height()));
+ ctm.mapVectors(&radius, 1);
+ int width = SkScalarFloorToInt(radius.fX);
+ int height = SkScalarFloorToInt(radius.fY);
if (width < 0 || height < 0) {
return false;
}
+ SkIRect srcBounds = bounds;
+ srcBounds.offset(-srcOffset);
+
if (width == 0 && height == 0) {
- src.extractSubset(dst, bounds);
+ src.extractSubset(dst, srcBounds);
offset->fX = bounds.left();
offset->fY = bounds.top();
return true;
@@ -279,18 +290,17 @@ 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());
+ dilateX(src, &temp, width, srcBounds);
+ SkIRect tmpBounds = SkIRect::MakeWH(srcBounds.width(), srcBounds.height());
dilateY(temp, dst, height, tmpBounds);
} else if (width > 0) {
- dilateX(src, dst, width, bounds);
+ dilateX(src, dst, width, srcBounds);
} else if (height > 0) {
- dilateY(src, dst, height, bounds);
+ dilateY(src, dst, height, srcBounds);
}
+ offset->fX = bounds.left();
+ offset->fY = bounds.top();
return true;
}
@@ -569,29 +579,36 @@ bool apply_morphology(const SkBitmap& input,
bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap input;
- if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &input, offset)) {
+ SkIPoint srcOffset = SkIPoint::Make(0, 0);
+ if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
- src.getBounds(&bounds);
+ input.getBounds(&bounds);
+ bounds.offset(srcOffset);
if (!this->applyCropRect(&bounds, ctm)) {
return false;
}
- int width = radius().width();
- int height = radius().height();
+ SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
+ SkIntToScalar(this->radius().height()));
+ ctm.mapVectors(&radius, 1);
+ int width = SkScalarFloorToInt(radius.fX);
+ int height = SkScalarFloorToInt(radius.fY);
if (width < 0 || height < 0) {
return false;
}
+ SkIRect srcBounds = bounds;
+ srcBounds.offset(-srcOffset);
if (width == 0 && height == 0) {
- src.extractSubset(result, bounds);
+ input.extractSubset(result, srcBounds);
offset->fX = bounds.left();
offset->fY = bounds.top();
return true;
}
- if (!apply_morphology(input, bounds, GrMorphologyEffect::kDilate_MorphologyType, radius(), result)) {
+ if (!apply_morphology(input, srcBounds, GrMorphologyEffect::kDilate_MorphologyType, SkISize::Make(width, height), result)) {
sugoi 2014/01/20 19:36:57 Exceeds 100 chars.
Stephen White 2014/01/20 19:46:01 Fixed.
return false;
}
offset->fX = bounds.left();
@@ -602,29 +619,37 @@ bool SkDilateImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, cons
bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
SkBitmap* result, SkIPoint* offset) {
SkBitmap input;
- if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &input, offset)) {
+ SkIPoint srcOffset = SkIPoint::Make(0, 0);
+ if (!SkImageFilterUtils::GetInputResultGPU(getInput(0), proxy, src, ctm, &input, &srcOffset)) {
return false;
}
SkIRect bounds;
- src.getBounds(&bounds);
+ input.getBounds(&bounds);
+ bounds.offset(srcOffset);
if (!this->applyCropRect(&bounds, ctm)) {
return false;
}
- int width = radius().width();
- int height = radius().height();
+ SkVector radius = SkVector::Make(SkIntToScalar(this->radius().width()),
+ SkIntToScalar(this->radius().height()));
+ ctm.mapVectors(&radius, 1);
+ int width = SkScalarFloorToInt(radius.fX);
+ int height = SkScalarFloorToInt(radius.fY);
if (width < 0 || height < 0) {
return false;
}
+ SkIRect srcBounds = bounds;
+ srcBounds.offset(-srcOffset);
+
if (width == 0 && height == 0) {
- src.extractSubset(result, bounds);
+ input.extractSubset(result, srcBounds);
offset->fX = bounds.left();
offset->fY = bounds.top();
return true;
}
- if (!apply_morphology(input, bounds, GrMorphologyEffect::kErode_MorphologyType, radius(), result)) {
+ if (!apply_morphology(input, srcBounds, GrMorphologyEffect::kErode_MorphologyType, SkISize::Make(width, height), result)) {
sugoi 2014/01/20 19:36:57 Exceeds 100 chars.
Stephen White 2014/01/20 19:46:01 Fixed.
return false;
}
offset->fX = bounds.left();
« gm/imagefiltersscaled.cpp ('K') | « src/effects/SkDropShadowImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698