| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 void SVGAnimatedOrder::setBaseValueAsString(const String& value, SVGParsingError
& parseError) | 62 void SVGAnimatedOrder::setBaseValueAsString(const String& value, SVGParsingError
& parseError) |
| 63 { | 63 { |
| 64 SVGAnimatedIntegerOptionalInteger::setBaseValueAsString(value, parseError); | 64 SVGAnimatedIntegerOptionalInteger::setBaseValueAsString(value, parseError); |
| 65 | 65 |
| 66 ASSERT(contextElement()); | 66 ASSERT(contextElement()); |
| 67 if (parseError == NoError && (firstInteger()->baseValue()->value() < 1 || se
condInteger()->baseValue()->value() < 1)) { | 67 if (parseError == NoError && (firstInteger()->baseValue()->value() < 1 || se
condInteger()->baseValue()->value() < 1)) { |
| 68 contextElement()->document().accessSVGExtensions().reportWarning( | 68 contextElement()->document().accessSVGExtensions().reportWarning( |
| 69 "feConvolveMatrix: problem parsing order=\"" + value | 69 "feConvolveMatrix: problem parsing order=\"" + value + "\"."); |
| 70 + "\". Filtered element will not be displayed."); | |
| 71 } | 70 } |
| 72 } | 71 } |
| 73 | 72 |
| 74 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) | 73 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) |
| 75 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) | 74 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) |
| 76 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) | 75 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) |
| 77 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) | 76 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) |
| 78 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) | 77 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
| 79 , m_edgeMode(SVGAnimatedEnumeration<EdgeModeType>::create(this, SVGNames::ed
geModeAttr, EDGEMODE_DUPLICATE)) | 78 , m_edgeMode(SVGAnimatedEnumeration<EdgeModeType>::create(this, SVGNames::ed
geModeAttr, EDGEMODE_DUPLICATE)) |
| 80 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) | 79 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 158 |
| 160 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilter
Builder* filterBuilder, Filter* filter) | 159 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilter
Builder* filterBuilder, Filter* filter) |
| 161 { | 160 { |
| 162 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); | 161 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr
entValue()->value())); |
| 163 | 162 |
| 164 if (!input1) | 163 if (!input1) |
| 165 return nullptr; | 164 return nullptr; |
| 166 | 165 |
| 167 int orderXValue = orderX()->currentValue()->value(); | 166 int orderXValue = orderX()->currentValue()->value(); |
| 168 int orderYValue = orderY()->currentValue()->value(); | 167 int orderYValue = orderY()->currentValue()->value(); |
| 169 if (!hasAttribute(SVGNames::orderAttr)) { | 168 if (!m_order->isSpecified()) { |
| 170 orderXValue = 3; | 169 orderXValue = 3; |
| 171 orderYValue = 3; | 170 orderYValue = 3; |
| 172 } | 171 } |
| 173 // Spec says order must be > 0. Bail if it is not. | |
| 174 if (orderXValue < 1 || orderYValue < 1) | |
| 175 return nullptr; | |
| 176 RefPtrWillBeRawPtr<SVGNumberList> kernelMatrix = this->m_kernelMatrix->curre
ntValue(); | |
| 177 size_t kernelMatrixSize = kernelMatrix->length(); | |
| 178 // The spec says this is a requirement, and should bail out if fails | |
| 179 if (orderXValue * orderYValue != static_cast<int>(kernelMatrixSize)) | |
| 180 return nullptr; | |
| 181 | 172 |
| 182 int targetXValue = m_targetX->currentValue()->value(); | 173 int targetXValue = m_targetX->currentValue()->value(); |
| 174 // The spec says the default value is: targetX = floor ( orderX / 2 )) |
| 175 if (!m_targetX->isSpecified()) |
| 176 targetXValue = static_cast<int>(floorf(orderXValue / 2)); |
| 177 |
| 183 int targetYValue = m_targetY->currentValue()->value(); | 178 int targetYValue = m_targetY->currentValue()->value(); |
| 184 if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue
>= orderXValue)) | |
| 185 return nullptr; | |
| 186 // The spec says the default value is: targetX = floor ( orderX / 2 )) | |
| 187 if (!hasAttribute(SVGNames::targetXAttr)) | |
| 188 targetXValue = static_cast<int>(floorf(orderXValue / 2)); | |
| 189 if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue
>= orderYValue)) | |
| 190 return nullptr; | |
| 191 // The spec says the default value is: targetY = floor ( orderY / 2 )) | 179 // The spec says the default value is: targetY = floor ( orderY / 2 )) |
| 192 if (!hasAttribute(SVGNames::targetYAttr)) | 180 if (!m_targetY->isSpecified()) |
| 193 targetYValue = static_cast<int>(floorf(orderYValue / 2)); | 181 targetYValue = static_cast<int>(floorf(orderYValue / 2)); |
| 194 | 182 |
| 195 float divisorValue = m_divisor->currentValue()->value(); | 183 float divisorValue = m_divisor->currentValue()->value(); |
| 196 if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) | 184 if (!m_divisor->isSpecified()) { |
| 197 return nullptr; | 185 RefPtrWillBeRawPtr<SVGNumberList> kernelMatrix = m_kernelMatrix->current
Value(); |
| 198 if (!hasAttribute(SVGNames::divisorAttr)) { | 186 size_t kernelMatrixSize = kernelMatrix->length(); |
| 199 for (size_t i = 0; i < kernelMatrixSize; ++i) | 187 for (size_t i = 0; i < kernelMatrixSize; ++i) |
| 200 divisorValue += kernelMatrix->at(i)->value(); | 188 divisorValue += kernelMatrix->at(i)->value(); |
| 201 if (!divisorValue) | 189 if (!divisorValue) |
| 202 divisorValue = 1; | 190 divisorValue = 1; |
| 203 } | 191 } |
| 204 | 192 |
| 205 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 193 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
| 206 IntSize(orderXValue, orderYValue), divisorValue, | 194 IntSize(orderXValue, orderYValue), divisorValue, |
| 207 m_bias->currentValue()->value(), IntPoint(targetXValue, targetYValue), m
_edgeMode->currentValue()->enumValue(), | 195 m_bias->currentValue()->value(), IntPoint(targetXValue, targetYValue), m
_edgeMode->currentValue()->enumValue(), |
| 208 m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()
->toFloatVector()); | 196 m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()
->toFloatVector()); |
| 209 effect->inputEffects().append(input1); | 197 effect->inputEffects().append(input1); |
| 210 return effect.release(); | 198 return effect.release(); |
| 211 } | 199 } |
| 212 | 200 |
| 213 } // namespace blink | 201 } // namespace blink |
| OLD | NEW |