| 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 cec0220ca90ccdf722737863637aeb6096ae0166..4cbb72d65edbb79b619a8703b3f0a4017f68ecdc 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
|
| @@ -33,6 +33,10 @@
|
|
|
| FilterEffect::FilterEffect(Filter* filter)
|
| : m_filter(filter)
|
| + , m_hasX(false)
|
| + , m_hasY(false)
|
| + , m_hasWidth(false)
|
| + , m_hasHeight(false)
|
| , m_clipsToBounds(true)
|
| , m_originTainted(false)
|
| , m_operatingColorSpace(ColorSpaceLinearRGB)
|
| @@ -129,44 +133,58 @@
|
| return ts;
|
| }
|
|
|
| -FloatRect FilterEffect::determineMaximumEffectRect(DetermineMaxEffectRectFlags flags)
|
| -{
|
| - DCHECK(getFilter());
|
| - Filter* filter = getFilter();
|
| -
|
| - // Compute the union of the inputs. Always do this because it has
|
| - // side-effects. (It computes the maximum effect rect of the input.)
|
| - FloatRect absoluteInputUnion;
|
| - for (auto& effect : m_inputEffects)
|
| - absoluteInputUnion.unite(effect->determineMaximumEffectRect(flags));
|
| -
|
| - FloatRect absoluteSubregion;
|
| - switch (getFilterEffectType()) {
|
| - default:
|
| - if (m_inputEffects.size()) {
|
| - absoluteSubregion = absoluteInputUnion;
|
| - if (clipsToBounds())
|
| - absoluteSubregion.intersect(filter->mapLocalRectToAbsoluteRect(filterPrimitiveSubregion()));
|
| - break;
|
| - }
|
| - // Else fall-through and use the primitive region. (FETurbulence/FEFlood/FEImage)
|
| - case FilterEffectTypeTile:
|
| - absoluteSubregion = filter->mapLocalRectToAbsoluteRect(filterPrimitiveSubregion());
|
| - break;
|
| - case FilterEffectTypeSourceInput:
|
| - absoluteSubregion = filter->absoluteFilterRegion();
|
| - break;
|
| - }
|
| -
|
| - if (flags & MapRectForward)
|
| - absoluteSubregion = mapRect(absoluteSubregion);
|
| +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->getFilter();
|
| + ASSERT(filter);
|
| +
|
| + // FETile, FETurbulence, FEFlood don't have input effects, take the filter region as unite rect.
|
| + FloatRect subregion;
|
| + if (unsigned numberOfInputEffects = inputEffects().size()) {
|
| + subregion = inputEffect(0)->determineFilterPrimitiveSubregion(flags);
|
| + for (unsigned i = 1; i < numberOfInputEffects; ++i)
|
| + subregion.unite(inputEffect(i)->determineFilterPrimitiveSubregion(flags));
|
| + } else {
|
| + subregion = filter->filterRegion();
|
| + }
|
| +
|
| + // After calling determineFilterPrimitiveSubregion on the target effect, reset the subregion again for <feTile>.
|
| + if (getFilterEffectType() == FilterEffectTypeTile)
|
| + subregion = filter->filterRegion();
|
| +
|
| + if (flags & MapRectForward) {
|
| + // mapRect works on absolute rectangles.
|
| + subregion = filter->mapAbsoluteRectToLocalRect(mapRect(
|
| + filter->mapLocalRectToAbsoluteRect(subregion)));
|
| + }
|
| +
|
| + subregion = applyEffectBoundaries(subregion);
|
| +
|
| + setFilterPrimitiveSubregion(subregion);
|
| +
|
| + FloatRect absoluteSubregion = filter->mapLocalRectToAbsoluteRect(subregion);
|
|
|
| // Clip every filter effect to the filter region.
|
| - if (flags & ClipToFilterRegion)
|
| + if (flags & ClipToFilterRegion) {
|
| absoluteSubregion.intersect(filter->absoluteFilterRegion());
|
| -
|
| - m_maxEffectRect = absoluteSubregion;
|
| - return absoluteSubregion;
|
| + }
|
| +
|
| + setMaxEffectRect(absoluteSubregion);
|
| + return subregion;
|
| }
|
|
|
| sk_sp<SkImageFilter> FilterEffect::createImageFilter()
|
| @@ -198,7 +216,8 @@
|
| SkImageFilter::CropRect FilterEffect::getCropRect() const
|
| {
|
| if (!filterPrimitiveSubregion().isEmpty()) {
|
| - FloatRect rect = getFilter()->mapLocalRectToAbsoluteRect(filterPrimitiveSubregion());
|
| + FloatRect rect = filterPrimitiveSubregion();
|
| + rect.scale(getFilter()->scale());
|
| return SkImageFilter::CropRect(rect);
|
| } else {
|
| return SkImageFilter::CropRect(SkRect::MakeEmpty(), 0);
|
|
|