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

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

Issue 180273025: Keep dedicated layers for hiding animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
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/window_animations.h" 5 #include "ash/wm/window_animations.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Now that the window has been restored, we need to clear its animation style 166 // Now that the window has been restored, we need to clear its animation style
167 // to default so that normal animation applies. 167 // to default so that normal animation applies.
168 views::corewm::SetWindowVisibilityAnimationType( 168 views::corewm::SetWindowVisibilityAnimationType(
169 window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 169 window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
170 } 170 }
171 171
172 void AnimateHideWindow_Minimize(aura::Window* window) { 172 void AnimateHideWindow_Minimize(aura::Window* window) {
173 window->layer()->set_delegate(NULL); 173 window->layer()->set_delegate(NULL);
174 174
175 // Property sets within this scope will be implicitly animated. 175 // Property sets within this scope will be implicitly animated.
176 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 176 views::corewm::ScopedHidingAnimationSettings hiding_settings(window);
177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
178 kLayerAnimationsForMinimizeDurationMS); 178 kLayerAnimationsForMinimizeDurationMS);
179 settings.SetTransitionDuration(duration); 179 hiding_settings.layer_animation_settings()->SetTransitionDuration(duration);
180 settings.AddObserver(
181 views::corewm::CreateHidingWindowAnimationObserver(window));
182 window->layer()->SetVisible(false); 180 window->layer()->SetVisible(false);
183 181
184 AddLayerAnimationsForMinimize(window, false); 182 AddLayerAnimationsForMinimize(window, false);
185 } 183 }
186 184
187 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, 185 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
188 bool show) { 186 bool show) {
189 window->layer()->set_delegate(window); 187 window->layer()->set_delegate(window);
190 188
191 float start_value, end_value; 189 float start_value, end_value;
192 if (show) { 190 if (show) {
193 start_value = kWindowAnimation_HideBrightnessGrayscale; 191 start_value = kWindowAnimation_HideBrightnessGrayscale;
194 end_value = kWindowAnimation_ShowBrightnessGrayscale; 192 end_value = kWindowAnimation_ShowBrightnessGrayscale;
195 } else { 193 } else {
196 start_value = kWindowAnimation_ShowBrightnessGrayscale; 194 start_value = kWindowAnimation_ShowBrightnessGrayscale;
197 end_value = kWindowAnimation_HideBrightnessGrayscale; 195 end_value = kWindowAnimation_HideBrightnessGrayscale;
198 } 196 }
199 197
200 window->layer()->SetLayerBrightness(start_value); 198 window->layer()->SetLayerBrightness(start_value);
201 window->layer()->SetLayerGrayscale(start_value); 199 window->layer()->SetLayerGrayscale(start_value);
202 if (show) { 200 if (show) {
203 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); 201 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
204 window->layer()->SetVisible(true); 202 window->layer()->SetVisible(true);
205 } 203 }
206 204
207 base::TimeDelta duration = 205 base::TimeDelta duration =
208 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); 206 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs);
209 207
210 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 208 if (show) {
211 settings.SetTransitionDuration(duration); 209 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
212 if (!show) { 210 window->layer()->GetAnimator()->
213 settings.AddObserver( 211 ScheduleTogether(
214 views::corewm::CreateHidingWindowAnimationObserver(window)); 212 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
215 } 213 } else {
216 214 views::corewm::ScopedHidingAnimationSettings hiding_settings(window);
217 window->layer()->GetAnimator()-> 215 window->layer()->GetAnimator()->
218 ScheduleTogether( 216 ScheduleTogether(
219 CreateBrightnessGrayscaleAnimationSequence(end_value, duration)); 217 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
220 if (!show) {
221 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 218 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
222 window->layer()->SetVisible(false); 219 window->layer()->SetVisible(false);
223 } 220 }
224 } 221 }
225 222
226 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { 223 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
227 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); 224 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
228 } 225 }
229 226
230 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { 227 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 495 }
499 496
500 // Assume the shelf is overflowed, zoom off to the bottom right of the 497 // Assume the shelf is overflowed, zoom off to the bottom right of the
501 // work area. 498 // work area.
502 gfx::Rect work_area = 499 gfx::Rect work_area =
503 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); 500 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
504 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); 501 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0);
505 } 502 }
506 503
507 } // namespace ash 504 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698