22 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
31 #include "SVGRenderStyle.h"
37 SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(
const QualifiedName& tagName, Document* doc)
38 : SVGFilterPrimitiveStandardAttributes(tagName, doc)
39 , m_diffuseConstant(1.0f)
40 , m_surfaceScale(1.0f)
41 , m_kernelUnitLengthX(0.0f)
42 , m_kernelUnitLengthY(0.0f)
47 SVGFEDiffuseLightingElement::~SVGFEDiffuseLightingElement()
49 delete m_filterEffect;
53 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement,
float, Number, number, DiffuseConstant, diffuseConstant, SVGNames::
diffuseConstantAttr, m_diffuseConstant)
54 ANIMATED_PROPERTY_DEFINITIONS(SVGFEDiffuseLightingElement,
float, Number, number, SurfaceScale, surfaceScale, SVGNames::
surfaceScaleAttr, m_surfaceScale)
55 ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGFEDiffuseLightingElement,
float, Number, number, KernelUnitLengthX, kernelUnitLengthX, SVGNames::
kernelUnitLengthAttr, "kernelUnitLengthX", m_kernelUnitLengthX)
56 ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGFEDiffuseLightingElement,
float, Number, number, KernelUnitLengthY, kernelUnitLengthY, SVGNames::kernelUnitLengthAttr, "kernelUnitLengthY", m_kernelUnitLengthY)
58 void SVGFEDiffuseLightingElement::parseMappedAttribute(MappedAttribute *attr)
60 const String& value = attr->value();
62 setIn1BaseValue(value);
64 setSurfaceScaleBaseValue(value.toFloat());
66 setDiffuseConstantBaseValue(value.toInt());
69 if (parseNumberOptionalNumber(value, x, y)) {
70 setKernelUnitLengthXBaseValue(x);
71 setKernelUnitLengthYBaseValue(y);
74 SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
77 SVGFilterEffect* SVGFEDiffuseLightingElement::filterEffect(SVGResourceFilter* filter)
const
80 m_filterEffect =
new SVGFEDiffuseLighting(filter);
82 m_filterEffect->setIn(in1());
83 m_filterEffect->setDiffuseConstant(diffuseConstant());
84 m_filterEffect->setSurfaceScale(surfaceScale());
85 m_filterEffect->setKernelUnitLengthX(kernelUnitLengthX());
86 m_filterEffect->setKernelUnitLengthY(kernelUnitLengthY());
88 SVGFEDiffuseLightingElement* nonConstThis =
const_cast<SVGFEDiffuseLightingElement*
>(
this);
90 RenderStyle* parentStyle = nonConstThis->styleForRenderer(parent()->renderer());
91 RenderStyle* filterStyle = nonConstThis->resolveStyle(parentStyle);
93 m_filterEffect->setLightingColor(filterStyle->svgStyle()->lightingColor());
94 setStandardAttributes(m_filterEffect);
96 parentStyle->deref(document()->renderArena());
97 filterStyle->deref(document()->renderArena());
100 return m_filterEffect;
103 void SVGFEDiffuseLightingElement::updateLights()
const
108 SVGLightSource* light = 0;
109 for (Node* n = firstChild(); n; n = n->nextSibling()) {
113 SVGFELightElement* lightNode =
static_cast<SVGFELightElement*
>(n);
114 light = lightNode->lightSource();
119 m_filterEffect->setLightSource(light);
124 #endif // ENABLE(SVG)