summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/svg/SVGFESpecularLightingElement.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/svg/SVGFESpecularLightingElement.cpp
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/svg/SVGFESpecularLightingElement.cpp')
-rw-r--r--Source/WebCore/svg/SVGFESpecularLightingElement.cpp85
1 files changed, 63 insertions, 22 deletions
diff --git a/Source/WebCore/svg/SVGFESpecularLightingElement.cpp b/Source/WebCore/svg/SVGFESpecularLightingElement.cpp
index f4f2648..60684ed 100644
--- a/Source/WebCore/svg/SVGFESpecularLightingElement.cpp
+++ b/Source/WebCore/svg/SVGFESpecularLightingElement.cpp
@@ -89,18 +89,69 @@ void SVGFESpecularLightingElement::parseMappedAttribute(Attribute* attr)
SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
}
+bool SVGFESpecularLightingElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
+{
+ FESpecularLighting* specularLighting = static_cast<FESpecularLighting*>(effect);
+ if (attrName == SVGNames::surfaceScaleAttr)
+ return specularLighting->setSurfaceScale(surfaceScale());
+ if (attrName == SVGNames::specularConstantAttr)
+ return specularLighting->setSpecularConstant(specularConstant());
+ if (attrName == SVGNames::specularExponentAttr)
+ return specularLighting->setSpecularExponent(specularExponent());
+
+ LightSource* lightSource = const_cast<LightSource*>(specularLighting->lightSource());
+ const SVGFELightElement* lightElement = SVGFELightElement::findLightElement(this);
+ ASSERT(lightSource);
+ ASSERT(lightElement);
+
+ if (attrName == SVGNames::azimuthAttr)
+ return lightSource->setAzimuth(lightElement->azimuth());
+ if (attrName == SVGNames::elevationAttr)
+ return lightSource->setElevation(lightElement->elevation());
+ if (attrName == SVGNames::xAttr)
+ return lightSource->setX(lightElement->x());
+ if (attrName == SVGNames::yAttr)
+ return lightSource->setY(lightElement->y());
+ if (attrName == SVGNames::zAttr)
+ return lightSource->setZ(lightElement->z());
+ if (attrName == SVGNames::pointsAtXAttr)
+ return lightSource->setPointsAtX(lightElement->pointsAtX());
+ if (attrName == SVGNames::pointsAtYAttr)
+ return lightSource->setPointsAtY(lightElement->pointsAtY());
+ if (attrName == SVGNames::pointsAtZAttr)
+ return lightSource->setPointsAtZ(lightElement->pointsAtZ());
+ if (attrName == SVGNames::specularExponentAttr)
+ return lightSource->setSpecularExponent(lightElement->specularExponent());
+ if (attrName == SVGNames::limitingConeAngleAttr)
+ return lightSource->setLimitingConeAngle(lightElement->limitingConeAngle());
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
void SVGFESpecularLightingElement::svgAttributeChanged(const QualifiedName& attrName)
{
SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
- if (attrName == SVGNames::inAttr
- || attrName == SVGNames::surfaceScaleAttr
+ if (attrName == SVGNames::surfaceScaleAttr
|| attrName == SVGNames::specularConstantAttr
|| attrName == SVGNames::specularExponentAttr
|| attrName == SVGNames::kernelUnitLengthAttr)
+ primitiveAttributeChanged(attrName);
+
+ if (attrName == SVGNames::inAttr)
invalidate();
}
+void SVGFESpecularLightingElement::lightElementAttributeChanged(const SVGFELightElement* lightElement, const QualifiedName& attrName)
+{
+ if (SVGFELightElement::findLightElement(this) != lightElement)
+ return;
+
+ // The light element has different attribute names so attrName can identify the requested attribute.
+ primitiveAttributeChanged(attrName);
+}
+
void SVGFESpecularLightingElement::synchronizeProperty(const QualifiedName& attrName)
{
SVGFilterPrimitiveStandardAttributes::synchronizeProperty(attrName);
@@ -147,33 +198,23 @@ void SVGFESpecularLightingElement::fillAttributeToPropertyTypeMap()
attributeToPropertyTypeMap.set(SVGNames::kernelUnitLengthAttr, AnimatedNumberOptionalNumber);
}
-PassRefPtr<LightSource> SVGFESpecularLightingElement::findLights() const
-{
- for (Node* node = firstChild(); node; node = node->nextSibling()) {
- if (node->hasTagName(SVGNames::feDistantLightTag)
- || node->hasTagName(SVGNames::fePointLightTag)
- || node->hasTagName(SVGNames::feSpotLightTag)) {
- SVGFELightElement* lightNode = static_cast<SVGFELightElement*>(node);
- return lightNode->lightSource();
- }
- }
-
- return 0;
-}
-
PassRefPtr<FilterEffect> SVGFESpecularLightingElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
{
FilterEffect* input1 = filterBuilder->getEffectById(in1());
-
+
if (!input1)
return 0;
-
- RefPtr<RenderStyle> filterStyle = styleForRenderer();
-
+
+ RefPtr<LightSource> lightSource = SVGFELightElement::findLightSource(this);
+ if (!lightSource)
+ return 0;
+
+ RefPtr<RenderStyle> filterStyle = styleForRenderer();
+
Color color = filterStyle->svgStyle()->lightingColor();
- RefPtr<FilterEffect> effect = FESpecularLighting::create(filter, color, surfaceScale(), specularConstant(),
- specularExponent(), kernelUnitLengthX(), kernelUnitLengthY(), findLights());
+ RefPtr<FilterEffect> effect = FESpecularLighting::create(filter, color, surfaceScale(), specularConstant(),
+ specularExponent(), kernelUnitLengthX(), kernelUnitLengthY(), lightSource.release());
effect->inputEffects().append(input1);
return effect.release();
}