Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Side by Side Diff: ui/gfx/compositor/layer_animation_manager.h

Issue 8362006: Reland r107720 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_COMPOSITOR_LAYER_ANIMATION_MANAGER_H_
6 #define UI_GFX_COMPOSITOR_LAYER_ANIMATION_MANAGER_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "third_party/skia/include/core/SkScalar.h"
15 #include "third_party/skia/include/utils/SkMatrix44.h"
16 #include "ui/base/animation/animation_delegate.h"
17 #include "ui/gfx/compositor/compositor_export.h"
18
19 namespace gfx {
20 class Point;
21 }
22
23 namespace ui {
24
25 class Animation;
26 class Layer;
27 class LayerAnimatorDelegate;
28 class Transform;
29
30 // LayerAnimationManager manages animating various properties of a Layer.
31 class COMPOSITOR_EXPORT LayerAnimationManager : public ui::AnimationDelegate {
32 public:
33 // Types of properties that can be animated.
34 enum AnimationProperty {
35 LOCATION,
36 OPACITY,
37 TRANSFORM,
38 };
39
40 explicit LayerAnimationManager(Layer* layer);
41 virtual ~LayerAnimationManager();
42
43 // Sets the animation to use. LayerAnimationManager takes ownership of the
44 // animation.
45 void SetAnimation(Animation* animation);
46
47 ui::Layer* layer() { return layer_; }
48
49 // Animates the layer to the specified point. The point is relative to the
50 // parent layer.
51 void AnimateToPoint(const gfx::Point& target);
52
53 // Animates the transform from the current transform to |transform|.
54 void AnimateTransform(const Transform& transform);
55
56 // Animates the opacity from the current opacity to |target_opacity|.
57 void AnimateOpacity(float target_opacity);
58
59 // Returns the target value for the specified type. If the specified property
60 // is not animating, the current value is returned.
61 gfx::Point GetTargetPoint();
62 float GetTargetOpacity();
63 ui::Transform GetTargetTransform();
64
65 // Returns true if animating |property|.
66 bool IsAnimating(AnimationProperty property) const;
67
68 // Returns true if the animation is running.
69 bool IsRunning() const;
70
71 // Returns true if the animation has progressed at least once since
72 // SetAnimation() was invoked.
73 bool got_initial_tick() const { return got_initial_tick_; }
74
75 // AnimationDelegate:
76 virtual void AnimationProgressed(const Animation* animation) OVERRIDE;
77 virtual void AnimationEnded(const Animation* animation) OVERRIDE;
78
79 private:
80 // Parameters used when animating the location.
81 struct LocationParams {
82 int start_x;
83 int start_y;
84 int target_x;
85 int target_y;
86 };
87
88 // Parameters used when animating the transform.
89 struct TransformParams {
90 SkMScalar start[16];
91 SkMScalar target[16];
92 };
93
94 // Parameters used when animating the opacity.
95 struct OpacityParams {
96 float start;
97 float target;
98 };
99
100 union Params {
101 LocationParams location;
102 OpacityParams opacity;
103 TransformParams transform;
104 };
105
106 typedef std::map<AnimationProperty, Params> Elements;
107
108 // Stops animating the specified property. This does not set the property
109 // being animated to its final value.
110 void StopAnimating(AnimationProperty property);
111
112 LayerAnimatorDelegate* delegate();
113
114 // The layer.
115 Layer* layer_;
116
117 // Properties being animated.
118 Elements elements_;
119
120 scoped_ptr<ui::Animation> animation_;
121
122 bool got_initial_tick_;
123
124 DISALLOW_COPY_AND_ASSIGN(LayerAnimationManager);
125 };
126
127 } // namespace ui
128
129 #endif // UI_GFX_COMPOSITOR_LAYER_ANIMATION_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer_animation_element_unittest.cc ('k') | ui/gfx/compositor/layer_animation_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698