OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> | 2 * Copyright (C) 2008 Alex Mathews <possessedpenguinbob@gmail.com> |
3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "platform/graphics/filters/FilterEffect.h" | 24 #include "platform/graphics/filters/FilterEffect.h" |
25 #include "platform/heap/Handle.h" | 25 #include "platform/heap/Handle.h" |
26 #include "wtf/HashMap.h" | 26 #include "wtf/HashMap.h" |
27 #include "wtf/HashSet.h" | 27 #include "wtf/HashSet.h" |
28 #include "wtf/PassRefPtr.h" | 28 #include "wtf/PassRefPtr.h" |
29 #include "wtf/text/AtomicStringHash.h" | 29 #include "wtf/text/AtomicStringHash.h" |
30 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class FloatRect; | |
34 class LayoutObject; | 35 class LayoutObject; |
36 class SVGFilterElement; | |
35 | 37 |
36 class SVGFilterBuilder final : public RefCountedWillBeGarbageCollectedFinalized< SVGFilterBuilder> { | 38 // A map from LayoutObject -> FilterEffect and FilterEffect -> dependent (downst ream) FilterEffects ("reverse DAG"). |
39 // Used during invalidations from changes to the primitives (graph nodes). | |
40 class SVGFilterGraphNodeMap final : public RefCountedWillBeGarbageCollectedFinal ized<SVGFilterGraphNodeMap> { | |
37 public: | 41 public: |
42 static PassRefPtrWillBeRawPtr<SVGFilterGraphNodeMap> create() | |
43 { | |
44 return adoptRefWillBeNoop(new SVGFilterGraphNodeMap); | |
45 } | |
46 | |
38 typedef WillBeHeapHashSet<RawPtrWillBeMember<FilterEffect>> FilterEffectSet; | 47 typedef WillBeHeapHashSet<RawPtrWillBeMember<FilterEffect>> FilterEffectSet; |
39 | 48 |
40 static PassRefPtrWillBeRawPtr<SVGFilterBuilder> create(PassRefPtrWillBeRawPt r<FilterEffect> sourceGraphic) | 49 void addBuiltinEffect(FilterEffect*); |
41 { | 50 void addPrimitive(PassRefPtrWillBeRawPtr<FilterEffect>, LayoutObject*); |
Stephen White
2015/10/07 19:44:01
Nit: while we're here, could we switch the order o
fs
2015/10/08 10:53:11
Done.
| |
42 return adoptRefWillBeNoop(new SVGFilterBuilder(sourceGraphic)); | |
43 } | |
44 | |
45 void add(const AtomicString& id, PassRefPtrWillBeRawPtr<FilterEffect>); | |
46 | |
47 FilterEffect* getEffectById(const AtomicString& id) const; | |
48 FilterEffect* lastEffect() const { return m_lastEffect.get(); } | |
49 | |
50 void appendEffectToEffectReferences(PassRefPtrWillBeRawPtr<FilterEffect>, La youtObject*); | |
51 | 51 |
52 inline FilterEffectSet& effectReferences(FilterEffect* effect) | 52 inline FilterEffectSet& effectReferences(FilterEffect* effect) |
53 { | 53 { |
54 // Only allowed for effects belongs to this builder. | 54 // Only allowed for effects belongs to this builder. |
55 ASSERT(m_effectReferences.contains(effect)); | 55 ASSERT(m_effectReferences.contains(effect)); |
56 return m_effectReferences.find(effect)->value; | 56 return m_effectReferences.find(effect)->value; |
57 } | 57 } |
58 | 58 |
59 // Required to change the attributes of a filter during an svgAttributeChang ed. | 59 // Required to change the attributes of a filter during an svgAttributeChang ed. |
60 inline FilterEffect* effectByRenderer(LayoutObject* object) { return m_effec tRenderer.get(object); } | 60 inline FilterEffect* effectByRenderer(LayoutObject* object) { return m_effec tRenderer.get(object); } |
61 | 61 |
62 void clearEffects(); | 62 void invalidateDependentEffects(FilterEffect*); |
63 void clearResultsRecursive(FilterEffect*); | |
64 | 63 |
65 DECLARE_TRACE(); | 64 DECLARE_TRACE(); |
66 | 65 |
67 private: | 66 private: |
68 SVGFilterBuilder(PassRefPtrWillBeRawPtr<FilterEffect> sourceGraphic); | 67 SVGFilterGraphNodeMap() = default; |
69 | 68 |
70 inline void addBuiltinEffects() | 69 // The value is a list, which contains those filter effects, |
71 { | 70 // which depends on the key filter effect. |
72 for (const auto& entry : m_builtinEffects) | 71 WillBeHeapHashMap<RefPtrWillBeMember<FilterEffect>, FilterEffectSet> m_effec tReferences; |
73 m_effectReferences.add(entry.value, FilterEffectSet()); | 72 WillBeHeapHashMap<LayoutObject*, RawPtrWillBeMember<FilterEffect>> m_effectR enderer; |
74 } | 73 }; |
74 | |
75 class SVGFilterBuilder { | |
76 STACK_ALLOCATED(); | |
77 public: | |
78 SVGFilterBuilder( | |
79 PassRefPtrWillBeRawPtr<Filter>, | |
80 PassRefPtrWillBeRawPtr<FilterEffect> sourceGraphic, | |
81 PassRefPtrWillBeRawPtr<SVGFilterGraphNodeMap> = nullptr); | |
82 | |
83 void buildGraph(SVGFilterElement&, const FloatRect&); | |
84 | |
85 FilterEffect* getEffectById(const AtomicString& id) const; | |
86 | |
87 private: | |
88 void add(const AtomicString& id, PassRefPtrWillBeRawPtr<FilterEffect>); | |
89 void addBuiltinEffects(); | |
75 | 90 |
76 typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<FilterEffect>> Na medFilterEffectMap; | 91 typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<FilterEffect>> Na medFilterEffectMap; |
77 | 92 |
78 NamedFilterEffectMap m_builtinEffects; | 93 NamedFilterEffectMap m_builtinEffects; |
79 NamedFilterEffectMap m_namedEffects; | 94 NamedFilterEffectMap m_namedEffects; |
80 // The value is a list, which contains those filter effects, | |
81 // which depends on the key filter effect. | |
82 WillBeHeapHashMap<RefPtrWillBeMember<FilterEffect>, FilterEffectSet> m_effec tReferences; | |
83 WillBeHeapHashMap<LayoutObject*, RawPtrWillBeMember<FilterEffect>> m_effectR enderer; | |
84 | 95 |
85 RefPtrWillBeMember<FilterEffect> m_lastEffect; | 96 RefPtrWillBeMember<FilterEffect> m_lastEffect; |
97 RefPtrWillBeMember<Filter> m_filter; | |
98 RefPtrWillBeMember<SVGFilterGraphNodeMap> m_nodeMap; | |
86 }; | 99 }; |
87 | 100 |
88 } // namespace blink | 101 } // namespace blink |
89 | 102 |
90 #endif // SVGFilterBuilder_h | 103 #endif // SVGFilterBuilder_h |
OLD | NEW |