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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "core/animation/CompositorAnimations.h" | 33 #include "core/animation/CompositorAnimations.h" |
34 | 34 |
35 #include "core/animation/Animation.h" | 35 #include "core/animation/Animation.h" |
36 #include "core/animation/AnimationPlayer.h" | |
37 #include "core/animation/AnimationTimeline.h" | 36 #include "core/animation/AnimationTimeline.h" |
38 #include "core/animation/ElementAnimations.h" | |
39 #include "core/animation/CompositorAnimationsImpl.h" | 37 #include "core/animation/CompositorAnimationsImpl.h" |
40 #include "core/animation/CompositorAnimationsTestHelper.h" | 38 #include "core/animation/CompositorAnimationsTestHelper.h" |
| 39 #include "core/animation/ElementAnimations.h" |
| 40 #include "core/animation/KeyframeEffect.h" |
41 #include "core/animation/animatable/AnimatableDouble.h" | 41 #include "core/animation/animatable/AnimatableDouble.h" |
42 #include "core/animation/animatable/AnimatableFilterOperations.h" | 42 #include "core/animation/animatable/AnimatableFilterOperations.h" |
43 #include "core/animation/animatable/AnimatableTransform.h" | 43 #include "core/animation/animatable/AnimatableTransform.h" |
44 #include "core/animation/animatable/AnimatableValueTestHelper.h" | 44 #include "core/animation/animatable/AnimatableValueTestHelper.h" |
45 #include "core/dom/Document.h" | 45 #include "core/dom/Document.h" |
46 #include "core/layout/LayoutObject.h" | 46 #include "core/layout/LayoutObject.h" |
47 #include "platform/geometry/FloatBox.h" | 47 #include "platform/geometry/FloatBox.h" |
48 #include "platform/geometry/IntSize.h" | 48 #include "platform/geometry/IntSize.h" |
49 #include "platform/graphics/filters/FilterOperations.h" | 49 #include "platform/graphics/filters/FilterOperations.h" |
50 #include "platform/transforms/TransformOperations.h" | 50 #include "platform/transforms/TransformOperations.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 m_timeline = AnimationTimeline::create(m_document.get()); | 111 m_timeline = AnimationTimeline::create(m_document.get()); |
112 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); | 112 m_element = m_document->createElement("test", ASSERT_NO_EXCEPTION); |
113 } | 113 } |
114 | 114 |
115 public: | 115 public: |
116 | 116 |
117 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) | 117 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) |
118 { | 118 { |
119 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1
); | 119 return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1
); |
120 } | 120 } |
121 bool isCandidateForAnimationOnCompositor(const Timing& timing, const Animati
onEffect& effect) | 121 bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectM
odel& effect) |
122 { | 122 { |
123 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, *m_element.get(), nullptr, effect, 1); | 123 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, *m_element.get(), nullptr, effect, 1); |
124 } | 124 } |
125 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations) | 125 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations) |
126 { | 126 { |
127 return getAnimationOnCompositor(timing, effect, animations, 1); | 127 return getAnimationOnCompositor(timing, effect, animations, 1); |
128 } | 128 } |
129 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations, double playerP
laybackRate) | 129 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations, double playerP
laybackRate) |
130 { | 130 { |
131 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std
::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate
); | 131 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std
::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate
); |
132 } | 132 } |
133 bool getAnimationBounds(FloatBox& boundingBox, const AnimationEffect& effect
, double minValue, double maxValue) | 133 bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, do
uble minValue, double maxValue) |
134 { | 134 { |
135 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); | 135 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); |
136 } | 136 } |
137 | 137 |
138 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) | 138 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) |
139 { | 139 { |
140 EXPECT_EQ(frame->offset(), 0); | 140 EXPECT_EQ(frame->offset(), 0); |
141 AnimatableValueKeyframeVector frames; | 141 AnimatableValueKeyframeVector frames; |
142 RefPtrWillBeRawPtr<Keyframe> second = frame->cloneWithOffset(1); | 142 RefPtrWillBeRawPtr<Keyframe> second = frame->cloneWithOffset(1); |
143 | 143 |
(...skipping 16 matching lines...) Expand all Loading... |
160 timing.direction = Timing::PlaybackDirectionNormal; | 160 timing.direction = Timing::PlaybackDirectionNormal; |
161 ASSERT(m_linearTimingFunction); | 161 ASSERT(m_linearTimingFunction); |
162 timing.timingFunction = m_linearTimingFunction; | 162 timing.timingFunction = m_linearTimingFunction; |
163 return timing; | 163 return timing; |
164 } | 164 } |
165 | 165 |
166 PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createReplaceOpKeyframe(CSSP
ropertyID id, AnimatableValue* value, double offset = 0) | 166 PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createReplaceOpKeyframe(CSSP
ropertyID id, AnimatableValue* value, double offset = 0) |
167 { | 167 { |
168 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe
yframe::create(); | 168 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe
yframe::create(); |
169 keyframe->setPropertyValue(id, value); | 169 keyframe->setPropertyValue(id, value); |
170 keyframe->setComposite(AnimationEffect::CompositeReplace); | 170 keyframe->setComposite(EffectModel::CompositeReplace); |
171 keyframe->setOffset(offset); | 171 keyframe->setOffset(offset); |
172 keyframe->setEasing(LinearTimingFunction::shared()); | 172 keyframe->setEasing(LinearTimingFunction::shared()); |
173 return keyframe; | 173 return keyframe; |
174 } | 174 } |
175 | 175 |
176 PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createDefaultKeyframe(CSSPro
pertyID id, AnimationEffect::CompositeOperation op, double offset = 0) | 176 PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createDefaultKeyframe(CSSPro
pertyID id, EffectModel::CompositeOperation op, double offset = 0) |
177 { | 177 { |
178 RefPtrWillBeRawPtr<AnimatableValue> value = nullptr; | 178 RefPtrWillBeRawPtr<AnimatableValue> value = nullptr; |
179 if (id == CSSPropertyTransform) | 179 if (id == CSSPropertyTransform) |
180 value = AnimatableTransform::create(TransformOperations()); | 180 value = AnimatableTransform::create(TransformOperations()); |
181 else | 181 else |
182 value = AnimatableDouble::create(10.0); | 182 value = AnimatableDouble::create(10.0); |
183 | 183 |
184 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = createReplaceOpKe
yframe(id, value.get(), offset); | 184 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = createReplaceOpKe
yframe(id, value.get(), offset); |
185 keyframe->setComposite(op); | 185 keyframe->setComposite(op); |
186 return keyframe; | 186 return keyframe; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 : LayoutObject(node) | 274 : LayoutObject(node) |
275 { | 275 { |
276 } | 276 } |
277 }; | 277 }; |
278 | 278 |
279 // ----------------------------------------------------------------------- | 279 // ----------------------------------------------------------------------- |
280 // ----------------------------------------------------------------------- | 280 // ----------------------------------------------------------------------- |
281 | 281 |
282 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) | 282 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameMultipleCSSProperties) |
283 { | 283 { |
284 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDef
aultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace); | 284 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDef
aultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace); |
285 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations()).get()); | 285 keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTrans
form::create(TransformOperations()).get()); |
286 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); | 286 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); |
287 | 287 |
288 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDe
faultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace); | 288 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDe
faultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace); |
289 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); | 289 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); |
290 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMu
ltipleID.get())); | 290 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMu
ltipleID.get())); |
291 } | 291 } |
292 | 292 |
293 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) | 293 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) |
294 { | 294 { |
295 TransformOperations ops; | 295 TransformOperations ops; |
296 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(2, Fixed), TransformOperation::TranslateX)); | 296 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(2, Fixed), TransformOperation::TranslateX)); |
297 RefPtrWillBeRawPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops).get()); | 297 RefPtrWillBeRawPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops).get()); |
298 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.g
et())); | 298 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.g
et())); |
299 | 299 |
300 ops.operations().append(TranslateTransformOperation::create(Length(50, Perce
nt), Length(2, Fixed), TransformOperation::TranslateX)); | 300 ops.operations().append(TranslateTransformOperation::create(Length(50, Perce
nt), Length(2, Fixed), TransformOperation::TranslateX)); |
301 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKey
frame(CSSPropertyTransform, AnimatableTransform::create(ops).get()); | 301 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKey
frame(CSSPropertyTransform, AnimatableTransform::create(ops).get()); |
302 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.g
et())); | 302 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.g
et())); |
303 | 303 |
304 TransformOperations ops2; | 304 TransformOperations ops2; |
305 Length calcLength = Length(100, Percent).blend(Length(100, Fixed), 0.5, Valu
eRangeAll); | 305 Length calcLength = Length(100, Percent).blend(Length(100, Fixed), 0.5, Valu
eRangeAll); |
306 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, Fixed), TransformOperation::TranslateX)); | 306 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, Fixed), TransformOperation::TranslateX)); |
307 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops2).get()); | 307 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops2).get()); |
308 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.
get())); | 308 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.
get())); |
309 } | 309 } |
310 | 310 |
311 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) | 311 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) |
312 { | 312 { |
313 AnimatableValueKeyframeVector framesSame; | 313 AnimatableValueKeyframeVector framesSame; |
314 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0).get()); | 314 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Com
positeReplace, 0.0).get()); |
315 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0).get()); | 315 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Com
positeReplace, 1.0).get()); |
316 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKe
yframeEffectModel::create(framesSame).get())); | 316 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKe
yframeEffectModel::create(framesSame).get())); |
317 | 317 |
318 AnimatableValueKeyframeVector framesMixed; | 318 AnimatableValueKeyframeVector framesMixed; |
319 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect
::CompositeReplace, 0.0).get()); | 319 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Co
mpositeReplace, 0.0).get()); |
320 framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, AnimationEffe
ct::CompositeReplace, 1.0).get()); | 320 framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, EffectModel::
CompositeReplace, 1.0).get()); |
321 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixed).get())); | 321 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixed).get())); |
322 } | 322 } |
323 | 323 |
324 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModel) | 324 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModel) |
325 { | 325 { |
326 AnimatableValueKeyframeVector framesSame; | 326 AnimatableValueKeyframeVector framesSame; |
327 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 0.0).get()); | 327 framesSame.append(createDefaultKeyframe(CSSPropertyColor, EffectModel::Compo
siteReplace, 0.0).get()); |
328 framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::C
ompositeReplace, 1.0).get()); | 328 framesSame.append(createDefaultKeyframe(CSSPropertyColor, EffectModel::Compo
siteReplace, 1.0).get()); |
329 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesSame).get())); | 329 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesSame).get())); |
330 | 330 |
331 AnimatableValueKeyframeVector framesMixedProperties; | 331 AnimatableValueKeyframeVector framesMixedProperties; |
332 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, Anima
tionEffect::CompositeReplace, 0.0).get()); | 332 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, Effec
tModel::CompositeReplace, 0.0).get()); |
333 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, Animati
onEffect::CompositeReplace, 1.0).get()); | 333 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, EffectM
odel::CompositeReplace, 1.0).get()); |
334 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixedProperties).get())); | 334 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixedProperties).get())); |
335 } | 335 } |
336 | 336 |
337 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) | 337 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) |
338 { | 338 { |
339 Vector<TransformOperations> transformVector; | 339 Vector<TransformOperations> transformVector; |
340 transformVector.append(TransformOperations()); | 340 transformVector.append(TransformOperations()); |
341 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(0, Fixed), Length(0, Fixed), 0.0, TransformOperation::Translate3D)); | 341 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(0, Fixed), Length(0, Fixed), 0.0, TransformOperation::Translate3D)); |
342 transformVector.append(TransformOperations()); | 342 transformVector.append(TransformOperations()); |
343 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(200, Fixed), Length(200, Fixed), 0.0, TransformOperation::Translate3D)
); | 343 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(200, Fixed), Length(200, Fixed), 0.0, TransformOperation::Translate3D)
); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); | 600 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); |
601 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector5); | 601 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector5); |
602 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); | 602 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
603 } | 603 } |
604 | 604 |
605 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) | 605 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) |
606 { | 606 { |
607 Timing linearTiming(createCompositableTiming()); | 607 Timing linearTiming(createCompositableTiming()); |
608 | 608 |
609 AnimatableValueKeyframeVector basicFramesVector; | 609 AnimatableValueKeyframeVector basicFramesVector; |
610 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation
Effect::CompositeReplace, 0.0).get()); | 610 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectMod
el::CompositeReplace, 0.0).get()); |
611 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animation
Effect::CompositeReplace, 1.0).get()); | 611 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectMod
el::CompositeReplace, 1.0).get()); |
612 | 612 |
613 AnimatableValueKeyframeVector nonBasicFramesVector; | 613 AnimatableValueKeyframeVector nonBasicFramesVector; |
614 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 0.0).get()); | 614 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Effect
Model::CompositeReplace, 0.0).get()); |
615 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 0.5).get()); | 615 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Effect
Model::CompositeReplace, 0.5).get()); |
616 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Animat
ionEffect::CompositeReplace, 1.0).get()); | 616 nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, Effect
Model::CompositeReplace, 1.0).get()); |
617 | 617 |
618 basicFramesVector[0]->setEasing(m_linearTimingFunction.get()); | 618 basicFramesVector[0]->setEasing(m_linearTimingFunction.get()); |
619 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> basicFrames = Animata
bleValueKeyframeEffectModel::create(basicFramesVector).get(); | 619 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> basicFrames = Animata
bleValueKeyframeEffectModel::create(basicFramesVector).get(); |
620 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames.g
et())); | 620 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames.g
et())); |
621 | 621 |
622 basicFramesVector[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::EaseIn)); | 622 basicFramesVector[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezie
rTimingFunction::EaseIn)); |
623 basicFrames = AnimatableValueKeyframeEffectModel::create(basicFramesVector).
get(); | 623 basicFrames = AnimatableValueKeyframeEffectModel::create(basicFramesVector).
get(); |
624 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames.g
et())); | 624 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *basicFrames.g
et())); |
625 | 625 |
626 nonBasicFramesVector[0]->setEasing(m_linearTimingFunction.get()); | 626 nonBasicFramesVector[0]->setEasing(m_linearTimingFunction.get()); |
627 nonBasicFramesVector[1]->setEasing(CubicBezierTimingFunction::preset(CubicBe
zierTimingFunction::EaseIn)); | 627 nonBasicFramesVector[1]->setEasing(CubicBezierTimingFunction::preset(CubicBe
zierTimingFunction::EaseIn)); |
628 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> nonBasicFrames = Anim
atableValueKeyframeEffectModel::create(nonBasicFramesVector).get(); | 628 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> nonBasicFrames = Anim
atableValueKeyframeEffectModel::create(nonBasicFramesVector).get(); |
629 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *nonBasicFrame
s.get())); | 629 EXPECT_TRUE(isCandidateForAnimationOnCompositor(linearTiming, *nonBasicFrame
s.get())); |
630 } | 630 } |
631 | 631 |
632 // ----------------------------------------------------------------------- | 632 // ----------------------------------------------------------------------- |
633 // ----------------------------------------------------------------------- | 633 // ----------------------------------------------------------------------- |
634 | 634 |
635 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) | 635 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation) |
636 { | 636 { |
637 // Animation to convert | 637 // KeyframeEffect to convert |
638 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 638 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
639 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 639 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
640 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 640 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
641 // -- | 641 // -- |
642 | 642 |
643 WebCompositorSupportMock mockCompositor; | 643 WebCompositorSupportMock mockCompositor; |
644 | 644 |
645 // Curve is created | 645 // Curve is created |
646 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 646 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
647 ExpectationSet usesMockCurve; | 647 ExpectationSet usesMockCurve; |
(...skipping 25 matching lines...) Expand all Loading... |
673 // Go! | 673 // Go! |
674 setCompositorForTesting(mockCompositor); | 674 setCompositorForTesting(mockCompositor); |
675 Vector<OwnPtr<WebCompositorAnimation>> result; | 675 Vector<OwnPtr<WebCompositorAnimation>> result; |
676 getAnimationOnCompositor(m_timing, *effect.get(), result); | 676 getAnimationOnCompositor(m_timing, *effect.get(), result); |
677 EXPECT_EQ(1U, result.size()); | 677 EXPECT_EQ(1U, result.size()); |
678 result[0].clear(); | 678 result[0].clear(); |
679 } | 679 } |
680 | 680 |
681 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) | 681 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
682 { | 682 { |
683 // Animation to convert | 683 // KeyframeEffect to convert |
684 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 684 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
685 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 685 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
686 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 686 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
687 | 687 |
688 m_timing.iterationDuration = 10.0; | 688 m_timing.iterationDuration = 10.0; |
689 // -- | 689 // -- |
690 | 690 |
691 WebCompositorSupportMock mockCompositor; | 691 WebCompositorSupportMock mockCompositor; |
692 | 692 |
693 // Curve is created | 693 // Curve is created |
(...skipping 27 matching lines...) Expand all Loading... |
721 // Go! | 721 // Go! |
722 setCompositorForTesting(mockCompositor); | 722 setCompositorForTesting(mockCompositor); |
723 Vector<OwnPtr<WebCompositorAnimation>> result; | 723 Vector<OwnPtr<WebCompositorAnimation>> result; |
724 getAnimationOnCompositor(m_timing, *effect.get(), result); | 724 getAnimationOnCompositor(m_timing, *effect.get(), result); |
725 EXPECT_EQ(1U, result.size()); | 725 EXPECT_EQ(1U, result.size()); |
726 result[0].clear(); | 726 result[0].clear(); |
727 } | 727 } |
728 | 728 |
729 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) | 729 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) |
730 { | 730 { |
731 // Animation to convert | 731 // KeyframeEffect to convert |
732 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 732 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
733 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 733 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
734 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), | 734 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), |
735 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), | 735 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), |
736 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 736 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
737 | 737 |
738 m_timing.iterationCount = 5; | 738 m_timing.iterationCount = 5; |
739 m_timing.direction = Timing::PlaybackDirectionAlternate; | 739 m_timing.direction = Timing::PlaybackDirectionAlternate; |
740 m_timing.playbackRate = 2.0; | 740 m_timing.playbackRate = 2.0; |
741 // -- | 741 // -- |
742 | 742 |
743 WebCompositorSupportMock mockCompositor; | 743 WebCompositorSupportMock mockCompositor; |
744 | 744 |
745 // Curve is created | 745 // Curve is created |
746 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); | 746 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
747 ExpectationSet usesMockCurve; | 747 ExpectationSet usesMockCurve; |
748 | 748 |
749 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 749 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
750 .WillOnce(Return(mockCurvePtr)); | 750 .WillOnce(Return(mockCurvePtr)); |
751 | 751 |
752 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 752 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
753 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.25, -1.0)
, WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 753 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.25, -1.0)
, WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
754 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 754 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
755 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; | 755 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; |
756 | 756 |
757 // Animation is created | 757 // KeyframeEffect is created |
758 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 758 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
759 ExpectationSet usesMockAnimation; | 759 ExpectationSet usesMockAnimation; |
760 | 760 |
761 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 761 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) |
762 .WillOnce(Return(mockAnimationPtr)); | 762 .WillOnce(Return(mockAnimationPtr)); |
763 | 763 |
764 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 764 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
765 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 765 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
766 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternate)); | 766 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternate)); |
767 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); | 767 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(2.0)); |
768 | 768 |
769 EXPECT_CALL(*mockAnimationPtr, delete_()) | 769 EXPECT_CALL(*mockAnimationPtr, delete_()) |
770 .Times(1) | 770 .Times(1) |
771 .After(usesMockAnimation); | 771 .After(usesMockAnimation); |
772 EXPECT_CALL(*mockCurvePtr, delete_()) | 772 EXPECT_CALL(*mockCurvePtr, delete_()) |
773 .Times(1) | 773 .Times(1) |
774 .After(usesMockCurve); | 774 .After(usesMockCurve); |
775 | 775 |
776 // Go! | 776 // Go! |
777 setCompositorForTesting(mockCompositor); | 777 setCompositorForTesting(mockCompositor); |
778 Vector<OwnPtr<WebCompositorAnimation>> result; | 778 Vector<OwnPtr<WebCompositorAnimation>> result; |
779 getAnimationOnCompositor(m_timing, *effect.get(), result); | 779 getAnimationOnCompositor(m_timing, *effect.get(), result); |
780 EXPECT_EQ(1U, result.size()); | 780 EXPECT_EQ(1U, result.size()); |
781 result[0].clear(); | 781 result[0].clear(); |
782 } | 782 } |
783 | 783 |
784 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) | 784 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) |
785 { | 785 { |
786 // Animation to convert | 786 // KeyframeEffect to convert |
787 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 787 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
788 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 788 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
789 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 789 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
790 | 790 |
791 m_timing.iterationCount = 5.0; | 791 m_timing.iterationCount = 5.0; |
792 m_timing.iterationDuration = 1.75; | 792 m_timing.iterationDuration = 1.75; |
793 m_timing.startDelay = 3.25; | 793 m_timing.startDelay = 3.25; |
794 // -- | 794 // -- |
795 | 795 |
796 WebCompositorSupportMock mockCompositor; | 796 WebCompositorSupportMock mockCompositor; |
(...skipping 29 matching lines...) Expand all Loading... |
826 // Go! | 826 // Go! |
827 setCompositorForTesting(mockCompositor); | 827 setCompositorForTesting(mockCompositor); |
828 Vector<OwnPtr<WebCompositorAnimation>> result; | 828 Vector<OwnPtr<WebCompositorAnimation>> result; |
829 getAnimationOnCompositor(m_timing, *effect.get(), result); | 829 getAnimationOnCompositor(m_timing, *effect.get(), result); |
830 EXPECT_EQ(1U, result.size()); | 830 EXPECT_EQ(1U, result.size()); |
831 result[0].clear(); | 831 result[0].clear(); |
832 } | 832 } |
833 | 833 |
834 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) | 834 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) |
835 { | 835 { |
836 // Animation to convert | 836 // KeyframeEffect to convert |
837 AnimatableValueKeyframeVector frames; | 837 AnimatableValueKeyframeVector frames; |
838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); |
839 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 839 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); |
840 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 840 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); |
841 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 841 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); |
842 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); | 842 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); |
843 frames[1]->setEasing(m_linearTimingFunction.get()); | 843 frames[1]->setEasing(m_linearTimingFunction.get()); |
844 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); | 844 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); |
845 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); | 845 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); |
846 | 846 |
(...skipping 10 matching lines...) Expand all Loading... |
857 ExpectationSet usesMockCurve; | 857 ExpectationSet usesMockCurve; |
858 | 858 |
859 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 859 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
860 .WillOnce(Return(mockCurvePtr)); | 860 .WillOnce(Return(mockCurvePtr)); |
861 | 861 |
862 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeEase)); | 862 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeEase)); |
863 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, -1.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); | 863 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, -1.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
864 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 20.0),
1.0, 2.0, 3.0, 4.0)); | 864 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 20.0),
1.0, 2.0, 3.0, 4.0)); |
865 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(2.0, 5.0)))
; | 865 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(2.0, 5.0)))
; |
866 | 866 |
867 // Animation is created | 867 // KeyframeEffect is created |
868 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); | 868 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
869 ExpectationSet usesMockAnimation; | 869 ExpectationSet usesMockAnimation; |
870 | 870 |
871 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) | 871 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) |
872 .WillOnce(Return(mockAnimationPtr)); | 872 .WillOnce(Return(mockAnimationPtr)); |
873 | 873 |
874 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 874 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
875 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 875 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
876 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternate)); | 876 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(WebComposit
orAnimation::DirectionAlternate)); |
877 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); | 877 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
(...skipping 10 matching lines...) Expand all Loading... |
888 Vector<OwnPtr<WebCompositorAnimation>> result; | 888 Vector<OwnPtr<WebCompositorAnimation>> result; |
889 getAnimationOnCompositor(m_timing, *effect.get(), result); | 889 getAnimationOnCompositor(m_timing, *effect.get(), result); |
890 EXPECT_EQ(1U, result.size()); | 890 EXPECT_EQ(1U, result.size()); |
891 result[0].clear(); | 891 result[0].clear(); |
892 } | 892 } |
893 | 893 |
894 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) | 894 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
895 { | 895 { |
896 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); | 896 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); |
897 | 897 |
898 // Animation to convert | 898 // KeyframeEffect to convert |
899 AnimatableValueKeyframeVector frames; | 899 AnimatableValueKeyframeVector frames; |
900 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 900 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); |
901 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 901 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); |
902 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 902 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); |
903 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 903 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); |
904 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); | 904 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); |
905 frames[1]->setEasing(m_linearTimingFunction.get()); | 905 frames[1]->setEasing(m_linearTimingFunction.get()); |
906 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); | 906 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); |
907 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); | 907 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); |
908 | 908 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 // Go! | 947 // Go! |
948 setCompositorForTesting(mockCompositor); | 948 setCompositorForTesting(mockCompositor); |
949 Vector<OwnPtr<WebCompositorAnimation>> result; | 949 Vector<OwnPtr<WebCompositorAnimation>> result; |
950 getAnimationOnCompositor(m_timing, *effect.get(), result); | 950 getAnimationOnCompositor(m_timing, *effect.get(), result); |
951 EXPECT_EQ(1U, result.size()); | 951 EXPECT_EQ(1U, result.size()); |
952 result[0].clear(); | 952 result[0].clear(); |
953 } | 953 } |
954 | 954 |
955 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) | 955 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) |
956 { | 956 { |
957 // Animation to convert | 957 // KeyframeEffect to convert |
958 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 958 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
959 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 959 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 960 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
961 | 961 |
962 m_timing.iterationCount = 5.0; | 962 m_timing.iterationCount = 5.0; |
963 m_timing.iterationDuration = 1.5; | 963 m_timing.iterationDuration = 1.5; |
964 m_timing.startDelay = -3; | 964 m_timing.startDelay = -3; |
965 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 965 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
966 // -- | 966 // -- |
967 | 967 |
(...skipping 30 matching lines...) Expand all Loading... |
998 // Go! | 998 // Go! |
999 setCompositorForTesting(mockCompositor); | 999 setCompositorForTesting(mockCompositor); |
1000 Vector<OwnPtr<WebCompositorAnimation>> result; | 1000 Vector<OwnPtr<WebCompositorAnimation>> result; |
1001 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1001 getAnimationOnCompositor(m_timing, *effect.get(), result); |
1002 EXPECT_EQ(1U, result.size()); | 1002 EXPECT_EQ(1U, result.size()); |
1003 result[0].clear(); | 1003 result[0].clear(); |
1004 } | 1004 } |
1005 | 1005 |
1006 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
tes) | 1006 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
tes) |
1007 { | 1007 { |
1008 // Animation to convert | 1008 // KeyframeEffect to convert |
1009 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1009 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
1010 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1010 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
1011 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1011 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
1012 | 1012 |
1013 m_timing.playbackRate = 2; | 1013 m_timing.playbackRate = 2; |
1014 // -- | 1014 // -- |
1015 | 1015 |
1016 WebCompositorSupportMock mockCompositor; | 1016 WebCompositorSupportMock mockCompositor; |
1017 | 1017 |
1018 // Curve is created | 1018 // Curve is created |
(...skipping 28 matching lines...) Expand all Loading... |
1047 setCompositorForTesting(mockCompositor); | 1047 setCompositorForTesting(mockCompositor); |
1048 Vector<OwnPtr<WebCompositorAnimation>> result; | 1048 Vector<OwnPtr<WebCompositorAnimation>> result; |
1049 // Set player plaback rate also | 1049 // Set player plaback rate also |
1050 getAnimationOnCompositor(m_timing, *effect.get(), result, -1.5); | 1050 getAnimationOnCompositor(m_timing, *effect.get(), result, -1.5); |
1051 EXPECT_EQ(1U, result.size()); | 1051 EXPECT_EQ(1U, result.size()); |
1052 result[0].clear(); | 1052 result[0].clear(); |
1053 } | 1053 } |
1054 | 1054 |
1055 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
ne) | 1055 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
ne) |
1056 { | 1056 { |
1057 // Animation to convert | 1057 // KeyframeEffect to convert |
1058 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1058 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
1059 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1059 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
1060 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1060 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
1061 | 1061 |
1062 m_timing.fillMode = Timing::FillModeNone; | 1062 m_timing.fillMode = Timing::FillModeNone; |
1063 | 1063 |
1064 WebCompositorSupportMock mockCompositor; | 1064 WebCompositorSupportMock mockCompositor; |
1065 | 1065 |
1066 // Curve is created | 1066 // Curve is created |
1067 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1067 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
(...skipping 27 matching lines...) Expand all Loading... |
1095 // Go! | 1095 // Go! |
1096 setCompositorForTesting(mockCompositor); | 1096 setCompositorForTesting(mockCompositor); |
1097 Vector<OwnPtr<WebCompositorAnimation>> result; | 1097 Vector<OwnPtr<WebCompositorAnimation>> result; |
1098 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1098 getAnimationOnCompositor(m_timing, *effect.get(), result); |
1099 EXPECT_EQ(1U, result.size()); | 1099 EXPECT_EQ(1U, result.size()); |
1100 result[0].clear(); | 1100 result[0].clear(); |
1101 } | 1101 } |
1102 | 1102 |
1103 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
to) | 1103 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
to) |
1104 { | 1104 { |
1105 // Animation to convert | 1105 // KeyframeEffect to convert |
1106 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1106 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
1107 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1107 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
1108 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1108 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
1109 | 1109 |
1110 m_timing.fillMode = Timing::FillModeAuto; | 1110 m_timing.fillMode = Timing::FillModeAuto; |
1111 | 1111 |
1112 WebCompositorSupportMock mockCompositor; | 1112 WebCompositorSupportMock mockCompositor; |
1113 | 1113 |
1114 // Curve is created | 1114 // Curve is created |
1115 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1115 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
(...skipping 27 matching lines...) Expand all Loading... |
1143 // Go! | 1143 // Go! |
1144 setCompositorForTesting(mockCompositor); | 1144 setCompositorForTesting(mockCompositor); |
1145 Vector<OwnPtr<WebCompositorAnimation>> result; | 1145 Vector<OwnPtr<WebCompositorAnimation>> result; |
1146 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1146 getAnimationOnCompositor(m_timing, *effect.get(), result); |
1147 EXPECT_EQ(1U, result.size()); | 1147 EXPECT_EQ(1U, result.size()); |
1148 result[0].clear(); | 1148 result[0].clear(); |
1149 } | 1149 } |
1150 | 1150 |
1151 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) | 1151 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) |
1152 { | 1152 { |
1153 // Animation to convert | 1153 // KeyframeEffect to convert |
1154 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 1154 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
1155 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 1155 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
1156 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 1156 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
1157 | 1157 |
1158 m_timing.timingFunction = m_cubicCustomTimingFunction; | 1158 m_timing.timingFunction = m_cubicCustomTimingFunction; |
1159 | 1159 |
1160 WebCompositorSupportMock mockCompositor; | 1160 WebCompositorSupportMock mockCompositor; |
1161 | 1161 |
1162 // Curve is created | 1162 // Curve is created |
1163 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; | 1163 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 { | 1200 { |
1201 WebCompositorSupportMock mockCompositor; | 1201 WebCompositorSupportMock mockCompositor; |
1202 setCompositorForTesting(mockCompositor); | 1202 setCompositorForTesting(mockCompositor); |
1203 | 1203 |
1204 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); | 1204 RefPtrWillBePersistent<Element> element = m_document->createElement("shared"
, ASSERT_NO_EXCEPTION); |
1205 | 1205 |
1206 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); | 1206 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); |
1207 element->setLayoutObject(layoutObject); | 1207 element->setLayoutObject(layoutObject); |
1208 | 1208 |
1209 AnimatableValueKeyframeVector keyFrames; | 1209 AnimatableValueKeyframeVector keyFrames; |
1210 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 0.0).get()); | 1210 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp
ositeReplace, 0.0).get()); |
1211 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::
CompositeReplace, 1.0).get()); | 1211 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::Comp
ositeReplace, 1.0).get()); |
1212 RefPtrWillBeRawPtr<AnimationEffect> animationEffect1 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); | 1212 RefPtrWillBeRawPtr<EffectModel> animationEffect1 = AnimatableValueKeyframeEf
fectModel::create(keyFrames); |
1213 RefPtrWillBeRawPtr<AnimationEffect> animationEffect2 = AnimatableValueKeyfra
meEffectModel::create(keyFrames); | 1213 RefPtrWillBeRawPtr<EffectModel> animationEffect2 = AnimatableValueKeyframeEf
fectModel::create(keyFrames); |
1214 | 1214 |
1215 Timing timing; | 1215 Timing timing; |
1216 timing.iterationDuration = 1.f; | 1216 timing.iterationDuration = 1.f; |
1217 | 1217 |
1218 // The first player for opacity is ok to run on compositor. | 1218 // The first animation for opacity is ok to run on compositor. |
1219 RefPtrWillBeRawPtr<Animation> animation1 = Animation::create(element.get(),
animationEffect1, timing); | 1219 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect1 = KeyframeEffect::create(
element.get(), animationEffect1, timing); |
1220 RefPtrWillBePersistent<AnimationPlayer> player1 = m_timeline->play(animation
1.get()); | 1220 RefPtrWillBePersistent<Animation> animation1 = m_timeline->play(keyframeEffe
ct1.get()); |
1221 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo
sitor(timing, *element.get(), player1.get(), *animationEffect1.get(), 1)); | 1221 EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompo
sitor(timing, *element.get(), animation1.get(), *animationEffect1.get(), 1)); |
1222 | 1222 |
1223 // simulate Animation::maybeStartAnimationOnCompositor | 1223 // simulate KeyframeEffect::maybeStartAnimationOnCompositor |
1224 Vector<int> compositorAnimationIds; | 1224 Vector<int> compositorAnimationIds; |
1225 compositorAnimationIds.append(1); | 1225 compositorAnimationIds.append(1); |
1226 animation1->setCompositorAnimationIdsForTesting(compositorAnimationIds); | 1226 keyframeEffect1->setCompositorAnimationIdsForTesting(compositorAnimationIds)
; |
1227 EXPECT_TRUE(player1->hasActiveAnimationsOnCompositor()); | 1227 EXPECT_TRUE(animation1->hasActiveAnimationsOnCompositor()); |
1228 | 1228 |
1229 // The second player for opacity is not ok to run on compositor. | 1229 // The second animation for opacity is not ok to run on compositor. |
1230 RefPtrWillBeRawPtr<Animation> animation2 = Animation::create(element.get(),
animationEffect2, timing); | 1230 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect2 = KeyframeEffect::create(
element.get(), animationEffect2, timing); |
1231 RefPtrWillBePersistent<AnimationPlayer> player2 = m_timeline->play(animation
2.get()); | 1231 RefPtrWillBePersistent<Animation> animation2 = m_timeline->play(keyframeEffe
ct2.get()); |
1232 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp
ositor(timing, *element.get(), player2.get(), *animationEffect2.get(), 1)); | 1232 EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnComp
ositor(timing, *element.get(), animation2.get(), *animationEffect2.get(), 1)); |
1233 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); | 1233 EXPECT_FALSE(animation2->hasActiveAnimationsOnCompositor()); |
1234 | 1234 |
1235 // A fallback to blink implementation needed, so cancel all compositor-side
opacity animations for this element. | 1235 // A fallback to blink implementation needed, so cancel all compositor-side
opacity animations for this element. |
1236 player2->cancelIncompatibleAnimationsOnCompositor(); | 1236 animation2->cancelIncompatibleAnimationsOnCompositor(); |
1237 | 1237 |
1238 EXPECT_FALSE(player1->hasActiveAnimationsOnCompositor()); | 1238 EXPECT_FALSE(animation1->hasActiveAnimationsOnCompositor()); |
1239 EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor()); | 1239 EXPECT_FALSE(animation2->hasActiveAnimationsOnCompositor()); |
1240 | 1240 |
1241 simulateFrame(0); | 1241 simulateFrame(0); |
1242 EXPECT_EQ(2U, element->elementAnimations()->players().size()); | 1242 EXPECT_EQ(2U, element->elementAnimations()->animations().size()); |
1243 simulateFrame(1.); | 1243 simulateFrame(1.); |
1244 | 1244 |
1245 element->setLayoutObject(nullptr); | 1245 element->setLayoutObject(nullptr); |
1246 LayoutObjectProxy::dispose(layoutObject); | 1246 LayoutObjectProxy::dispose(layoutObject); |
1247 | 1247 |
1248 player1.release(); | 1248 animation1.release(); |
1249 player2.release(); | 1249 animation2.release(); |
1250 Heap::collectAllGarbage(); | 1250 Heap::collectAllGarbage(); |
1251 EXPECT_TRUE(element->elementAnimations()->players().isEmpty()); | 1251 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); |
1252 } | 1252 } |
1253 | 1253 |
1254 } // namespace blink | 1254 } // namespace blink |
OLD | NEW |