| 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 "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "ui/compositor/float_animation_curve_adapter.h" | 10 #include "ui/compositor/float_animation_curve_adapter.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 protected: | 334 protected: |
| 335 explicit ThreadedLayerAnimationElement(const LayerAnimationElement& element) | 335 explicit ThreadedLayerAnimationElement(const LayerAnimationElement& element) |
| 336 : LayerAnimationElement(element) { | 336 : LayerAnimationElement(element) { |
| 337 } | 337 } |
| 338 | 338 |
| 339 bool OnProgress(double t, LayerAnimationDelegate* delegate) override { | 339 bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
| 340 if (t < 1.0) | 340 if (t < 1.0) |
| 341 return false; | 341 return false; |
| 342 | 342 |
| 343 if (Started()) { | 343 if (Started() && IsThreaded()) { |
| 344 delegate->RemoveThreadedAnimation(animation_id()); | 344 delegate->RemoveThreadedAnimation(animation_id()); |
| 345 } | 345 } |
| 346 | 346 |
| 347 OnEnd(delegate); | 347 OnEnd(delegate); |
| 348 return true; | 348 return true; |
| 349 } | 349 } |
| 350 | 350 |
| 351 void OnAbort(LayerAnimationDelegate* delegate) override { | 351 void OnAbort(LayerAnimationDelegate* delegate) override { |
| 352 if (delegate && Started()) { | 352 if (delegate && Started() && IsThreaded()) { |
| 353 delegate->RemoveThreadedAnimation(animation_id()); | 353 delegate->RemoveThreadedAnimation(animation_id()); |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 | 356 |
| 357 void RequestEffectiveStart(LayerAnimationDelegate* delegate) override { | 357 void RequestEffectiveStart(LayerAnimationDelegate* delegate) override { |
| 358 DCHECK(animation_group_id()); | 358 DCHECK(animation_group_id()); |
| 359 if (duration() == base::TimeDelta()) { | 359 if (!IsThreaded()) { |
| 360 set_effective_start_time(requested_start_time()); | 360 set_effective_start_time(requested_start_time()); |
| 361 return; | 361 return; |
| 362 } | 362 } |
| 363 set_effective_start_time(base::TimeTicks()); | 363 set_effective_start_time(base::TimeTicks()); |
| 364 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); | 364 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); |
| 365 animation->set_needs_synchronized_start_time(true); | 365 animation->set_needs_synchronized_start_time(true); |
| 366 delegate->AddThreadedAnimation(animation.Pass()); | 366 delegate->AddThreadedAnimation(animation.Pass()); |
| 367 } | 367 } |
| 368 | 368 |
| 369 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0; | 369 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0; |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 } | 833 } |
| 834 | 834 |
| 835 // static | 835 // static |
| 836 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 836 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
| 837 SkColor color, | 837 SkColor color, |
| 838 base::TimeDelta duration) { | 838 base::TimeDelta duration) { |
| 839 return new ColorTransition(color, duration); | 839 return new ColorTransition(color, duration); |
| 840 } | 840 } |
| 841 | 841 |
| 842 } // namespace ui | 842 } // namespace ui |
| OLD | NEW |