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

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

Issue 2341923002: Harmonize FilterEffect::mapRect and mapPaintRect (Closed)
Patch Set: Rebase Created 4 years, 3 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
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 1b5f60c7b2725cb7b309c48a587378a669e0b253..4d8dbdf5802d6b662cad33a2489f881d0ede8658 100644
--- a/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
+++ b/third_party/WebKit/Source/platform/graphics/filters/FilterEffect.cpp
@@ -56,40 +56,40 @@ FloatRect FilterEffect::absoluteBounds() const
return getFilter()->mapLocalRectToAbsoluteRect(computedBounds);
}
-FloatRect FilterEffect::determineAbsolutePaintRect(const FloatRect& originalRequestedRect) const
+FloatRect FilterEffect::mapInputs(const FloatRect& rect) const
{
- FloatRect requestedRect = originalRequestedRect;
- // Filters in SVG clip to primitive subregion, while CSS doesn't.
- if (clipsToBounds())
- requestedRect.intersect(absoluteBounds());
-
- FloatRect inputRect = mapPaintRect(requestedRect, false);
+ if (!m_inputEffects.size()) {
+ if (clipsToBounds())
+ return absoluteBounds();
+ return rect;
+ }
FloatRect inputUnion;
- unsigned size = m_inputEffects.size();
+ for (const auto& effect : m_inputEffects)
+ inputUnion.unite(effect->mapRect(rect));
+ return inputUnion;
+}
- for (unsigned i = 0; i < size; ++i)
- inputUnion.unite(m_inputEffects.at(i)->determineAbsolutePaintRect(inputRect));
- inputUnion = mapPaintRect(inputUnion, true);
+FloatRect FilterEffect::mapEffect(const FloatRect& rect) const
+{
+ return rect;
+}
- if (affectsTransparentPixels() || !size) {
- inputUnion = requestedRect;
- } else {
- // Rect may have inflated. Re-intersect with request.
- inputUnion.intersect(requestedRect);
- }
- return inputUnion;
+FloatRect FilterEffect::applyBounds(const FloatRect& rect) const
+{
+ // Filters in SVG clip to primitive subregion, while CSS doesn't.
+ if (!clipsToBounds())
+ return rect;
+ FloatRect bounds = absoluteBounds();
+ if (affectsTransparentPixels())
+ return bounds;
+ return intersection(rect, bounds);
}
-FloatRect FilterEffect::mapRectRecursive(const FloatRect& rect) const
+FloatRect FilterEffect::mapRect(const FloatRect& rect) const
{
- FloatRect result;
- if (m_inputEffects.size() > 0) {
- result = m_inputEffects.at(0)->mapRectRecursive(rect);
- for (unsigned i = 1; i < m_inputEffects.size(); ++i)
- result.unite(m_inputEffects.at(i)->mapRectRecursive(rect));
- } else
- result = rect;
- return mapRect(result);
+ FloatRect result = mapInputs(rect);
+ result = mapEffect(result);
+ return applyBounds(result);
}
FilterEffect* FilterEffect::inputEffect(unsigned number) const

Powered by Google App Engine
This is Rietveld 408576698