OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
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 15 matching lines...) Expand all Loading... |
26 #include "core/svg/SVGElementInstance.h" | 26 #include "core/svg/SVGElementInstance.h" |
27 #include "core/svg/SVGParserUtilities.h" | 27 #include "core/svg/SVGParserUtilities.h" |
28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 28 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
29 #include "platform/geometry/FloatPoint.h" | 29 #include "platform/geometry/FloatPoint.h" |
30 #include "platform/geometry/IntPoint.h" | 30 #include "platform/geometry/IntPoint.h" |
31 #include "platform/geometry/IntSize.h" | 31 #include "platform/geometry/IntSize.h" |
32 | 32 |
33 namespace WebCore { | 33 namespace WebCore { |
34 | 34 |
35 // Animated property definitions | 35 // Animated property definitions |
36 DEFINE_ANIMATED_STRING(SVGFEConvolveMatrixElement, SVGNames::inAttr, In1, in1) | |
37 DEFINE_ANIMATED_INTEGER_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::
orderAttr, orderXIdentifier(), OrderX, orderX) | 36 DEFINE_ANIMATED_INTEGER_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::
orderAttr, orderXIdentifier(), OrderX, orderX) |
38 DEFINE_ANIMATED_INTEGER_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::
orderAttr, orderYIdentifier(), OrderY, orderY) | 37 DEFINE_ANIMATED_INTEGER_MULTIPLE_WRAPPERS(SVGFEConvolveMatrixElement, SVGNames::
orderAttr, orderYIdentifier(), OrderY, orderY) |
39 DEFINE_ANIMATED_INTEGER(SVGFEConvolveMatrixElement, SVGNames::targetXAttr, Targe
tX, targetX) | 38 DEFINE_ANIMATED_INTEGER(SVGFEConvolveMatrixElement, SVGNames::targetXAttr, Targe
tX, targetX) |
40 DEFINE_ANIMATED_INTEGER(SVGFEConvolveMatrixElement, SVGNames::targetYAttr, Targe
tY, targetY) | 39 DEFINE_ANIMATED_INTEGER(SVGFEConvolveMatrixElement, SVGNames::targetYAttr, Targe
tY, targetY) |
41 DEFINE_ANIMATED_ENUMERATION(SVGFEConvolveMatrixElement, SVGNames::edgeModeAttr,
EdgeMode, edgeMode, EdgeModeType) | 40 DEFINE_ANIMATED_ENUMERATION(SVGFEConvolveMatrixElement, SVGNames::edgeModeAttr,
EdgeMode, edgeMode, EdgeModeType) |
42 | 41 |
43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEConvolveMatrixElement) | 42 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFEConvolveMatrixElement) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(in1) | |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(orderX) | 43 REGISTER_LOCAL_ANIMATED_PROPERTY(orderX) |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(orderY) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(orderY) |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(targetX) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(targetX) |
48 REGISTER_LOCAL_ANIMATED_PROPERTY(targetY) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(targetY) |
49 REGISTER_LOCAL_ANIMATED_PROPERTY(edgeMode) | 47 REGISTER_LOCAL_ANIMATED_PROPERTY(edgeMode) |
50 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 48 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
51 END_REGISTER_ANIMATED_PROPERTIES | 49 END_REGISTER_ANIMATED_PROPERTIES |
52 | 50 |
53 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) | 51 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) |
54 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) | 52 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) |
55 , m_preserveAlpha(SVGAnimatedBoolean::create(this, SVGNames::preserveAlphaAt
tr, SVGBoolean::create())) | 53 , m_preserveAlpha(SVGAnimatedBoolean::create(this, SVGNames::preserveAlphaAt
tr, SVGBoolean::create())) |
56 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) | 54 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) |
57 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) | 55 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) |
58 , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames:
:kernelUnitLengthAttr)) | 56 , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames:
:kernelUnitLengthAttr)) |
59 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) | 57 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) |
| 58 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
60 , m_edgeMode(EDGEMODE_DUPLICATE) | 59 , m_edgeMode(EDGEMODE_DUPLICATE) |
61 { | 60 { |
62 ScriptWrappable::init(this); | 61 ScriptWrappable::init(this); |
63 | 62 |
64 addToPropertyMap(m_preserveAlpha); | 63 addToPropertyMap(m_preserveAlpha); |
65 addToPropertyMap(m_divisor); | 64 addToPropertyMap(m_divisor); |
66 addToPropertyMap(m_bias); | 65 addToPropertyMap(m_bias); |
67 addToPropertyMap(m_kernelUnitLength); | 66 addToPropertyMap(m_kernelUnitLength); |
68 addToPropertyMap(m_kernelMatrix); | 67 addToPropertyMap(m_kernelMatrix); |
| 68 addToPropertyMap(m_in1); |
69 registerAnimatedPropertiesForSVGFEConvolveMatrixElement(); | 69 registerAnimatedPropertiesForSVGFEConvolveMatrixElement(); |
70 } | 70 } |
71 | 71 |
72 PassRefPtr<SVGFEConvolveMatrixElement> SVGFEConvolveMatrixElement::create(Docume
nt& document) | 72 PassRefPtr<SVGFEConvolveMatrixElement> SVGFEConvolveMatrixElement::create(Docume
nt& document) |
73 { | 73 { |
74 return adoptRef(new SVGFEConvolveMatrixElement(document)); | 74 return adoptRef(new SVGFEConvolveMatrixElement(document)); |
75 } | 75 } |
76 | 76 |
77 const AtomicString& SVGFEConvolveMatrixElement::orderXIdentifier() | 77 const AtomicString& SVGFEConvolveMatrixElement::orderXIdentifier() |
78 { | 78 { |
(...skipping 25 matching lines...) Expand all Loading... |
104 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 104 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
105 } | 105 } |
106 | 106 |
107 void SVGFEConvolveMatrixElement::parseAttribute(const QualifiedName& name, const
AtomicString& value) | 107 void SVGFEConvolveMatrixElement::parseAttribute(const QualifiedName& name, const
AtomicString& value) |
108 { | 108 { |
109 if (!isSupportedAttribute(name)) { | 109 if (!isSupportedAttribute(name)) { |
110 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | 110 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 if (name == SVGNames::inAttr) { | |
115 setIn1BaseValue(value); | |
116 return; | |
117 } | |
118 | |
119 if (name == SVGNames::orderAttr) { | 114 if (name == SVGNames::orderAttr) { |
120 float x, y; | 115 float x, y; |
121 if (parseNumberOptionalNumber(value, x, y) && x >= 1 && y >= 1) { | 116 if (parseNumberOptionalNumber(value, x, y) && x >= 1 && y >= 1) { |
122 setOrderXBaseValue(x); | 117 setOrderXBaseValue(x); |
123 setOrderYBaseValue(y); | 118 setOrderYBaseValue(y); |
124 } else { | 119 } else { |
125 document().accessSVGExtensions()->reportWarning( | 120 document().accessSVGExtensions()->reportWarning( |
126 "feConvolveMatrix: problem parsing order=\"" + value | 121 "feConvolveMatrix: problem parsing order=\"" + value |
127 + "\". Filtered element will not be displayed."); | 122 + "\". Filtered element will not be displayed."); |
128 } | 123 } |
(...skipping 16 matching lines...) Expand all Loading... |
145 return; | 140 return; |
146 } | 141 } |
147 | 142 |
148 if (name == SVGNames::targetYAttr) { | 143 if (name == SVGNames::targetYAttr) { |
149 setTargetYBaseValue(value.string().toUIntStrict()); | 144 setTargetYBaseValue(value.string().toUIntStrict()); |
150 return; | 145 return; |
151 } | 146 } |
152 | 147 |
153 SVGParsingError parseError = NoError; | 148 SVGParsingError parseError = NoError; |
154 | 149 |
155 if (name == SVGNames::divisorAttr) | 150 if (name == SVGNames::inAttr) |
| 151 m_in1->setBaseValueAsString(value, parseError); |
| 152 else if (name == SVGNames::divisorAttr) |
156 m_divisor->setBaseValueAsString(value, parseError); | 153 m_divisor->setBaseValueAsString(value, parseError); |
157 else if (name == SVGNames::biasAttr) | 154 else if (name == SVGNames::biasAttr) |
158 m_bias->setBaseValueAsString(value, parseError); | 155 m_bias->setBaseValueAsString(value, parseError); |
159 else if (name == SVGNames::kernelUnitLengthAttr) | 156 else if (name == SVGNames::kernelUnitLengthAttr) |
160 m_kernelUnitLength->setBaseValueAsString(value, parseError); | 157 m_kernelUnitLength->setBaseValueAsString(value, parseError); |
161 else if (name == SVGNames::kernelMatrixAttr) | 158 else if (name == SVGNames::kernelMatrixAttr) |
162 m_kernelMatrix->setBaseValueAsString(value, parseError); | 159 m_kernelMatrix->setBaseValueAsString(value, parseError); |
163 else if (name == SVGNames::preserveAlphaAttr) | 160 else if (name == SVGNames::preserveAlphaAttr) |
164 m_preserveAlpha->setBaseValueAsString(value, parseError); | 161 m_preserveAlpha->setBaseValueAsString(value, parseError); |
165 else | 162 else |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 || attrName == SVGNames::kernelMatrixAttr) { | 226 || attrName == SVGNames::kernelMatrixAttr) { |
230 invalidate(); | 227 invalidate(); |
231 return; | 228 return; |
232 } | 229 } |
233 | 230 |
234 ASSERT_NOT_REACHED(); | 231 ASSERT_NOT_REACHED(); |
235 } | 232 } |
236 | 233 |
237 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) | 234 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) |
238 { | 235 { |
239 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(in1CurrentV
alue())); | 236 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
240 | 237 |
241 if (!input1) | 238 if (!input1) |
242 return 0; | 239 return 0; |
243 | 240 |
244 int orderXValue = orderXCurrentValue(); | 241 int orderXValue = orderXCurrentValue(); |
245 int orderYValue = orderYCurrentValue(); | 242 int orderYValue = orderYCurrentValue(); |
246 if (!hasAttribute(SVGNames::orderAttr)) { | 243 if (!hasAttribute(SVGNames::orderAttr)) { |
247 orderXValue = 3; | 244 orderXValue = 3; |
248 orderYValue = 3; | 245 orderYValue = 3; |
249 } | 246 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 289 |
293 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 290 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
294 IntSize(orderXValue, orderYValue), divisorValue, | 291 IntSize(orderXValue, orderYValue), divisorValue, |
295 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), edgeModeCurrentValue(), | 292 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), edgeModeCurrentValue(), |
296 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); | 293 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); |
297 effect->inputEffects().append(input1); | 294 effect->inputEffects().append(input1); |
298 return effect.release(); | 295 return effect.release(); |
299 } | 296 } |
300 | 297 |
301 } // namespace WebCore | 298 } // namespace WebCore |
OLD | NEW |