| 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 #ifndef UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
| 6 #define UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 6 #define UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "cc/animation/layer_animation_event_observer.h" | 17 #include "cc/animation/layer_animation_event_observer.h" |
| 18 #include "ui/compositor/compositor_export.h" | 18 #include "ui/compositor/compositor_export.h" |
| 19 #include "ui/compositor/layer_animation_element.h" | 19 #include "ui/compositor/layer_animation_element.h" |
| 20 #include "ui/gfx/animation/tween.h" | 20 #include "ui/gfx/animation/tween.h" |
| 21 | 21 |
| 22 namespace cc { | 22 namespace cc { |
| 23 class Animation; |
| 24 class AnimationPlayer; |
| 25 class AnimationTimeline; |
| 23 class Layer; | 26 class Layer; |
| 24 } | 27 } |
| 25 | 28 |
| 26 namespace gfx { | 29 namespace gfx { |
| 27 class Animation; | 30 class Animation; |
| 28 class Rect; | 31 class Rect; |
| 29 class Transform; | 32 class Transform; |
| 30 } | 33 } |
| 31 | 34 |
| 32 namespace ui { | 35 namespace ui { |
| 36 class Compositor; |
| 33 class Layer; | 37 class Layer; |
| 34 class LayerAnimationSequence; | 38 class LayerAnimationSequence; |
| 35 class LayerAnimationDelegate; | 39 class LayerAnimationDelegate; |
| 36 class LayerAnimationObserver; | 40 class LayerAnimationObserver; |
| 37 class LayerAnimatorCollection; | 41 class LayerAnimatorCollection; |
| 38 class ScopedLayerAnimationSettings; | 42 class ScopedLayerAnimationSettings; |
| 39 | 43 |
| 40 // When a property of layer needs to be changed it is set by way of | 44 // When a property of layer needs to be changed it is set by way of |
| 41 // LayerAnimator. This enables LayerAnimator to animate property changes. | 45 // LayerAnimator. This enables LayerAnimator to animate property changes. |
| 42 // NB: during many tests, set_disable_animations_for_test is used and causes | 46 // NB: during many tests, set_disable_animations_for_test is used and causes |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 104 |
| 101 // Sets the layer animation delegate the animator is associated with. The | 105 // Sets the layer animation delegate the animator is associated with. The |
| 102 // animator does not own the delegate. The layer animator expects a non-NULL | 106 // animator does not own the delegate. The layer animator expects a non-NULL |
| 103 // delegate for most of its operations, so do not call any methods without | 107 // delegate for most of its operations, so do not call any methods without |
| 104 // a valid delegate installed. | 108 // a valid delegate installed. |
| 105 void SetDelegate(LayerAnimationDelegate* delegate); | 109 void SetDelegate(LayerAnimationDelegate* delegate); |
| 106 | 110 |
| 107 // Unsubscribe from |cc_layer_| and subscribe to |new_layer|. | 111 // Unsubscribe from |cc_layer_| and subscribe to |new_layer|. |
| 108 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); | 112 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); |
| 109 | 113 |
| 114 // Attach AnimationPlayer to Layer and AnimationTimeline |
| 115 void SetCompositor(Compositor* compositor); |
| 116 // Detach AnimationPlayer to Layer and AnimationTimeline |
| 117 void ResetCompositor(Compositor* compositor); |
| 118 |
| 119 // TODO(loyso): Rework it as an implementation for |
| 120 // LayerThreadedAnimationDelegate and make it private. |
| 121 void AddThreadedAnimation(scoped_ptr<cc::Animation> animation); |
| 122 void RemoveThreadedAnimation(int animation_id); |
| 123 |
| 110 // Sets the animation preemption strategy. This determines the behaviour if | 124 // Sets the animation preemption strategy. This determines the behaviour if |
| 111 // a property is set during an animation. The default is | 125 // a property is set during an animation. The default is |
| 112 // IMMEDIATELY_SET_NEW_TARGET (see ImmediatelySetNewTarget below). | 126 // IMMEDIATELY_SET_NEW_TARGET (see ImmediatelySetNewTarget below). |
| 113 void set_preemption_strategy(PreemptionStrategy strategy) { | 127 void set_preemption_strategy(PreemptionStrategy strategy) { |
| 114 preemption_strategy_ = strategy; | 128 preemption_strategy_ = strategy; |
| 115 } | 129 } |
| 116 | 130 |
| 117 PreemptionStrategy preemption_strategy() const { | 131 PreemptionStrategy preemption_strategy() const { |
| 118 return preemption_strategy_; | 132 return preemption_strategy_; |
| 119 } | 133 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 void ClearAnimationsInternal(); | 331 void ClearAnimationsInternal(); |
| 318 | 332 |
| 319 // Cleans up any running animations that may have been deleted. | 333 // Cleans up any running animations that may have been deleted. |
| 320 void PurgeDeletedAnimations(); | 334 void PurgeDeletedAnimations(); |
| 321 | 335 |
| 322 LayerAnimatorCollection* GetLayerAnimatorCollection(); | 336 LayerAnimatorCollection* GetLayerAnimatorCollection(); |
| 323 | 337 |
| 324 // LayerAnimationEventObserver | 338 // LayerAnimationEventObserver |
| 325 void OnAnimationStarted(const cc::AnimationEvent& event) override; | 339 void OnAnimationStarted(const cc::AnimationEvent& event) override; |
| 326 | 340 |
| 341 void AttachLayerToAnimationPlayer(int layer_id); |
| 342 void DetachLayerFromAnimationPlayer(); |
| 343 |
| 327 // This is the queue of animations to run. | 344 // This is the queue of animations to run. |
| 328 AnimationQueue animation_queue_; | 345 AnimationQueue animation_queue_; |
| 329 | 346 |
| 330 // The target of all layer animations. | 347 // The target of all layer animations. |
| 331 LayerAnimationDelegate* delegate_; | 348 LayerAnimationDelegate* delegate_; |
| 332 | 349 |
| 350 // Plays CC animations. |
| 351 scoped_refptr<cc::AnimationPlayer> animation_player_; |
| 352 |
| 333 // The currently running animations. | 353 // The currently running animations. |
| 334 RunningAnimations running_animations_; | 354 RunningAnimations running_animations_; |
| 335 | 355 |
| 336 // Determines how animations are replaced. | 356 // Determines how animations are replaced. |
| 337 PreemptionStrategy preemption_strategy_; | 357 PreemptionStrategy preemption_strategy_; |
| 338 | 358 |
| 339 // Whether the length of animations is locked. While it is locked | 359 // Whether the length of animations is locked. While it is locked |
| 340 // SetTransitionDuration does not set |transition_duration_|. | 360 // SetTransitionDuration does not set |transition_duration_|. |
| 341 bool is_transition_duration_locked_; | 361 bool is_transition_duration_locked_; |
| 342 | 362 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 363 // Observers are notified when layer animations end, are scheduled or are | 383 // Observers are notified when layer animations end, are scheduled or are |
| 364 // aborted. | 384 // aborted. |
| 365 base::ObserverList<LayerAnimationObserver> observers_; | 385 base::ObserverList<LayerAnimationObserver> observers_; |
| 366 | 386 |
| 367 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); | 387 DISALLOW_COPY_AND_ASSIGN(LayerAnimator); |
| 368 }; | 388 }; |
| 369 | 389 |
| 370 } // namespace ui | 390 } // namespace ui |
| 371 | 391 |
| 372 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ | 392 #endif // UI_COMPOSITOR_LAYER_ANIMATOR_H_ |
| OLD | NEW |