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 "ash/display/output_configurator_animation.h" | 5 #include "ash/display/output_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" |
16 #include "ui/compositor/layer_animation_sequence.h" | 16 #include "ui/compositor/layer_animation_sequence.h" |
17 #include "ui/compositor/layer_animator.h" | 17 #include "ui/compositor/layer_animator.h" |
18 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
19 | 19 |
20 namespace ash { | 20 namespace ash { |
21 namespace internal { | |
22 namespace { | 21 namespace { |
23 | 22 |
24 const int kFadingAnimationDurationInMS = 200; | 23 const int kFadingAnimationDurationInMS = 200; |
25 const int kFadingTimeoutDurationInSeconds = 10; | 24 const int kFadingTimeoutDurationInSeconds = 10; |
26 | 25 |
27 // CallbackRunningObserver accepts multiple layer animations and | 26 // CallbackRunningObserver accepts multiple layer animations and |
28 // runs the specified |callback| when all of the animations have finished. | 27 // runs the specified |callback| when all of the animations have finished. |
29 class CallbackRunningObserver { | 28 class CallbackRunningObserver { |
30 public: | 29 public: |
31 CallbackRunningObserver(base::Closure callback) | 30 CallbackRunningObserver(base::Closure callback) |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // 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 |
116 // after the animation of OnDisplayModeChanged(). | 115 // after the animation of OnDisplayModeChanged(). |
117 aura::Window::Windows root_windows = | 116 aura::Window::Windows root_windows = |
118 Shell::GetInstance()->GetAllRootWindows(); | 117 Shell::GetInstance()->GetAllRootWindows(); |
119 for (aura::Window::Windows::const_iterator it = root_windows.begin(); | 118 for (aura::Window::Windows::const_iterator it = root_windows.begin(); |
120 it != root_windows.end(); ++it) { | 119 it != root_windows.end(); ++it) { |
121 aura::Window* root_window = *it; | 120 aura::Window* root_window = *it; |
122 ui::Layer* hiding_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); | 121 ui::Layer* hiding_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); |
123 hiding_layer->SetColor(SK_ColorBLACK); | 122 hiding_layer->SetColor(SK_ColorBLACK); |
124 hiding_layer->SetBounds(root_window->bounds()); | 123 hiding_layer->SetBounds(root_window->bounds()); |
125 ui::Layer* parent = ash::Shell::GetContainer( | 124 ui::Layer* parent = |
126 root_window, | 125 ash::Shell::GetContainer(root_window, |
127 ash::internal::kShellWindowId_OverlayContainer)->layer(); | 126 ash::kShellWindowId_OverlayContainer)->layer(); |
128 parent->Add(hiding_layer); | 127 parent->Add(hiding_layer); |
129 | 128 |
130 hiding_layer->SetOpacity(0.0); | 129 hiding_layer->SetOpacity(0.0); |
131 | 130 |
132 ui::ScopedLayerAnimationSettings settings(hiding_layer->GetAnimator()); | 131 ui::ScopedLayerAnimationSettings settings(hiding_layer->GetAnimator()); |
133 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 132 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
134 kFadingAnimationDurationInMS)); | 133 kFadingAnimationDurationInMS)); |
135 observer->AddNewAnimator(hiding_layer->GetAnimator()); | 134 observer->AddNewAnimator(hiding_layer->GetAnimator()); |
136 hiding_layer->SetOpacity(1.0f); | 135 hiding_layer->SetOpacity(1.0f); |
137 hiding_layer->SetVisible(true); | 136 hiding_layer->SetVisible(true); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 it != root_windows.end(); ++it) { | 173 it != root_windows.end(); ++it) { |
175 aura::Window* root_window = *it; | 174 aura::Window* root_window = *it; |
176 ui::Layer* hiding_layer = NULL; | 175 ui::Layer* hiding_layer = NULL; |
177 if (hiding_layers_.find(root_window) == hiding_layers_.end()) { | 176 if (hiding_layers_.find(root_window) == hiding_layers_.end()) { |
178 // In case of the transition from mirroring->non-mirroring, new root | 177 // In case of the transition from mirroring->non-mirroring, new root |
179 // windows appear and we do not have the black layers for them. Thus | 178 // windows appear and we do not have the black layers for them. Thus |
180 // we need to create the layer and make it visible. | 179 // we need to create the layer and make it visible. |
181 hiding_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); | 180 hiding_layer = new ui::Layer(ui::LAYER_SOLID_COLOR); |
182 hiding_layer->SetColor(SK_ColorBLACK); | 181 hiding_layer->SetColor(SK_ColorBLACK); |
183 hiding_layer->SetBounds(root_window->bounds()); | 182 hiding_layer->SetBounds(root_window->bounds()); |
184 ui::Layer* parent = ash::Shell::GetContainer( | 183 ui::Layer* parent = |
185 root_window, | 184 ash::Shell::GetContainer( |
186 ash::internal::kShellWindowId_OverlayContainer)->layer(); | 185 root_window, ash::kShellWindowId_OverlayContainer)->layer(); |
187 parent->Add(hiding_layer); | 186 parent->Add(hiding_layer); |
188 hiding_layer->SetOpacity(1.0f); | 187 hiding_layer->SetOpacity(1.0f); |
189 hiding_layer->SetVisible(true); | 188 hiding_layer->SetVisible(true); |
190 hiding_layers_[root_window] = hiding_layer; | 189 hiding_layers_[root_window] = hiding_layer; |
191 } else { | 190 } else { |
192 hiding_layer = hiding_layers_[root_window]; | 191 hiding_layer = hiding_layers_[root_window]; |
193 if (hiding_layer->bounds() != root_window->bounds()) | 192 if (hiding_layer->bounds() != root_window->bounds()) |
194 hiding_layer->SetBounds(root_window->bounds()); | 193 hiding_layer->SetBounds(root_window->bounds()); |
195 } | 194 } |
196 | 195 |
(...skipping 21 matching lines...) Expand all Loading... |
218 void OutputConfiguratorAnimation::ClearHidingLayers() { | 217 void OutputConfiguratorAnimation::ClearHidingLayers() { |
219 if (timer_) { | 218 if (timer_) { |
220 timer_->Stop(); | 219 timer_->Stop(); |
221 timer_.reset(); | 220 timer_.reset(); |
222 } | 221 } |
223 STLDeleteContainerPairSecondPointers( | 222 STLDeleteContainerPairSecondPointers( |
224 hiding_layers_.begin(), hiding_layers_.end()); | 223 hiding_layers_.begin(), hiding_layers_.end()); |
225 hiding_layers_.clear(); | 224 hiding_layers_.clear(); |
226 } | 225 } |
227 | 226 |
228 } // namespace internal | |
229 } // namespace ash | 227 } // namespace ash |
OLD | NEW |