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

Unified Diff: third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp

Issue 1463513002: Move application of filter effect boundaries to a helper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make method "functional". Created 5 years, 1 month 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 | « third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
index ef6fc81000b28690c7575c2992ed67f8a2a341bf..8965d1aa66933df14abed69bf989665c8237ce4e 100644
--- a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
+++ b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
@@ -135,6 +135,20 @@ TextStream& FilterEffect::externalRepresentation(TextStream& ts, int) const
return ts;
}
+FloatRect FilterEffect::applyEffectBoundaries(const FloatRect& rect) const
+{
+ FloatRect clippedRect = rect;
+ if (hasX())
+ clippedRect.setX(effectBoundaries().x());
+ if (hasY())
+ clippedRect.setY(effectBoundaries().y());
+ if (hasWidth())
+ clippedRect.setWidth(effectBoundaries().width());
+ if (hasHeight())
+ clippedRect.setHeight(effectBoundaries().height());
+ return clippedRect;
+}
+
FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlags flags)
{
Filter* filter = this->filter();
@@ -160,15 +174,7 @@ FloatRect FilterEffect::determineFilterPrimitiveSubregion(DetermineSubregionFlag
filter->mapLocalRectToAbsoluteRect(subregion)));
}
- FloatRect boundaries = effectBoundaries();
- if (hasX())
- subregion.setX(boundaries.x());
- if (hasY())
- subregion.setY(boundaries.y());
- if (hasWidth())
- subregion.setWidth(boundaries.width());
- if (hasHeight())
- subregion.setHeight(boundaries.height());
+ subregion = applyEffectBoundaries(subregion);
setFilterPrimitiveSubregion(subregion);
@@ -217,27 +223,18 @@ SkImageFilter::CropRect FilterEffect::getCropRect(const FloatSize& cropOffset) c
if (!hasConnectedInput() && !filter()->filterRegion().isEmpty()) {
rect = filter()->filterRegion();
flags = SkImageFilter::CropRect::kHasAll_CropEdge;
- rect.move(cropOffset);
- }
- FloatRect boundaries = effectBoundaries();
- boundaries.move(cropOffset);
- if (hasX()) {
- rect.setX(boundaries.x());
- flags |= SkImageFilter::CropRect::kHasLeft_CropEdge;
- }
- if (hasY()) {
- rect.setY(boundaries.y());
- flags |= SkImageFilter::CropRect::kHasTop_CropEdge;
- }
- if (hasWidth()) {
- rect.setWidth(boundaries.width());
- flags |= SkImageFilter::CropRect::kHasWidth_CropEdge;
- }
- if (hasHeight()) {
- rect.setHeight(boundaries.height());
- flags |= SkImageFilter::CropRect::kHasHeight_CropEdge;
}
+
+ rect = applyEffectBoundaries(rect);
+
+ rect.move(cropOffset);
rect.scale(filter()->scale());
+
+ flags |= hasX() ? SkImageFilter::CropRect::kHasLeft_CropEdge : 0;
+ flags |= hasY() ? SkImageFilter::CropRect::kHasTop_CropEdge : 0;
+ flags |= hasWidth() ? SkImageFilter::CropRect::kHasWidth_CropEdge : 0;
+ flags |= hasHeight() ? SkImageFilter::CropRect::kHasHeight_CropEdge : 0;
+
return SkImageFilter::CropRect(rect, flags);
}
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/filters/FilterEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698