| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 | 213 |
| 214 ASSERT_NOT_REACHED(); | 214 ASSERT_NOT_REACHED(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) | 217 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) |
| 218 { | 218 { |
| 219 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); | 219 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); |
| 220 if (attrName == SVGNames::edgeModeAttr) | 220 if (attrName == SVGNames::edgeModeAttr) |
| 221 return convolveMatrix->setEdgeMode(edgeMode()); | 221 return convolveMatrix->setEdgeMode(edgeModeCurrentValue()); |
| 222 if (attrName == SVGNames::divisorAttr) | 222 if (attrName == SVGNames::divisorAttr) |
| 223 return convolveMatrix->setDivisor(divisor()); | 223 return convolveMatrix->setDivisor(divisorCurrentValue()); |
| 224 if (attrName == SVGNames::biasAttr) | 224 if (attrName == SVGNames::biasAttr) |
| 225 return convolveMatrix->setBias(bias()); | 225 return convolveMatrix->setBias(biasCurrentValue()); |
| 226 if (attrName == SVGNames::targetXAttr) | 226 if (attrName == SVGNames::targetXAttr) |
| 227 return convolveMatrix->setTargetOffset(IntPoint(targetX(), targetY())); | 227 return convolveMatrix->setTargetOffset(IntPoint(targetXCurrentValue(), t
argetYCurrentValue())); |
| 228 if (attrName == SVGNames::targetYAttr) | 228 if (attrName == SVGNames::targetYAttr) |
| 229 return convolveMatrix->setTargetOffset(IntPoint(targetX(), targetY())); | 229 return convolveMatrix->setTargetOffset(IntPoint(targetXCurrentValue(), t
argetYCurrentValue())); |
| 230 if (attrName == SVGNames::kernelUnitLengthAttr) | 230 if (attrName == SVGNames::kernelUnitLengthAttr) |
| 231 return convolveMatrix->setKernelUnitLength(FloatPoint(kernelUnitLengthX()
, kernelUnitLengthY())); | 231 return convolveMatrix->setKernelUnitLength(FloatPoint(kernelUnitLengthXC
urrentValue(), kernelUnitLengthYCurrentValue())); |
| 232 if (attrName == SVGNames::preserveAlphaAttr) | 232 if (attrName == SVGNames::preserveAlphaAttr) |
| 233 return convolveMatrix->setPreserveAlpha(preserveAlpha()); | 233 return convolveMatrix->setPreserveAlpha(preserveAlphaCurrentValue()); |
| 234 | 234 |
| 235 ASSERT_NOT_REACHED(); | 235 ASSERT_NOT_REACHED(); |
| 236 return false; | 236 return false; |
| 237 } | 237 } |
| 238 | 238 |
| 239 void SVGFEConvolveMatrixElement::setOrder(float x, float y) | 239 void SVGFEConvolveMatrixElement::setOrder(float x, float y) |
| 240 { | 240 { |
| 241 setOrderXBaseValue(x); | 241 setOrderXBaseValue(x); |
| 242 setOrderYBaseValue(y); | 242 setOrderYBaseValue(y); |
| 243 invalidate(); | 243 invalidate(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 || attrName == SVGNames::kernelMatrixAttr) { | 275 || attrName == SVGNames::kernelMatrixAttr) { |
| 276 invalidate(); | 276 invalidate(); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 | 279 |
| 280 ASSERT_NOT_REACHED(); | 280 ASSERT_NOT_REACHED(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) | 283 PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* fil
terBuilder, Filter* filter) |
| 284 { | 284 { |
| 285 FilterEffect* input1 = filterBuilder->getEffectById(in1()); | 285 FilterEffect* input1 = filterBuilder->getEffectById(in1CurrentValue()); |
| 286 | 286 |
| 287 if (!input1) | 287 if (!input1) |
| 288 return 0; | 288 return 0; |
| 289 | 289 |
| 290 int orderXValue = orderX(); | 290 int orderXValue = orderXCurrentValue(); |
| 291 int orderYValue = orderY(); | 291 int orderYValue = orderYCurrentValue(); |
| 292 if (!hasAttribute(SVGNames::orderAttr)) { | 292 if (!hasAttribute(SVGNames::orderAttr)) { |
| 293 orderXValue = 3; | 293 orderXValue = 3; |
| 294 orderYValue = 3; | 294 orderYValue = 3; |
| 295 } | 295 } |
| 296 // Spec says order must be > 0. Bail if it is not. | 296 // Spec says order must be > 0. Bail if it is not. |
| 297 if (orderXValue < 1 || orderYValue < 1) | 297 if (orderXValue < 1 || orderYValue < 1) |
| 298 return 0; | 298 return 0; |
| 299 SVGNumberList& kernelMatrix = this->kernelMatrix(); | 299 SVGNumberList& kernelMatrix = this->kernelMatrixCurrentValue(); |
| 300 int kernelMatrixSize = kernelMatrix.size(); | 300 int kernelMatrixSize = kernelMatrix.size(); |
| 301 // The spec says this is a requirement, and should bail out if fails | 301 // The spec says this is a requirement, and should bail out if fails |
| 302 if (orderXValue * orderYValue != kernelMatrixSize) | 302 if (orderXValue * orderYValue != kernelMatrixSize) |
| 303 return 0; | 303 return 0; |
| 304 | 304 |
| 305 int targetXValue = targetX(); | 305 int targetXValue = targetXCurrentValue(); |
| 306 int targetYValue = targetY(); | 306 int targetYValue = targetYCurrentValue(); |
| 307 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) | 307 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) |
| 308 return 0; | 308 return 0; |
| 309 // The spec says the default value is: targetX = floor ( orderX / 2 )) | 309 // The spec says the default value is: targetX = floor ( orderX / 2 )) |
| 310 if (!hasAttribute(SVGNames::targetXAttr)) | 310 if (!hasAttribute(SVGNames::targetXAttr)) |
| 311 targetXValue = static_cast<int>(floorf(orderXValue / 2)); | 311 targetXValue = static_cast<int>(floorf(orderXValue / 2)); |
| 312 if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue
>= orderYValue)) | 312 if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue
>= orderYValue)) |
| 313 return 0; | 313 return 0; |
| 314 // The spec says the default value is: targetY = floor ( orderY / 2 )) | 314 // The spec says the default value is: targetY = floor ( orderY / 2 )) |
| 315 if (!hasAttribute(SVGNames::targetYAttr)) | 315 if (!hasAttribute(SVGNames::targetYAttr)) |
| 316 targetYValue = static_cast<int>(floorf(orderYValue / 2)); | 316 targetYValue = static_cast<int>(floorf(orderYValue / 2)); |
| 317 | 317 |
| 318 // Spec says default kernelUnitLength is 1.0, and a specified length cannot
be 0. | 318 // Spec says default kernelUnitLength is 1.0, and a specified length cannot
be 0. |
| 319 int kernelUnitLengthXValue = kernelUnitLengthX(); | 319 int kernelUnitLengthXValue = kernelUnitLengthXCurrentValue(); |
| 320 int kernelUnitLengthYValue = kernelUnitLengthY(); | 320 int kernelUnitLengthYValue = kernelUnitLengthYCurrentValue(); |
| 321 if (!hasAttribute(SVGNames::kernelUnitLengthAttr)) { | 321 if (!hasAttribute(SVGNames::kernelUnitLengthAttr)) { |
| 322 kernelUnitLengthXValue = 1; | 322 kernelUnitLengthXValue = 1; |
| 323 kernelUnitLengthYValue = 1; | 323 kernelUnitLengthYValue = 1; |
| 324 } | 324 } |
| 325 if (kernelUnitLengthXValue <= 0 || kernelUnitLengthYValue <= 0) | 325 if (kernelUnitLengthXValue <= 0 || kernelUnitLengthYValue <= 0) |
| 326 return 0; | 326 return 0; |
| 327 | 327 |
| 328 float divisorValue = divisor(); | 328 float divisorValue = divisorCurrentValue(); |
| 329 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) | 329 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) |
| 330 return 0; | 330 return 0; |
| 331 if (!hasAttribute(SVGNames::divisorAttr)) { | 331 if (!hasAttribute(SVGNames::divisorAttr)) { |
| 332 for (int i = 0; i < kernelMatrixSize; ++i) | 332 for (int i = 0; i < kernelMatrixSize; ++i) |
| 333 divisorValue += kernelMatrix.at(i); | 333 divisorValue += kernelMatrix.at(i); |
| 334 if (!divisorValue) | 334 if (!divisorValue) |
| 335 divisorValue = 1; | 335 divisorValue = 1; |
| 336 } | 336 } |
| 337 | 337 |
| 338 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 338 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
| 339 IntSize(orderXValue, orderYValue), divisorValue, | 339 IntSize(orderXValue, orderYValue), divisorValue, |
| 340 bias(), IntPoint(targetXValue, targetYValue), edgeMode(), | 340 biasCurrentValue(), IntPoint(targetXValue, targetYValue), ed
geModeCurrentValue(), |
| 341 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
preserveAlpha(), kernelMatrix); | 341 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
preserveAlphaCurrentValue(), kernelMatrix); |
| 342 effect->inputEffects().append(input1); | 342 effect->inputEffects().append(input1); |
| 343 return effect.release(); | 343 return effect.release(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace WebCore | 346 } // namespace WebCore |
| OLD | NEW |