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

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

Issue 9222018: reland -- Disable animations during aura tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Gardening Created 8 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 | Annotate | Revision Log
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/gfx/compositor/layer_animation_observer.h" 5 #include "ui/gfx/compositor/layer_animation_observer.h"
6 6
7 #include "ui/gfx/compositor/layer_animation_sequence.h" 7 #include "ui/gfx/compositor/layer_animation_sequence.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 //////////////////////////////////////////////////////////////////////////////// 11 ////////////////////////////////////////////////////////////////////////////////
12 // LayerAnimationObserver 12 // LayerAnimationObserver
13 13
14 bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const {
15 return false;
16 }
17
18 LayerAnimationObserver::LayerAnimationObserver() { 14 LayerAnimationObserver::LayerAnimationObserver() {
19 } 15 }
20 16
21 LayerAnimationObserver::~LayerAnimationObserver() { 17 LayerAnimationObserver::~LayerAnimationObserver() {
22 while (!attached_sequences_.empty()) { 18 while (!attached_sequences_.empty()) {
23 LayerAnimationSequence* sequence = *attached_sequences_.begin(); 19 LayerAnimationSequence* sequence = *attached_sequences_.begin();
24 sequence->RemoveObserver(this); 20 sequence->RemoveObserver(this);
25 } 21 }
26 } 22 }
27 23
24 bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const {
25 return false;
26 }
27
28 void LayerAnimationObserver::OnAttachedToSequence(
29 LayerAnimationSequence* sequence) {
30 }
31
32 void LayerAnimationObserver::OnDetachedFromSequence(
33 LayerAnimationSequence* sequence) {
34 }
35
28 void LayerAnimationObserver::AttachedToSequence( 36 void LayerAnimationObserver::AttachedToSequence(
29 LayerAnimationSequence* sequence) { 37 LayerAnimationSequence* sequence) {
30 DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end()); 38 DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end());
31 attached_sequences_.insert(sequence); 39 attached_sequences_.insert(sequence);
32 } 40 }
33 41
34 void LayerAnimationObserver::DetachedFromSequence( 42 void LayerAnimationObserver::DetachedFromSequence(
35 LayerAnimationSequence* sequence) { 43 LayerAnimationSequence* sequence) {
36 if (attached_sequences_.find(sequence) != attached_sequences_.end()) 44 if (attached_sequences_.find(sequence) != attached_sequences_.end())
37 attached_sequences_.erase(sequence); 45 attached_sequences_.erase(sequence);
38 } 46 }
39 47
40 //////////////////////////////////////////////////////////////////////////////// 48 ////////////////////////////////////////////////////////////////////////////////
41 // ImplicitAnimationObserver 49 // ImplicitAnimationObserver
42 50
43 ImplicitAnimationObserver::ImplicitAnimationObserver() 51 ImplicitAnimationObserver::ImplicitAnimationObserver()
44 : active_(false), 52 : active_(false) {
45 animation_count_(0) {
46 } 53 }
47 54
48 ImplicitAnimationObserver::~ImplicitAnimationObserver() {} 55 ImplicitAnimationObserver::~ImplicitAnimationObserver() {}
49 56
50 void ImplicitAnimationObserver::SetActive(bool active) { 57 void ImplicitAnimationObserver::SetActive(bool active) {
51 active_ = active; 58 active_ = active;
52 CheckCompleted(); 59 CheckCompleted();
53 } 60 }
54 61
55 void ImplicitAnimationObserver::OnLayerAnimationEnded( 62 void ImplicitAnimationObserver::OnLayerAnimationEnded(
56 const LayerAnimationSequence* sequence) { 63 const LayerAnimationSequence* sequence) {
57 animation_count_--; 64 unfinished_animations_.erase(sequence);
58 CheckCompleted(); 65 CheckCompleted();
59 } 66 }
60 67
61 void ImplicitAnimationObserver::OnLayerAnimationAborted( 68 void ImplicitAnimationObserver::OnLayerAnimationAborted(
62 const LayerAnimationSequence* sequence) { 69 const LayerAnimationSequence* sequence) {
63 animation_count_--; 70 unfinished_animations_.erase(sequence);
64 CheckCompleted(); 71 CheckCompleted();
65 } 72 }
66 73
67 void ImplicitAnimationObserver::OnLayerAnimationScheduled( 74 void ImplicitAnimationObserver::OnLayerAnimationScheduled(
68 const LayerAnimationSequence* sequence) { 75 const LayerAnimationSequence* sequence) {
69 animation_count_++; 76 unfinished_animations_.insert(sequence);
77 }
78
79 void ImplicitAnimationObserver::OnAttachedToSequence(
80 LayerAnimationSequence* sequence) {
81 // If we're attached to a sequence that is already animating, we must add it
82 // to the list now (because we've missed the AnimationScheduled notification).
83 if (sequence->is_animating())
84 unfinished_animations_.insert(sequence);
85 }
86
87 void ImplicitAnimationObserver::OnDetachedFromSequence(
88 LayerAnimationSequence* sequence) {
89 // There is a chance that we were removed as an observer while an animation
90 // was in progress. It is important that we remove this animation from the
91 // list in this case, so we will attempt to remove the animation now.
92 unfinished_animations_.erase(sequence);
93 CheckCompleted();
70 } 94 }
71 95
72 void ImplicitAnimationObserver::CheckCompleted() { 96 void ImplicitAnimationObserver::CheckCompleted() {
73 if (active_ && animation_count_ == 0) 97 if (active_ && unfinished_animations_.empty()) {
74 OnImplicitAnimationsCompleted(); 98 OnImplicitAnimationsCompleted();
99 active_ = false;
100 }
75 } 101 }
76 102
77 } // namespace ui 103 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698