PassRefPtr<LightSource> SVGFELightElement::findLightSource(const SVGElement* svgElement) { SVGFELightElement* lightNode = findLightElement(svgElement); if (!lightNode) return 0; return lightNode->lightSource(); }
PassRefPtr<LightSource> SVGFEDiffuseLightingElement::findLights() const { for (Node* n = firstChild(); n; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feDistantLightTag) || n->hasTagName(SVGNames::fePointLightTag) || n->hasTagName(SVGNames::feSpotLightTag)) { SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(n); return lightNode->lightSource(); } } return 0; }
void SVGFESpecularLightingElement::updateLights() const { if (!m_filterEffect) return; KCLightSource *light = 0; for (Node *n = firstChild(); n; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feDistantLightTag)||n->hasTagName(SVGNames::fePointLightTag)||n->hasTagName(SVGNames::feSpotLightTag)) { SVGFELightElement *lightNode = static_cast<SVGFELightElement *>(n); light = lightNode->lightSource(); break; } } m_filterEffect->setLightSource(light); }
PassRefPtr<FilterEffect> SVGFESpecularLightingElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) { FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->currentValue()->value())); if (!input1) return nullptr; SVGFELightElement* lightNode = SVGFELightElement::findLightElement(*this); if (!lightNode) return nullptr; RenderObject* renderer = this->renderer(); if (!renderer) return nullptr; ASSERT(renderer->style()); Color color = renderer->style()->svgStyle()->lightingColor(); RefPtr<LightSource> lightSource = lightNode->lightSource(filter); RefPtr<FilterEffect> effect = FESpecularLighting::create(filter, color, m_surfaceScale->currentValue()->value(), m_specularConstant->currentValue()->value(), m_specularExponent->currentValue()->value(), kernelUnitLengthX()->currentValue()->value(), kernelUnitLengthY()->currentValue()->value(), lightSource.release()); effect->inputEffects().append(input1); return effect.release(); }