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); |
} |