Index: third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.h |
diff --git a/third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.h b/third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.h |
index 9328bded421d900ff1fc175cef478cd98472b778..6cfd03ccc3488711f3fc93aa3a1e0a7f6a1e2da2 100644 |
--- a/third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.h |
+++ b/third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.h |
@@ -31,23 +31,23 @@ |
namespace blink { |
+class FloatRect; |
class LayoutObject; |
+class SVGFilterElement; |
-class SVGFilterBuilder final : public RefCountedWillBeGarbageCollectedFinalized<SVGFilterBuilder> { |
+// A map from LayoutObject -> FilterEffect and FilterEffect -> dependent (downstream) FilterEffects ("reverse DAG"). |
+// Used during invalidations from changes to the primitives (graph nodes). |
+class SVGFilterGraphNodeMap final : public RefCountedWillBeGarbageCollectedFinalized<SVGFilterGraphNodeMap> { |
public: |
- typedef WillBeHeapHashSet<RawPtrWillBeMember<FilterEffect>> FilterEffectSet; |
- |
- static PassRefPtrWillBeRawPtr<SVGFilterBuilder> create(PassRefPtrWillBeRawPtr<FilterEffect> sourceGraphic) |
+ static PassRefPtrWillBeRawPtr<SVGFilterGraphNodeMap> create() |
{ |
- return adoptRefWillBeNoop(new SVGFilterBuilder(sourceGraphic)); |
+ return adoptRefWillBeNoop(new SVGFilterGraphNodeMap); |
} |
- void add(const AtomicString& id, PassRefPtrWillBeRawPtr<FilterEffect>); |
- |
- FilterEffect* getEffectById(const AtomicString& id) const; |
- FilterEffect* lastEffect() const { return m_lastEffect.get(); } |
+ typedef WillBeHeapHashSet<RawPtrWillBeMember<FilterEffect>> FilterEffectSet; |
- void appendEffectToEffectReferences(PassRefPtrWillBeRawPtr<FilterEffect>, LayoutObject*); |
+ void addBuiltinEffect(FilterEffect*); |
+ void addPrimitive(LayoutObject*, PassRefPtrWillBeRawPtr<FilterEffect>); |
inline FilterEffectSet& effectReferences(FilterEffect* effect) |
{ |
@@ -59,30 +59,42 @@ public: |
// Required to change the attributes of a filter during an svgAttributeChanged. |
inline FilterEffect* effectByRenderer(LayoutObject* object) { return m_effectRenderer.get(object); } |
- void clearEffects(); |
- void clearResultsRecursive(FilterEffect*); |
+ void invalidateDependentEffects(FilterEffect*); |
DECLARE_TRACE(); |
private: |
- SVGFilterBuilder(PassRefPtrWillBeRawPtr<FilterEffect> sourceGraphic); |
+ SVGFilterGraphNodeMap() = default; |
- inline void addBuiltinEffects() |
- { |
- for (const auto& entry : m_builtinEffects) |
- m_effectReferences.add(entry.value, FilterEffectSet()); |
- } |
+ // The value is a list, which contains those filter effects, |
+ // which depends on the key filter effect. |
+ WillBeHeapHashMap<RefPtrWillBeMember<FilterEffect>, FilterEffectSet> m_effectReferences; |
+ WillBeHeapHashMap<LayoutObject*, RawPtrWillBeMember<FilterEffect>> m_effectRenderer; |
+}; |
+ |
+class SVGFilterBuilder { |
+ STACK_ALLOCATED(); |
+public: |
+ SVGFilterBuilder( |
+ PassRefPtrWillBeRawPtr<FilterEffect> sourceGraphic, |
+ PassRefPtrWillBeRawPtr<SVGFilterGraphNodeMap> = nullptr); |
+ |
+ void buildGraph(Filter*, SVGFilterElement&, const FloatRect&); |
+ |
+ FilterEffect* getEffectById(const AtomicString& id) const; |
+ FilterEffect* lastEffect() const { return m_lastEffect.get(); } |
+ |
+private: |
+ void add(const AtomicString& id, PassRefPtrWillBeRawPtr<FilterEffect>); |
+ void addBuiltinEffects(); |
typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<FilterEffect>> NamedFilterEffectMap; |
NamedFilterEffectMap m_builtinEffects; |
NamedFilterEffectMap m_namedEffects; |
- // The value is a list, which contains those filter effects, |
- // which depends on the key filter effect. |
- WillBeHeapHashMap<RefPtrWillBeMember<FilterEffect>, FilterEffectSet> m_effectReferences; |
- WillBeHeapHashMap<LayoutObject*, RawPtrWillBeMember<FilterEffect>> m_effectRenderer; |
RefPtrWillBeMember<FilterEffect> m_lastEffect; |
+ RefPtrWillBeMember<SVGFilterGraphNodeMap> m_nodeMap; |
}; |
} // namespace blink |