Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.cpp

Issue 2124583002: Consider 'order' when updating feConvolveMatrix 'target*' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 visitor->trace(m_kernelUnitLength); 111 visitor->trace(m_kernelUnitLength);
112 visitor->trace(m_order); 112 visitor->trace(m_order);
113 visitor->trace(m_preserveAlpha); 113 visitor->trace(m_preserveAlpha);
114 visitor->trace(m_targetX); 114 visitor->trace(m_targetX);
115 visitor->trace(m_targetY); 115 visitor->trace(m_targetY);
116 SVGFilterPrimitiveStandardAttributes::trace(visitor); 116 SVGFilterPrimitiveStandardAttributes::trace(visitor);
117 } 117 }
118 118
119 DEFINE_NODE_FACTORY(SVGFEConvolveMatrixElement) 119 DEFINE_NODE_FACTORY(SVGFEConvolveMatrixElement)
120 120
121 IntSize SVGFEConvolveMatrixElement::matrixOrder() const
122 {
123 if (!m_order->isSpecified())
124 return IntSize(3, 3);
125 return IntSize(orderX()->currentValue()->value(), orderY()->currentValue()-> value());
126 }
127
128 IntPoint SVGFEConvolveMatrixElement::targetPoint() const
129 {
130 IntSize order = matrixOrder();
131 IntPoint target(m_targetX->currentValue()->value(), m_targetY->currentValue( )->value());
132 // The spec says the default value is: targetX = floor ( orderX / 2 ))
133 if (!m_targetX->isSpecified())
134 target.setX(order.width() / 2);
f(malita) 2016/07/05 15:20:12 I was worried here about negative half-value treat
fs 2016/07/05 15:29:43 We verify all the parameters down in FEConvolveMat
135 // The spec says the default value is: targetY = floor ( orderY / 2 ))
136 if (!m_targetY->isSpecified())
137 target.setY(order.height() / 2);
138 return target;
139 }
140
121 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) 141 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
122 { 142 {
123 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); 143 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect);
124 if (attrName == SVGNames::edgeModeAttr) 144 if (attrName == SVGNames::edgeModeAttr)
125 return convolveMatrix->setEdgeMode(m_edgeMode->currentValue()->enumValue ()); 145 return convolveMatrix->setEdgeMode(m_edgeMode->currentValue()->enumValue ());
126 if (attrName == SVGNames::divisorAttr) 146 if (attrName == SVGNames::divisorAttr)
127 return convolveMatrix->setDivisor(m_divisor->currentValue()->value()); 147 return convolveMatrix->setDivisor(m_divisor->currentValue()->value());
128 if (attrName == SVGNames::biasAttr) 148 if (attrName == SVGNames::biasAttr)
129 return convolveMatrix->setBias(m_bias->currentValue()->value()); 149 return convolveMatrix->setBias(m_bias->currentValue()->value());
130 if (attrName == SVGNames::targetXAttr) 150 if (attrName == SVGNames::targetXAttr || attrName == SVGNames::targetYAttr)
131 return convolveMatrix->setTargetOffset(IntPoint(m_targetX->currentValue( )->value(), m_targetY->currentValue()->value())); 151 return convolveMatrix->setTargetOffset(targetPoint());
132 if (attrName == SVGNames::targetYAttr)
133 return convolveMatrix->setTargetOffset(IntPoint(m_targetX->currentValue( )->value(), m_targetY->currentValue()->value()));
134 if (attrName == SVGNames::preserveAlphaAttr) 152 if (attrName == SVGNames::preserveAlphaAttr)
135 return convolveMatrix->setPreserveAlpha(m_preserveAlpha->currentValue()- >value()); 153 return convolveMatrix->setPreserveAlpha(m_preserveAlpha->currentValue()- >value());
136 154
137 ASSERT_NOT_REACHED(); 155 ASSERT_NOT_REACHED();
138 return false; 156 return false;
139 } 157 }
140 158
141 void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrNa me) 159 void SVGFEConvolveMatrixElement::svgAttributeChanged(const QualifiedName& attrNa me)
142 { 160 {
143 if (attrName == SVGNames::edgeModeAttr 161 if (attrName == SVGNames::edgeModeAttr
(...skipping 16 matching lines...) Expand all
160 } 178 }
161 179
162 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName); 180 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
163 } 181 }
164 182
165 FilterEffect* SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter) 183 FilterEffect* SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder, Filter* filter)
166 { 184 {
167 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value())); 185 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value()));
168 ASSERT(input1); 186 ASSERT(input1);
169 187
170 int orderXValue = orderX()->currentValue()->value();
171 int orderYValue = orderY()->currentValue()->value();
172 if (!m_order->isSpecified()) {
173 orderXValue = 3;
174 orderYValue = 3;
175 }
176
177 int targetXValue = m_targetX->currentValue()->value();
178 // The spec says the default value is: targetX = floor ( orderX / 2 ))
179 if (!m_targetX->isSpecified())
180 targetXValue = static_cast<int>(floorf(orderXValue / 2));
181
182 int targetYValue = m_targetY->currentValue()->value();
183 // The spec says the default value is: targetY = floor ( orderY / 2 ))
184 if (!m_targetY->isSpecified())
185 targetYValue = static_cast<int>(floorf(orderYValue / 2));
186
187 float divisorValue = m_divisor->currentValue()->value(); 188 float divisorValue = m_divisor->currentValue()->value();
188 if (!m_divisor->isSpecified()) { 189 if (!m_divisor->isSpecified()) {
189 SVGNumberList* kernelMatrix = m_kernelMatrix->currentValue(); 190 SVGNumberList* kernelMatrix = m_kernelMatrix->currentValue();
190 size_t kernelMatrixSize = kernelMatrix->length(); 191 size_t kernelMatrixSize = kernelMatrix->length();
191 for (size_t i = 0; i < kernelMatrixSize; ++i) 192 for (size_t i = 0; i < kernelMatrixSize; ++i)
192 divisorValue += kernelMatrix->at(i)->value(); 193 divisorValue += kernelMatrix->at(i)->value();
193 if (!divisorValue) 194 if (!divisorValue)
194 divisorValue = 1; 195 divisorValue = 1;
195 } 196 }
196 197
197 FilterEffect* effect = FEConvolveMatrix::create(filter, 198 FilterEffect* effect = FEConvolveMatrix::create(filter,
198 IntSize(orderXValue, orderYValue), divisorValue, 199 matrixOrder(), divisorValue,
199 m_bias->currentValue()->value(), IntPoint(targetXValue, targetYValue), m _edgeMode->currentValue()->enumValue(), 200 m_bias->currentValue()->value(), targetPoint(), m_edgeMode->currentValue ()->enumValue(),
200 m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue() ->toFloatVector()); 201 m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue() ->toFloatVector());
201 effect->inputEffects().append(input1); 202 effect->inputEffects().append(input1);
202 return effect; 203 return effect;
203 } 204 }
204 205
205 } // namespace blink 206 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGFEConvolveMatrixElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698