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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return CompositorAnimations::getAnimatedBoundingBox(boundingBox, effect, | 141 return CompositorAnimations::getAnimatedBoundingBox(boundingBox, effect, |
142 minValue, maxValue); | 142 minValue, maxValue); |
143 } | 143 } |
144 | 144 |
145 bool duplicateSingleKeyframeAndTestIsCandidateOnResult( | 145 bool duplicateSingleKeyframeAndTestIsCandidateOnResult( |
146 AnimatableValueKeyframe* frame) { | 146 AnimatableValueKeyframe* frame) { |
147 EXPECT_EQ(frame->offset(), 0); | 147 EXPECT_EQ(frame->offset(), 0); |
148 AnimatableValueKeyframeVector frames; | 148 AnimatableValueKeyframeVector frames; |
149 RefPtr<Keyframe> second = frame->cloneWithOffset(1); | 149 RefPtr<Keyframe> second = frame->cloneWithOffset(1); |
150 | 150 |
151 frames.append(frame); | 151 frames.push_back(frame); |
152 frames.append(toAnimatableValueKeyframe(second.get())); | 152 frames.push_back(toAnimatableValueKeyframe(second.get())); |
153 return isCandidateForAnimationOnCompositor( | 153 return isCandidateForAnimationOnCompositor( |
154 m_timing, *AnimatableValueKeyframeEffectModel::create(frames)); | 154 m_timing, *AnimatableValueKeyframeEffectModel::create(frames)); |
155 } | 155 } |
156 | 156 |
157 // ------------------------------------------------------------------- | 157 // ------------------------------------------------------------------- |
158 | 158 |
159 Timing createCompositableTiming() { | 159 Timing createCompositableTiming() { |
160 Timing timing; | 160 Timing timing; |
161 timing.startDelay = 0; | 161 timing.startDelay = 0; |
162 timing.fillMode = Timing::FillMode::NONE; | 162 timing.fillMode = Timing::FillMode::NONE; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 RefPtr<AnimatableValueKeyframe> keyframe = | 195 RefPtr<AnimatableValueKeyframe> keyframe = |
196 createReplaceOpKeyframe(id, value.get(), offset); | 196 createReplaceOpKeyframe(id, value.get(), offset); |
197 keyframe->setComposite(op); | 197 keyframe->setComposite(op); |
198 return keyframe; | 198 return keyframe; |
199 } | 199 } |
200 | 200 |
201 std::unique_ptr<AnimatableValueKeyframeVector> | 201 std::unique_ptr<AnimatableValueKeyframeVector> |
202 createCompositableFloatKeyframeVector(size_t n) { | 202 createCompositableFloatKeyframeVector(size_t n) { |
203 Vector<double> values; | 203 Vector<double> values; |
204 for (size_t i = 0; i < n; i++) { | 204 for (size_t i = 0; i < n; i++) { |
205 values.append(static_cast<double>(i)); | 205 values.push_back(static_cast<double>(i)); |
206 } | 206 } |
207 return createCompositableFloatKeyframeVector(values); | 207 return createCompositableFloatKeyframeVector(values); |
208 } | 208 } |
209 | 209 |
210 std::unique_ptr<AnimatableValueKeyframeVector> | 210 std::unique_ptr<AnimatableValueKeyframeVector> |
211 createCompositableFloatKeyframeVector(Vector<double>& values) { | 211 createCompositableFloatKeyframeVector(Vector<double>& values) { |
212 std::unique_ptr<AnimatableValueKeyframeVector> frames = | 212 std::unique_ptr<AnimatableValueKeyframeVector> frames = |
213 WTF::wrapUnique(new AnimatableValueKeyframeVector); | 213 WTF::wrapUnique(new AnimatableValueKeyframeVector); |
214 for (size_t i = 0; i < values.size(); i++) { | 214 for (size_t i = 0; i < values.size(); i++) { |
215 double offset = 1.0 / (values.size() - 1) * i; | 215 double offset = 1.0 / (values.size() - 1) * i; |
216 RefPtr<AnimatableDouble> value = AnimatableDouble::create(values[i]); | 216 RefPtr<AnimatableDouble> value = AnimatableDouble::create(values[i]); |
217 frames->append( | 217 frames->push_back( |
218 createReplaceOpKeyframe(CSSPropertyOpacity, value.get(), offset) | 218 createReplaceOpKeyframe(CSSPropertyOpacity, value.get(), offset) |
219 .get()); | 219 .get()); |
220 } | 220 } |
221 return frames; | 221 return frames; |
222 } | 222 } |
223 | 223 |
224 std::unique_ptr<AnimatableValueKeyframeVector> | 224 std::unique_ptr<AnimatableValueKeyframeVector> |
225 createCompositableTransformKeyframeVector( | 225 createCompositableTransformKeyframeVector( |
226 const Vector<TransformOperations>& values) { | 226 const Vector<TransformOperations>& values) { |
227 std::unique_ptr<AnimatableValueKeyframeVector> frames = | 227 std::unique_ptr<AnimatableValueKeyframeVector> frames = |
228 WTF::wrapUnique(new AnimatableValueKeyframeVector); | 228 WTF::wrapUnique(new AnimatableValueKeyframeVector); |
229 for (size_t i = 0; i < values.size(); ++i) { | 229 for (size_t i = 0; i < values.size(); ++i) { |
230 double offset = 1.0f / (values.size() - 1) * i; | 230 double offset = 1.0f / (values.size() - 1) * i; |
231 RefPtr<AnimatableTransform> value = | 231 RefPtr<AnimatableTransform> value = |
232 AnimatableTransform::create(values[i], 1); | 232 AnimatableTransform::create(values[i], 1); |
233 frames->append( | 233 frames->push_back( |
234 createReplaceOpKeyframe(CSSPropertyTransform, value.get(), offset) | 234 createReplaceOpKeyframe(CSSPropertyTransform, value.get(), offset) |
235 .get()); | 235 .get()); |
236 } | 236 } |
237 return frames; | 237 return frames; |
238 } | 238 } |
239 | 239 |
240 AnimatableValueKeyframeEffectModel* createKeyframeEffectModel( | 240 AnimatableValueKeyframeEffectModel* createKeyframeEffectModel( |
241 PassRefPtr<AnimatableValueKeyframe> prpFrom, | 241 PassRefPtr<AnimatableValueKeyframe> prpFrom, |
242 PassRefPtr<AnimatableValueKeyframe> prpTo, | 242 PassRefPtr<AnimatableValueKeyframe> prpTo, |
243 PassRefPtr<AnimatableValueKeyframe> prpC = nullptr, | 243 PassRefPtr<AnimatableValueKeyframe> prpC = nullptr, |
244 PassRefPtr<AnimatableValueKeyframe> prpD = nullptr) { | 244 PassRefPtr<AnimatableValueKeyframe> prpD = nullptr) { |
245 RefPtr<AnimatableValueKeyframe> from = prpFrom; | 245 RefPtr<AnimatableValueKeyframe> from = prpFrom; |
246 RefPtr<AnimatableValueKeyframe> to = prpTo; | 246 RefPtr<AnimatableValueKeyframe> to = prpTo; |
247 RefPtr<AnimatableValueKeyframe> c = prpC; | 247 RefPtr<AnimatableValueKeyframe> c = prpC; |
248 RefPtr<AnimatableValueKeyframe> d = prpD; | 248 RefPtr<AnimatableValueKeyframe> d = prpD; |
249 | 249 |
250 EXPECT_EQ(from->offset(), 0); | 250 EXPECT_EQ(from->offset(), 0); |
251 AnimatableValueKeyframeVector frames; | 251 AnimatableValueKeyframeVector frames; |
252 frames.append(from); | 252 frames.push_back(from); |
253 EXPECT_LE(from->offset(), to->offset()); | 253 EXPECT_LE(from->offset(), to->offset()); |
254 frames.append(to); | 254 frames.push_back(to); |
255 if (c) { | 255 if (c) { |
256 EXPECT_LE(to->offset(), c->offset()); | 256 EXPECT_LE(to->offset(), c->offset()); |
257 frames.append(c); | 257 frames.push_back(c); |
258 } | 258 } |
259 if (d) { | 259 if (d) { |
260 frames.append(d); | 260 frames.push_back(d); |
261 EXPECT_LE(c->offset(), d->offset()); | 261 EXPECT_LE(c->offset(), d->offset()); |
262 EXPECT_EQ(d->offset(), 1.0); | 262 EXPECT_EQ(d->offset(), 1.0); |
263 } else { | 263 } else { |
264 EXPECT_EQ(to->offset(), 1.0); | 264 EXPECT_EQ(to->offset(), 1.0); |
265 } | 265 } |
266 if (!HasFatalFailure()) { | 266 if (!HasFatalFailure()) { |
267 return AnimatableValueKeyframeEffectModel::create(frames); | 267 return AnimatableValueKeyframeEffectModel::create(frames); |
268 } | 268 } |
269 return nullptr; | 269 return nullptr; |
270 } | 270 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace); | 334 createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace); |
335 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, | 335 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, |
336 AnimatableDouble::create(10.0).get()); | 336 AnimatableDouble::create(10.0).get()); |
337 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult( | 337 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult( |
338 keyframeBadMultipleID.get())); | 338 keyframeBadMultipleID.get())); |
339 } | 339 } |
340 | 340 |
341 TEST_F(AnimationCompositorAnimationsTest, | 341 TEST_F(AnimationCompositorAnimationsTest, |
342 isNotCandidateForCompositorAnimationTransformDependsOnBoxSize) { | 342 isNotCandidateForCompositorAnimationTransformDependsOnBoxSize) { |
343 TransformOperations ops; | 343 TransformOperations ops; |
344 ops.operations().append(TranslateTransformOperation::create( | 344 ops.operations().push_back(TranslateTransformOperation::create( |
345 Length(2, Fixed), Length(2, Fixed), TransformOperation::TranslateX)); | 345 Length(2, Fixed), Length(2, Fixed), TransformOperation::TranslateX)); |
346 RefPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKeyframe( | 346 RefPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKeyframe( |
347 CSSPropertyTransform, AnimatableTransform::create(ops, 1).get()); | 347 CSSPropertyTransform, AnimatableTransform::create(ops, 1).get()); |
348 EXPECT_TRUE( | 348 EXPECT_TRUE( |
349 duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.get())); | 349 duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.get())); |
350 | 350 |
351 ops.operations().append(TranslateTransformOperation::create( | 351 ops.operations().push_back(TranslateTransformOperation::create( |
352 Length(50, Percent), Length(2, Fixed), TransformOperation::TranslateX)); | 352 Length(50, Percent), Length(2, Fixed), TransformOperation::TranslateX)); |
353 RefPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKeyframe( | 353 RefPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKeyframe( |
354 CSSPropertyTransform, AnimatableTransform::create(ops, 1).get()); | 354 CSSPropertyTransform, AnimatableTransform::create(ops, 1).get()); |
355 EXPECT_FALSE( | 355 EXPECT_FALSE( |
356 duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.get())); | 356 duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.get())); |
357 | 357 |
358 TransformOperations ops2; | 358 TransformOperations ops2; |
359 Length calcLength = | 359 Length calcLength = |
360 Length(100, Percent).blend(Length(100, Fixed), 0.5, ValueRangeAll); | 360 Length(100, Percent).blend(Length(100, Fixed), 0.5, ValueRangeAll); |
361 ops2.operations().append(TranslateTransformOperation::create( | 361 ops2.operations().push_back(TranslateTransformOperation::create( |
362 calcLength, Length(0, Fixed), TransformOperation::TranslateX)); | 362 calcLength, Length(0, Fixed), TransformOperation::TranslateX)); |
363 RefPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKeyframe( | 363 RefPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKeyframe( |
364 CSSPropertyTransform, AnimatableTransform::create(ops2, 1).get()); | 364 CSSPropertyTransform, AnimatableTransform::create(ops2, 1).get()); |
365 EXPECT_FALSE( | 365 EXPECT_FALSE( |
366 duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.get())); | 366 duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.get())); |
367 } | 367 } |
368 | 368 |
369 TEST_F( | 369 TEST_F( |
370 AnimationCompositorAnimationsTest, | 370 AnimationCompositorAnimationsTest, |
371 isCandidateForAnimationOnCompositorKeyframeEffectModelMultipleFramesOkay) { | 371 isCandidateForAnimationOnCompositorKeyframeEffectModelMultipleFramesOkay) { |
372 AnimatableValueKeyframeVector framesSame; | 372 AnimatableValueKeyframeVector framesSame; |
373 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, | 373 framesSame.push_back(createDefaultKeyframe(CSSPropertyOpacity, |
374 EffectModel::CompositeReplace, 0.0) | 374 EffectModel::CompositeReplace, 0.0) |
375 .get()); | 375 .get()); |
376 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, | 376 framesSame.push_back(createDefaultKeyframe(CSSPropertyOpacity, |
377 EffectModel::CompositeReplace, 1.0) | 377 EffectModel::CompositeReplace, 1.0) |
378 .get()); | 378 .get()); |
379 EXPECT_TRUE(isCandidateForAnimationOnCompositor( | 379 EXPECT_TRUE(isCandidateForAnimationOnCompositor( |
380 m_timing, *AnimatableValueKeyframeEffectModel::create(framesSame))); | 380 m_timing, *AnimatableValueKeyframeEffectModel::create(framesSame))); |
381 | 381 |
382 AnimatableValueKeyframeVector framesMixed; | 382 AnimatableValueKeyframeVector framesMixed; |
383 framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, | 383 framesMixed.push_back(createDefaultKeyframe(CSSPropertyOpacity, |
384 EffectModel::CompositeReplace, 0.0) | 384 EffectModel::CompositeReplace, |
385 .get()); | 385 0.0) |
386 framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, | 386 .get()); |
387 EffectModel::CompositeReplace, 1.0) | 387 framesMixed.push_back(createDefaultKeyframe(CSSPropertyTransform, |
388 .get()); | 388 EffectModel::CompositeReplace, |
| 389 1.0) |
| 390 .get()); |
389 EXPECT_FALSE(isCandidateForAnimationOnCompositor( | 391 EXPECT_FALSE(isCandidateForAnimationOnCompositor( |
390 m_timing, *AnimatableValueKeyframeEffectModel::create(framesMixed))); | 392 m_timing, *AnimatableValueKeyframeEffectModel::create(framesMixed))); |
391 } | 393 } |
392 | 394 |
393 TEST_F(AnimationCompositorAnimationsTest, | 395 TEST_F(AnimationCompositorAnimationsTest, |
394 isCandidateForAnimationOnCompositorKeyframeEffectModel) { | 396 isCandidateForAnimationOnCompositorKeyframeEffectModel) { |
395 AnimatableValueKeyframeVector framesSame; | 397 AnimatableValueKeyframeVector framesSame; |
396 framesSame.append(createDefaultKeyframe(CSSPropertyColor, | 398 framesSame.push_back(createDefaultKeyframe(CSSPropertyColor, |
397 EffectModel::CompositeReplace, 0.0) | 399 EffectModel::CompositeReplace, 0.0) |
398 .get()); | 400 .get()); |
399 framesSame.append(createDefaultKeyframe(CSSPropertyColor, | 401 framesSame.push_back(createDefaultKeyframe(CSSPropertyColor, |
400 EffectModel::CompositeReplace, 1.0) | 402 EffectModel::CompositeReplace, 1.0) |
401 .get()); | 403 .get()); |
402 EXPECT_FALSE(isCandidateForAnimationOnCompositor( | 404 EXPECT_FALSE(isCandidateForAnimationOnCompositor( |
403 m_timing, *AnimatableValueKeyframeEffectModel::create(framesSame))); | 405 m_timing, *AnimatableValueKeyframeEffectModel::create(framesSame))); |
404 | 406 |
405 AnimatableValueKeyframeVector framesMixedProperties; | 407 AnimatableValueKeyframeVector framesMixedProperties; |
406 framesMixedProperties.append( | 408 framesMixedProperties.push_back( |
407 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, | 409 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, |
408 0.0) | 410 0.0) |
409 .get()); | 411 .get()); |
410 framesMixedProperties.append( | 412 framesMixedProperties.push_back( |
411 createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace, | 413 createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace, |
412 1.0) | 414 1.0) |
413 .get()); | 415 .get()); |
414 EXPECT_FALSE(isCandidateForAnimationOnCompositor( | 416 EXPECT_FALSE(isCandidateForAnimationOnCompositor( |
415 m_timing, | 417 m_timing, |
416 *AnimatableValueKeyframeEffectModel::create(framesMixedProperties))); | 418 *AnimatableValueKeyframeEffectModel::create(framesMixedProperties))); |
417 } | 419 } |
418 | 420 |
419 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) { | 421 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) { |
420 Vector<TransformOperations> transformVector; | 422 Vector<TransformOperations> transformVector; |
421 transformVector.append(TransformOperations()); | 423 transformVector.push_back(TransformOperations()); |
422 transformVector.back().operations().append( | 424 transformVector.back().operations().push_back( |
423 TranslateTransformOperation::create(Length(0, Fixed), Length(0, Fixed), | 425 TranslateTransformOperation::create(Length(0, Fixed), Length(0, Fixed), |
424 0.0, | 426 0.0, |
425 TransformOperation::Translate3D)); | 427 TransformOperation::Translate3D)); |
426 transformVector.append(TransformOperations()); | 428 transformVector.push_back(TransformOperations()); |
427 transformVector.back().operations().append( | 429 transformVector.back().operations().push_back( |
428 TranslateTransformOperation::create(Length(200, Fixed), | 430 TranslateTransformOperation::create(Length(200, Fixed), |
429 Length(200, Fixed), 0.0, | 431 Length(200, Fixed), 0.0, |
430 TransformOperation::Translate3D)); | 432 TransformOperation::Translate3D)); |
431 std::unique_ptr<AnimatableValueKeyframeVector> frames = | 433 std::unique_ptr<AnimatableValueKeyframeVector> frames = |
432 createCompositableTransformKeyframeVector(transformVector); | 434 createCompositableTransformKeyframeVector(transformVector); |
433 FloatBox bounds; | 435 FloatBox bounds; |
434 EXPECT_TRUE(getAnimationBounds( | 436 EXPECT_TRUE(getAnimationBounds( |
435 bounds, *AnimatableValueKeyframeEffectModel::create(*frames), 0, 1)); | 437 bounds, *AnimatableValueKeyframeEffectModel::create(*frames), 0, 1)); |
436 EXPECT_EQ(FloatBox(0.0f, 0.f, 0.0f, 200.0f, 200.0f, 0.0f), bounds); | 438 EXPECT_EQ(FloatBox(0.0f, 0.f, 0.0f, 200.0f, 200.0f, 0.0f), bounds); |
437 bounds = FloatBox(); | 439 bounds = FloatBox(); |
438 EXPECT_TRUE(getAnimationBounds( | 440 EXPECT_TRUE(getAnimationBounds( |
439 bounds, *AnimatableValueKeyframeEffectModel::create(*frames), -1, 1)); | 441 bounds, *AnimatableValueKeyframeEffectModel::create(*frames), -1, 1)); |
440 EXPECT_EQ(FloatBox(-200.0f, -200.0, 0.0, 400.0f, 400.0f, 0.0f), bounds); | 442 EXPECT_EQ(FloatBox(-200.0f, -200.0, 0.0, 400.0f, 400.0f, 0.0f), bounds); |
441 transformVector.append(TransformOperations()); | 443 transformVector.push_back(TransformOperations()); |
442 transformVector.back().operations().append( | 444 transformVector.back().operations().push_back( |
443 TranslateTransformOperation::create(Length(-300, Fixed), | 445 TranslateTransformOperation::create(Length(-300, Fixed), |
444 Length(-400, Fixed), 1.0f, | 446 Length(-400, Fixed), 1.0f, |
445 TransformOperation::Translate3D)); | 447 TransformOperation::Translate3D)); |
446 bounds = FloatBox(); | 448 bounds = FloatBox(); |
447 frames = createCompositableTransformKeyframeVector(transformVector); | 449 frames = createCompositableTransformKeyframeVector(transformVector); |
448 EXPECT_TRUE(getAnimationBounds( | 450 EXPECT_TRUE(getAnimationBounds( |
449 bounds, *AnimatableValueKeyframeEffectModel::create(*frames), 0, 1)); | 451 bounds, *AnimatableValueKeyframeEffectModel::create(*frames), 0, 1)); |
450 EXPECT_EQ(FloatBox(-300.0f, -400.f, 0.0f, 500.0f, 600.0f, 1.0f), bounds); | 452 EXPECT_EQ(FloatBox(-300.0f, -400.f, 0.0f, 500.0f, 600.0f, 1.0f), bounds); |
451 bounds = FloatBox(); | 453 bounds = FloatBox(); |
452 EXPECT_TRUE(getAnimationBounds( | 454 EXPECT_TRUE(getAnimationBounds( |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get()); | 727 (*m_keyframeVector5)[2]->setEasing(m_cubicEaseTimingFunction.get()); |
726 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); | 728 (*m_keyframeVector5)[3]->setEasing(m_stepTimingFunction.get()); |
727 m_keyframeAnimationEffect5 = | 729 m_keyframeAnimationEffect5 = |
728 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); | 730 AnimatableValueKeyframeEffectModel::create(*m_keyframeVector5); |
729 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, | 731 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, |
730 *m_keyframeAnimationEffect5)); | 732 *m_keyframeAnimationEffect5)); |
731 } | 733 } |
732 | 734 |
733 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) { | 735 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor) { |
734 AnimatableValueKeyframeVector basicFramesVector; | 736 AnimatableValueKeyframeVector basicFramesVector; |
735 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, | 737 basicFramesVector.push_back( |
736 EffectModel::CompositeReplace, | |
737 0.0) | |
738 .get()); | |
739 basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, | |
740 EffectModel::CompositeReplace, | |
741 1.0) | |
742 .get()); | |
743 | |
744 AnimatableValueKeyframeVector nonBasicFramesVector; | |
745 nonBasicFramesVector.append( | |
746 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, | 738 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, |
747 0.0) | 739 0.0) |
748 .get()); | 740 .get()); |
749 nonBasicFramesVector.append( | 741 basicFramesVector.push_back( |
| 742 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, |
| 743 1.0) |
| 744 .get()); |
| 745 |
| 746 AnimatableValueKeyframeVector nonBasicFramesVector; |
| 747 nonBasicFramesVector.push_back( |
| 748 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, |
| 749 0.0) |
| 750 .get()); |
| 751 nonBasicFramesVector.push_back( |
750 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, | 752 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, |
751 0.5) | 753 0.5) |
752 .get()); | 754 .get()); |
753 nonBasicFramesVector.append( | 755 nonBasicFramesVector.push_back( |
754 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, | 756 createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, |
755 1.0) | 757 1.0) |
756 .get()); | 758 .get()); |
757 | 759 |
758 basicFramesVector[0]->setEasing(m_linearTimingFunction.get()); | 760 basicFramesVector[0]->setEasing(m_linearTimingFunction.get()); |
759 AnimatableValueKeyframeEffectModel* basicFrames = | 761 AnimatableValueKeyframeEffectModel* basicFrames = |
760 AnimatableValueKeyframeEffectModel::create(basicFramesVector); | 762 AnimatableValueKeyframeEffectModel::create(basicFramesVector); |
761 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *basicFrames)); | 763 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *basicFrames)); |
762 | 764 |
763 basicFramesVector[0]->setEasing(CubicBezierTimingFunction::preset( | 765 basicFramesVector[0]->setEasing(CubicBezierTimingFunction::preset( |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 ASSERT_EQ(2UL, keyframes.size()); | 920 ASSERT_EQ(2UL, keyframes.size()); |
919 | 921 |
920 EXPECT_EQ(1.75, keyframes[1]->time() * m_timing.iterationDuration); | 922 EXPECT_EQ(1.75, keyframes[1]->time() * m_timing.iterationDuration); |
921 EXPECT_EQ(5.0f, keyframes[1]->value()); | 923 EXPECT_EQ(5.0f, keyframes[1]->value()); |
922 } | 924 } |
923 | 925 |
924 TEST_F(AnimationCompositorAnimationsTest, | 926 TEST_F(AnimationCompositorAnimationsTest, |
925 createMultipleKeyframeOpacityAnimationChained) { | 927 createMultipleKeyframeOpacityAnimationChained) { |
926 // KeyframeEffect to convert | 928 // KeyframeEffect to convert |
927 AnimatableValueKeyframeVector frames; | 929 AnimatableValueKeyframeVector frames; |
928 frames.append(createReplaceOpKeyframe( | 930 frames.push_back(createReplaceOpKeyframe( |
929 CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0)); | 931 CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0)); |
930 frames.append(createReplaceOpKeyframe( | 932 frames.push_back(createReplaceOpKeyframe( |
931 CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25)); | 933 CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25)); |
932 frames.append(createReplaceOpKeyframe( | 934 frames.push_back(createReplaceOpKeyframe( |
933 CSSPropertyOpacity, AnimatableDouble::create(20.0).get(), 0.5)); | 935 CSSPropertyOpacity, AnimatableDouble::create(20.0).get(), 0.5)); |
934 frames.append(createReplaceOpKeyframe( | 936 frames.push_back(createReplaceOpKeyframe( |
935 CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); | 937 CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
936 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); | 938 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); |
937 frames[1]->setEasing(m_linearTimingFunction.get()); | 939 frames[1]->setEasing(m_linearTimingFunction.get()); |
938 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); | 940 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); |
939 AnimatableValueKeyframeEffectModel* effect = | 941 AnimatableValueKeyframeEffectModel* effect = |
940 AnimatableValueKeyframeEffectModel::create(frames); | 942 AnimatableValueKeyframeEffectModel::create(frames); |
941 | 943 |
942 m_timing.timingFunction = m_linearTimingFunction.get(); | 944 m_timing.timingFunction = m_linearTimingFunction.get(); |
943 m_timing.iterationDuration = 2.0; | 945 m_timing.iterationDuration = 2.0; |
944 m_timing.iterationCount = 10; | 946 m_timing.iterationCount = 10; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 EXPECT_EQ(TimingFunction::Type::LINEAR, | 982 EXPECT_EQ(TimingFunction::Type::LINEAR, |
981 keyframes[3]->getTimingFunctionForTesting()->getType()); | 983 keyframes[3]->getTimingFunctionForTesting()->getType()); |
982 } | 984 } |
983 | 985 |
984 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) { | 986 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) { |
985 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = | 987 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = |
986 CubicBezierTimingFunction::create(0.0, 0.0, 0.0, 1.0); | 988 CubicBezierTimingFunction::create(0.0, 0.0, 0.0, 1.0); |
987 | 989 |
988 // KeyframeEffect to convert | 990 // KeyframeEffect to convert |
989 AnimatableValueKeyframeVector frames; | 991 AnimatableValueKeyframeVector frames; |
990 frames.append(createReplaceOpKeyframe( | 992 frames.push_back(createReplaceOpKeyframe( |
991 CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0)); | 993 CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0)); |
992 frames.append(createReplaceOpKeyframe( | 994 frames.push_back(createReplaceOpKeyframe( |
993 CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25)); | 995 CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25)); |
994 frames.append(createReplaceOpKeyframe( | 996 frames.push_back(createReplaceOpKeyframe( |
995 CSSPropertyOpacity, AnimatableDouble::create(20.0).get(), 0.5)); | 997 CSSPropertyOpacity, AnimatableDouble::create(20.0).get(), 0.5)); |
996 frames.append(createReplaceOpKeyframe( | 998 frames.push_back(createReplaceOpKeyframe( |
997 CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); | 999 CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0)); |
998 frames[0]->setEasing(CubicBezierTimingFunction::preset( | 1000 frames[0]->setEasing(CubicBezierTimingFunction::preset( |
999 CubicBezierTimingFunction::EaseType::EASE_IN)); | 1001 CubicBezierTimingFunction::EaseType::EASE_IN)); |
1000 frames[1]->setEasing(m_linearTimingFunction.get()); | 1002 frames[1]->setEasing(m_linearTimingFunction.get()); |
1001 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); | 1003 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); |
1002 AnimatableValueKeyframeEffectModel* effect = | 1004 AnimatableValueKeyframeEffectModel* effect = |
1003 AnimatableValueKeyframeEffectModel::create(frames); | 1005 AnimatableValueKeyframeEffectModel::create(frames); |
1004 | 1006 |
1005 m_timing.timingFunction = m_linearTimingFunction.get(); | 1007 m_timing.timingFunction = m_linearTimingFunction.get(); |
1006 m_timing.iterationCount = 10; | 1008 m_timing.iterationCount = 10; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 } | 1192 } |
1191 | 1193 |
1192 TEST_F(AnimationCompositorAnimationsTest, | 1194 TEST_F(AnimationCompositorAnimationsTest, |
1193 cancelIncompatibleCompositorAnimations) { | 1195 cancelIncompatibleCompositorAnimations) { |
1194 Persistent<Element> element = m_document->createElement("shared"); | 1196 Persistent<Element> element = m_document->createElement("shared"); |
1195 | 1197 |
1196 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); | 1198 LayoutObjectProxy* layoutObject = LayoutObjectProxy::create(element.get()); |
1197 element->setLayoutObject(layoutObject); | 1199 element->setLayoutObject(layoutObject); |
1198 | 1200 |
1199 AnimatableValueKeyframeVector keyFrames; | 1201 AnimatableValueKeyframeVector keyFrames; |
1200 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, | 1202 keyFrames.push_back(createDefaultKeyframe(CSSPropertyOpacity, |
1201 EffectModel::CompositeReplace, 0.0) | 1203 EffectModel::CompositeReplace, 0.0) |
1202 .get()); | 1204 .get()); |
1203 keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, | 1205 keyFrames.push_back(createDefaultKeyframe(CSSPropertyOpacity, |
1204 EffectModel::CompositeReplace, 1.0) | 1206 EffectModel::CompositeReplace, 1.0) |
1205 .get()); | 1207 .get()); |
1206 EffectModel* animationEffect1 = | 1208 EffectModel* animationEffect1 = |
1207 AnimatableValueKeyframeEffectModel::create(keyFrames); | 1209 AnimatableValueKeyframeEffectModel::create(keyFrames); |
1208 EffectModel* animationEffect2 = | 1210 EffectModel* animationEffect2 = |
1209 AnimatableValueKeyframeEffectModel::create(keyFrames); | 1211 AnimatableValueKeyframeEffectModel::create(keyFrames); |
1210 | 1212 |
1211 Timing timing; | 1213 Timing timing; |
1212 timing.iterationDuration = 1.f; | 1214 timing.iterationDuration = 1.f; |
1213 | 1215 |
1214 // The first animation for opacity is ok to run on compositor. | 1216 // The first animation for opacity is ok to run on compositor. |
1215 KeyframeEffect* keyframeEffect1 = | 1217 KeyframeEffect* keyframeEffect1 = |
1216 KeyframeEffect::create(element.get(), animationEffect1, timing); | 1218 KeyframeEffect::create(element.get(), animationEffect1, timing); |
1217 Animation* animation1 = m_timeline->play(keyframeEffect1); | 1219 Animation* animation1 = m_timeline->play(keyframeEffect1); |
1218 EXPECT_TRUE(CompositorAnimations::isCandidateForAnimationOnCompositor( | 1220 EXPECT_TRUE(CompositorAnimations::isCandidateForAnimationOnCompositor( |
1219 timing, *element.get(), animation1, *animationEffect1, 1)); | 1221 timing, *element.get(), animation1, *animationEffect1, 1)); |
1220 | 1222 |
1221 // simulate KeyframeEffect::maybeStartAnimationOnCompositor | 1223 // simulate KeyframeEffect::maybeStartAnimationOnCompositor |
1222 Vector<int> compositorAnimationIds; | 1224 Vector<int> compositorAnimationIds; |
1223 compositorAnimationIds.append(1); | 1225 compositorAnimationIds.push_back(1); |
1224 keyframeEffect1->setCompositorAnimationIdsForTesting(compositorAnimationIds); | 1226 keyframeEffect1->setCompositorAnimationIdsForTesting(compositorAnimationIds); |
1225 EXPECT_TRUE(animation1->hasActiveAnimationsOnCompositor()); | 1227 EXPECT_TRUE(animation1->hasActiveAnimationsOnCompositor()); |
1226 | 1228 |
1227 // The second animation for opacity is not ok to run on compositor. | 1229 // The second animation for opacity is not ok to run on compositor. |
1228 KeyframeEffect* keyframeEffect2 = | 1230 KeyframeEffect* keyframeEffect2 = |
1229 KeyframeEffect::create(element.get(), animationEffect2, timing); | 1231 KeyframeEffect::create(element.get(), animationEffect2, timing); |
1230 Animation* animation2 = m_timeline->play(keyframeEffect2); | 1232 Animation* animation2 = m_timeline->play(keyframeEffect2); |
1231 EXPECT_FALSE(CompositorAnimations::isCandidateForAnimationOnCompositor( | 1233 EXPECT_FALSE(CompositorAnimations::isCandidateForAnimationOnCompositor( |
1232 timing, *element.get(), animation2, *animationEffect2, 1)); | 1234 timing, *element.get(), animation2, *animationEffect2, 1)); |
1233 EXPECT_FALSE(animation2->hasActiveAnimationsOnCompositor()); | 1235 EXPECT_FALSE(animation2->hasActiveAnimationsOnCompositor()); |
(...skipping 10 matching lines...) Expand all Loading... |
1244 simulateFrame(1.); | 1246 simulateFrame(1.); |
1245 | 1247 |
1246 element->setLayoutObject(nullptr); | 1248 element->setLayoutObject(nullptr); |
1247 LayoutObjectProxy::dispose(layoutObject); | 1249 LayoutObjectProxy::dispose(layoutObject); |
1248 | 1250 |
1249 ThreadState::current()->collectAllGarbage(); | 1251 ThreadState::current()->collectAllGarbage(); |
1250 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); | 1252 EXPECT_TRUE(element->elementAnimations()->animations().isEmpty()); |
1251 } | 1253 } |
1252 | 1254 |
1253 } // namespace blink | 1255 } // namespace blink |
OLD | NEW |