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(LayoutObject*, PassRefPtrWillBeRawPtr<FilterEffect>); |
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<FilterEffect> sourceGraphic, |
| 80 PassRefPtrWillBeRawPtr<SVGFilterGraphNodeMap> = nullptr); |
| 81 |
| 82 void buildGraph(Filter*, SVGFilterElement&, const FloatRect&); |
| 83 |
| 84 FilterEffect* getEffectById(const AtomicString& id) const; |
| 85 FilterEffect* lastEffect() const { return m_lastEffect.get(); } |
| 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<SVGFilterGraphNodeMap> m_nodeMap; |
86 }; | 98 }; |
87 | 99 |
88 } // namespace blink | 100 } // namespace blink |
89 | 101 |
90 #endif // SVGFilterBuilder_h | 102 #endif // SVGFilterBuilder_h |
OLD | NEW |