SVGFECompositeElement.cpp [plain text]
#include "config.h"
#if SVG_SUPPORT
#include "DeprecatedStringList.h"
#include "Attr.h"
#include <kcanvas/KCanvasResources.h>
#include <kcanvas/KCanvasFilters.h>
#include <kcanvas/device/KRenderingDevice.h>
#include <kcanvas/device/KRenderingPaintServerGradient.h>
#include "ksvg.h"
#include "SVGNames.h"
#include "SVGHelper.h"
#include "SVGRenderStyle.h"
#include "SVGFECompositeElement.h"
#include "SVGAnimatedNumber.h"
#include "SVGAnimatedEnumeration.h"
#include "SVGAnimatedString.h"
#include "SVGDOMImplementation.h"
using namespace WebCore;
SVGFECompositeElement::SVGFECompositeElement(const QualifiedName& tagName, Document *doc) :
SVGFilterPrimitiveStandardAttributes(tagName, doc)
{
m_filterEffect = 0;
}
SVGFECompositeElement::~SVGFECompositeElement()
{
delete m_filterEffect;
}
SVGAnimatedString *SVGFECompositeElement::in1() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedString>(m_in1, dummy);
}
SVGAnimatedString *SVGFECompositeElement::in2() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedString>(m_in2, dummy);
}
SVGAnimatedEnumeration *SVGFECompositeElement::_operator() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedEnumeration>(m_operator, dummy);
}
SVGAnimatedNumber *SVGFECompositeElement::k1() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedNumber>(m_k1, dummy);
}
SVGAnimatedNumber *SVGFECompositeElement::k2() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedNumber>(m_k2, dummy);
}
SVGAnimatedNumber *SVGFECompositeElement::k3() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedNumber>(m_k3, dummy);
}
SVGAnimatedNumber *SVGFECompositeElement::k4() const
{
SVGStyledElement *dummy = 0;
return lazy_create<SVGAnimatedNumber>(m_k4, dummy);
}
void SVGFECompositeElement::parseMappedAttribute(MappedAttribute *attr)
{
const String& value = attr->value();
if (attr->name() == SVGNames::operatorAttr)
{
if(value == "over")
_operator()->setBaseVal(SVG_FECOMPOSITE_OPERATOR_OVER);
else if(value == "in")
_operator()->setBaseVal(SVG_FECOMPOSITE_OPERATOR_IN);
else if(value == "out")
_operator()->setBaseVal(SVG_FECOMPOSITE_OPERATOR_OUT);
else if(value == "atop")
_operator()->setBaseVal(SVG_FECOMPOSITE_OPERATOR_ATOP);
else if(value == "xor")
_operator()->setBaseVal(SVG_FECOMPOSITE_OPERATOR_XOR);
else if(value == "arithmetic")
_operator()->setBaseVal(SVG_FECOMPOSITE_OPERATOR_ARITHMETIC);
}
else if (attr->name() == SVGNames::inAttr)
in1()->setBaseVal(value.impl());
else if (attr->name() == SVGNames::in2Attr)
in2()->setBaseVal(value.impl());
else if (attr->name() == SVGNames::k1Attr)
k1()->setBaseVal(value.deprecatedString().toDouble());
else if (attr->name() == SVGNames::k2Attr)
k2()->setBaseVal(value.deprecatedString().toDouble());
else if (attr->name() == SVGNames::k3Attr)
k3()->setBaseVal(value.deprecatedString().toDouble());
else if (attr->name() == SVGNames::k4Attr)
k4()->setBaseVal(value.deprecatedString().toDouble());
else
SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
}
KCanvasFEComposite *SVGFECompositeElement::filterEffect() const
{
if (!m_filterEffect)
m_filterEffect = static_cast<KCanvasFEComposite *>(renderingDevice()->createFilterEffect(FE_COMPOSITE));
if (!m_filterEffect)
return 0;
m_filterEffect->setOperation((KCCompositeOperationType)(_operator()->baseVal() - 1));
m_filterEffect->setIn(String(in1()->baseVal()).deprecatedString());
m_filterEffect->setIn2(String(in2()->baseVal()).deprecatedString());
setStandardAttributes(m_filterEffect);
m_filterEffect->setK1(k1()->baseVal());
m_filterEffect->setK2(k2()->baseVal());
m_filterEffect->setK3(k3()->baseVal());
m_filterEffect->setK4(k4()->baseVal());
return m_filterEffect;
}
#endif // SVG_SUPPORT