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

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: . 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
« no previous file with comments | « ui/gfx/compositor/layer_animation_observer.h ('k') | ui/gfx/compositor/layer_animator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 LayerAnimationObserver::LayerAnimationObserver() {
15 }
16
17 LayerAnimationObserver::~LayerAnimationObserver() {
18 StopObserving();
19 }
20
14 bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const { 21 bool LayerAnimationObserver::RequiresNotificationWhenAnimatorDestroyed() const {
15 return false; 22 return false;
16 } 23 }
17 24
18 LayerAnimationObserver::LayerAnimationObserver() { 25 void LayerAnimationObserver::OnAttachedToSequence(
26 LayerAnimationSequence* sequence) {
19 } 27 }
20 28
21 LayerAnimationObserver::~LayerAnimationObserver() { 29 void LayerAnimationObserver::OnDetachedFromSequence(
30 LayerAnimationSequence* sequence) {
31 }
32
33 void LayerAnimationObserver::StopObserving() {
22 while (!attached_sequences_.empty()) { 34 while (!attached_sequences_.empty()) {
23 LayerAnimationSequence* sequence = *attached_sequences_.begin(); 35 LayerAnimationSequence* sequence = *attached_sequences_.begin();
24 sequence->RemoveObserver(this); 36 sequence->RemoveObserver(this);
25 } 37 }
26 } 38 }
27 39
28 void LayerAnimationObserver::AttachedToSequence( 40 void LayerAnimationObserver::AttachedToSequence(
29 LayerAnimationSequence* sequence) { 41 LayerAnimationSequence* sequence) {
30 DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end()); 42 DCHECK(attached_sequences_.find(sequence) == attached_sequences_.end());
31 attached_sequences_.insert(sequence); 43 attached_sequences_.insert(sequence);
44 OnAttachedToSequence(sequence);
32 } 45 }
33 46
34 void LayerAnimationObserver::DetachedFromSequence( 47 void LayerAnimationObserver::DetachedFromSequence(
35 LayerAnimationSequence* sequence) { 48 LayerAnimationSequence* sequence) {
36 if (attached_sequences_.find(sequence) != attached_sequences_.end()) 49 if (attached_sequences_.find(sequence) != attached_sequences_.end())
37 attached_sequences_.erase(sequence); 50 attached_sequences_.erase(sequence);
51 OnDetachedFromSequence(sequence);
38 } 52 }
39 53
40 //////////////////////////////////////////////////////////////////////////////// 54 ////////////////////////////////////////////////////////////////////////////////
41 // ImplicitAnimationObserver 55 // ImplicitAnimationObserver
42 56
43 ImplicitAnimationObserver::ImplicitAnimationObserver() 57 ImplicitAnimationObserver::ImplicitAnimationObserver()
44 : active_(false), 58 : active_(false) {
45 animation_count_(0) {
46 } 59 }
47 60
48 ImplicitAnimationObserver::~ImplicitAnimationObserver() {} 61 ImplicitAnimationObserver::~ImplicitAnimationObserver() {}
49 62
50 void ImplicitAnimationObserver::SetActive(bool active) { 63 void ImplicitAnimationObserver::SetActive(bool active) {
51 active_ = active; 64 active_ = active;
52 CheckCompleted(); 65 CheckCompleted();
53 } 66 }
54 67
68 void ImplicitAnimationObserver::StopObservingImplicitAnimations() {
69 SetActive(false);
70 StopObserving();
71 }
72
55 void ImplicitAnimationObserver::OnLayerAnimationEnded( 73 void ImplicitAnimationObserver::OnLayerAnimationEnded(
56 const LayerAnimationSequence* sequence) { 74 LayerAnimationSequence* sequence) {
57 animation_count_--; 75 sequence->RemoveObserver(this);
76 DCHECK(attached_sequences().find(sequence) == attached_sequences().end());
58 CheckCompleted(); 77 CheckCompleted();
59 } 78 }
60 79
61 void ImplicitAnimationObserver::OnLayerAnimationAborted( 80 void ImplicitAnimationObserver::OnLayerAnimationAborted(
62 const LayerAnimationSequence* sequence) { 81 LayerAnimationSequence* sequence) {
63 animation_count_--; 82 sequence->RemoveObserver(this);
83 DCHECK(attached_sequences().find(sequence) == attached_sequences().end());
64 CheckCompleted(); 84 CheckCompleted();
65 } 85 }
66 86
67 void ImplicitAnimationObserver::OnLayerAnimationScheduled( 87 void ImplicitAnimationObserver::OnLayerAnimationScheduled(
68 const LayerAnimationSequence* sequence) { 88 LayerAnimationSequence* sequence) {
69 animation_count_++; 89 }
90
91 void ImplicitAnimationObserver::OnAttachedToSequence(
92 LayerAnimationSequence* sequence) {
93 }
94
95 void ImplicitAnimationObserver::OnDetachedFromSequence(
96 LayerAnimationSequence* sequence) {
97 DCHECK(attached_sequences().find(sequence) == attached_sequences().end());
98 CheckCompleted();
70 } 99 }
71 100
72 void ImplicitAnimationObserver::CheckCompleted() { 101 void ImplicitAnimationObserver::CheckCompleted() {
73 if (active_ && animation_count_ == 0) 102 if (active_ && attached_sequences().empty()) {
74 OnImplicitAnimationsCompleted(); 103 OnImplicitAnimationsCompleted();
104 active_ = false;
105 }
75 } 106 }
76 107
77 } // namespace ui 108 } // namespace ui
OLDNEW
« no previous file with comments | « ui/gfx/compositor/layer_animation_observer.h ('k') | ui/gfx/compositor/layer_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698