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

Side by Side Diff: ash/wm/session_state_animator.cc

Issue 11273059: ash: Clean up system background layer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile errors, hopefully Created 8 years, 1 month 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 "ash/wm/session_state_animator.h" 5 #include "ash/wm/session_state_animator.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 "ash/wm/workspace/workspace_animations.h" 9 #include "ash/wm/workspace/workspace_animations.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) 195 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq)
196 OVERRIDE {} 196 OVERRIDE {}
197 197
198 SessionStateAnimator* animator_; 198 SessionStateAnimator* animator_;
199 199
200 DISALLOW_COPY_AND_ASSIGN(ForegroundDropAnimationObserver); 200 DISALLOW_COPY_AND_ASSIGN(ForegroundDropAnimationObserver);
201 }; 201 };
202 202
203 } // namespace 203 } // namespace
204 204
205 void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() {
206 animator_->DropBlackLayer();
207 animator_->hide_black_layer_timer_.Stop();
208 }
209
210 bool SessionStateAnimator::TestApi::ContainersAreAnimated( 205 bool SessionStateAnimator::TestApi::ContainersAreAnimated(
211 int container_mask, AnimationType type) const { 206 int container_mask, AnimationType type) const {
212 aura::Window::Windows containers; 207 aura::Window::Windows containers;
213 animator_->GetContainers(container_mask, &containers); 208 animator_->GetContainers(container_mask, &containers);
214 for (aura::Window::Windows::const_iterator it = containers.begin(); 209 for (aura::Window::Windows::const_iterator it = containers.begin();
215 it != containers.end(); ++it) { 210 it != containers.end(); ++it) {
216 aura::Window* window = *it; 211 aura::Window* window = *it;
217 ui::Layer* layer = window->layer(); 212 ui::Layer* layer = window->layer();
218 213
219 switch (type) { 214 switch (type) {
(...skipping 23 matching lines...) Expand all
243 return false; 238 return false;
244 break; 239 break;
245 default: 240 default:
246 NOTREACHED() << "Unhandled animation type " << type; 241 NOTREACHED() << "Unhandled animation type " << type;
247 return false; 242 return false;
248 } 243 }
249 } 244 }
250 return true; 245 return true;
251 } 246 }
252 247
253 bool SessionStateAnimator::TestApi::BlackLayerIsVisible() const {
254 return animator_->black_layer_.get() &&
255 animator_->black_layer_->visible();
256 }
257
258 gfx::Rect SessionStateAnimator::TestApi::GetBlackLayerBounds() const {
259 ui::Layer* layer = animator_->black_layer_.get();
260 return layer ? layer->bounds() : gfx::Rect();
261 }
262
263 const int SessionStateAnimator::kAllLockScreenContainersMask = 248 const int SessionStateAnimator::kAllLockScreenContainersMask =
264 SessionStateAnimator::LOCK_SCREEN_BACKGROUND | 249 SessionStateAnimator::LOCK_SCREEN_BACKGROUND |
265 SessionStateAnimator::LOCK_SCREEN_CONTAINERS | 250 SessionStateAnimator::LOCK_SCREEN_CONTAINERS |
266 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS; 251 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS;
267 252
268 const int SessionStateAnimator::kAllContainersMask = 253 const int SessionStateAnimator::kAllContainersMask =
269 SessionStateAnimator::kAllLockScreenContainersMask | 254 SessionStateAnimator::kAllLockScreenContainersMask |
270 SessionStateAnimator::DESKTOP_BACKGROUND | 255 SessionStateAnimator::DESKTOP_BACKGROUND |
271 SessionStateAnimator::LAUNCHER | 256 SessionStateAnimator::LAUNCHER |
272 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS; 257 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS;
273 258
274 SessionStateAnimator::SessionStateAnimator() { 259 SessionStateAnimator::SessionStateAnimator() {
275 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this);
276 } 260 }
277 261
278 SessionStateAnimator::~SessionStateAnimator() { 262 SessionStateAnimator::~SessionStateAnimator() {
279 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this);
280 } 263 }
281 264
282 // Fills |containers| with the containers described by |container_mask|. 265 // Fills |containers| with the containers described by |container_mask|.
283 void SessionStateAnimator::GetContainers(int container_mask, 266 void SessionStateAnimator::GetContainers(int container_mask,
284 aura::Window::Windows* containers) { 267 aura::Window::Windows* containers) {
285 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 268 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
286 containers->clear(); 269 containers->clear();
287 270
288 if (container_mask & DESKTOP_BACKGROUND) { 271 if (container_mask & DESKTOP_BACKGROUND) {
289 containers->push_back(Shell::GetContainer( 272 containers->push_back(Shell::GetContainer(
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 case ANIMATION_FULL_FADE_IN: 365 case ANIMATION_FULL_FADE_IN:
383 StartPartialFadeAnimation(window, 1.0, 366 StartPartialFadeAnimation(window, 1.0,
384 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), NULL); 367 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), NULL);
385 break; 368 break;
386 default: 369 default:
387 NOTREACHED() << "Unhandled animation type " << type; 370 NOTREACHED() << "Unhandled animation type " << type;
388 } 371 }
389 } 372 }
390 } 373 }
391 374
392 void SessionStateAnimator::OnRootWindowResized(const aura::RootWindow* root,
393 const gfx::Size& new_size) {
394 if (black_layer_.get())
395 black_layer_->SetBounds(gfx::Rect(root->bounds().size()));
396 }
397
398 void SessionStateAnimator::ShowBlackLayer() {
399 if (hide_black_layer_timer_.IsRunning())
400 hide_black_layer_timer_.Stop();
401
402 if (!black_layer_.get()) {
403 black_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
404 black_layer_->SetColor(SK_ColorBLACK);
405
406 ui::Layer* root_layer = Shell::GetPrimaryRootWindow()->layer();
407 black_layer_->SetBounds(root_layer->bounds());
408 root_layer->Add(black_layer_.get());
409 root_layer->StackAtBottom(black_layer_.get());
410 }
411 black_layer_->SetVisible(true);
412 }
413
414 void SessionStateAnimator::DropBlackLayer() {
415 black_layer_.reset();
416 }
417
418 void SessionStateAnimator::ScheduleDropBlackLayer() {
419 hide_black_layer_timer_.Stop();
420 hide_black_layer_timer_.Start(
421 FROM_HERE,
422 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs),
423 this, &SessionStateAnimator::DropBlackLayer);
424 }
425
426 void SessionStateAnimator::CreateForeground() { 375 void SessionStateAnimator::CreateForeground() {
427 if (foreground_.get()) 376 if (foreground_.get())
428 return; 377 return;
429 aura::Window* window = Shell::GetContainer( 378 aura::Window* window = Shell::GetContainer(
430 Shell::GetPrimaryRootWindow(), 379 Shell::GetPrimaryRootWindow(),
431 internal::kShellWindowId_PowerButtonAnimationContainer); 380 internal::kShellWindowId_PowerButtonAnimationContainer);
432 HideWindow(window); 381 HideWindow(window);
433 foreground_.reset( 382 foreground_.reset(
434 new ColoredWindowController(window, "SessionStateAnimatorForeground")); 383 new ColoredWindowController(window, "SessionStateAnimatorForeground"));
435 foreground_->SetColor(SK_ColorWHITE); 384 foreground_->SetColor(SK_ColorWHITE);
436 foreground_->GetWidget()->Show(); 385 foreground_->GetWidget()->Show();
437 } 386 }
438 387
439 void SessionStateAnimator::DropForeground() { 388 void SessionStateAnimator::DropForeground() {
440 foreground_.reset(); 389 foreground_.reset();
441 } 390 }
442 391
443 } // namespace internal 392 } // namespace internal
444 } // namespace ash 393 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698