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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 visitor->trace(m_kernelUnitLength); | 106 visitor->trace(m_kernelUnitLength); |
107 visitor->trace(m_order); | 107 visitor->trace(m_order); |
108 visitor->trace(m_preserveAlpha); | 108 visitor->trace(m_preserveAlpha); |
109 visitor->trace(m_targetX); | 109 visitor->trace(m_targetX); |
110 visitor->trace(m_targetY); | 110 visitor->trace(m_targetY); |
111 SVGFilterPrimitiveStandardAttributes::trace(visitor); | 111 SVGFilterPrimitiveStandardAttributes::trace(visitor); |
112 } | 112 } |
113 | 113 |
114 DEFINE_NODE_FACTORY(SVGFEConvolveMatrixElement) | 114 DEFINE_NODE_FACTORY(SVGFEConvolveMatrixElement) |
115 | 115 |
116 bool SVGFEConvolveMatrixElement::isSupportedAttribute(const QualifiedName& attrN
ame) | |
117 { | |
118 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | |
119 if (supportedAttributes.isEmpty()) { | |
120 supportedAttributes.add(SVGNames::inAttr); | |
121 supportedAttributes.add(SVGNames::orderAttr); | |
122 supportedAttributes.add(SVGNames::kernelMatrixAttr); | |
123 supportedAttributes.add(SVGNames::edgeModeAttr); | |
124 supportedAttributes.add(SVGNames::divisorAttr); | |
125 supportedAttributes.add(SVGNames::biasAttr); | |
126 supportedAttributes.add(SVGNames::targetXAttr); | |
127 supportedAttributes.add(SVGNames::targetYAttr); | |
128 supportedAttributes.add(SVGNames::kernelUnitLengthAttr); | |
129 supportedAttributes.add(SVGNames::preserveAlphaAttr); | |
130 } | |
131 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | |
132 } | |
133 | |
134 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) | 116 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) |
135 { | 117 { |
136 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); | 118 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); |
137 if (attrName == SVGNames::edgeModeAttr) | 119 if (attrName == SVGNames::edgeModeAttr) |
138 return convolveMatrix->setEdgeMode(m_edgeMode->currentValue()->enumValue
()); | 120 return convolveMatrix->setEdgeMode(m_edgeMode->currentValue()->enumValue
()); |
139 if (attrName == SVGNames::divisorAttr) | 121 if (attrName == SVGNames::divisorAttr) |
140 return convolveMatrix->setDivisor(m_divisor->currentValue()->value()); | 122 return convolveMatrix->setDivisor(m_divisor->currentValue()->value()); |
141 if (attrName == SVGNames::biasAttr) | 123 if (attrName == SVGNames::biasAttr) |
142 return convolveMatrix->setBias(m_bias->currentValue()->value()); | 124 return convolveMatrix->setBias(m_bias->currentValue()->value()); |
143 if (attrName == SVGNames::targetXAttr) | 125 if (attrName == SVGNames::targetXAttr) |
144 return convolveMatrix->setTargetOffset(IntPoint(m_targetX->currentValue(
)->value(), m_targetY->currentValue()->value())); | 126 return convolveMatrix->setTargetOffset(IntPoint(m_targetX->currentValue(
)->value(), m_targetY->currentValue()->value())); |
145 if (attrName == SVGNames::targetYAttr) | 127 if (attrName == SVGNames::targetYAttr) |
146 return convolveMatrix->setTargetOffset(IntPoint(m_targetX->currentValue(
)->value(), m_targetY->currentValue()->value())); | 128 return convolveMatrix->setTargetOffset(IntPoint(m_targetX->currentValue(
)->value(), m_targetY->currentValue()->value())); |
147 if (attrName == SVGNames::kernelUnitLengthAttr) | 129 if (attrName == SVGNames::kernelUnitLengthAttr) |
148 return convolveMatrix->setKernelUnitLength(FloatPoint(kernelUnitLengthX(
)->currentValue()->value(), kernelUnitLengthY()->currentValue()->value())); | 130 return convolveMatrix->setKernelUnitLength(FloatPoint(kernelUnitLengthX(
)->currentValue()->value(), kernelUnitLengthY()->currentValue()->value())); |
149 if (attrName == SVGNames::preserveAlphaAttr) | 131 if (attrName == SVGNames::preserveAlphaAttr) |
150 return convolveMatrix->setPreserveAlpha(m_preserveAlpha->currentValue()-
>value()); | 132 return convolveMatrix->setPreserveAlpha(m_preserveAlpha->currentValue()-
>value()); |
151 | 133 |
152 ASSERT_NOT_REACHED(); | 134 ASSERT_NOT_REACHED(); |
153 return false; | 135 return false; |
154 } | 136 } |
155 | 137 |
156 void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrNa
me) | 138 void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrNa
me) |
157 { | 139 { |
158 if (!isSupportedAttribute(attrName)) { | |
159 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); | |
160 return; | |
161 } | |
162 | |
163 SVGElement::InvalidationGuard invalidationGuard(this); | |
164 | |
165 if (attrName == SVGNames::edgeModeAttr | 140 if (attrName == SVGNames::edgeModeAttr |
166 || attrName == SVGNames::divisorAttr | 141 || attrName == SVGNames::divisorAttr |
167 || attrName == SVGNames::biasAttr | 142 || attrName == SVGNames::biasAttr |
168 || attrName == SVGNames::targetXAttr | 143 || attrName == SVGNames::targetXAttr |
169 || attrName == SVGNames::targetYAttr | 144 || attrName == SVGNames::targetYAttr |
170 || attrName == SVGNames::kernelUnitLengthAttr | 145 || attrName == SVGNames::kernelUnitLengthAttr |
171 || attrName == SVGNames::preserveAlphaAttr) { | 146 || attrName == SVGNames::preserveAlphaAttr) { |
| 147 SVGElement::InvalidationGuard invalidationGuard(this); |
172 primitiveAttributeChanged(attrName); | 148 primitiveAttributeChanged(attrName); |
173 return; | 149 return; |
174 } | 150 } |
175 | 151 |
176 if (attrName == SVGNames::inAttr | 152 if (attrName == SVGNames::inAttr |
177 || attrName == SVGNames::orderAttr | 153 || attrName == SVGNames::orderAttr |
178 || attrName == SVGNames::kernelMatrixAttr) { | 154 || attrName == SVGNames::kernelMatrixAttr) { |
| 155 SVGElement::InvalidationGuard invalidationGuard(this); |
179 invalidate(); | 156 invalidate(); |
180 return; | 157 return; |
181 } | 158 } |
182 | 159 |
183 ASSERT_NOT_REACHED(); | 160 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); |
184 } | 161 } |
185 | 162 |
186 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilter
Builder* filterBuilder, Filter* filter) | 163 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilter
Builder* filterBuilder, Filter* filter) |
187 { | 164 { |
188 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); | 165 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
189 | 166 |
190 if (!input1) | 167 if (!input1) |
191 return nullptr; | 168 return nullptr; |
192 | 169 |
193 int orderXValue = orderX()->currentValue()->value(); | 170 int orderXValue = orderX()->currentValue()->value(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 218 |
242 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 219 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
243 IntSize(orderXValue, orderYValue), divisorValue, | 220 IntSize(orderXValue, orderYValue), divisorValue, |
244 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), | 221 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), |
245 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); | 222 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); |
246 effect->inputEffects().append(input1); | 223 effect->inputEffects().append(input1); |
247 return effect.release(); | 224 return effect.release(); |
248 } | 225 } |
249 | 226 |
250 } // namespace blink | 227 } // namespace blink |
OLD | NEW |