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 27 matching lines...) Expand all Loading... |
38 if (entries.isEmpty()) { | 38 if (entries.isEmpty()) { |
39 entries.append(std::make_pair(EDGEMODE_DUPLICATE, "duplicate")); | 39 entries.append(std::make_pair(EDGEMODE_DUPLICATE, "duplicate")); |
40 entries.append(std::make_pair(EDGEMODE_WRAP, "wrap")); | 40 entries.append(std::make_pair(EDGEMODE_WRAP, "wrap")); |
41 entries.append(std::make_pair(EDGEMODE_NONE, "none")); | 41 entries.append(std::make_pair(EDGEMODE_NONE, "none")); |
42 } | 42 } |
43 return entries; | 43 return entries; |
44 } | 44 } |
45 | 45 |
46 class SVGAnimatedOrder : public SVGAnimatedIntegerOptionalInteger { | 46 class SVGAnimatedOrder : public SVGAnimatedIntegerOptionalInteger { |
47 public: | 47 public: |
48 static PassRefPtr<SVGAnimatedOrder> create(SVGElement* contextElement) | 48 static PassRefPtrWillBeRawPtr<SVGAnimatedOrder> create(SVGElement* contextEl
ement) |
49 { | 49 { |
50 return adoptRef(new SVGAnimatedOrder(contextElement)); | 50 return adoptRefWillBeNoop(new SVGAnimatedOrder(contextElement)); |
51 } | 51 } |
52 | 52 |
53 void setBaseValueAsString(const String&, SVGParsingError&) override; | 53 void setBaseValueAsString(const String&, SVGParsingError&) override; |
54 | 54 |
55 protected: | 55 protected: |
56 SVGAnimatedOrder(SVGElement* contextElement) | 56 SVGAnimatedOrder(SVGElement* contextElement) |
57 : SVGAnimatedIntegerOptionalInteger(contextElement, SVGNames::orderAttr,
0, 0) | 57 : SVGAnimatedIntegerOptionalInteger(contextElement, SVGNames::orderAttr,
0, 0) |
58 { | 58 { |
59 } | 59 } |
60 }; | 60 }; |
(...skipping 28 matching lines...) Expand all Loading... |
89 addToPropertyMap(m_bias); | 89 addToPropertyMap(m_bias); |
90 addToPropertyMap(m_kernelUnitLength); | 90 addToPropertyMap(m_kernelUnitLength); |
91 addToPropertyMap(m_kernelMatrix); | 91 addToPropertyMap(m_kernelMatrix); |
92 addToPropertyMap(m_in1); | 92 addToPropertyMap(m_in1); |
93 addToPropertyMap(m_edgeMode); | 93 addToPropertyMap(m_edgeMode); |
94 addToPropertyMap(m_order); | 94 addToPropertyMap(m_order); |
95 addToPropertyMap(m_targetX); | 95 addToPropertyMap(m_targetX); |
96 addToPropertyMap(m_targetY); | 96 addToPropertyMap(m_targetY); |
97 } | 97 } |
98 | 98 |
| 99 void SVGFEConvolveMatrixElement::trace(Visitor* visitor) |
| 100 { |
| 101 visitor->trace(m_bias); |
| 102 visitor->trace(m_divisor); |
| 103 visitor->trace(m_in1); |
| 104 visitor->trace(m_edgeMode); |
| 105 visitor->trace(m_kernelMatrix); |
| 106 visitor->trace(m_kernelUnitLength); |
| 107 visitor->trace(m_order); |
| 108 visitor->trace(m_preserveAlpha); |
| 109 visitor->trace(m_targetX); |
| 110 visitor->trace(m_targetY); |
| 111 SVGFilterPrimitiveStandardAttributes::trace(visitor); |
| 112 } |
| 113 |
99 DEFINE_NODE_FACTORY(SVGFEConvolveMatrixElement) | 114 DEFINE_NODE_FACTORY(SVGFEConvolveMatrixElement) |
100 | 115 |
101 bool SVGFEConvolveMatrixElement::isSupportedAttribute(const QualifiedName& attrN
ame) | 116 bool SVGFEConvolveMatrixElement::isSupportedAttribute(const QualifiedName& attrN
ame) |
102 { | 117 { |
103 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 118 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
104 if (supportedAttributes.isEmpty()) { | 119 if (supportedAttributes.isEmpty()) { |
105 supportedAttributes.add(SVGNames::inAttr); | 120 supportedAttributes.add(SVGNames::inAttr); |
106 supportedAttributes.add(SVGNames::orderAttr); | 121 supportedAttributes.add(SVGNames::orderAttr); |
107 supportedAttributes.add(SVGNames::kernelMatrixAttr); | 122 supportedAttributes.add(SVGNames::kernelMatrixAttr); |
108 supportedAttributes.add(SVGNames::edgeModeAttr); | 123 supportedAttributes.add(SVGNames::edgeModeAttr); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (attrName == SVGNames::inAttr | 181 if (attrName == SVGNames::inAttr |
167 || attrName == SVGNames::orderAttr | 182 || attrName == SVGNames::orderAttr |
168 || attrName == SVGNames::kernelMatrixAttr) { | 183 || attrName == SVGNames::kernelMatrixAttr) { |
169 invalidate(); | 184 invalidate(); |
170 return; | 185 return; |
171 } | 186 } |
172 | 187 |
173 ASSERT_NOT_REACHED(); | 188 ASSERT_NOT_REACHED(); |
174 } | 189 } |
175 | 190 |
176 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) | 191 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilter
Builder* filterBuilder, Filter* filter) |
177 { | 192 { |
178 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); | 193 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
179 | 194 |
180 if (!input1) | 195 if (!input1) |
181 return nullptr; | 196 return nullptr; |
182 | 197 |
183 int orderXValue = orderX()->currentValue()->value(); | 198 int orderXValue = orderX()->currentValue()->value(); |
184 int orderYValue = orderY()->currentValue()->value(); | 199 int orderYValue = orderY()->currentValue()->value(); |
185 if (!hasAttribute(SVGNames::orderAttr)) { | 200 if (!hasAttribute(SVGNames::orderAttr)) { |
186 orderXValue = 3; | 201 orderXValue = 3; |
187 orderYValue = 3; | 202 orderYValue = 3; |
188 } | 203 } |
189 // Spec says order must be > 0. Bail if it is not. | 204 // Spec says order must be > 0. Bail if it is not. |
190 if (orderXValue < 1 || orderYValue < 1) | 205 if (orderXValue < 1 || orderYValue < 1) |
191 return nullptr; | 206 return nullptr; |
192 RefPtr<SVGNumberList> kernelMatrix = this->m_kernelMatrix->currentValue(); | 207 RefPtrWillBeRawPtr<SVGNumberList> kernelMatrix = this->m_kernelMatrix->curre
ntValue(); |
193 size_t kernelMatrixSize = kernelMatrix->length(); | 208 size_t kernelMatrixSize = kernelMatrix->length(); |
194 // The spec says this is a requirement, and should bail out if fails | 209 // The spec says this is a requirement, and should bail out if fails |
195 if (orderXValue * orderYValue != static_cast<int>(kernelMatrixSize)) | 210 if (orderXValue * orderYValue != static_cast<int>(kernelMatrixSize)) |
196 return nullptr; | 211 return nullptr; |
197 | 212 |
198 int targetXValue = m_targetX->currentValue()->value(); | 213 int targetXValue = m_targetX->currentValue()->value(); |
199 int targetYValue = m_targetY->currentValue()->value(); | 214 int targetYValue = m_targetY->currentValue()->value(); |
200 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) | 215 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) |
201 return nullptr; | 216 return nullptr; |
202 // The spec says the default value is: targetX = floor ( orderX / 2 )) | 217 // The spec says the default value is: targetX = floor ( orderX / 2 )) |
(...skipping 19 matching lines...) Expand all Loading... |
222 float divisorValue = m_divisor->currentValue()->value(); | 237 float divisorValue = m_divisor->currentValue()->value(); |
223 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) | 238 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) |
224 return nullptr; | 239 return nullptr; |
225 if (!hasAttribute(SVGNames::divisorAttr)) { | 240 if (!hasAttribute(SVGNames::divisorAttr)) { |
226 for (size_t i = 0; i < kernelMatrixSize; ++i) | 241 for (size_t i = 0; i < kernelMatrixSize; ++i) |
227 divisorValue += kernelMatrix->at(i)->value(); | 242 divisorValue += kernelMatrix->at(i)->value(); |
228 if (!divisorValue) | 243 if (!divisorValue) |
229 divisorValue = 1; | 244 divisorValue = 1; |
230 } | 245 } |
231 | 246 |
232 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 247 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
233 IntSize(orderXValue, orderYValue), divisorValue, | 248 IntSize(orderXValue, orderYValue), divisorValue, |
234 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), | 249 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), |
235 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); | 250 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); |
236 effect->inputEffects().append(input1); | 251 effect->inputEffects().append(input1); |
237 return effect.release(); | 252 return effect.release(); |
238 } | 253 } |
239 | 254 |
240 } // namespace blink | 255 } // namespace blink |
OLD | NEW |