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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "config.h" | 20 #include "config.h" |
21 #include "core/svg/SVGFEDiffuseLightingElement.h" | 21 #include "core/svg/SVGFEDiffuseLightingElement.h" |
22 | 22 |
23 #include "core/rendering/RenderObject.h" | 23 #include "core/layout/LayoutObject.h" |
24 #include "core/rendering/style/RenderStyle.h" | 24 #include "core/rendering/style/RenderStyle.h" |
25 #include "core/svg/SVGParserUtilities.h" | 25 #include "core/svg/SVGParserUtilities.h" |
26 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 26 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
27 #include "platform/graphics/filters/FEDiffuseLighting.h" | 27 #include "platform/graphics/filters/FEDiffuseLighting.h" |
28 #include "platform/graphics/filters/FilterEffect.h" | 28 #include "platform/graphics/filters/FilterEffect.h" |
29 | 29 |
30 namespace blink { | 30 namespace blink { |
31 | 31 |
32 inline SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(Document& docume
nt) | 32 inline SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement(Document& docume
nt) |
33 : SVGFilterPrimitiveStandardAttributes(SVGNames::feDiffuseLightingTag, docum
ent) | 33 : SVGFilterPrimitiveStandardAttributes(SVGNames::feDiffuseLightingTag, docum
ent) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 void SVGFEDiffuseLightingElement::parseAttribute(const QualifiedName& name, cons
t AtomicString& value) | 69 void SVGFEDiffuseLightingElement::parseAttribute(const QualifiedName& name, cons
t AtomicString& value) |
70 { | 70 { |
71 parseAttributeNew(name, value); | 71 parseAttributeNew(name, value); |
72 } | 72 } |
73 | 73 |
74 bool SVGFEDiffuseLightingElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) | 74 bool SVGFEDiffuseLightingElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) |
75 { | 75 { |
76 FEDiffuseLighting* diffuseLighting = static_cast<FEDiffuseLighting*>(effect)
; | 76 FEDiffuseLighting* diffuseLighting = static_cast<FEDiffuseLighting*>(effect)
; |
77 | 77 |
78 if (attrName == SVGNames::lighting_colorAttr) { | 78 if (attrName == SVGNames::lighting_colorAttr) { |
79 RenderObject* renderer = this->renderer(); | 79 LayoutObject* renderer = this->renderer(); |
80 ASSERT(renderer); | 80 ASSERT(renderer); |
81 ASSERT(renderer->style()); | 81 ASSERT(renderer->style()); |
82 return diffuseLighting->setLightingColor(renderer->style()->svgStyle().l
ightingColor()); | 82 return diffuseLighting->setLightingColor(renderer->style()->svgStyle().l
ightingColor()); |
83 } | 83 } |
84 if (attrName == SVGNames::surfaceScaleAttr) | 84 if (attrName == SVGNames::surfaceScaleAttr) |
85 return diffuseLighting->setSurfaceScale(m_surfaceScale->currentValue()->
value()); | 85 return diffuseLighting->setSurfaceScale(m_surfaceScale->currentValue()->
value()); |
86 if (attrName == SVGNames::diffuseConstantAttr) | 86 if (attrName == SVGNames::diffuseConstantAttr) |
87 return diffuseLighting->setDiffuseConstant(m_diffuseConstant->currentVal
ue()->value()); | 87 return diffuseLighting->setDiffuseConstant(m_diffuseConstant->currentVal
ue()->value()); |
88 if (attrName == SVGNames::kernelUnitLengthAttr) { | 88 if (attrName == SVGNames::kernelUnitLengthAttr) { |
89 bool changedX = diffuseLighting->setKernelUnitLengthX(m_kernelUnitLength
->firstNumber()->currentValue()->value()); | 89 bool changedX = diffuseLighting->setKernelUnitLengthX(m_kernelUnitLength
->firstNumber()->currentValue()->value()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 { | 152 { |
153 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); | 153 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
154 | 154 |
155 if (!input1) | 155 if (!input1) |
156 return nullptr; | 156 return nullptr; |
157 | 157 |
158 SVGFELightElement* lightNode = SVGFELightElement::findLightElement(*this); | 158 SVGFELightElement* lightNode = SVGFELightElement::findLightElement(*this); |
159 if (!lightNode) | 159 if (!lightNode) |
160 return nullptr; | 160 return nullptr; |
161 | 161 |
162 RenderObject* renderer = this->renderer(); | 162 LayoutObject* renderer = this->renderer(); |
163 if (!renderer) | 163 if (!renderer) |
164 return nullptr; | 164 return nullptr; |
165 | 165 |
166 ASSERT(renderer->style()); | 166 ASSERT(renderer->style()); |
167 Color color = renderer->style()->svgStyle().lightingColor(); | 167 Color color = renderer->style()->svgStyle().lightingColor(); |
168 | 168 |
169 RefPtr<LightSource> lightSource = lightNode->lightSource(filter); | 169 RefPtr<LightSource> lightSource = lightNode->lightSource(filter); |
170 RefPtrWillBeRawPtr<FilterEffect> effect = FEDiffuseLighting::create(filter,
color, m_surfaceScale->currentValue()->value(), m_diffuseConstant->currentValue(
)->value(), | 170 RefPtrWillBeRawPtr<FilterEffect> effect = FEDiffuseLighting::create(filter,
color, m_surfaceScale->currentValue()->value(), m_diffuseConstant->currentValue(
)->value(), |
171 kernelUnitLengthX()->currentValue()->value(), kernelUnitLengthY()->curre
ntValue()->value(), lightSource.release()); | 171 kernelUnitLengthX()->currentValue()->value(), kernelUnitLengthY()->curre
ntValue()->value(), lightSource.release()); |
172 effect->inputEffects().append(input1); | 172 effect->inputEffects().append(input1); |
173 return effect.release(); | 173 return effect.release(); |
174 } | 174 } |
175 | 175 |
176 } // namespace blink | 176 } // namespace blink |
OLD | NEW |