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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // Pause ----------------------------------------------------------------------- | 29 // Pause ----------------------------------------------------------------------- |
30 class Pause : public LayerAnimationElement { | 30 class Pause : public LayerAnimationElement { |
31 public: | 31 public: |
32 Pause(AnimatableProperties properties, base::TimeDelta duration) | 32 Pause(AnimatableProperties properties, base::TimeDelta duration) |
33 : LayerAnimationElement(properties, duration) { | 33 : LayerAnimationElement(properties, duration) { |
34 } | 34 } |
35 virtual ~Pause() {} | 35 virtual ~Pause() {} |
36 | 36 |
37 private: | 37 private: |
38 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {} | 38 virtual void OnStart(LayerAnimationDelegate* delegate) override {} |
39 virtual bool OnProgress(double t, | 39 virtual bool OnProgress(double t, |
40 LayerAnimationDelegate* delegate) OVERRIDE { | 40 LayerAnimationDelegate* delegate) override { |
41 return false; | 41 return false; |
42 } | 42 } |
43 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {} | 43 virtual void OnGetTarget(TargetValue* target) const override {} |
44 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 44 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(Pause); | 46 DISALLOW_COPY_AND_ASSIGN(Pause); |
47 }; | 47 }; |
48 | 48 |
49 // TransformTransition --------------------------------------------------------- | 49 // TransformTransition --------------------------------------------------------- |
50 | 50 |
51 class TransformTransition : public LayerAnimationElement { | 51 class TransformTransition : public LayerAnimationElement { |
52 public: | 52 public: |
53 TransformTransition(const gfx::Transform& target, base::TimeDelta duration) | 53 TransformTransition(const gfx::Transform& target, base::TimeDelta duration) |
54 : LayerAnimationElement(TRANSFORM, duration), | 54 : LayerAnimationElement(TRANSFORM, duration), |
55 target_(target) { | 55 target_(target) { |
56 } | 56 } |
57 virtual ~TransformTransition() {} | 57 virtual ~TransformTransition() {} |
58 | 58 |
59 protected: | 59 protected: |
60 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 60 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
61 start_ = delegate->GetTransformForAnimation(); | 61 start_ = delegate->GetTransformForAnimation(); |
62 } | 62 } |
63 | 63 |
64 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 64 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
65 delegate->SetTransformFromAnimation( | 65 delegate->SetTransformFromAnimation( |
66 gfx::Tween::TransformValueBetween(t, start_, target_)); | 66 gfx::Tween::TransformValueBetween(t, start_, target_)); |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 70 virtual void OnGetTarget(TargetValue* target) const override { |
71 target->transform = target_; | 71 target->transform = target_; |
72 } | 72 } |
73 | 73 |
74 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 74 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
75 | 75 |
76 private: | 76 private: |
77 gfx::Transform start_; | 77 gfx::Transform start_; |
78 const gfx::Transform target_; | 78 const gfx::Transform target_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(TransformTransition); | 80 DISALLOW_COPY_AND_ASSIGN(TransformTransition); |
81 }; | 81 }; |
82 | 82 |
83 // InterpolatedTransformTransition --------------------------------------------- | 83 // InterpolatedTransformTransition --------------------------------------------- |
84 | 84 |
85 class InterpolatedTransformTransition : public LayerAnimationElement { | 85 class InterpolatedTransformTransition : public LayerAnimationElement { |
86 public: | 86 public: |
87 InterpolatedTransformTransition(InterpolatedTransform* interpolated_transform, | 87 InterpolatedTransformTransition(InterpolatedTransform* interpolated_transform, |
88 base::TimeDelta duration) | 88 base::TimeDelta duration) |
89 : LayerAnimationElement(TRANSFORM, duration), | 89 : LayerAnimationElement(TRANSFORM, duration), |
90 interpolated_transform_(interpolated_transform) { | 90 interpolated_transform_(interpolated_transform) { |
91 } | 91 } |
92 virtual ~InterpolatedTransformTransition() {} | 92 virtual ~InterpolatedTransformTransition() {} |
93 | 93 |
94 protected: | 94 protected: |
95 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 95 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
96 } | 96 } |
97 | 97 |
98 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 98 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
99 delegate->SetTransformFromAnimation( | 99 delegate->SetTransformFromAnimation( |
100 interpolated_transform_->Interpolate(static_cast<float>(t))); | 100 interpolated_transform_->Interpolate(static_cast<float>(t))); |
101 return true; | 101 return true; |
102 } | 102 } |
103 | 103 |
104 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 104 virtual void OnGetTarget(TargetValue* target) const override { |
105 target->transform = interpolated_transform_->Interpolate(1.0f); | 105 target->transform = interpolated_transform_->Interpolate(1.0f); |
106 } | 106 } |
107 | 107 |
108 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 108 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
109 | 109 |
110 private: | 110 private: |
111 scoped_ptr<InterpolatedTransform> interpolated_transform_; | 111 scoped_ptr<InterpolatedTransform> interpolated_transform_; |
112 | 112 |
113 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition); | 113 DISALLOW_COPY_AND_ASSIGN(InterpolatedTransformTransition); |
114 }; | 114 }; |
115 | 115 |
116 // BoundsTransition ------------------------------------------------------------ | 116 // BoundsTransition ------------------------------------------------------------ |
117 | 117 |
118 class BoundsTransition : public LayerAnimationElement { | 118 class BoundsTransition : public LayerAnimationElement { |
119 public: | 119 public: |
120 BoundsTransition(const gfx::Rect& target, base::TimeDelta duration) | 120 BoundsTransition(const gfx::Rect& target, base::TimeDelta duration) |
121 : LayerAnimationElement(BOUNDS, duration), | 121 : LayerAnimationElement(BOUNDS, duration), |
122 target_(target) { | 122 target_(target) { |
123 } | 123 } |
124 virtual ~BoundsTransition() {} | 124 virtual ~BoundsTransition() {} |
125 | 125 |
126 protected: | 126 protected: |
127 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 127 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
128 start_ = delegate->GetBoundsForAnimation(); | 128 start_ = delegate->GetBoundsForAnimation(); |
129 } | 129 } |
130 | 130 |
131 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 131 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
132 delegate->SetBoundsFromAnimation( | 132 delegate->SetBoundsFromAnimation( |
133 gfx::Tween::RectValueBetween(t, start_, target_)); | 133 gfx::Tween::RectValueBetween(t, start_, target_)); |
134 return true; | 134 return true; |
135 } | 135 } |
136 | 136 |
137 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 137 virtual void OnGetTarget(TargetValue* target) const override { |
138 target->bounds = target_; | 138 target->bounds = target_; |
139 } | 139 } |
140 | 140 |
141 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 141 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
142 | 142 |
143 private: | 143 private: |
144 gfx::Rect start_; | 144 gfx::Rect start_; |
145 const gfx::Rect target_; | 145 const gfx::Rect target_; |
146 | 146 |
147 DISALLOW_COPY_AND_ASSIGN(BoundsTransition); | 147 DISALLOW_COPY_AND_ASSIGN(BoundsTransition); |
148 }; | 148 }; |
149 | 149 |
150 // OpacityTransition ----------------------------------------------------------- | 150 // OpacityTransition ----------------------------------------------------------- |
151 | 151 |
152 class OpacityTransition : public LayerAnimationElement { | 152 class OpacityTransition : public LayerAnimationElement { |
153 public: | 153 public: |
154 OpacityTransition(float target, base::TimeDelta duration) | 154 OpacityTransition(float target, base::TimeDelta duration) |
155 : LayerAnimationElement(OPACITY, duration), | 155 : LayerAnimationElement(OPACITY, duration), |
156 start_(0.0f), | 156 start_(0.0f), |
157 target_(target) { | 157 target_(target) { |
158 } | 158 } |
159 virtual ~OpacityTransition() {} | 159 virtual ~OpacityTransition() {} |
160 | 160 |
161 protected: | 161 protected: |
162 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 162 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
163 start_ = delegate->GetOpacityForAnimation(); | 163 start_ = delegate->GetOpacityForAnimation(); |
164 } | 164 } |
165 | 165 |
166 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 166 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
167 delegate->SetOpacityFromAnimation( | 167 delegate->SetOpacityFromAnimation( |
168 gfx::Tween::FloatValueBetween(t, start_, target_)); | 168 gfx::Tween::FloatValueBetween(t, start_, target_)); |
169 return true; | 169 return true; |
170 } | 170 } |
171 | 171 |
172 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 172 virtual void OnGetTarget(TargetValue* target) const override { |
173 target->opacity = target_; | 173 target->opacity = target_; |
174 } | 174 } |
175 | 175 |
176 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 176 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
177 | 177 |
178 private: | 178 private: |
179 float start_; | 179 float start_; |
180 const float target_; | 180 const float target_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(OpacityTransition); | 182 DISALLOW_COPY_AND_ASSIGN(OpacityTransition); |
183 }; | 183 }; |
184 | 184 |
185 // VisibilityTransition -------------------------------------------------------- | 185 // VisibilityTransition -------------------------------------------------------- |
186 | 186 |
187 class VisibilityTransition : public LayerAnimationElement { | 187 class VisibilityTransition : public LayerAnimationElement { |
188 public: | 188 public: |
189 VisibilityTransition(bool target, base::TimeDelta duration) | 189 VisibilityTransition(bool target, base::TimeDelta duration) |
190 : LayerAnimationElement(VISIBILITY, duration), | 190 : LayerAnimationElement(VISIBILITY, duration), |
191 start_(false), | 191 start_(false), |
192 target_(target) { | 192 target_(target) { |
193 } | 193 } |
194 virtual ~VisibilityTransition() {} | 194 virtual ~VisibilityTransition() {} |
195 | 195 |
196 protected: | 196 protected: |
197 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 197 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
198 start_ = delegate->GetVisibilityForAnimation(); | 198 start_ = delegate->GetVisibilityForAnimation(); |
199 } | 199 } |
200 | 200 |
201 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 201 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
202 delegate->SetVisibilityFromAnimation(t == 1.0 ? target_ : start_); | 202 delegate->SetVisibilityFromAnimation(t == 1.0 ? target_ : start_); |
203 return t == 1.0; | 203 return t == 1.0; |
204 } | 204 } |
205 | 205 |
206 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 206 virtual void OnGetTarget(TargetValue* target) const override { |
207 target->visibility = target_; | 207 target->visibility = target_; |
208 } | 208 } |
209 | 209 |
210 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 210 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
211 | 211 |
212 private: | 212 private: |
213 bool start_; | 213 bool start_; |
214 const bool target_; | 214 const bool target_; |
215 | 215 |
216 DISALLOW_COPY_AND_ASSIGN(VisibilityTransition); | 216 DISALLOW_COPY_AND_ASSIGN(VisibilityTransition); |
217 }; | 217 }; |
218 | 218 |
219 // BrightnessTransition -------------------------------------------------------- | 219 // BrightnessTransition -------------------------------------------------------- |
220 | 220 |
221 class BrightnessTransition : public LayerAnimationElement { | 221 class BrightnessTransition : public LayerAnimationElement { |
222 public: | 222 public: |
223 BrightnessTransition(float target, base::TimeDelta duration) | 223 BrightnessTransition(float target, base::TimeDelta duration) |
224 : LayerAnimationElement(BRIGHTNESS, duration), | 224 : LayerAnimationElement(BRIGHTNESS, duration), |
225 start_(0.0f), | 225 start_(0.0f), |
226 target_(target) { | 226 target_(target) { |
227 } | 227 } |
228 virtual ~BrightnessTransition() {} | 228 virtual ~BrightnessTransition() {} |
229 | 229 |
230 protected: | 230 protected: |
231 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 231 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
232 start_ = delegate->GetBrightnessForAnimation(); | 232 start_ = delegate->GetBrightnessForAnimation(); |
233 } | 233 } |
234 | 234 |
235 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 235 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
236 delegate->SetBrightnessFromAnimation( | 236 delegate->SetBrightnessFromAnimation( |
237 gfx::Tween::FloatValueBetween(t, start_, target_)); | 237 gfx::Tween::FloatValueBetween(t, start_, target_)); |
238 return true; | 238 return true; |
239 } | 239 } |
240 | 240 |
241 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 241 virtual void OnGetTarget(TargetValue* target) const override { |
242 target->brightness = target_; | 242 target->brightness = target_; |
243 } | 243 } |
244 | 244 |
245 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 245 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
246 | 246 |
247 private: | 247 private: |
248 float start_; | 248 float start_; |
249 const float target_; | 249 const float target_; |
250 | 250 |
251 DISALLOW_COPY_AND_ASSIGN(BrightnessTransition); | 251 DISALLOW_COPY_AND_ASSIGN(BrightnessTransition); |
252 }; | 252 }; |
253 | 253 |
254 // GrayscaleTransition --------------------------------------------------------- | 254 // GrayscaleTransition --------------------------------------------------------- |
255 | 255 |
256 class GrayscaleTransition : public LayerAnimationElement { | 256 class GrayscaleTransition : public LayerAnimationElement { |
257 public: | 257 public: |
258 GrayscaleTransition(float target, base::TimeDelta duration) | 258 GrayscaleTransition(float target, base::TimeDelta duration) |
259 : LayerAnimationElement(GRAYSCALE, duration), | 259 : LayerAnimationElement(GRAYSCALE, duration), |
260 start_(0.0f), | 260 start_(0.0f), |
261 target_(target) { | 261 target_(target) { |
262 } | 262 } |
263 virtual ~GrayscaleTransition() {} | 263 virtual ~GrayscaleTransition() {} |
264 | 264 |
265 protected: | 265 protected: |
266 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 266 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
267 start_ = delegate->GetGrayscaleForAnimation(); | 267 start_ = delegate->GetGrayscaleForAnimation(); |
268 } | 268 } |
269 | 269 |
270 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 270 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
271 delegate->SetGrayscaleFromAnimation( | 271 delegate->SetGrayscaleFromAnimation( |
272 gfx::Tween::FloatValueBetween(t, start_, target_)); | 272 gfx::Tween::FloatValueBetween(t, start_, target_)); |
273 return true; | 273 return true; |
274 } | 274 } |
275 | 275 |
276 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 276 virtual void OnGetTarget(TargetValue* target) const override { |
277 target->grayscale = target_; | 277 target->grayscale = target_; |
278 } | 278 } |
279 | 279 |
280 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 280 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
281 | 281 |
282 private: | 282 private: |
283 float start_; | 283 float start_; |
284 const float target_; | 284 const float target_; |
285 | 285 |
286 DISALLOW_COPY_AND_ASSIGN(GrayscaleTransition); | 286 DISALLOW_COPY_AND_ASSIGN(GrayscaleTransition); |
287 }; | 287 }; |
288 | 288 |
289 // ColorTransition ------------------------------------------------------------- | 289 // ColorTransition ------------------------------------------------------------- |
290 | 290 |
291 class ColorTransition : public LayerAnimationElement { | 291 class ColorTransition : public LayerAnimationElement { |
292 public: | 292 public: |
293 ColorTransition(SkColor target, base::TimeDelta duration) | 293 ColorTransition(SkColor target, base::TimeDelta duration) |
294 : LayerAnimationElement(COLOR, duration), | 294 : LayerAnimationElement(COLOR, duration), |
295 start_(SK_ColorBLACK), | 295 start_(SK_ColorBLACK), |
296 target_(target) { | 296 target_(target) { |
297 } | 297 } |
298 virtual ~ColorTransition() {} | 298 virtual ~ColorTransition() {} |
299 | 299 |
300 protected: | 300 protected: |
301 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 301 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
302 start_ = delegate->GetColorForAnimation(); | 302 start_ = delegate->GetColorForAnimation(); |
303 } | 303 } |
304 | 304 |
305 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { | 305 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) override { |
306 delegate->SetColorFromAnimation( | 306 delegate->SetColorFromAnimation( |
307 gfx::Tween::ColorValueBetween(t, start_, target_)); | 307 gfx::Tween::ColorValueBetween(t, start_, target_)); |
308 return true; | 308 return true; |
309 } | 309 } |
310 | 310 |
311 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 311 virtual void OnGetTarget(TargetValue* target) const override { |
312 target->color = target_; | 312 target->color = target_; |
313 } | 313 } |
314 | 314 |
315 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {} | 315 virtual void OnAbort(LayerAnimationDelegate* delegate) override {} |
316 | 316 |
317 private: | 317 private: |
318 SkColor start_; | 318 SkColor start_; |
319 const SkColor target_; | 319 const SkColor target_; |
320 | 320 |
321 DISALLOW_COPY_AND_ASSIGN(ColorTransition); | 321 DISALLOW_COPY_AND_ASSIGN(ColorTransition); |
322 }; | 322 }; |
323 | 323 |
324 // ThreadedLayerAnimationElement ----------------------------------------------- | 324 // ThreadedLayerAnimationElement ----------------------------------------------- |
325 | 325 |
326 class ThreadedLayerAnimationElement : public LayerAnimationElement { | 326 class ThreadedLayerAnimationElement : public LayerAnimationElement { |
327 public: | 327 public: |
328 ThreadedLayerAnimationElement(AnimatableProperties properties, | 328 ThreadedLayerAnimationElement(AnimatableProperties properties, |
329 base::TimeDelta duration) | 329 base::TimeDelta duration) |
330 : LayerAnimationElement(properties, duration) { | 330 : LayerAnimationElement(properties, duration) { |
331 } | 331 } |
332 virtual ~ThreadedLayerAnimationElement() {} | 332 virtual ~ThreadedLayerAnimationElement() {} |
333 | 333 |
334 virtual bool IsThreaded() const OVERRIDE { | 334 virtual bool IsThreaded() const override { |
335 return (duration() != base::TimeDelta()); | 335 return (duration() != base::TimeDelta()); |
336 } | 336 } |
337 | 337 |
338 protected: | 338 protected: |
339 explicit ThreadedLayerAnimationElement(const LayerAnimationElement& element) | 339 explicit ThreadedLayerAnimationElement(const LayerAnimationElement& element) |
340 : LayerAnimationElement(element) { | 340 : LayerAnimationElement(element) { |
341 } | 341 } |
342 | 342 |
343 virtual bool OnProgress(double t, | 343 virtual bool OnProgress(double t, |
344 LayerAnimationDelegate* delegate) OVERRIDE { | 344 LayerAnimationDelegate* delegate) override { |
345 if (t < 1.0) | 345 if (t < 1.0) |
346 return false; | 346 return false; |
347 | 347 |
348 if (Started()) { | 348 if (Started()) { |
349 delegate->RemoveThreadedAnimation(animation_id()); | 349 delegate->RemoveThreadedAnimation(animation_id()); |
350 } | 350 } |
351 | 351 |
352 OnEnd(delegate); | 352 OnEnd(delegate); |
353 return true; | 353 return true; |
354 } | 354 } |
355 | 355 |
356 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE { | 356 virtual void OnAbort(LayerAnimationDelegate* delegate) override { |
357 if (delegate && Started()) { | 357 if (delegate && Started()) { |
358 delegate->RemoveThreadedAnimation(animation_id()); | 358 delegate->RemoveThreadedAnimation(animation_id()); |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 virtual void RequestEffectiveStart( | 362 virtual void RequestEffectiveStart( |
363 LayerAnimationDelegate* delegate) OVERRIDE { | 363 LayerAnimationDelegate* delegate) override { |
364 DCHECK(animation_group_id()); | 364 DCHECK(animation_group_id()); |
365 if (duration() == base::TimeDelta()) { | 365 if (duration() == base::TimeDelta()) { |
366 set_effective_start_time(requested_start_time()); | 366 set_effective_start_time(requested_start_time()); |
367 return; | 367 return; |
368 } | 368 } |
369 set_effective_start_time(base::TimeTicks()); | 369 set_effective_start_time(base::TimeTicks()); |
370 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); | 370 scoped_ptr<cc::Animation> animation = CreateCCAnimation(); |
371 animation->set_needs_synchronized_start_time(true); | 371 animation->set_needs_synchronized_start_time(true); |
372 delegate->AddThreadedAnimation(animation.Pass()); | 372 delegate->AddThreadedAnimation(animation.Pass()); |
373 } | 373 } |
(...skipping 11 matching lines...) Expand all Loading... |
385 class ThreadedOpacityTransition : public ThreadedLayerAnimationElement { | 385 class ThreadedOpacityTransition : public ThreadedLayerAnimationElement { |
386 public: | 386 public: |
387 ThreadedOpacityTransition(float target, base::TimeDelta duration) | 387 ThreadedOpacityTransition(float target, base::TimeDelta duration) |
388 : ThreadedLayerAnimationElement(OPACITY, duration), | 388 : ThreadedLayerAnimationElement(OPACITY, duration), |
389 start_(0.0f), | 389 start_(0.0f), |
390 target_(target) { | 390 target_(target) { |
391 } | 391 } |
392 virtual ~ThreadedOpacityTransition() {} | 392 virtual ~ThreadedOpacityTransition() {} |
393 | 393 |
394 protected: | 394 protected: |
395 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 395 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
396 start_ = delegate->GetOpacityForAnimation(); | 396 start_ = delegate->GetOpacityForAnimation(); |
397 } | 397 } |
398 | 398 |
399 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE { | 399 virtual void OnAbort(LayerAnimationDelegate* delegate) override { |
400 if (delegate && Started()) { | 400 if (delegate && Started()) { |
401 ThreadedLayerAnimationElement::OnAbort(delegate); | 401 ThreadedLayerAnimationElement::OnAbort(delegate); |
402 delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween( | 402 delegate->SetOpacityFromAnimation(gfx::Tween::FloatValueBetween( |
403 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), | 403 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
404 start_, | 404 start_, |
405 target_)); | 405 target_)); |
406 } | 406 } |
407 } | 407 } |
408 | 408 |
409 virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE { | 409 virtual void OnEnd(LayerAnimationDelegate* delegate) override { |
410 delegate->SetOpacityFromAnimation(target_); | 410 delegate->SetOpacityFromAnimation(target_); |
411 } | 411 } |
412 | 412 |
413 virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE { | 413 virtual scoped_ptr<cc::Animation> CreateCCAnimation() override { |
414 scoped_ptr<cc::AnimationCurve> animation_curve( | 414 scoped_ptr<cc::AnimationCurve> animation_curve( |
415 new FloatAnimationCurveAdapter(tween_type(), | 415 new FloatAnimationCurveAdapter(tween_type(), |
416 start_, | 416 start_, |
417 target_, | 417 target_, |
418 duration())); | 418 duration())); |
419 scoped_ptr<cc::Animation> animation( | 419 scoped_ptr<cc::Animation> animation( |
420 cc::Animation::Create(animation_curve.Pass(), | 420 cc::Animation::Create(animation_curve.Pass(), |
421 animation_id(), | 421 animation_id(), |
422 animation_group_id(), | 422 animation_group_id(), |
423 cc::Animation::Opacity)); | 423 cc::Animation::Opacity)); |
424 return animation.Pass(); | 424 return animation.Pass(); |
425 } | 425 } |
426 | 426 |
427 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 427 virtual void OnGetTarget(TargetValue* target) const override { |
428 target->opacity = target_; | 428 target->opacity = target_; |
429 } | 429 } |
430 | 430 |
431 private: | 431 private: |
432 float start_; | 432 float start_; |
433 const float target_; | 433 const float target_; |
434 | 434 |
435 DISALLOW_COPY_AND_ASSIGN(ThreadedOpacityTransition); | 435 DISALLOW_COPY_AND_ASSIGN(ThreadedOpacityTransition); |
436 }; | 436 }; |
437 | 437 |
438 // ThreadedTransformTransition ------------------------------------------------- | 438 // ThreadedTransformTransition ------------------------------------------------- |
439 | 439 |
440 class ThreadedTransformTransition : public ThreadedLayerAnimationElement { | 440 class ThreadedTransformTransition : public ThreadedLayerAnimationElement { |
441 public: | 441 public: |
442 ThreadedTransformTransition(const gfx::Transform& target, | 442 ThreadedTransformTransition(const gfx::Transform& target, |
443 base::TimeDelta duration) | 443 base::TimeDelta duration) |
444 : ThreadedLayerAnimationElement(TRANSFORM, duration), | 444 : ThreadedLayerAnimationElement(TRANSFORM, duration), |
445 target_(target) { | 445 target_(target) { |
446 } | 446 } |
447 virtual ~ThreadedTransformTransition() {} | 447 virtual ~ThreadedTransformTransition() {} |
448 | 448 |
449 protected: | 449 protected: |
450 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 450 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
451 start_ = delegate->GetTransformForAnimation(); | 451 start_ = delegate->GetTransformForAnimation(); |
452 } | 452 } |
453 | 453 |
454 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE { | 454 virtual void OnAbort(LayerAnimationDelegate* delegate) override { |
455 if (delegate && Started()) { | 455 if (delegate && Started()) { |
456 ThreadedLayerAnimationElement::OnAbort(delegate); | 456 ThreadedLayerAnimationElement::OnAbort(delegate); |
457 delegate->SetTransformFromAnimation(gfx::Tween::TransformValueBetween( | 457 delegate->SetTransformFromAnimation(gfx::Tween::TransformValueBetween( |
458 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), | 458 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
459 start_, | 459 start_, |
460 target_)); | 460 target_)); |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE { | 464 virtual void OnEnd(LayerAnimationDelegate* delegate) override { |
465 delegate->SetTransformFromAnimation(target_); | 465 delegate->SetTransformFromAnimation(target_); |
466 } | 466 } |
467 | 467 |
468 virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE { | 468 virtual scoped_ptr<cc::Animation> CreateCCAnimation() override { |
469 scoped_ptr<cc::AnimationCurve> animation_curve( | 469 scoped_ptr<cc::AnimationCurve> animation_curve( |
470 new TransformAnimationCurveAdapter(tween_type(), | 470 new TransformAnimationCurveAdapter(tween_type(), |
471 start_, | 471 start_, |
472 target_, | 472 target_, |
473 duration())); | 473 duration())); |
474 scoped_ptr<cc::Animation> animation( | 474 scoped_ptr<cc::Animation> animation( |
475 cc::Animation::Create(animation_curve.Pass(), | 475 cc::Animation::Create(animation_curve.Pass(), |
476 animation_id(), | 476 animation_id(), |
477 animation_group_id(), | 477 animation_group_id(), |
478 cc::Animation::Transform)); | 478 cc::Animation::Transform)); |
479 return animation.Pass(); | 479 return animation.Pass(); |
480 } | 480 } |
481 | 481 |
482 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 482 virtual void OnGetTarget(TargetValue* target) const override { |
483 target->transform = target_; | 483 target->transform = target_; |
484 } | 484 } |
485 | 485 |
486 private: | 486 private: |
487 gfx::Transform start_; | 487 gfx::Transform start_; |
488 const gfx::Transform target_; | 488 const gfx::Transform target_; |
489 | 489 |
490 DISALLOW_COPY_AND_ASSIGN(ThreadedTransformTransition); | 490 DISALLOW_COPY_AND_ASSIGN(ThreadedTransformTransition); |
491 }; | 491 }; |
492 | 492 |
(...skipping 12 matching lines...) Expand all Loading... |
505 virtual ~InverseTransformTransition() {} | 505 virtual ~InverseTransformTransition() {} |
506 | 506 |
507 static InverseTransformTransition* Clone(const LayerAnimationElement* other) { | 507 static InverseTransformTransition* Clone(const LayerAnimationElement* other) { |
508 const InverseTransformTransition* other_inverse = | 508 const InverseTransformTransition* other_inverse = |
509 CheckAndCast<const InverseTransformTransition*>(other); | 509 CheckAndCast<const InverseTransformTransition*>(other); |
510 return new InverseTransformTransition( | 510 return new InverseTransformTransition( |
511 other_inverse->base_transform_, other_inverse->uninverted_transition_); | 511 other_inverse->base_transform_, other_inverse->uninverted_transition_); |
512 } | 512 } |
513 | 513 |
514 protected: | 514 protected: |
515 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { | 515 virtual void OnStart(LayerAnimationDelegate* delegate) override { |
516 gfx::Transform start(delegate->GetTransformForAnimation()); | 516 gfx::Transform start(delegate->GetTransformForAnimation()); |
517 effective_start_ = base_transform_ * start; | 517 effective_start_ = base_transform_ * start; |
518 | 518 |
519 TargetValue target; | 519 TargetValue target; |
520 uninverted_transition_->GetTargetValue(&target); | 520 uninverted_transition_->GetTargetValue(&target); |
521 base_target_ = target.transform; | 521 base_target_ = target.transform; |
522 | 522 |
523 set_tween_type(uninverted_transition_->tween_type()); | 523 set_tween_type(uninverted_transition_->tween_type()); |
524 | 524 |
525 TransformAnimationCurveAdapter base_curve(tween_type(), | 525 TransformAnimationCurveAdapter base_curve(tween_type(), |
526 base_transform_, | 526 base_transform_, |
527 base_target_, | 527 base_target_, |
528 duration()); | 528 duration()); |
529 | 529 |
530 animation_curve_.reset(new InverseTransformCurveAdapter( | 530 animation_curve_.reset(new InverseTransformCurveAdapter( |
531 base_curve, start, duration())); | 531 base_curve, start, duration())); |
532 computed_target_transform_ = ComputeWithBaseTransform(effective_start_, | 532 computed_target_transform_ = ComputeWithBaseTransform(effective_start_, |
533 base_target_); | 533 base_target_); |
534 } | 534 } |
535 | 535 |
536 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE { | 536 virtual void OnAbort(LayerAnimationDelegate* delegate) override { |
537 if (delegate && Started()) { | 537 if (delegate && Started()) { |
538 ThreadedLayerAnimationElement::OnAbort(delegate); | 538 ThreadedLayerAnimationElement::OnAbort(delegate); |
539 delegate->SetTransformFromAnimation(ComputeCurrentTransform()); | 539 delegate->SetTransformFromAnimation(ComputeCurrentTransform()); |
540 } | 540 } |
541 } | 541 } |
542 | 542 |
543 virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE { | 543 virtual void OnEnd(LayerAnimationDelegate* delegate) override { |
544 delegate->SetTransformFromAnimation(computed_target_transform_); | 544 delegate->SetTransformFromAnimation(computed_target_transform_); |
545 } | 545 } |
546 | 546 |
547 virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE { | 547 virtual scoped_ptr<cc::Animation> CreateCCAnimation() override { |
548 scoped_ptr<cc::Animation> animation( | 548 scoped_ptr<cc::Animation> animation( |
549 cc::Animation::Create(animation_curve_->Clone(), | 549 cc::Animation::Create(animation_curve_->Clone(), |
550 animation_id(), | 550 animation_id(), |
551 animation_group_id(), | 551 animation_group_id(), |
552 cc::Animation::Transform)); | 552 cc::Animation::Transform)); |
553 return animation.Pass(); | 553 return animation.Pass(); |
554 } | 554 } |
555 | 555 |
556 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { | 556 virtual void OnGetTarget(TargetValue* target) const override { |
557 target->transform = computed_target_transform_; | 557 target->transform = computed_target_transform_; |
558 } | 558 } |
559 | 559 |
560 private: | 560 private: |
561 gfx::Transform ComputeCurrentTransform() const { | 561 gfx::Transform ComputeCurrentTransform() const { |
562 gfx::Transform base_current = gfx::Tween::TransformValueBetween( | 562 gfx::Transform base_current = gfx::Tween::TransformValueBetween( |
563 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), | 563 gfx::Tween::CalculateValue(tween_type(), last_progressed_fraction()), |
564 base_transform_, | 564 base_transform_, |
565 base_target_); | 565 base_target_); |
566 return ComputeWithBaseTransform(effective_start_, base_current); | 566 return ComputeWithBaseTransform(effective_start_, base_current); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 } | 845 } |
846 | 846 |
847 // static | 847 // static |
848 LayerAnimationElement* LayerAnimationElement::CreateColorElement( | 848 LayerAnimationElement* LayerAnimationElement::CreateColorElement( |
849 SkColor color, | 849 SkColor color, |
850 base::TimeDelta duration) { | 850 base::TimeDelta duration) { |
851 return new ColorTransition(color, duration); | 851 return new ColorTransition(color, duration); |
852 } | 852 } |
853 | 853 |
854 } // namespace ui | 854 } // namespace ui |
OLD | NEW |