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

Side by Side Diff: ui/gfx/compositor/layer_animation_element.cc

Issue 8362006: Reland r107720 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address reviewer comments. Created 9 years, 2 months 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/gfx/compositor/layer_animation_element.h" 5 #include "ui/gfx/compositor/layer_animation_element.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "ui/base/animation/tween.h" 8 #include "ui/base/animation/tween.h"
9 #include "ui/gfx/compositor/layer_animation_delegate.h" 9 #include "ui/gfx/compositor/layer_animation_delegate.h"
10 #include "ui/gfx/rect.h"
11 #include "ui/gfx/transform.h"
12 10
13 namespace ui { 11 namespace ui {
14 12
15 namespace { 13 namespace {
16 14
17 // Pause ----------------------------------------------------------------------- 15 // Pause -----------------------------------------------------------------------
18 class Pause : public LayerAnimationElement { 16 class Pause : public LayerAnimationElement {
19 public: 17 public:
20 Pause(const AnimatableProperties& properties, base::TimeDelta duration) 18 Pause(const AnimatableProperties& properties, base::TimeDelta duration)
21 : LayerAnimationElement(properties, duration) { 19 : LayerAnimationElement(properties, duration) {
22 } 20 }
23 virtual ~Pause() {} 21 virtual ~Pause() {}
24 22
25 private: 23 private:
26 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {} 24 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {}
27 virtual void OnProgress(double t, 25 virtual void OnProgress(double t,
28 LayerAnimationDelegate* delegate) OVERRIDE {} 26 LayerAnimationDelegate* delegate) OVERRIDE {}
27 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {}
29 virtual void OnAbort() OVERRIDE {} 28 virtual void OnAbort() OVERRIDE {}
30 29
31 DISALLOW_COPY_AND_ASSIGN(Pause); 30 DISALLOW_COPY_AND_ASSIGN(Pause);
32 }; 31 };
33 32
34 // TransformTransition --------------------------------------------------------- 33 // TransformTransition ---------------------------------------------------------
35 34
36 class TransformTransition : public LayerAnimationElement { 35 class TransformTransition : public LayerAnimationElement {
37 public: 36 public:
38 TransformTransition(const Transform& target, base::TimeDelta duration) 37 TransformTransition(const Transform& target, base::TimeDelta duration)
39 : LayerAnimationElement(GetProperties(), duration), 38 : LayerAnimationElement(GetProperties(), duration),
40 target_(target) { 39 target_(target) {
41 } 40 }
42 virtual ~TransformTransition() {} 41 virtual ~TransformTransition() {}
43 42
44 protected: 43 protected:
45 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { 44 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
46 start_ = delegate->GetTransformForAnimation(); 45 start_ = delegate->GetTransformForAnimation();
47 } 46 }
48 47
49 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 48 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
50 delegate->SetTransformFromAnimation( 49 delegate->SetTransformFromAnimation(
51 Tween::ValueBetween(t, start_, target_)); 50 Tween::ValueBetween(t, start_, target_));
52 } 51 }
53 52
53 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
54 target->transform = target_;
55 }
56
54 virtual void OnAbort() OVERRIDE {} 57 virtual void OnAbort() OVERRIDE {}
55 58
56 private: 59 private:
57 static const AnimatableProperties& GetProperties() { 60 static const AnimatableProperties& GetProperties() {
58 static AnimatableProperties properties; 61 static AnimatableProperties properties;
59 if (properties.size() == 0) 62 if (properties.size() == 0)
60 properties.insert(LayerAnimationElement::TRANSFORM); 63 properties.insert(LayerAnimationElement::TRANSFORM);
61 return properties; 64 return properties;
62 } 65 }
63 66
(...skipping 15 matching lines...) Expand all
79 82
80 protected: 83 protected:
81 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { 84 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
82 start_ = delegate->GetBoundsForAnimation(); 85 start_ = delegate->GetBoundsForAnimation();
83 } 86 }
84 87
85 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 88 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
86 delegate->SetBoundsFromAnimation(Tween::ValueBetween(t, start_, target_)); 89 delegate->SetBoundsFromAnimation(Tween::ValueBetween(t, start_, target_));
87 } 90 }
88 91
92 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
93 target->bounds = target_;
94 }
95
89 virtual void OnAbort() OVERRIDE {} 96 virtual void OnAbort() OVERRIDE {}
90 97
91 private: 98 private:
92 static const AnimatableProperties& GetProperties() { 99 static const AnimatableProperties& GetProperties() {
93 static AnimatableProperties properties; 100 static AnimatableProperties properties;
94 if (properties.size() == 0) 101 if (properties.size() == 0)
95 properties.insert(LayerAnimationElement::BOUNDS); 102 properties.insert(LayerAnimationElement::BOUNDS);
96 return properties; 103 return properties;
97 } 104 }
98 105
(...skipping 13 matching lines...) Expand all
112 119
113 protected: 120 protected:
114 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { 121 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
115 start_ = delegate->GetOpacityForAnimation(); 122 start_ = delegate->GetOpacityForAnimation();
116 } 123 }
117 124
118 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 125 virtual void OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
119 delegate->SetOpacityFromAnimation(Tween::ValueBetween(t, start_, target_)); 126 delegate->SetOpacityFromAnimation(Tween::ValueBetween(t, start_, target_));
120 } 127 }
121 128
129 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
130 target->opacity = target_;
131 }
132
122 virtual void OnAbort() OVERRIDE {} 133 virtual void OnAbort() OVERRIDE {}
123 134
124 private: 135 private:
125 static const AnimatableProperties& GetProperties() { 136 static const AnimatableProperties& GetProperties() {
126 static AnimatableProperties properties; 137 static AnimatableProperties properties;
127 if (properties.size() == 0) 138 if (properties.size() == 0)
128 properties.insert(LayerAnimationElement::OPACITY); 139 properties.insert(LayerAnimationElement::OPACITY);
129 return properties; 140 return properties;
130 } 141 }
131 142
(...skipping 16 matching lines...) Expand all
148 } 159 }
149 160
150 LayerAnimationElement::~LayerAnimationElement() { 161 LayerAnimationElement::~LayerAnimationElement() {
151 } 162 }
152 163
153 void LayerAnimationElement::Progress(double t, 164 void LayerAnimationElement::Progress(double t,
154 LayerAnimationDelegate* delegate) { 165 LayerAnimationDelegate* delegate) {
155 if (first_frame_) 166 if (first_frame_)
156 OnStart(delegate); 167 OnStart(delegate);
157 OnProgress(t, delegate); 168 OnProgress(t, delegate);
169 delegate->ScheduleDrawForAnimation();
158 first_frame_ = t == 1.0; 170 first_frame_ = t == 1.0;
159 } 171 }
160 172
173 void LayerAnimationElement::GetTargetValue(TargetValue* target) const {
174 OnGetTarget(target);
175 }
176
161 void LayerAnimationElement::Abort() { 177 void LayerAnimationElement::Abort() {
162 first_frame_ = true; 178 first_frame_ = true;
163 OnAbort(); 179 OnAbort();
164 } 180 }
165 181
166 // static 182 // static
167 LayerAnimationElement* LayerAnimationElement::CreateTransformElement( 183 LayerAnimationElement* LayerAnimationElement::CreateTransformElement(
168 const Transform& transform, base::TimeDelta duration) { 184 const Transform& transform, base::TimeDelta duration) {
169 return new TransformTransition(transform, duration); 185 return new TransformTransition(transform, duration);
170 } 186 }
(...skipping 10 matching lines...) Expand all
181 return new OpacityTransition(opacity, duration); 197 return new OpacityTransition(opacity, duration);
182 } 198 }
183 199
184 // static 200 // static
185 LayerAnimationElement* LayerAnimationElement::CreatePauseElement( 201 LayerAnimationElement* LayerAnimationElement::CreatePauseElement(
186 const AnimatableProperties& properties, base::TimeDelta duration) { 202 const AnimatableProperties& properties, base::TimeDelta duration) {
187 return new Pause(properties, duration); 203 return new Pause(properties, duration);
188 } 204 }
189 205
190 } // namespace ui 206 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698