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

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

Issue 11896017: Thread ui opacity animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix ash_unittests Created 7 years, 10 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
OLDNEW
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.h"
9 #include "cc/animation_id_provider.h"
8 #include "ui/base/animation/tween.h" 10 #include "ui/base/animation/tween.h"
11 #include "ui/compositor/float_animation_curve_adapter.h"
9 #include "ui/compositor/layer_animation_delegate.h" 12 #include "ui/compositor/layer_animation_delegate.h"
10 #include "ui/compositor/layer_animator.h" 13 #include "ui/compositor/layer_animator.h"
11 #include "ui/gfx/interpolated_transform.h" 14 #include "ui/gfx/interpolated_transform.h"
12 15
13 namespace ui { 16 namespace ui {
14 17
15 namespace { 18 namespace {
16 19
17 // Pause ----------------------------------------------------------------------- 20 // Pause -----------------------------------------------------------------------
18 class Pause : public LayerAnimationElement { 21 class Pause : public LayerAnimationElement {
19 public: 22 public:
20 Pause(const AnimatableProperties& properties, base::TimeDelta duration) 23 Pause(const AnimatableProperties& properties, base::TimeDelta duration)
21 : LayerAnimationElement(properties, duration) { 24 : LayerAnimationElement(properties, duration) {
22 } 25 }
23 virtual ~Pause() {} 26 virtual ~Pause() {}
24 27
25 private: 28 private:
26 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {} 29 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {}
27 virtual bool OnProgress(double t, 30 virtual bool OnProgress(double t,
28 LayerAnimationDelegate* delegate) OVERRIDE { 31 LayerAnimationDelegate* delegate) OVERRIDE {
29 return false; 32 return false;
30 } 33 }
31 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {} 34 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {}
32 virtual void OnAbort() OVERRIDE {} 35 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
33 36
34 DISALLOW_COPY_AND_ASSIGN(Pause); 37 DISALLOW_COPY_AND_ASSIGN(Pause);
35 }; 38 };
36 39
37 // TransformTransition --------------------------------------------------------- 40 // TransformTransition ---------------------------------------------------------
38 41
39 class TransformTransition : public LayerAnimationElement { 42 class TransformTransition : public LayerAnimationElement {
40 public: 43 public:
41 TransformTransition(const gfx::Transform& target, base::TimeDelta duration) 44 TransformTransition(const gfx::Transform& target, base::TimeDelta duration)
42 : LayerAnimationElement(GetProperties(), duration), 45 : LayerAnimationElement(GetProperties(), duration),
43 target_(target) { 46 target_(target) {
44 } 47 }
45 virtual ~TransformTransition() {} 48 virtual ~TransformTransition() {}
46 49
47 protected: 50 protected:
48 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE { 51 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
49 start_ = delegate->GetTransformForAnimation(); 52 start_ = delegate->GetTransformForAnimation();
50 } 53 }
51 54
52 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 55 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
53 delegate->SetTransformFromAnimation( 56 delegate->SetTransformFromAnimation(
54 Tween::ValueBetween(t, start_, target_)); 57 Tween::ValueBetween(t, start_, target_));
55 return true; 58 return true;
56 } 59 }
57 60
58 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 61 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
59 target->transform = target_; 62 target->transform = target_;
60 } 63 }
61 64
62 virtual void OnAbort() OVERRIDE {} 65 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
63 66
64 private: 67 private:
65 static AnimatableProperties GetProperties() { 68 static AnimatableProperties GetProperties() {
66 AnimatableProperties properties; 69 AnimatableProperties properties;
67 properties.insert(LayerAnimationElement::TRANSFORM); 70 properties.insert(LayerAnimationElement::TRANSFORM);
68 return properties; 71 return properties;
69 } 72 }
70 73
71 gfx::Transform start_; 74 gfx::Transform start_;
72 const gfx::Transform target_; 75 const gfx::Transform target_;
(...skipping 19 matching lines...) Expand all
92 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 95 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
93 delegate->SetTransformFromAnimation( 96 delegate->SetTransformFromAnimation(
94 interpolated_transform_->Interpolate(static_cast<float>(t))); 97 interpolated_transform_->Interpolate(static_cast<float>(t)));
95 return true; 98 return true;
96 } 99 }
97 100
98 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 101 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
99 target->transform = interpolated_transform_->Interpolate(1.0f); 102 target->transform = interpolated_transform_->Interpolate(1.0f);
100 } 103 }
101 104
102 virtual void OnAbort() OVERRIDE {} 105 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
103 106
104 private: 107 private:
105 static AnimatableProperties GetProperties() { 108 static AnimatableProperties GetProperties() {
106 AnimatableProperties properties; 109 AnimatableProperties properties;
107 properties.insert(LayerAnimationElement::TRANSFORM); 110 properties.insert(LayerAnimationElement::TRANSFORM);
108 return properties; 111 return properties;
109 } 112 }
110 113
111 scoped_ptr<InterpolatedTransform> interpolated_transform_; 114 scoped_ptr<InterpolatedTransform> interpolated_transform_;
112 115
(...skipping 17 matching lines...) Expand all
130 133
131 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 134 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
132 delegate->SetBoundsFromAnimation(Tween::ValueBetween(t, start_, target_)); 135 delegate->SetBoundsFromAnimation(Tween::ValueBetween(t, start_, target_));
133 return true; 136 return true;
134 } 137 }
135 138
136 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 139 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
137 target->bounds = target_; 140 target->bounds = target_;
138 } 141 }
139 142
140 virtual void OnAbort() OVERRIDE {} 143 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
141 144
142 private: 145 private:
143 static AnimatableProperties GetProperties() { 146 static AnimatableProperties GetProperties() {
144 AnimatableProperties properties; 147 AnimatableProperties properties;
145 properties.insert(LayerAnimationElement::BOUNDS); 148 properties.insert(LayerAnimationElement::BOUNDS);
146 return properties; 149 return properties;
147 } 150 }
148 151
149 gfx::Rect start_; 152 gfx::Rect start_;
150 const gfx::Rect target_; 153 const gfx::Rect target_;
(...skipping 19 matching lines...) Expand all
170 173
171 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 174 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
172 delegate->SetOpacityFromAnimation(Tween::ValueBetween(t, start_, target_)); 175 delegate->SetOpacityFromAnimation(Tween::ValueBetween(t, start_, target_));
173 return true; 176 return true;
174 } 177 }
175 178
176 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 179 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
177 target->opacity = target_; 180 target->opacity = target_;
178 } 181 }
179 182
180 virtual void OnAbort() OVERRIDE {} 183 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
181 184
182 private: 185 private:
183 static AnimatableProperties GetProperties() { 186 static AnimatableProperties GetProperties() {
184 AnimatableProperties properties; 187 AnimatableProperties properties;
185 properties.insert(LayerAnimationElement::OPACITY); 188 properties.insert(LayerAnimationElement::OPACITY);
186 return properties; 189 return properties;
187 } 190 }
188 191
189 float start_; 192 float start_;
190 const float target_; 193 const float target_;
(...skipping 19 matching lines...) Expand all
210 213
211 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 214 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
212 delegate->SetVisibilityFromAnimation(t == 1.0 ? target_ : start_); 215 delegate->SetVisibilityFromAnimation(t == 1.0 ? target_ : start_);
213 return t == 1.0; 216 return t == 1.0;
214 } 217 }
215 218
216 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 219 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
217 target->visibility = target_; 220 target->visibility = target_;
218 } 221 }
219 222
220 virtual void OnAbort() OVERRIDE {} 223 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
221 224
222 private: 225 private:
223 static AnimatableProperties GetProperties() { 226 static AnimatableProperties GetProperties() {
224 AnimatableProperties properties; 227 AnimatableProperties properties;
225 properties.insert(LayerAnimationElement::VISIBILITY); 228 properties.insert(LayerAnimationElement::VISIBILITY);
226 return properties; 229 return properties;
227 } 230 }
228 231
229 bool start_; 232 bool start_;
230 const bool target_; 233 const bool target_;
(...skipping 20 matching lines...) Expand all
251 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 254 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
252 delegate->SetBrightnessFromAnimation( 255 delegate->SetBrightnessFromAnimation(
253 Tween::ValueBetween(t, start_, target_)); 256 Tween::ValueBetween(t, start_, target_));
254 return true; 257 return true;
255 } 258 }
256 259
257 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 260 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
258 target->brightness = target_; 261 target->brightness = target_;
259 } 262 }
260 263
261 virtual void OnAbort() OVERRIDE {} 264 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
262 265
263 private: 266 private:
264 static AnimatableProperties GetProperties() { 267 static AnimatableProperties GetProperties() {
265 AnimatableProperties properties; 268 AnimatableProperties properties;
266 properties.insert(LayerAnimationElement::BRIGHTNESS); 269 properties.insert(LayerAnimationElement::BRIGHTNESS);
267 return properties; 270 return properties;
268 } 271 }
269 272
270 float start_; 273 float start_;
271 const float target_; 274 const float target_;
(...skipping 20 matching lines...) Expand all
292 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE { 295 virtual bool OnProgress(double t, LayerAnimationDelegate* delegate) OVERRIDE {
293 delegate->SetGrayscaleFromAnimation( 296 delegate->SetGrayscaleFromAnimation(
294 Tween::ValueBetween(t, start_, target_)); 297 Tween::ValueBetween(t, start_, target_));
295 return true; 298 return true;
296 } 299 }
297 300
298 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 301 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
299 target->grayscale = target_; 302 target->grayscale = target_;
300 } 303 }
301 304
302 virtual void OnAbort() OVERRIDE {} 305 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
303 306
304 private: 307 private:
305 static AnimatableProperties GetProperties() { 308 static AnimatableProperties GetProperties() {
306 AnimatableProperties properties; 309 AnimatableProperties properties;
307 properties.insert(LayerAnimationElement::GRAYSCALE); 310 properties.insert(LayerAnimationElement::GRAYSCALE);
308 return properties; 311 return properties;
309 } 312 }
310 313
311 float start_; 314 float start_;
312 const float target_; 315 const float target_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 Tween::ValueBetween(t, 348 Tween::ValueBetween(t,
346 static_cast<int>(SkColorGetB(start_)), 349 static_cast<int>(SkColorGetB(start_)),
347 static_cast<int>(SkColorGetB(target_))))); 350 static_cast<int>(SkColorGetB(target_)))));
348 return true; 351 return true;
349 } 352 }
350 353
351 virtual void OnGetTarget(TargetValue* target) const OVERRIDE { 354 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
352 target->color = target_; 355 target->color = target_;
353 } 356 }
354 357
355 virtual void OnAbort() OVERRIDE {} 358 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {}
356 359
357 private: 360 private:
358 static AnimatableProperties GetProperties() { 361 static AnimatableProperties GetProperties() {
359 AnimatableProperties properties; 362 AnimatableProperties properties;
360 properties.insert(LayerAnimationElement::COLOR); 363 properties.insert(LayerAnimationElement::COLOR);
361 return properties; 364 return properties;
362 } 365 }
363 366
364 SkColor start_; 367 SkColor start_;
365 const SkColor target_; 368 const SkColor target_;
366 369
367 DISALLOW_COPY_AND_ASSIGN(ColorTransition); 370 DISALLOW_COPY_AND_ASSIGN(ColorTransition);
368 }; 371 };
369 372
373 // ThreadedLayerAnimationElement -----------------------------------------------
374
375 class ThreadedLayerAnimationElement : public LayerAnimationElement {
376 public:
377 ThreadedLayerAnimationElement(const AnimatableProperties& properties,
378 base::TimeDelta duration)
379 : LayerAnimationElement(properties, duration) {
380 }
381 virtual ~ThreadedLayerAnimationElement() {}
382
383 virtual bool IsThreaded() const OVERRIDE {
384 return (duration() != base::TimeDelta());
385 }
386
387 protected:
388 virtual bool OnProgress(double t,
389 LayerAnimationDelegate* delegate) OVERRIDE {
390 if (t < 1.0)
391 return false;
392
393 if (Started()) {
394 delegate->RemoveThreadedAnimation(animation_id());
395 }
396
397 OnEnd(delegate);
398 return true;
399 }
400
401 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {
402 if (delegate && Started()) {
403 delegate->RemoveThreadedAnimation(animation_id());
404 }
405 }
406
407 virtual void RequestEffectiveStart(
408 LayerAnimationDelegate* delegate) OVERRIDE {
409 DCHECK(animation_group_id());
410 if (duration() == base::TimeDelta()) {
411 set_effective_start_time(requested_start_time());
412 return;
413 }
414 set_effective_start_time(base::TimeTicks());
415 scoped_ptr<cc::Animation> animation = CreateCCAnimation();
416 animation->setNeedsSynchronizedStartTime(true);
417 delegate->AddThreadedAnimation(animation.Pass());
418 }
419
420 virtual void OnEnd(LayerAnimationDelegate* delegate) = 0;
421
422 virtual scoped_ptr<cc::Animation> CreateCCAnimation() = 0;
423
424 private:
425 DISALLOW_COPY_AND_ASSIGN(ThreadedLayerAnimationElement);
426 };
427
428 // ThreadedOpacityTransition ---------------------------------------------------
429
430 class ThreadedOpacityTransition : public ThreadedLayerAnimationElement {
431 public:
432 ThreadedOpacityTransition(float target, base::TimeDelta duration)
433 : ThreadedLayerAnimationElement(GetProperties(), duration),
434 start_(0.0f),
435 target_(target) {
436 }
437 virtual ~ThreadedOpacityTransition() {}
438
439 protected:
440 virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
441 start_ = delegate->GetOpacityForAnimation();
442 }
443
444 virtual void OnAbort(LayerAnimationDelegate* delegate) OVERRIDE {
445 if (delegate && Started()) {
446 ThreadedLayerAnimationElement::OnAbort(delegate);
447 delegate->SetOpacityFromAnimation(
448 Tween::ValueBetween(last_progressed_fraction(), start_, target_));
449 }
450 }
451
452 virtual void OnEnd(LayerAnimationDelegate* delegate) OVERRIDE {
453 delegate->SetOpacityFromAnimation(target_);
454 }
455
456 virtual scoped_ptr<cc::Animation> CreateCCAnimation() OVERRIDE {
457 scoped_ptr<cc::AnimationCurve> animation_curve(
458 new FloatAnimationCurveAdapter(tween_type(),
459 start_,
460 target_,
461 duration()));
462 scoped_ptr<cc::Animation> animation(
463 cc::Animation::create(animation_curve.Pass(),
464 animation_id(),
465 animation_group_id(),
466 cc::Animation::Opacity));
467 return animation.Pass();
468 }
469
470 virtual void OnGetTarget(TargetValue* target) const OVERRIDE {
471 target->opacity = target_;
472 }
473
474 private:
475 static AnimatableProperties GetProperties() {
476 AnimatableProperties properties;
477 properties.insert(LayerAnimationElement::OPACITY);
478 return properties;
479 }
480
481 float start_;
482 const float target_;
483
484 DISALLOW_COPY_AND_ASSIGN(ThreadedOpacityTransition);
485 };
486
370 } // namespace 487 } // namespace
371 488
372 // LayerAnimationElement::TargetValue ------------------------------------------ 489 // LayerAnimationElement::TargetValue ------------------------------------------
373 490
374 LayerAnimationElement::TargetValue::TargetValue() 491 LayerAnimationElement::TargetValue::TargetValue()
375 : opacity(0.0f), 492 : opacity(0.0f),
376 visibility(false), 493 visibility(false),
377 brightness(0.0f), 494 brightness(0.0f),
378 grayscale(0.0f), 495 grayscale(0.0f),
379 color(SK_ColorBLACK) { 496 color(SK_ColorBLACK) {
(...skipping 12 matching lines...) Expand all
392 } 509 }
393 510
394 // LayerAnimationElement ------------------------------------------------------- 511 // LayerAnimationElement -------------------------------------------------------
395 512
396 LayerAnimationElement::LayerAnimationElement( 513 LayerAnimationElement::LayerAnimationElement(
397 const AnimatableProperties& properties, 514 const AnimatableProperties& properties,
398 base::TimeDelta duration) 515 base::TimeDelta duration)
399 : first_frame_(true), 516 : first_frame_(true),
400 properties_(properties), 517 properties_(properties),
401 duration_(GetEffectiveDuration(duration)), 518 duration_(GetEffectiveDuration(duration)),
402 tween_type_(Tween::LINEAR) { 519 tween_type_(Tween::LINEAR),
520 animation_id_(cc::AnimationIdProvider::NextAnimationId()),
521 animation_group_id_(0),
522 last_progressed_fraction_(0.0) {
403 } 523 }
404 524
405 LayerAnimationElement::~LayerAnimationElement() { 525 LayerAnimationElement::~LayerAnimationElement() {
406 } 526 }
407 527
528 void LayerAnimationElement::Start(LayerAnimationDelegate* delegate,
529 int animation_group_id) {
530 DCHECK(requested_start_time_ != base::TimeTicks());
531 DCHECK(first_frame_);
532 animation_group_id_ = animation_group_id;
533 last_progressed_fraction_ = 0.0;
534 OnStart(delegate);
535 RequestEffectiveStart(delegate);
536 first_frame_ = false;
537 }
538
408 bool LayerAnimationElement::Progress(base::TimeTicks now, 539 bool LayerAnimationElement::Progress(base::TimeTicks now,
409 LayerAnimationDelegate* delegate) { 540 LayerAnimationDelegate* delegate) {
410 DCHECK(start_time_ != base::TimeTicks()); 541 DCHECK(requested_start_time_ != base::TimeTicks());
411 base::TimeDelta elapsed = now - start_time_; 542 DCHECK(!first_frame_);
412 if (first_frame_) 543
413 OnStart(delegate); 544 bool need_draw;
414 double t = 1.0; 545 double t = 1.0;
546
547 if (effective_start_time_ == base::TimeTicks()) {
548 // This hasn't actually started yet.
549 need_draw = false;
550 last_progressed_fraction_ = 0.0;
551 return need_draw;
552 }
553
554 base::TimeDelta elapsed = now - effective_start_time_;
415 if ((duration_ > base::TimeDelta()) && (elapsed < duration_)) 555 if ((duration_ > base::TimeDelta()) && (elapsed < duration_))
416 t = elapsed.InMillisecondsF() / duration_.InMillisecondsF(); 556 t = elapsed.InMillisecondsF() / duration_.InMillisecondsF();
417 bool need_draw = OnProgress(Tween::CalculateValue(tween_type_, t), delegate); 557 need_draw = OnProgress(Tween::CalculateValue(tween_type_, t), delegate);
418 first_frame_ = t == 1.0; 558 first_frame_ = t == 1.0;
559 last_progressed_fraction_ = t;
419 return need_draw; 560 return need_draw;
420 } 561 }
421 562
422 bool LayerAnimationElement::IsFinished(base::TimeTicks time, 563 bool LayerAnimationElement::IsFinished(base::TimeTicks time,
423 base::TimeDelta* total_duration) { 564 base::TimeDelta* total_duration) {
424 base::TimeDelta elapsed = time - start_time_; 565 // If an effective start has been requested but the effective start time
425 if (elapsed >= duration_) { 566 // hasn't yet been set, the animation is not finished, regardless of the
426 *total_duration = duration_; 567 // value of |time|.
568 if (!first_frame_ && (effective_start_time_ == base::TimeTicks()))
569 return false;
570
571 base::TimeDelta queueing_delay;
572 if (!first_frame_)
573 queueing_delay = effective_start_time_ - requested_start_time_;
574
575 base::TimeDelta elapsed = time - requested_start_time_;
576 if (elapsed >= duration_ + queueing_delay) {
577 *total_duration = duration_ + queueing_delay;
427 return true; 578 return true;
428 } 579 }
429 return false; 580 return false;
430 } 581 }
431 582
432 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) { 583 bool LayerAnimationElement::ProgressToEnd(LayerAnimationDelegate* delegate) {
433 if (first_frame_) 584 if (first_frame_)
434 OnStart(delegate); 585 OnStart(delegate);
435 bool need_draw = OnProgress(1.0, delegate); 586 bool need_draw = OnProgress(1.0, delegate);
587 last_progressed_fraction_ = 1.0;
436 first_frame_ = true; 588 first_frame_ = true;
437 return need_draw; 589 return need_draw;
438 } 590 }
439 591
440 void LayerAnimationElement::GetTargetValue(TargetValue* target) const { 592 void LayerAnimationElement::GetTargetValue(TargetValue* target) const {
441 OnGetTarget(target); 593 OnGetTarget(target);
442 } 594 }
443 595
444 void LayerAnimationElement::Abort() { 596 bool LayerAnimationElement::IsThreaded() const {
597 return false;
598 }
599
600 void LayerAnimationElement::Abort(LayerAnimationDelegate* delegate) {
601 OnAbort(delegate);
445 first_frame_ = true; 602 first_frame_ = true;
446 OnAbort(); 603 }
604
605 void LayerAnimationElement::RequestEffectiveStart(
606 LayerAnimationDelegate* delegate) {
607 DCHECK(requested_start_time_ != base::TimeTicks());
608 effective_start_time_ = requested_start_time_;
447 } 609 }
448 610
449 // static 611 // static
612 LayerAnimationElement::AnimatableProperty
613 LayerAnimationElement::ToAnimatableProperty(
614 cc::Animation::TargetProperty property) {
615 switch (property) {
616 case cc::Animation::Transform:
617 return TRANSFORM;
618 case cc::Animation::Opacity:
619 return OPACITY;
620 default:
621 NOTREACHED();
622 return AnimatableProperty();
623 }
624 }
625
626 // static
450 base::TimeDelta LayerAnimationElement::GetEffectiveDuration( 627 base::TimeDelta LayerAnimationElement::GetEffectiveDuration(
451 const base::TimeDelta& duration) { 628 const base::TimeDelta& duration) {
452 if (LayerAnimator::disable_animations_for_test()) 629 if (LayerAnimator::disable_animations_for_test())
453 return base::TimeDelta(); 630 return base::TimeDelta();
454 631
455 if (LayerAnimator::slow_animation_mode()) 632 if (LayerAnimator::slow_animation_mode())
456 return duration * LayerAnimator::slow_animation_scale_factor(); 633 return duration * LayerAnimator::slow_animation_scale_factor();
457 634
458 return duration; 635 return duration;
459 } 636 }
(...skipping 17 matching lines...) Expand all
477 LayerAnimationElement* LayerAnimationElement::CreateBoundsElement( 654 LayerAnimationElement* LayerAnimationElement::CreateBoundsElement(
478 const gfx::Rect& bounds, 655 const gfx::Rect& bounds,
479 base::TimeDelta duration) { 656 base::TimeDelta duration) {
480 return new BoundsTransition(bounds, duration); 657 return new BoundsTransition(bounds, duration);
481 } 658 }
482 659
483 // static 660 // static
484 LayerAnimationElement* LayerAnimationElement::CreateOpacityElement( 661 LayerAnimationElement* LayerAnimationElement::CreateOpacityElement(
485 float opacity, 662 float opacity,
486 base::TimeDelta duration) { 663 base::TimeDelta duration) {
487 return new OpacityTransition(opacity, duration); 664 return new ThreadedOpacityTransition(opacity, duration);
488 } 665 }
489 666
490 // static 667 // static
491 LayerAnimationElement* LayerAnimationElement::CreateVisibilityElement( 668 LayerAnimationElement* LayerAnimationElement::CreateVisibilityElement(
492 bool visibility, 669 bool visibility,
493 base::TimeDelta duration) { 670 base::TimeDelta duration) {
494 return new VisibilityTransition(visibility, duration); 671 return new VisibilityTransition(visibility, duration);
495 } 672 }
496 673
497 // static 674 // static
(...skipping 18 matching lines...) Expand all
516 } 693 }
517 694
518 // static 695 // static
519 LayerAnimationElement* LayerAnimationElement::CreateColorElement( 696 LayerAnimationElement* LayerAnimationElement::CreateColorElement(
520 SkColor color, 697 SkColor color,
521 base::TimeDelta duration) { 698 base::TimeDelta duration) {
522 return new ColorTransition(color, duration); 699 return new ColorTransition(color, duration);
523 } 700 }
524 701
525 } // namespace ui 702 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_element.h ('k') | ui/compositor/layer_animation_element_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698