OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz> | 2 * Copyright (C) 2005 Oliver Hunt <ojh16@student.canterbury.ac.nz> |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "core/rendering/style/RenderStyle.h" | 24 #include "core/rendering/style/RenderStyle.h" |
25 #include "core/svg/SVGElementInstance.h" | 25 #include "core/svg/SVGElementInstance.h" |
26 #include "core/svg/SVGParserUtilities.h" | 26 #include "core/svg/SVGParserUtilities.h" |
27 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 27 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
28 #include "platform/graphics/filters/FEDiffuseLighting.h" | 28 #include "platform/graphics/filters/FEDiffuseLighting.h" |
29 #include "platform/graphics/filters/FilterEffect.h" | 29 #include "platform/graphics/filters/FilterEffect.h" |
30 | 30 |
31 namespace WebCore { | 31 namespace WebCore { |
32 | 32 |
33 // Animated property definitions | 33 // Animated property definitions |
34 DEFINE_ANIMATED_STRING(SVGFEDiffuseLightingElement, SVGNames::inAttr, In1, in1) | |
35 | 34 |
36 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEDiffuseLightingElement) | 35 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEDiffuseLightingElement) |
37 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) | |
38 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 36 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
39 END_REGISTER_ANIMATED_PROPERTIES | 37 END_REGISTER_ANIMATED_PROPERTIES |
40 | 38 |
41 inline SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(Document& docume
nt) | 39 inline SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(Document& docume
nt) |
42 : SVGFilterPrimitiveStandardAttributes(SVGNames::feDiffuseLightingTag, docum
ent) | 40 : SVGFilterPrimitiveStandardAttributes(SVGNames::feDiffuseLightingTag, docum
ent) |
43 , m_diffuseConstant(SVGAnimatedNumber::create(this, SVGNames::diffuseConstan
tAttr, SVGNumber::create(1))) | 41 , m_diffuseConstant(SVGAnimatedNumber::create(this, SVGNames::diffuseConstan
tAttr, SVGNumber::create(1))) |
44 , m_surfaceScale(SVGAnimatedNumber::create(this, SVGNames::surfaceScaleAttr,
SVGNumber::create(1))) | 42 , m_surfaceScale(SVGAnimatedNumber::create(this, SVGNames::surfaceScaleAttr,
SVGNumber::create(1))) |
45 , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames:
:kernelUnitLengthAttr)) | 43 , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames:
:kernelUnitLengthAttr)) |
| 44 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
46 { | 45 { |
47 ScriptWrappable::init(this); | 46 ScriptWrappable::init(this); |
48 | 47 |
49 addToPropertyMap(m_diffuseConstant); | 48 addToPropertyMap(m_diffuseConstant); |
50 addToPropertyMap(m_surfaceScale); | 49 addToPropertyMap(m_surfaceScale); |
51 addToPropertyMap(m_kernelUnitLength); | 50 addToPropertyMap(m_kernelUnitLength); |
| 51 addToPropertyMap(m_in1); |
52 registerAnimatedPropertiesForSVGFEDiffuseLightingElement(); | 52 registerAnimatedPropertiesForSVGFEDiffuseLightingElement(); |
53 } | 53 } |
54 | 54 |
55 PassRefPtr<SVGFEDiffuseLightingElement> SVGFEDiffuseLightingElement::create(Docu
ment& document) | 55 PassRefPtr<SVGFEDiffuseLightingElement> SVGFEDiffuseLightingElement::create(Docu
ment& document) |
56 { | 56 { |
57 return adoptRef(new SVGFEDiffuseLightingElement(document)); | 57 return adoptRef(new SVGFEDiffuseLightingElement(document)); |
58 } | 58 } |
59 | 59 |
60 bool SVGFEDiffuseLightingElement::isSupportedAttribute(const QualifiedName& attr
Name) | 60 bool SVGFEDiffuseLightingElement::isSupportedAttribute(const QualifiedName& attr
Name) |
61 { | 61 { |
62 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 62 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
63 if (supportedAttributes.isEmpty()) { | 63 if (supportedAttributes.isEmpty()) { |
64 supportedAttributes.add(SVGNames::inAttr); | 64 supportedAttributes.add(SVGNames::inAttr); |
65 supportedAttributes.add(SVGNames::diffuseConstantAttr); | 65 supportedAttributes.add(SVGNames::diffuseConstantAttr); |
66 supportedAttributes.add(SVGNames::surfaceScaleAttr); | 66 supportedAttributes.add(SVGNames::surfaceScaleAttr); |
67 supportedAttributes.add(SVGNames::kernelUnitLengthAttr); | 67 supportedAttributes.add(SVGNames::kernelUnitLengthAttr); |
68 supportedAttributes.add(SVGNames::lighting_colorAttr); // Even though it
's a SVG-CSS property, we override its handling here. | 68 supportedAttributes.add(SVGNames::lighting_colorAttr); // Even though it
's a SVG-CSS property, we override its handling here. |
69 } | 69 } |
70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
71 } | 71 } |
72 | 72 |
73 void SVGFEDiffuseLightingElement::parseAttribute(const QualifiedName& name, cons
t AtomicString& value) | 73 void SVGFEDiffuseLightingElement::parseAttribute(const QualifiedName& name, cons
t AtomicString& value) |
74 { | 74 { |
75 if (!isSupportedAttribute(name) || name == SVGNames::lighting_colorAttr) { | 75 if (!isSupportedAttribute(name) || name == SVGNames::lighting_colorAttr) { |
76 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | 76 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); |
77 return; | 77 return; |
78 } | 78 } |
79 | 79 |
80 if (name == SVGNames::inAttr) { | |
81 setIn1BaseValue(value); | |
82 return; | |
83 } | |
84 | |
85 SVGParsingError parseError = NoError; | 80 SVGParsingError parseError = NoError; |
86 | 81 |
87 if (name == SVGNames::diffuseConstantAttr) | 82 if (name == SVGNames::inAttr) |
| 83 m_in1->setBaseValueAsString(value, parseError); |
| 84 else if (name == SVGNames::diffuseConstantAttr) |
88 m_diffuseConstant->setBaseValueAsString(value, parseError); | 85 m_diffuseConstant->setBaseValueAsString(value, parseError); |
89 else if (name == SVGNames::surfaceScaleAttr) | 86 else if (name == SVGNames::surfaceScaleAttr) |
90 m_surfaceScale->setBaseValueAsString(value, parseError); | 87 m_surfaceScale->setBaseValueAsString(value, parseError); |
91 else if (name == SVGNames::kernelUnitLengthAttr) | 88 else if (name == SVGNames::kernelUnitLengthAttr) |
92 m_kernelUnitLength->setBaseValueAsString(value, parseError); | 89 m_kernelUnitLength->setBaseValueAsString(value, parseError); |
93 else | 90 else |
94 ASSERT_NOT_REACHED(); | 91 ASSERT_NOT_REACHED(); |
95 | 92 |
96 reportAttributeParsingError(parseError, name, value); | 93 reportAttributeParsingError(parseError, name, value); |
97 } | 94 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 { | 167 { |
171 if (SVGFELightElement::findLightElement(this) != lightElement) | 168 if (SVGFELightElement::findLightElement(this) != lightElement) |
172 return; | 169 return; |
173 | 170 |
174 // The light element has different attribute names. | 171 // The light element has different attribute names. |
175 primitiveAttributeChanged(attrName); | 172 primitiveAttributeChanged(attrName); |
176 } | 173 } |
177 | 174 |
178 PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* fi
lterBuilder, Filter* filter) | 175 PassRefPtr<FilterEffect> SVGFEDiffuseLightingElement::build(SVGFilterBuilder* fi
lterBuilder, Filter* filter) |
179 { | 176 { |
180 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(in1CurrentV
alue())); | 177 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
181 | 178 |
182 if (!input1) | 179 if (!input1) |
183 return 0; | 180 return 0; |
184 | 181 |
185 RefPtr<LightSource> lightSource = SVGFELightElement::findLightSource(this); | 182 RefPtr<LightSource> lightSource = SVGFELightElement::findLightSource(this); |
186 if (!lightSource) | 183 if (!lightSource) |
187 return 0; | 184 return 0; |
188 | 185 |
189 RenderObject* renderer = this->renderer(); | 186 RenderObject* renderer = this->renderer(); |
190 if (!renderer) | 187 if (!renderer) |
191 return 0; | 188 return 0; |
192 | 189 |
193 ASSERT(renderer->style()); | 190 ASSERT(renderer->style()); |
194 Color color = renderer->style()->svgStyle()->lightingColor(); | 191 Color color = renderer->style()->svgStyle()->lightingColor(); |
195 | 192 |
196 RefPtr<FilterEffect> effect = FEDiffuseLighting::create(filter, color, m_sur
faceScale->currentValue()->value(), m_diffuseConstant->currentValue()->value(), | 193 RefPtr<FilterEffect> effect = FEDiffuseLighting::create(filter, color, m_sur
faceScale->currentValue()->value(), m_diffuseConstant->currentValue()->value(), |
197 kernelUnitLengthX()->currentValue()->value(), kernelUnitLengthY()->curre
ntValue()->value(), lightSource.release()); | 194 kernelUnitLengthX()->currentValue()->value(), kernelUnitLengthY()->curre
ntValue()->value(), lightSource.release()); |
198 effect->inputEffects().append(input1); | 195 effect->inputEffects().append(input1); |
199 return effect.release(); | 196 return effect.release(); |
200 } | 197 } |
201 | 198 |
202 } | 199 } |
OLD | NEW |