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

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

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/power_button_controller_unittest.cc ('k') | ash/wm/session_state_animator.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 #ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_ 5 #ifndef ASH_WM_SESSION_STATE_ANIMATOR_H_
6 #define ASH_WM_SESSION_STATE_ANIMATOR_H_ 6 #define ASH_WM_SESSION_STATE_ANIMATOR_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/wm/workspace/colored_window_controller.h" 9 #include "ash/wm/workspace/colored_window_controller.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/timer.h" 12 #include "base/timer.h"
13 #include "ui/aura/root_window_observer.h"
14 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
15 14
16 namespace gfx { 15 namespace gfx {
17 class Rect; 16 class Rect;
18 class Size; 17 class Size;
19 } 18 }
20 19
21 namespace ui { 20 namespace ui {
22 class Layer; 21 class Layer;
23 } 22 }
24 23
25 namespace ash { 24 namespace ash {
26 namespace internal { 25 namespace internal {
27 26
28 // Displays onscreen animations for session state changes (lock/unlock, sign 27 // Displays onscreen animations for session state changes (lock/unlock, sign
29 // out, shut down). 28 // out, shut down).
30 class ASH_EXPORT SessionStateAnimator : public aura::RootWindowObserver { 29 class ASH_EXPORT SessionStateAnimator {
31 public: 30 public:
32 // Animations that can be applied to groups of containers. 31 // Animations that can be applied to groups of containers.
33 enum AnimationType { 32 enum AnimationType {
34 ANIMATION_PARTIAL_CLOSE = 0, 33 ANIMATION_PARTIAL_CLOSE = 0,
35 ANIMATION_UNDO_PARTIAL_CLOSE, 34 ANIMATION_UNDO_PARTIAL_CLOSE,
36 ANIMATION_FULL_CLOSE, 35 ANIMATION_FULL_CLOSE,
37 ANIMATION_FADE_IN, 36 ANIMATION_FADE_IN,
38 ANIMATION_HIDE, 37 ANIMATION_HIDE,
39 ANIMATION_RESTORE, 38 ANIMATION_RESTORE,
40 ANIMATION_RAISE, 39 ANIMATION_RAISE,
(...skipping 27 matching lines...) Expand all
68 67
69 LOCK_SCREEN_SYSTEM_FOREGROUND = 1 << 6, 68 LOCK_SCREEN_SYSTEM_FOREGROUND = 1 << 6,
70 }; 69 };
71 70
72 // Helper class used by tests to access internal state. 71 // Helper class used by tests to access internal state.
73 class ASH_EXPORT TestApi { 72 class ASH_EXPORT TestApi {
74 public: 73 public:
75 explicit TestApi(SessionStateAnimator* animator) 74 explicit TestApi(SessionStateAnimator* animator)
76 : animator_(animator) {} 75 : animator_(animator) {}
77 76
78 bool hide_black_layer_timer_is_running() const {
79 return animator_->hide_black_layer_timer_.IsRunning();
80 }
81
82 void TriggerHideBlackLayerTimeout();
83
84 // Returns true if containers of a given |container_mask| 77 // Returns true if containers of a given |container_mask|
85 // were last animated with |type| (probably; the analysis is fairly ad-hoc). 78 // were last animated with |type| (probably; the analysis is fairly ad-hoc).
86 // |container_mask| is a bitfield of a Container. 79 // |container_mask| is a bitfield of a Container.
87 bool ContainersAreAnimated(int container_mask, AnimationType type) const; 80 bool ContainersAreAnimated(int container_mask, AnimationType type) const;
88 81
89 // Returns true if |black_layer_| is non-NULL and visible.
90 bool BlackLayerIsVisible() const;
91
92 // Returns |black_layer_|'s bounds, or an empty rect if the layer is
93 // NULL.
94 gfx::Rect GetBlackLayerBounds() const;
95
96 private: 82 private:
97 SessionStateAnimator* animator_; // not owned 83 SessionStateAnimator* animator_; // not owned
98 84
99 DISALLOW_COPY_AND_ASSIGN(TestApi); 85 DISALLOW_COPY_AND_ASSIGN(TestApi);
100 }; 86 };
101 87
102 // A bitfield mask including LOCK_SCREEN_WALLPAPER, 88 // A bitfield mask including LOCK_SCREEN_WALLPAPER,
103 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS. 89 // LOCK_SCREEN_CONTAINERS, and LOCK_SCREEN_RELATED_CONTAINERS.
104 const static int kAllLockScreenContainersMask; 90 const static int kAllLockScreenContainersMask;
105 91
106 // A bitfield mask of all containers. 92 // A bitfield mask of all containers.
107 const static int kAllContainersMask; 93 const static int kAllContainersMask;
108 94
109 SessionStateAnimator(); 95 SessionStateAnimator();
110 virtual ~SessionStateAnimator(); 96 virtual ~SessionStateAnimator();
111 97
112 // Shows or hides |black_layer_|. The show method creates and
113 // initializes the layer if it doesn't already exist.
114 void ShowBlackLayer();
115 void DropBlackLayer();
116
117 // Create |foreground_| layer if it doesn't already exist, but makes it 98 // Create |foreground_| layer if it doesn't already exist, but makes it
118 // completely transparent. 99 // completely transparent.
119 void CreateForeground(); 100 void CreateForeground();
120 // Destroy |foreground_| when it is not needed anymore. 101 // Destroy |foreground_| when it is not needed anymore.
121 void DropForeground(); 102 void DropForeground();
122 103
123 // Drops back layer after |UNDO_SLOW_CLOSE| animation delay.
124 void ScheduleDropBlackLayer();
125
126 // Apply animation |type| to all containers included in |container_mask|. 104 // Apply animation |type| to all containers included in |container_mask|.
127 void StartAnimation(int container_mask, 105 void StartAnimation(int container_mask,
128 AnimationType type); 106 AnimationType type);
129 107
130 // Apply animation |type| to all containers included in |container_mask| and 108 // Apply animation |type| to all containers included in |container_mask| and
131 // call a |callback| at the end of the animation, if it is not null. 109 // call a |callback| at the end of the animation, if it is not null.
132 void StartAnimationWithCallback(int container_mask, 110 void StartAnimationWithCallback(int container_mask,
133 AnimationType type, 111 AnimationType type,
134 base::Callback<void(void)>& callback); 112 base::Callback<void(void)>& callback);
135 113
136 // Fills |containers| with the containers included in |container_mask|. 114 // Fills |containers| with the containers included in |container_mask|.
137 void GetContainers(int container_mask, 115 void GetContainers(int container_mask,
138 aura::Window::Windows* containers); 116 aura::Window::Windows* containers);
139 117
140 // aura::RootWindowObserver overrides:
141 virtual void OnRootWindowResized(const aura::RootWindow* root,
142 const gfx::Size& old_size) OVERRIDE;
143
144 private:
145 // Apply animation |type| to window |window| and add |observer| if it is not 118 // Apply animation |type| to window |window| and add |observer| if it is not
146 // NULL to the last animation sequence. 119 // NULL to the last animation sequence.
147 void RunAnimationForWindow(aura::Window* window, 120 void RunAnimationForWindow(aura::Window* window,
148 AnimationType type, 121 AnimationType type,
149 ui::LayerAnimationObserver* observer); 122 ui::LayerAnimationObserver* observer);
150 123
151 // Layer that's stacked under all of the root window's children to provide a
152 // black background when we're scaling all of the other windows down.
153 // TODO(derat): Remove this in favor of having the compositor only clear the
154 // viewport when there are regions not covered by a layer:
155 // http://crbug.com/113445
156 scoped_ptr<ui::Layer> black_layer_;
157
158 // White foreground that is used during shutdown animation to "fade 124 // White foreground that is used during shutdown animation to "fade
159 // everything into white". 125 // everything into white".
160 scoped_ptr<ColoredWindowController> foreground_; 126 scoped_ptr<ColoredWindowController> foreground_;
161 127
162 // Started when we abort the pre-lock state. When it fires, we hide
163 // |black_layer_|, as the desktop background is now covering the whole
164 // screen.
165 base::OneShotTimer<SessionStateAnimator> hide_black_layer_timer_;
166
167 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator); 128 DISALLOW_COPY_AND_ASSIGN(SessionStateAnimator);
168 }; 129 };
169 130
170 } // namespace internal 131 } // namespace internal
171 } // namespace ash 132 } // namespace ash
172 133
173 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_ 134 #endif // ASH_WM_SESSION_STATE_ANIMATOR_H_
OLDNEW
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/session_state_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698