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

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: apply review feedback 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
« no previous file with comments | « ash/wm/session_state_animator.h ('k') | ash/wm/session_state_controller_impl.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/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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq) 238 virtual void OnLayerAnimationScheduled(ui::LayerAnimationSequence* seq)
239 OVERRIDE {} 239 OVERRIDE {}
240 240
241 base::Callback<void(void)> callback_; 241 base::Callback<void(void)> callback_;
242 242
243 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver); 243 DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver);
244 }; 244 };
245 245
246 } // namespace 246 } // namespace
247 247
248 void SessionStateAnimator::TestApi::TriggerHideBlackLayerTimeout() {
249 animator_->DropBlackLayer();
250 animator_->hide_black_layer_timer_.Stop();
251 }
252
253 bool SessionStateAnimator::TestApi::ContainersAreAnimated( 248 bool SessionStateAnimator::TestApi::ContainersAreAnimated(
254 int container_mask, AnimationType type) const { 249 int container_mask, AnimationType type) const {
255 aura::Window::Windows containers; 250 aura::Window::Windows containers;
256 animator_->GetContainers(container_mask, &containers); 251 animator_->GetContainers(container_mask, &containers);
257 for (aura::Window::Windows::const_iterator it = containers.begin(); 252 for (aura::Window::Windows::const_iterator it = containers.begin();
258 it != containers.end(); ++it) { 253 it != containers.end(); ++it) {
259 aura::Window* window = *it; 254 aura::Window* window = *it;
260 ui::Layer* layer = window->layer(); 255 ui::Layer* layer = window->layer();
261 256
262 switch (type) { 257 switch (type) {
(...skipping 23 matching lines...) Expand all
286 return false; 281 return false;
287 break; 282 break;
288 default: 283 default:
289 NOTREACHED() << "Unhandled animation type " << type; 284 NOTREACHED() << "Unhandled animation type " << type;
290 return false; 285 return false;
291 } 286 }
292 } 287 }
293 return true; 288 return true;
294 } 289 }
295 290
296 bool SessionStateAnimator::TestApi::BlackLayerIsVisible() const {
297 return animator_->black_layer_.get() &&
298 animator_->black_layer_->visible();
299 }
300
301 gfx::Rect SessionStateAnimator::TestApi::GetBlackLayerBounds() const {
302 ui::Layer* layer = animator_->black_layer_.get();
303 return layer ? layer->bounds() : gfx::Rect();
304 }
305
306 const int SessionStateAnimator::kAllLockScreenContainersMask = 291 const int SessionStateAnimator::kAllLockScreenContainersMask =
307 SessionStateAnimator::LOCK_SCREEN_BACKGROUND | 292 SessionStateAnimator::LOCK_SCREEN_BACKGROUND |
308 SessionStateAnimator::LOCK_SCREEN_CONTAINERS | 293 SessionStateAnimator::LOCK_SCREEN_CONTAINERS |
309 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS; 294 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS;
310 295
311 const int SessionStateAnimator::kAllContainersMask = 296 const int SessionStateAnimator::kAllContainersMask =
312 SessionStateAnimator::kAllLockScreenContainersMask | 297 SessionStateAnimator::kAllLockScreenContainersMask |
313 SessionStateAnimator::DESKTOP_BACKGROUND | 298 SessionStateAnimator::DESKTOP_BACKGROUND |
314 SessionStateAnimator::LAUNCHER | 299 SessionStateAnimator::LAUNCHER |
315 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS; 300 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS;
316 301
317 SessionStateAnimator::SessionStateAnimator() { 302 SessionStateAnimator::SessionStateAnimator() {
318 Shell::GetPrimaryRootWindow()->AddRootWindowObserver(this);
319 } 303 }
320 304
321 SessionStateAnimator::~SessionStateAnimator() { 305 SessionStateAnimator::~SessionStateAnimator() {
322 Shell::GetPrimaryRootWindow()->RemoveRootWindowObserver(this);
323 } 306 }
324 307
325 // Fills |containers| with the containers described by |container_mask|. 308 // Fills |containers| with the containers described by |container_mask|.
326 void SessionStateAnimator::GetContainers(int container_mask, 309 void SessionStateAnimator::GetContainers(int container_mask,
327 aura::Window::Windows* containers) { 310 aura::Window::Windows* containers) {
328 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 311 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
329 containers->clear(); 312 containers->clear();
330 313
331 if (container_mask & DESKTOP_BACKGROUND) { 314 if (container_mask & DESKTOP_BACKGROUND) {
332 containers->push_back(Shell::GetContainer( 315 containers->push_back(Shell::GetContainer(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 case ANIMATION_FULL_FADE_IN: 430 case ANIMATION_FULL_FADE_IN:
448 StartPartialFadeAnimation(window, 1.0, 431 StartPartialFadeAnimation(window, 1.0,
449 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs), 432 base::TimeDelta::FromMilliseconds(kFastCloseAnimMs),
450 observer); 433 observer);
451 break; 434 break;
452 default: 435 default:
453 NOTREACHED() << "Unhandled animation type " << type; 436 NOTREACHED() << "Unhandled animation type " << type;
454 } 437 }
455 } 438 }
456 439
457 void SessionStateAnimator::OnRootWindowResized(const aura::RootWindow* root,
458 const gfx::Size& new_size) {
459 if (black_layer_.get())
460 black_layer_->SetBounds(gfx::Rect(root->bounds().size()));
461 }
462
463 void SessionStateAnimator::ShowBlackLayer() {
464 if (hide_black_layer_timer_.IsRunning())
465 hide_black_layer_timer_.Stop();
466
467 if (!black_layer_.get()) {
468 black_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
469 black_layer_->SetColor(SK_ColorBLACK);
470
471 ui::Layer* root_layer = Shell::GetPrimaryRootWindow()->layer();
472 black_layer_->SetBounds(root_layer->bounds());
473 root_layer->Add(black_layer_.get());
474 root_layer->StackAtBottom(black_layer_.get());
475 }
476 black_layer_->SetVisible(true);
477 }
478
479 void SessionStateAnimator::DropBlackLayer() {
480 black_layer_.reset();
481 }
482
483 void SessionStateAnimator::ScheduleDropBlackLayer() {
484 hide_black_layer_timer_.Stop();
485 hide_black_layer_timer_.Start(
486 FROM_HERE,
487 base::TimeDelta::FromMilliseconds(kUndoSlowCloseAnimMs),
488 this, &SessionStateAnimator::DropBlackLayer);
489 }
490
491 void SessionStateAnimator::CreateForeground() { 440 void SessionStateAnimator::CreateForeground() {
492 if (foreground_.get()) 441 if (foreground_.get())
493 return; 442 return;
494 aura::Window* window = Shell::GetContainer( 443 aura::Window* window = Shell::GetContainer(
495 Shell::GetPrimaryRootWindow(), 444 Shell::GetPrimaryRootWindow(),
496 internal::kShellWindowId_PowerButtonAnimationContainer); 445 internal::kShellWindowId_PowerButtonAnimationContainer);
497 HideWindow(window, NULL); 446 HideWindow(window, NULL);
498 foreground_.reset( 447 foreground_.reset(
499 new ColoredWindowController(window, "SessionStateAnimatorForeground")); 448 new ColoredWindowController(window, "SessionStateAnimatorForeground"));
500 foreground_->SetColor(SK_ColorWHITE); 449 foreground_->SetColor(SK_ColorWHITE);
501 foreground_->GetWidget()->Show(); 450 foreground_->GetWidget()->Show();
502 } 451 }
503 452
504 void SessionStateAnimator::DropForeground() { 453 void SessionStateAnimator::DropForeground() {
505 foreground_.reset(); 454 foreground_.reset();
506 } 455 }
507 456
508 } // namespace internal 457 } // namespace internal
509 } // namespace ash 458 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/session_state_animator.h ('k') | ash/wm/session_state_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698