#ifndef SVGFilterBuilder_h
#define SVGFilterBuilder_h
#include "platform/graphics/filters/FilterEffect.h"
#include "wtf/HashMap.h"
#include "wtf/HashSet.h"
#include "wtf/PassRefPtr.h"
#include "wtf/text/AtomicStringHash.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class RenderObject;
class SVGFilterBuilder : public RefCounted<SVGFilterBuilder> {
public:
typedef HashSet<FilterEffect*> FilterEffectSet;
static PassRefPtr<SVGFilterBuilder> create(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEffect> sourceAlpha) { return adoptRef(new SVGFilterBuilder(sourceGraphic, sourceAlpha)); }
void add(const AtomicString& id, PassRefPtr<FilterEffect>);
FilterEffect* getEffectById(const AtomicString& id) const;
FilterEffect* lastEffect() const { return m_lastEffect.get(); }
void appendEffectToEffectReferences(PassRefPtr<FilterEffect>, RenderObject*);
inline FilterEffectSet& effectReferences(FilterEffect* effect)
{
ASSERT(m_effectReferences.contains(effect));
return m_effectReferences.find(effect)->value;
}
inline FilterEffect* effectByRenderer(RenderObject* object) { return m_effectRenderer.get(object); }
void clearEffects();
void clearResultsRecursive(FilterEffect*);
private:
SVGFilterBuilder(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEffect> sourceAlpha);
inline void addBuiltinEffects()
{
HashMap<AtomicString, RefPtr<FilterEffect> >::iterator end = m_builtinEffects.end();
for (HashMap<AtomicString, RefPtr<FilterEffect> >::iterator iterator = m_builtinEffects.begin(); iterator != end; ++iterator)
m_effectReferences.add(iterator->value, FilterEffectSet());
}
HashMap<AtomicString, RefPtr<FilterEffect> > m_builtinEffects;
HashMap<AtomicString, RefPtr<FilterEffect> > m_namedEffects;
HashMap<RefPtr<FilterEffect>, FilterEffectSet> m_effectReferences;
HashMap<RenderObject*, FilterEffect*> m_effectRenderer;
RefPtr<FilterEffect> m_lastEffect;
};
}
#endif