OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); | 138 const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(ef fect); |
139 | 139 |
140 PropertySet properties = keyframeEffect.properties(); | 140 PropertySet properties = keyframeEffect.properties(); |
141 | 141 |
142 if (properties.isEmpty()) | 142 if (properties.isEmpty()) |
143 return false; | 143 return false; |
144 | 144 |
145 for (const auto& property : properties) { | 145 for (const auto& property : properties) { |
146 const PropertySpecificKeyframeVector& keyframes = keyframeEffect.getProp ertySpecificKeyframes(property); | 146 const PropertySpecificKeyframeVector& keyframes = keyframeEffect.getProp ertySpecificKeyframes(property); |
147 ASSERT(keyframes.size() >= 2); | 147 ASSERT(keyframes.size() >= 2); |
148 auto* lastKeyframe = keyframes.last().get(); | |
149 for (const auto& keyframe : keyframes) { | 148 for (const auto& keyframe : keyframes) { |
150 // FIXME: Determine candidacy based on the CSSValue instead of a sna pshot AnimatableValue. | 149 // FIXME: Determine candidacy based on the CSSValue instead of a sna pshot AnimatableValue. |
151 if (keyframe->composite() != AnimationEffect::CompositeReplace || !k eyframe->getAnimatableValue()) | 150 if (keyframe->composite() != AnimationEffect::CompositeReplace || !k eyframe->getAnimatableValue()) |
152 return false; | 151 return false; |
153 | 152 |
154 switch (property) { | 153 switch (property) { |
155 case CSSPropertyOpacity: | 154 case CSSPropertyOpacity: |
156 break; | 155 break; |
157 case CSSPropertyTransform: | 156 case CSSPropertyTransform: |
158 if (toAnimatableTransform(keyframe->getAnimatableValue().get())- >transformOperations().dependsOnBoxSize()) | 157 if (toAnimatableTransform(keyframe->getAnimatableValue().get())- >transformOperations().dependsOnBoxSize()) |
159 return false; | 158 return false; |
160 break; | 159 break; |
161 case CSSPropertyWebkitFilter: { | 160 case CSSPropertyWebkitFilter: { |
162 const FilterOperations& operations = toAnimatableFilterOperation s(keyframe->getAnimatableValue().get())->operations(); | 161 const FilterOperations& operations = toAnimatableFilterOperation s(keyframe->getAnimatableValue().get())->operations(); |
163 if (operations.hasFilterThatMovesPixels()) | 162 if (operations.hasFilterThatMovesPixels()) |
164 return false; | 163 return false; |
165 break; | 164 break; |
166 } | 165 } |
167 default: | 166 default: |
168 return false; | 167 return false; |
169 } | 168 } |
170 | |
171 // FIXME: Remove this check when crbug.com/229405 is resolved | |
172 if (keyframe != lastKeyframe && keyframe->easing().type() == TimingF unction::StepsFunction) | |
173 return false; | |
174 } | 169 } |
175 } | 170 } |
176 | 171 |
177 CompositorAnimationsImpl::CompositorTiming out; | 172 CompositorAnimationsImpl::CompositorTiming out; |
178 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, pl ayerPlaybackRate)) | 173 if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, pl ayerPlaybackRate)) |
179 return false; | 174 return false; |
180 | 175 |
181 if (timing.timingFunction->type() != TimingFunction::LinearFunction) { | 176 if (timing.timingFunction->type() != TimingFunction::LinearFunction) { |
182 // Checks the of size of KeyframeVector instead of PropertySpecificKeyfr ameVector. | 177 // Checks the of size of KeyframeVector instead of PropertySpecificKeyfr ameVector. |
183 const KeyframeVector& keyframes = keyframeEffect.getFrames(); | 178 const KeyframeVector& keyframes = keyframeEffect.getFrames(); |
184 if (keyframes.size() == 2 && keyframes.first()->easing().type() == Timin gFunction::LinearFunction && timing.timingFunction->type() != TimingFunction::St epsFunction) | 179 if (keyframes.size() == 2 && keyframes.first()->easing().type() == Timin gFunction::LinearFunction && timing.timingFunction->type() != TimingFunction::St epsFunction) |
185 return true; | 180 return true; |
186 | 181 |
182 if (timing.timingFunction->type() == TimingFunction::StepsFunction) | |
dstockwell
2014/12/19 02:00:55
I think this isn't quite right, as the comment bel
loyso (OOO)
2014/12/22 07:00:54
That wasn't right, indeed. Fixed.
| |
183 return true; | |
184 | |
187 // FIXME: Support non-linear timing functions in the compositor for | 185 // FIXME: Support non-linear timing functions in the compositor for |
188 // more than two keyframes and step timing functions in the compositor. | 186 // more than two keyframes and step timing functions in the compositor. |
189 return false; | 187 return false; |
190 } | 188 } |
191 | 189 |
192 return true; | 190 return true; |
193 } | 191 } |
194 | 192 |
195 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) | 193 bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element) |
196 { | 194 { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 ASSERT_NOT_REACHED(); | 321 ASSERT_NOT_REACHED(); |
324 return; | 322 return; |
325 } | 323 } |
326 | 324 |
327 curve.add(keyframe, easeType); | 325 curve.add(keyframe, easeType); |
328 } | 326 } |
329 return; | 327 return; |
330 } | 328 } |
331 | 329 |
332 case TimingFunction::StepsFunction: | 330 case TimingFunction::StepsFunction: |
333 default: | 331 const StepsTimingFunction* steps = toStepsTimingFunction(timingFunction) ; |
334 ASSERT_NOT_REACHED(); | 332 |
333 float stepsStartOffset; | |
334 switch (steps->stepAtPosition()) { | |
335 case StepsTimingFunction::Start: | |
336 stepsStartOffset = 1; | |
337 break; | |
338 case StepsTimingFunction::Middle: | |
339 stepsStartOffset = 0.5; | |
340 break; | |
341 case StepsTimingFunction::End: | |
342 stepsStartOffset = 0; | |
343 break; | |
344 default: | |
345 ASSERT_NOT_REACHED(); | |
346 return; | |
347 } | |
348 curve.add(keyframe, steps->numberOfSteps(), stepsStartOffset); | |
335 return; | 349 return; |
336 } | 350 } |
337 } | 351 } |
338 | 352 |
339 } // namespace anoymous | 353 } // namespace anoymous |
340 | 354 |
341 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing) | 355 void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve& curve, const PropertySpecificKeyframeVector& keyframes, const Timing& timing) |
342 { | 356 { |
343 auto* lastKeyframe = keyframes.last().get(); | 357 auto* lastKeyframe = keyframes.last().get(); |
344 for (const auto& keyframe : keyframes) { | 358 for (const auto& keyframe : keyframes) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 break; | 486 break; |
473 default: | 487 default: |
474 ASSERT_NOT_REACHED(); | 488 ASSERT_NOT_REACHED(); |
475 } | 489 } |
476 animations.append(animation.release()); | 490 animations.append(animation.release()); |
477 } | 491 } |
478 ASSERT(!animations.isEmpty()); | 492 ASSERT(!animations.isEmpty()); |
479 } | 493 } |
480 | 494 |
481 } // namespace blink | 495 } // namespace blink |
OLD | NEW |