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

Side by Side Diff: ash/display/display_configurator_animation.cc

Issue 250163002: Update naming from OutputConfiguratorAnimation to DisplayConfiguratorAnimation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « ash/display/display_configurator_animation.h ('k') | ash/display/display_controller.cc » ('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 "ash/display/output_configurator_animation.h" 5 #include "ash/display/display_configurator_animation.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
13 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/compositor/layer.h" 14 #include "ui/compositor/layer.h"
15 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 size_t completed_counter_; 90 size_t completed_counter_;
91 bool animation_aborted_; 91 bool animation_aborted_;
92 ScopedVector<Observer> observer_list_; 92 ScopedVector<Observer> observer_list_;
93 base::Closure callback_; 93 base::Closure callback_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(CallbackRunningObserver); 95 DISALLOW_COPY_AND_ASSIGN(CallbackRunningObserver);
96 }; 96 };
97 97
98 } // namespace 98 } // namespace
99 99
100 OutputConfiguratorAnimation::OutputConfiguratorAnimation() { 100 DisplayConfiguratorAnimation::DisplayConfiguratorAnimation() {
101 } 101 }
102 102
103 OutputConfiguratorAnimation::~OutputConfiguratorAnimation() { 103 DisplayConfiguratorAnimation::~DisplayConfiguratorAnimation() {
104 ClearHidingLayers(); 104 ClearHidingLayers();
105 } 105 }
106 106
107 void OutputConfiguratorAnimation::StartFadeOutAnimation( 107 void DisplayConfiguratorAnimation::StartFadeOutAnimation(
108 base::Closure callback) { 108 base::Closure callback) {
109 CallbackRunningObserver* observer = new CallbackRunningObserver(callback); 109 CallbackRunningObserver* observer = new CallbackRunningObserver(callback);
110 ClearHidingLayers(); 110 ClearHidingLayers();
111 111
112 // Make the fade-out animation for all root windows. Instead of actually 112 // Make the fade-out animation for all root windows. Instead of actually
113 // hiding the root windows, we put a black layer over a root window for 113 // hiding the root windows, we put a black layer over a root window for
114 // safety. These layers remain to hide root windows and will be deleted 114 // safety. These layers remain to hide root windows and will be deleted
115 // after the animation of OnDisplayModeChanged(). 115 // after the animation of OnDisplayModeChanged().
116 aura::Window::Windows root_windows = 116 aura::Window::Windows root_windows =
117 Shell::GetInstance()->GetAllRootWindows(); 117 Shell::GetInstance()->GetAllRootWindows();
(...skipping 15 matching lines...) Expand all
133 kFadingAnimationDurationInMS)); 133 kFadingAnimationDurationInMS));
134 observer->AddNewAnimator(hiding_layer->GetAnimator()); 134 observer->AddNewAnimator(hiding_layer->GetAnimator());
135 hiding_layer->SetOpacity(1.0f); 135 hiding_layer->SetOpacity(1.0f);
136 hiding_layer->SetVisible(true); 136 hiding_layer->SetVisible(true);
137 hiding_layers_[root_window] = hiding_layer; 137 hiding_layers_[root_window] = hiding_layer;
138 } 138 }
139 139
140 // In case that OnDisplayModeChanged() isn't called or its animator is 140 // In case that OnDisplayModeChanged() isn't called or its animator is
141 // canceled due to some unknown errors, we set a timer to clear these 141 // canceled due to some unknown errors, we set a timer to clear these
142 // hiding layers. 142 // hiding layers.
143 timer_.reset(new base::OneShotTimer<OutputConfiguratorAnimation>()); 143 timer_.reset(new base::OneShotTimer<DisplayConfiguratorAnimation>());
144 timer_->Start(FROM_HERE, 144 timer_->Start(FROM_HERE,
145 base::TimeDelta::FromSeconds(kFadingTimeoutDurationInSeconds), 145 base::TimeDelta::FromSeconds(kFadingTimeoutDurationInSeconds),
146 this, 146 this,
147 &OutputConfiguratorAnimation::ClearHidingLayers); 147 &DisplayConfiguratorAnimation::ClearHidingLayers);
148 } 148 }
149 149
150 void OutputConfiguratorAnimation::StartFadeInAnimation() { 150 void DisplayConfiguratorAnimation::StartFadeInAnimation() {
151 // We want to make sure clearing all of hiding layers after the animation 151 // We want to make sure clearing all of hiding layers after the animation
152 // finished. Note that this callback can be canceled, but the cancel only 152 // finished. Note that this callback can be canceled, but the cancel only
153 // happens when the next animation is scheduled. Thus the hiding layers 153 // happens when the next animation is scheduled. Thus the hiding layers
154 // should be deleted eventually. 154 // should be deleted eventually.
155 CallbackRunningObserver* observer = new CallbackRunningObserver( 155 CallbackRunningObserver* observer = new CallbackRunningObserver(
156 base::Bind(&OutputConfiguratorAnimation::ClearHidingLayers, 156 base::Bind(&DisplayConfiguratorAnimation::ClearHidingLayers,
157 base::Unretained(this))); 157 base::Unretained(this)));
158 158
159 // Ensure that layers are not animating. 159 // Ensure that layers are not animating.
160 for (std::map<aura::Window*, ui::Layer*>::iterator it = 160 for (std::map<aura::Window*, ui::Layer*>::iterator it =
161 hiding_layers_.begin(); it != hiding_layers_.end(); ++it) { 161 hiding_layers_.begin(); it != hiding_layers_.end(); ++it) {
162 ui::LayerAnimator* animator = it->second->GetAnimator(); 162 ui::LayerAnimator* animator = it->second->GetAnimator();
163 if (animator->is_animating()) 163 if (animator->is_animating())
164 animator->StopAnimating(); 164 animator->StopAnimating();
165 } 165 }
166 166
(...skipping 28 matching lines...) Expand all
195 195
196 ui::ScopedLayerAnimationSettings settings(hiding_layer->GetAnimator()); 196 ui::ScopedLayerAnimationSettings settings(hiding_layer->GetAnimator());
197 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( 197 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
198 kFadingAnimationDurationInMS)); 198 kFadingAnimationDurationInMS));
199 observer->AddNewAnimator(hiding_layer->GetAnimator()); 199 observer->AddNewAnimator(hiding_layer->GetAnimator());
200 hiding_layer->SetOpacity(0.0f); 200 hiding_layer->SetOpacity(0.0f);
201 hiding_layer->SetVisible(false); 201 hiding_layer->SetVisible(false);
202 } 202 }
203 } 203 }
204 204
205 void OutputConfiguratorAnimation::OnDisplayModeChanged( 205 void DisplayConfiguratorAnimation::OnDisplayModeChanged(
206 const ui::DisplayConfigurator::DisplayStateList& outputs) { 206 const ui::DisplayConfigurator::DisplayStateList& displays) {
207 if (!hiding_layers_.empty()) 207 if (!hiding_layers_.empty())
208 StartFadeInAnimation(); 208 StartFadeInAnimation();
209 } 209 }
210 210
211 void OutputConfiguratorAnimation::OnDisplayModeChangeFailed( 211 void DisplayConfiguratorAnimation::OnDisplayModeChangeFailed(
212 ui::MultipleDisplayState failed_new_state) { 212 ui::MultipleDisplayState failed_new_state) {
213 if (!hiding_layers_.empty()) 213 if (!hiding_layers_.empty())
214 StartFadeInAnimation(); 214 StartFadeInAnimation();
215 } 215 }
216 216
217 void OutputConfiguratorAnimation::ClearHidingLayers() { 217 void DisplayConfiguratorAnimation::ClearHidingLayers() {
218 if (timer_) { 218 if (timer_) {
219 timer_->Stop(); 219 timer_->Stop();
220 timer_.reset(); 220 timer_.reset();
221 } 221 }
222 STLDeleteContainerPairSecondPointers( 222 STLDeleteContainerPairSecondPointers(
223 hiding_layers_.begin(), hiding_layers_.end()); 223 hiding_layers_.begin(), hiding_layers_.end());
224 hiding_layers_.clear(); 224 hiding_layers_.clear();
225 } 225 }
226 226
227 } // namespace ash 227 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_configurator_animation.h ('k') | ash/display/display_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698