| 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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 191 } |
| 192 | 192 |
| 193 ASSERT_NOT_REACHED(); | 193 ASSERT_NOT_REACHED(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) | 196 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) |
| 197 { | 197 { |
| 198 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); | 198 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
| 199 | 199 |
| 200 if (!input1) | 200 if (!input1) |
| 201 return 0; | 201 return nullptr; |
| 202 | 202 |
| 203 int orderXValue = orderX()->currentValue()->value(); | 203 int orderXValue = orderX()->currentValue()->value(); |
| 204 int orderYValue = orderY()->currentValue()->value(); | 204 int orderYValue = orderY()->currentValue()->value(); |
| 205 if (!hasAttribute(SVGNames::orderAttr)) { | 205 if (!hasAttribute(SVGNames::orderAttr)) { |
| 206 orderXValue = 3; | 206 orderXValue = 3; |
| 207 orderYValue = 3; | 207 orderYValue = 3; |
| 208 } | 208 } |
| 209 // Spec says order must be > 0. Bail if it is not. | 209 // Spec says order must be > 0. Bail if it is not. |
| 210 if (orderXValue < 1 || orderYValue < 1) | 210 if (orderXValue < 1 || orderYValue < 1) |
| 211 return 0; | 211 return nullptr; |
| 212 RefPtr<SVGNumberList> kernelMatrix = this->m_kernelMatrix->currentValue(); | 212 RefPtr<SVGNumberList> kernelMatrix = this->m_kernelMatrix->currentValue(); |
| 213 size_t kernelMatrixSize = kernelMatrix->numberOfItems(); | 213 size_t kernelMatrixSize = kernelMatrix->numberOfItems(); |
| 214 // The spec says this is a requirement, and should bail out if fails | 214 // The spec says this is a requirement, and should bail out if fails |
| 215 if (orderXValue * orderYValue != static_cast<int>(kernelMatrixSize)) | 215 if (orderXValue * orderYValue != static_cast<int>(kernelMatrixSize)) |
| 216 return 0; | 216 return nullptr; |
| 217 | 217 |
| 218 int targetXValue = m_targetX->currentValue()->value(); | 218 int targetXValue = m_targetX->currentValue()->value(); |
| 219 int targetYValue = m_targetY->currentValue()->value(); | 219 int targetYValue = m_targetY->currentValue()->value(); |
| 220 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) | 220 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) |
| 221 return 0; | 221 return nullptr; |
| 222 // The spec says the default value is: targetX = floor ( orderX / 2 )) | 222 // The spec says the default value is: targetX = floor ( orderX / 2 )) |
| 223 if (!hasAttribute(SVGNames::targetXAttr)) | 223 if (!hasAttribute(SVGNames::targetXAttr)) |
| 224 targetXValue = static_cast<int>(floorf(orderXValue / 2)); | 224 targetXValue = static_cast<int>(floorf(orderXValue / 2)); |
| 225 if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue
>= orderYValue)) | 225 if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue
>= orderYValue)) |
| 226 return 0; | 226 return nullptr; |
| 227 // The spec says the default value is: targetY = floor ( orderY / 2 )) | 227 // The spec says the default value is: targetY = floor ( orderY / 2 )) |
| 228 if (!hasAttribute(SVGNames::targetYAttr)) | 228 if (!hasAttribute(SVGNames::targetYAttr)) |
| 229 targetYValue = static_cast<int>(floorf(orderYValue / 2)); | 229 targetYValue = static_cast<int>(floorf(orderYValue / 2)); |
| 230 | 230 |
| 231 // Spec says default kernelUnitLength is 1.0, and a specified length cannot
be 0. | 231 // Spec says default kernelUnitLength is 1.0, and a specified length cannot
be 0. |
| 232 // FIXME: Why is this cast from float -> int -> float? | 232 // FIXME: Why is this cast from float -> int -> float? |
| 233 int kernelUnitLengthXValue = kernelUnitLengthX()->currentValue()->value(); | 233 int kernelUnitLengthXValue = kernelUnitLengthX()->currentValue()->value(); |
| 234 int kernelUnitLengthYValue = kernelUnitLengthY()->currentValue()->value(); | 234 int kernelUnitLengthYValue = kernelUnitLengthY()->currentValue()->value(); |
| 235 if (!hasAttribute(SVGNames::kernelUnitLengthAttr)) { | 235 if (!hasAttribute(SVGNames::kernelUnitLengthAttr)) { |
| 236 kernelUnitLengthXValue = 1; | 236 kernelUnitLengthXValue = 1; |
| 237 kernelUnitLengthYValue = 1; | 237 kernelUnitLengthYValue = 1; |
| 238 } | 238 } |
| 239 if (kernelUnitLengthXValue <= 0 || kernelUnitLengthYValue <= 0) | 239 if (kernelUnitLengthXValue <= 0 || kernelUnitLengthYValue <= 0) |
| 240 return 0; | 240 return nullptr; |
| 241 | 241 |
| 242 float divisorValue = m_divisor->currentValue()->value(); | 242 float divisorValue = m_divisor->currentValue()->value(); |
| 243 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) | 243 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) |
| 244 return 0; | 244 return nullptr; |
| 245 if (!hasAttribute(SVGNames::divisorAttr)) { | 245 if (!hasAttribute(SVGNames::divisorAttr)) { |
| 246 for (size_t i = 0; i < kernelMatrixSize; ++i) | 246 for (size_t i = 0; i < kernelMatrixSize; ++i) |
| 247 divisorValue += kernelMatrix->at(i)->value(); | 247 divisorValue += kernelMatrix->at(i)->value(); |
| 248 if (!divisorValue) | 248 if (!divisorValue) |
| 249 divisorValue = 1; | 249 divisorValue = 1; |
| 250 } | 250 } |
| 251 | 251 |
| 252 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 252 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
| 253 IntSize(orderXValue, orderYValue), divisorValue, | 253 IntSize(orderXValue, orderYValue), divisorValue, |
| 254 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), | 254 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), |
| 255 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); | 255 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); |
| 256 effect->inputEffects().append(input1); | 256 effect->inputEffects().append(input1); |
| 257 return effect.release(); | 257 return effect.release(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace WebCore | 260 } // namespace WebCore |
| OLD | NEW |