| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #ifndef SVGFilterBuilder_h | 21 #ifndef SVGFilterBuilder_h |
| 22 #define SVGFilterBuilder_h | 22 #define SVGFilterBuilder_h |
| 23 | 23 |
| 24 #include "platform/graphics/filters/FilterEffect.h" | 24 #include "platform/graphics/filters/FilterEffect.h" |
| 25 #include "platform/heap/Handle.h" |
| 25 #include "wtf/HashMap.h" | 26 #include "wtf/HashMap.h" |
| 26 #include "wtf/HashSet.h" | 27 #include "wtf/HashSet.h" |
| 27 #include "wtf/PassRefPtr.h" | 28 #include "wtf/PassRefPtr.h" |
| 28 #include "wtf/text/AtomicStringHash.h" | 29 #include "wtf/text/AtomicStringHash.h" |
| 29 #include "wtf/text/WTFString.h" | 30 #include "wtf/text/WTFString.h" |
| 30 | 31 |
| 31 namespace blink { | 32 namespace blink { |
| 32 | 33 |
| 33 class RenderObject; | 34 class RenderObject; |
| 34 | 35 |
| 35 class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> { | 36 class SVGFilterBuilder final : public RefCountedWillBeGarbageCollectedFinalized<
SVGFilterBuilder> { |
| 36 public: | 37 public: |
| 37 typedef HashSet<FilterEffect*> FilterEffectSet; | 38 typedef WillBeHeapHashSet<RawPtrWillBeMember<FilterEffect> > FilterEffectSet
; |
| 38 | 39 |
| 39 static PassRefPtr<SVGFilterBuilder> create(PassRefPtr<FilterEffect> sourceGr
aphic, PassRefPtr<FilterEffect> sourceAlpha) { return adoptRef(new SVGFilterBuil
der(sourceGraphic, sourceAlpha)); } | 40 static PassRefPtrWillBeRawPtr<SVGFilterBuilder> create(PassRefPtrWillBeRawPt
r<FilterEffect> sourceGraphic, PassRefPtrWillBeRawPtr<FilterEffect> sourceAlpha) |
| 41 { |
| 42 return adoptRefWillBeNoop(new SVGFilterBuilder(sourceGraphic, sourceAlph
a)); |
| 43 } |
| 40 | 44 |
| 41 void add(const AtomicString& id, PassRefPtr<FilterEffect>); | 45 void add(const AtomicString& id, PassRefPtrWillBeRawPtr<FilterEffect>); |
| 42 | 46 |
| 43 FilterEffect* getEffectById(const AtomicString& id) const; | 47 FilterEffect* getEffectById(const AtomicString& id) const; |
| 44 FilterEffect* lastEffect() const { return m_lastEffect.get(); } | 48 FilterEffect* lastEffect() const { return m_lastEffect.get(); } |
| 45 | 49 |
| 46 void appendEffectToEffectReferences(PassRefPtr<FilterEffect>, RenderObject*)
; | 50 void appendEffectToEffectReferences(PassRefPtrWillBeRawPtr<FilterEffect>, Re
nderObject*); |
| 47 | 51 |
| 48 inline FilterEffectSet& effectReferences(FilterEffect* effect) | 52 inline FilterEffectSet& effectReferences(FilterEffect* effect) |
| 49 { | 53 { |
| 50 // Only allowed for effects belongs to this builder. | 54 // Only allowed for effects belongs to this builder. |
| 51 ASSERT(m_effectReferences.contains(effect)); | 55 ASSERT(m_effectReferences.contains(effect)); |
| 52 return m_effectReferences.find(effect)->value; | 56 return m_effectReferences.find(effect)->value; |
| 53 } | 57 } |
| 54 | 58 |
| 55 // 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. |
| 56 inline FilterEffect* effectByRenderer(RenderObject* object) { return m_effec
tRenderer.get(object); } | 60 inline FilterEffect* effectByRenderer(RenderObject* object) { return m_effec
tRenderer.get(object); } |
| 57 | 61 |
| 58 void clearEffects(); | 62 void clearEffects(); |
| 59 void clearResultsRecursive(FilterEffect*); | 63 void clearResultsRecursive(FilterEffect*); |
| 60 | 64 |
| 65 void trace(Visitor*); |
| 66 |
| 61 private: | 67 private: |
| 62 SVGFilterBuilder(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEf
fect> sourceAlpha); | 68 SVGFilterBuilder(PassRefPtrWillBeRawPtr<FilterEffect> sourceGraphic, PassRef
PtrWillBeRawPtr<FilterEffect> sourceAlpha); |
| 63 | 69 |
| 64 inline void addBuiltinEffects() | 70 inline void addBuiltinEffects() |
| 65 { | 71 { |
| 66 HashMap<AtomicString, RefPtr<FilterEffect> >::iterator end = m_builtinEf
fects.end(); | 72 NamedFilterEffectMap::iterator end = m_builtinEffects.end(); |
| 67 for (HashMap<AtomicString, RefPtr<FilterEffect> >::iterator iterator = m
_builtinEffects.begin(); iterator != end; ++iterator) | 73 for (NamedFilterEffectMap::iterator iterator = m_builtinEffects.begin();
iterator != end; ++iterator) |
| 68 m_effectReferences.add(iterator->value, FilterEffectSet()); | 74 m_effectReferences.add(iterator->value, FilterEffectSet()); |
| 69 } | 75 } |
| 70 | 76 |
| 71 HashMap<AtomicString, RefPtr<FilterEffect> > m_builtinEffects; | 77 typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<FilterEffect> > N
amedFilterEffectMap; |
| 72 HashMap<AtomicString, RefPtr<FilterEffect> > m_namedEffects; | 78 |
| 79 NamedFilterEffectMap m_builtinEffects; |
| 80 NamedFilterEffectMap m_namedEffects; |
| 73 // The value is a list, which contains those filter effects, | 81 // The value is a list, which contains those filter effects, |
| 74 // which depends on the key filter effect. | 82 // which depends on the key filter effect. |
| 75 HashMap<RefPtr<FilterEffect>, FilterEffectSet> m_effectReferences; | 83 WillBeHeapHashMap<RefPtrWillBeMember<FilterEffect>, FilterEffectSet> m_effec
tReferences; |
| 76 HashMap<RenderObject*, FilterEffect*> m_effectRenderer; | 84 WillBeHeapHashMap<RenderObject*, RawPtrWillBeMember<FilterEffect> > m_effect
Renderer; |
| 77 | 85 |
| 78 RefPtr<FilterEffect> m_lastEffect; | 86 RefPtrWillBeMember<FilterEffect> m_lastEffect; |
| 79 }; | 87 }; |
| 80 | 88 |
| 81 } // namespace blink | 89 } // namespace blink |
| 82 | 90 |
| 83 #endif // SVGFilterBuilder_h | 91 #endif // SVGFilterBuilder_h |
| OLD | NEW |