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

Unified Diff: third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.h

Issue 1382163003: Split SVGFilterbuilder into "builder" and "node map" parts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No SVGFilterBuilder::m_filter; Reverse order of args to addPrimitive. Created 5 years, 2 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/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

Powered by Google App Engine
This is Rietveld 408576698