OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/compositor/layer_animation_element.h" | 5 #include "ui/compositor/layer_animation_element.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 void OnGetTarget(TargetValue* target) const override { | 105 void OnGetTarget(TargetValue* target) const override { |
106 target->transform = interpolated_transform_->Interpolate(1.0f); | 106 target->transform = interpolated_transform_->Interpolate(1.0f); |
107 } | 107 } |
108 | 108 |
109 void OnAbort(LayerAnimationDelegate* delegate) override {} | 109 void OnAbort(LayerAnimationDelegate* delegate) override {} |
110 | 110 |
111 private: | 111 private: |
112 scoped_ptr<InterpolatedTransform> interpolated_transform_; | 112 std::unique_ptr<InterpolatedTransform> interpolated_transform_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition); | 114 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition); |
115 }; | 115 }; |
116 | 116 |
117 // BoundsTransition ------------------------------------------------------------ | 117 // BoundsTransition ------------------------------------------------------------ |
118 | 118 |
119 class BoundsTransition : public LayerAnimationElement { | 119 class BoundsTransition : public LayerAnimationElement { |
120 public: | 120 public: |
121 BoundsTransition(const gfx::Rect& target, base::TimeDelta duration) | 121 BoundsTransition(const gfx::Rect& target, base::TimeDelta duration) |
122 : LayerAnimationElement(BOUNDS, duration), | 122 : LayerAnimationElement(BOUNDS, duration), |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 void RequestEffectiveStart(LayerAnimationDelegate* delegate) override { | 366 void RequestEffectiveStart(LayerAnimationDelegate* delegate) override { |
367 DCHECK(animation_group_id()); | 367 DCHECK(animation_group_id()); |
368 if (!IsThreaded()) { | 368 if (!IsThreaded()) { |
369 set_effective_start_time(requested_start_time()); | 369 set_effective_start_time(requested_start_time()); |
370 return; | 370 return; |
371 } | 371 } |
372 set_effective_start_time(base::TimeTicks()); | 372 set_effective_start_time(base::TimeTicks()); |
373 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); | 373 std::unique_ptr<cc::Animation> animation = CreateCCAnimation(); |
374 animation->set_needs_synchronized_start_time(true); | 374 animation->set_needs_synchronized_start_time(true); |
375 | 375 |
376 LayerThreadedAnimationDelegate* threaded = | 376 LayerThreadedAnimationDelegate* threaded = |
377 delegate->GetThreadedAnimationDelegate(); | 377 delegate->GetThreadedAnimationDelegate(); |
378 DCHECK(threaded); | 378 DCHECK(threaded); |
379 threaded->AddThreadedAnimation(std::move(animation)); | 379 threaded->AddThreadedAnimation(std::move(animation)); |
380 } | 380 } |
381 | 381 |
382 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0; | 382 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0; |
383 | 383 |
384 virtual scoped_ptr<cc::Animation> CreateCCAnimation() = 0; | 384 virtual std::unique_ptr<cc::Animation> CreateCCAnimation() = 0; |
385 | 385 |
386 private: | 386 private: |
387 DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement); | 387 DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement); |
388 }; | 388 }; |
389 | 389 |
390 // ThreadedOpacityTransition --------------------------------------------------- | 390 // ThreadedOpacityTransition --------------------------------------------------- |
391 | 391 |
392 class ThreadedOpacityTransition : public ThreadedLayerAnimationElement { | 392 class ThreadedOpacityTransition : public ThreadedLayerAnimationElement { |
393 public: | 393 public: |
394 ThreadedOpacityTransition(float target, base::TimeDelta duration) | 394 ThreadedOpacityTransition(float target, base::TimeDelta duration) |
(...skipping 15 matching lines...) Expand all Loading... |
410 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), | 410 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
411 start_, | 411 start_, |
412 target_)); | 412 target_)); |
413 } | 413 } |
414 } | 414 } |
415 | 415 |
416 void OnEnd(LayerAnimationDelegate* delegate) override { | 416 void OnEnd(LayerAnimationDelegate* delegate) override { |
417 delegate->SetOpacityFromAnimation(target_); | 417 delegate->SetOpacityFromAnimation(target_); |
418 } | 418 } |
419 | 419 |
420 scoped_ptr<cc::Animation> CreateCCAnimation() override { | 420 std::unique_ptr<cc::Animation> CreateCCAnimation() override { |
421 scoped_ptr<cc::AnimationCurve> animation_curve( | 421 std::unique_ptr<cc::AnimationCurve> animation_curve( |
422 new FloatAnimationCurveAdapter(tween_type(), | 422 new FloatAnimationCurveAdapter(tween_type(), start_, target_, |
423 start_, | |
424 target_, | |
425 duration())); | 423 duration())); |
426 scoped_ptr<cc::Animation> animation(cc::Animation::Create( | 424 std::unique_ptr<cc::Animation> animation(cc::Animation::Create( |
427 std::move(animation_curve), animation_id(), animation_group_id(), | 425 std::move(animation_curve), animation_id(), animation_group_id(), |
428 cc::TargetProperty::OPACITY)); | 426 cc::TargetProperty::OPACITY)); |
429 return animation; | 427 return animation; |
430 } | 428 } |
431 | 429 |
432 void OnGetTarget(TargetValue* target) const override { | 430 void OnGetTarget(TargetValue* target) const override { |
433 target->opacity = target_; | 431 target->opacity = target_; |
434 } | 432 } |
435 | 433 |
436 private: | 434 private: |
(...skipping 26 matching lines...) Expand all Loading... |
463 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), | 461 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
464 start_, | 462 start_, |
465 target_)); | 463 target_)); |
466 } | 464 } |
467 } | 465 } |
468 | 466 |
469 void OnEnd(LayerAnimationDelegate* delegate) override { | 467 void OnEnd(LayerAnimationDelegate* delegate) override { |
470 delegate->SetTransformFromAnimation(target_); | 468 delegate->SetTransformFromAnimation(target_); |
471 } | 469 } |
472 | 470 |
473 scoped_ptr<cc::Animation> CreateCCAnimation() override { | 471 std::unique_ptr<cc::Animation> CreateCCAnimation() override { |
474 scoped_ptr<cc::AnimationCurve> animation_curve( | 472 std::unique_ptr<cc::AnimationCurve> animation_curve( |
475 new TransformAnimationCurveAdapter(tween_type(), | 473 new TransformAnimationCurveAdapter(tween_type(), start_, target_, |
476 start_, | |
477 target_, | |
478 duration())); | 474 duration())); |
479 scoped_ptr<cc::Animation> animation(cc::Animation::Create( | 475 std::unique_ptr<cc::Animation> animation(cc::Animation::Create( |
480 std::move(animation_curve), animation_id(), animation_group_id(), | 476 std::move(animation_curve), animation_id(), animation_group_id(), |
481 cc::TargetProperty::TRANSFORM)); | 477 cc::TargetProperty::TRANSFORM)); |
482 return animation; | 478 return animation; |
483 } | 479 } |
484 | 480 |
485 void OnGetTarget(TargetValue* target) const override { | 481 void OnGetTarget(TargetValue* target) const override { |
486 target->transform = target_; | 482 target->transform = target_; |
487 } | 483 } |
488 | 484 |
489 private: | 485 private: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 if (delegate && Started()) { | 536 if (delegate && Started()) { |
541 ThreadedLayerAnimationElement::OnAbort(delegate); | 537 ThreadedLayerAnimationElement::OnAbort(delegate); |
542 delegate->SetTransformFromAnimation(ComputeCurrentTransform()); | 538 delegate->SetTransformFromAnimation(ComputeCurrentTransform()); |
543 } | 539 } |
544 } | 540 } |
545 | 541 |
546 void OnEnd(LayerAnimationDelegate* delegate) override { | 542 void OnEnd(LayerAnimationDelegate* delegate) override { |
547 delegate->SetTransformFromAnimation(computed_target_transform_); | 543 delegate->SetTransformFromAnimation(computed_target_transform_); |
548 } | 544 } |
549 | 545 |
550 scoped_ptr<cc::Animation> CreateCCAnimation() override { | 546 std::unique_ptr<cc::Animation> CreateCCAnimation() override { |
551 scoped_ptr<cc::Animation> animation(cc::Animation::Create( | 547 std::unique_ptr<cc::Animation> animation(cc::Animation::Create( |
552 animation_curve_->Clone(), animation_id(), animation_group_id(), | 548 animation_curve_->Clone(), animation_id(), animation_group_id(), |
553 cc::TargetProperty::TRANSFORM)); | 549 cc::TargetProperty::TRANSFORM)); |
554 return animation; | 550 return animation; |
555 } | 551 } |
556 | 552 |
557 void OnGetTarget(TargetValue* target) const override { | 553 void OnGetTarget(TargetValue* target) const override { |
558 target->transform = computed_target_transform_; | 554 target->transform = computed_target_transform_; |
559 } | 555 } |
560 | 556 |
561 private: | 557 private: |
(...skipping 21 matching lines...) Expand all Loading... |
583 DCHECK(properties & TRANSFORM); | 579 DCHECK(properties & TRANSFORM); |
584 return static_cast<T>(element); | 580 return static_cast<T>(element); |
585 } | 581 } |
586 | 582 |
587 gfx::Transform effective_start_; | 583 gfx::Transform effective_start_; |
588 gfx::Transform computed_target_transform_; | 584 gfx::Transform computed_target_transform_; |
589 | 585 |
590 const gfx::Transform base_transform_; | 586 const gfx::Transform base_transform_; |
591 gfx::Transform base_target_; | 587 gfx::Transform base_target_; |
592 | 588 |
593 scoped_ptr<cc::AnimationCurve> animation_curve_; | 589 std::unique_ptr<cc::AnimationCurve> animation_curve_; |
594 | 590 |
595 const ThreadedTransformTransition* const uninverted_transition_; | 591 const ThreadedTransformTransition* const uninverted_transition_; |
596 | 592 |
597 DISALLOW_COPY_AND_ASSIGN(InverseTransformTransition); | 593 DISALLOW_COPY_AND_ASSIGN(InverseTransformTransition); |
598 }; | 594 }; |
599 | 595 |
600 } // namespace | 596 } // namespace |
601 | 597 |
602 // LayerAnimationElement::TargetValue ------------------------------------------ | 598 // LayerAnimationElement::TargetValue ------------------------------------------ |
603 | 599 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 } | 841 } |
846 | 842 |
847 // static | 843 // static |
848 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 844 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
849 SkColor color, | 845 SkColor color, |
850 base::TimeDelta duration) { | 846 base::TimeDelta duration) { |
851 return new ColorTransition(color, duration); | 847 return new ColorTransition(color, duration); |
852 } | 848 } |
853 | 849 |
854 } // namespace ui | 850 } // namespace ui |
OLD | NEW |