OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/animation/FilterInterpolationFunctions.h" | 5 #include "core/animation/FilterInterpolationFunctions.h" |
6 | 6 |
7 #include "core/animation/CSSLengthInterpolationType.h" | 7 #include "core/animation/LengthInterpolationFunctions.h" |
8 #include "core/animation/ShadowInterpolationFunctions.h" | 8 #include "core/animation/ShadowInterpolationFunctions.h" |
9 #include "core/css/CSSFunctionValue.h" | 9 #include "core/css/CSSFunctionValue.h" |
10 #include "core/css/CSSPrimitiveValue.h" | 10 #include "core/css/CSSPrimitiveValue.h" |
11 #include "core/css/resolver/FilterOperationResolver.h" | 11 #include "core/css/resolver/FilterOperationResolver.h" |
12 #include "core/css/resolver/StyleResolverState.h" | 12 #include "core/css/resolver/StyleResolverState.h" |
13 #include "core/style/ShadowData.h" | 13 #include "core/style/ShadowData.h" |
14 #include "platform/graphics/filters/FilterOperations.h" | 14 #include "platform/graphics/filters/FilterOperations.h" |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 case FilterOperation::HUE_ROTATE: { | 121 case FilterOperation::HUE_ROTATE: { |
122 double angle = defaultParameter(type); | 122 double angle = defaultParameter(type); |
123 if (filter.length() == 1) | 123 if (filter.length() == 1) |
124 angle = toCSSPrimitiveValue(filter.item(0)).computeDegrees(); | 124 angle = toCSSPrimitiveValue(filter.item(0)).computeDegrees(); |
125 result.interpolableValue = InterpolableNumber::create(angle); | 125 result.interpolableValue = InterpolableNumber::create(angle); |
126 break; | 126 break; |
127 } | 127 } |
128 | 128 |
129 case FilterOperation::BLUR: { | 129 case FilterOperation::BLUR: { |
130 if (filter.length() == 0) | 130 if (filter.length() == 0) |
131 result.interpolableValue = CSSLengthInterpolationType::createNeutral
InterpolableValue(); | 131 result.interpolableValue = LengthInterpolationFunctions::createNeutr
alInterpolableValue(); |
132 else | 132 else |
133 result = CSSLengthInterpolationType::maybeConvertCSSValue(filter.ite
m(0)); | 133 result = LengthInterpolationFunctions::maybeConvertCSSValue(filter.i
tem(0)); |
134 break; | 134 break; |
135 } | 135 } |
136 | 136 |
137 case FilterOperation::DROP_SHADOW: { | 137 case FilterOperation::DROP_SHADOW: { |
138 result = ShadowInterpolationFunctions::maybeConvertCSSValue(filter.item(
0)); | 138 result = ShadowInterpolationFunctions::maybeConvertCSSValue(filter.item(
0)); |
139 break; | 139 break; |
140 } | 140 } |
141 | 141 |
142 default: | 142 default: |
143 NOTREACHED(); | 143 NOTREACHED(); |
(...skipping 20 matching lines...) Expand all Loading... |
164 break; | 164 break; |
165 | 165 |
166 case FilterOperation::BRIGHTNESS: | 166 case FilterOperation::BRIGHTNESS: |
167 case FilterOperation::CONTRAST: | 167 case FilterOperation::CONTRAST: |
168 case FilterOperation::INVERT: | 168 case FilterOperation::INVERT: |
169 case FilterOperation::OPACITY: | 169 case FilterOperation::OPACITY: |
170 result.interpolableValue = InterpolableNumber::create(toBasicComponentTr
ansferFilterOperation(filter).amount()); | 170 result.interpolableValue = InterpolableNumber::create(toBasicComponentTr
ansferFilterOperation(filter).amount()); |
171 break; | 171 break; |
172 | 172 |
173 case FilterOperation::BLUR: | 173 case FilterOperation::BLUR: |
174 result = CSSLengthInterpolationType::maybeConvertLength(toBlurFilterOper
ation(filter).stdDeviation(), zoom); | 174 result = LengthInterpolationFunctions::maybeConvertLength(toBlurFilterOp
eration(filter).stdDeviation(), zoom); |
175 break; | 175 break; |
176 | 176 |
177 case FilterOperation::DROP_SHADOW: { | 177 case FilterOperation::DROP_SHADOW: { |
178 const DropShadowFilterOperation& blurFilter = toDropShadowFilterOperatio
n(filter); | 178 const DropShadowFilterOperation& blurFilter = toDropShadowFilterOperatio
n(filter); |
179 ShadowData shadowData(blurFilter.location(), blurFilter.stdDeviation(),
0, Normal, blurFilter.getColor()); | 179 ShadowData shadowData(blurFilter.location(), blurFilter.stdDeviation(),
0, Normal, blurFilter.getColor()); |
180 result = ShadowInterpolationFunctions::convertShadowData(shadowData, zoo
m); | 180 result = ShadowInterpolationFunctions::convertShadowData(shadowData, zoo
m); |
181 break; | 181 break; |
182 } | 182 } |
183 | 183 |
184 case FilterOperation::REFERENCE: | 184 case FilterOperation::REFERENCE: |
(...skipping 20 matching lines...) Expand all Loading... |
205 case FilterOperation::HUE_ROTATE: | 205 case FilterOperation::HUE_ROTATE: |
206 return InterpolableNumber::create(0); | 206 return InterpolableNumber::create(0); |
207 | 207 |
208 case FilterOperation::BRIGHTNESS: | 208 case FilterOperation::BRIGHTNESS: |
209 case FilterOperation::CONTRAST: | 209 case FilterOperation::CONTRAST: |
210 case FilterOperation::OPACITY: | 210 case FilterOperation::OPACITY: |
211 case FilterOperation::SATURATE: | 211 case FilterOperation::SATURATE: |
212 return InterpolableNumber::create(1); | 212 return InterpolableNumber::create(1); |
213 | 213 |
214 case FilterOperation::BLUR: | 214 case FilterOperation::BLUR: |
215 return CSSLengthInterpolationType::createNeutralInterpolableValue(); | 215 return LengthInterpolationFunctions::createNeutralInterpolableValue(); |
216 | 216 |
217 case FilterOperation::DROP_SHADOW: | 217 case FilterOperation::DROP_SHADOW: |
218 return ShadowInterpolationFunctions::createNeutralInterpolableValue(); | 218 return ShadowInterpolationFunctions::createNeutralInterpolableValue(); |
219 | 219 |
220 default: | 220 default: |
221 NOTREACHED(); | 221 NOTREACHED(); |
222 return nullptr; | 222 return nullptr; |
223 } | 223 } |
224 } | 224 } |
225 | 225 |
(...skipping 18 matching lines...) Expand all Loading... |
244 | 244 |
245 case FilterOperation::BRIGHTNESS: | 245 case FilterOperation::BRIGHTNESS: |
246 case FilterOperation::CONTRAST: | 246 case FilterOperation::CONTRAST: |
247 case FilterOperation::INVERT: | 247 case FilterOperation::INVERT: |
248 case FilterOperation::OPACITY: { | 248 case FilterOperation::OPACITY: { |
249 double value = clampParameter(toInterpolableNumber(interpolableValue).va
lue(), type); | 249 double value = clampParameter(toInterpolableNumber(interpolableValue).va
lue(), type); |
250 return BasicComponentTransferFilterOperation::create(value, type); | 250 return BasicComponentTransferFilterOperation::create(value, type); |
251 } | 251 } |
252 | 252 |
253 case FilterOperation::BLUR: { | 253 case FilterOperation::BLUR: { |
254 Length stdDeviation = CSSLengthInterpolationType::createLength(interpola
bleValue, nonInterpolableValue.typeNonInterpolableValue(), state.cssToLengthConv
ersionData(), ValueRangeNonNegative); | 254 Length stdDeviation = LengthInterpolationFunctions::createLength(interpo
lableValue, nonInterpolableValue.typeNonInterpolableValue(), state.cssToLengthCo
nversionData(), ValueRangeNonNegative); |
255 return BlurFilterOperation::create(stdDeviation); | 255 return BlurFilterOperation::create(stdDeviation); |
256 } | 256 } |
257 | 257 |
258 case FilterOperation::DROP_SHADOW: { | 258 case FilterOperation::DROP_SHADOW: { |
259 ShadowData shadowData = ShadowInterpolationFunctions::createShadowData(i
nterpolableValue, nonInterpolableValue.typeNonInterpolableValue(), state); | 259 ShadowData shadowData = ShadowInterpolationFunctions::createShadowData(i
nterpolableValue, nonInterpolableValue.typeNonInterpolableValue(), state); |
260 Color color = shadowData.color().isCurrentColor() ? Color::black : shado
wData.color().getColor(); | 260 Color color = shadowData.color().isCurrentColor() ? Color::black : shado
wData.color().getColor(); |
261 return DropShadowFilterOperation::create(IntPoint(shadowData.x(), shadow
Data.y()), shadowData.blur(), color); | 261 return DropShadowFilterOperation::create(IntPoint(shadowData.x(), shadow
Data.y()), shadowData.blur(), color); |
262 } | 262 } |
263 | 263 |
264 default: | 264 default: |
265 NOTREACHED(); | 265 NOTREACHED(); |
266 return nullptr; | 266 return nullptr; |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 } // namespace blink | 270 } // namespace blink |
OLD | NEW |