This source file includes following definitions.
- add
- getEffectById
- appendEffectToEffectReferences
- clearEffects
- clearResultsRecursive
#include "config.h"
#include "core/svg/graphics/filters/SVGFilterBuilder.h"
#include "platform/graphics/filters/SourceAlpha.h"
#include "platform/graphics/filters/SourceGraphic.h"
namespace WebCore {
SVGFilterBuilder::SVGFilterBuilder(PassRefPtr<FilterEffect> sourceGraphic, PassRefPtr<FilterEffect> sourceAlpha)
{
m_builtinEffects.add(SourceGraphic::effectName(), sourceGraphic);
m_builtinEffects.add(SourceAlpha::effectName(), sourceAlpha);
addBuiltinEffects();
}
void SVGFilterBuilder::add(const AtomicString& id, PassRefPtr<FilterEffect> effect)
{
if (id.isEmpty()) {
m_lastEffect = effect;
return;
}
if (m_builtinEffects.contains(id))
return;
m_lastEffect = effect;
m_namedEffects.set(id, m_lastEffect);
}
FilterEffect* SVGFilterBuilder::getEffectById(const AtomicString& id) const
{
if (id.isEmpty()) {
if (m_lastEffect)
return m_lastEffect.get();
return m_builtinEffects.get(SourceGraphic::effectName());
}
if (m_builtinEffects.contains(id))
return m_builtinEffects.get(id);
return m_namedEffects.get(id);
}
void SVGFilterBuilder::appendEffectToEffectReferences(PassRefPtr<FilterEffect> prpEffect, RenderObject* object)
{
RefPtr<FilterEffect> effect = prpEffect;
ASSERT(!m_effectReferences.contains(effect));
ASSERT(object && !m_effectRenderer.contains(object));
m_effectReferences.add(effect, FilterEffectSet());
unsigned numberOfInputEffects = effect->inputEffects().size();
for (unsigned i = 0; i < numberOfInputEffects; ++i)
effectReferences(effect->inputEffect(i)).add(effect.get());
m_effectRenderer.add(object, effect.get());
}
void SVGFilterBuilder::clearEffects()
{
m_lastEffect = nullptr;
m_namedEffects.clear();
m_effectReferences.clear();
m_effectRenderer.clear();
addBuiltinEffects();
}
void SVGFilterBuilder::clearResultsRecursive(FilterEffect* effect)
{
if (!effect->hasResult())
return;
effect->clearResult();
HashSet<FilterEffect*>& effectReferences = this->effectReferences(effect);
HashSet<FilterEffect*>::iterator end = effectReferences.end();
for (HashSet<FilterEffect*>::iterator it = effectReferences.begin(); it != end; ++it)
clearResultsRecursive(*it);
}
}