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

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
« no previous file with comments | « ash/wm/system_modal_container_layout_manager.cc ('k') | ash/wm/window_animations_unittest.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/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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // Reset the transform to identity when the minimize animation is completed. 149 // Reset the transform to identity when the minimize animation is completed.
150 window->layer()->GetAnimator()->ScheduleAnimation( 150 window->layer()->GetAnimator()->ScheduleAnimation(
151 new ui::LayerAnimationSequence( 151 new ui::LayerAnimationSequence(
152 ui::LayerAnimationElement::CreateTransformElement( 152 ui::LayerAnimationElement::CreateTransformElement(
153 gfx::Transform(), 153 gfx::Transform(),
154 base::TimeDelta()))); 154 base::TimeDelta())));
155 } 155 }
156 156
157 void AnimateShowWindow_Minimize(aura::Window* window) { 157 void AnimateShowWindow_Minimize(aura::Window* window) {
158 window->layer()->set_delegate(window);
159 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 158 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
160 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 159 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
161 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 160 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
162 kLayerAnimationsForMinimizeDurationMS); 161 kLayerAnimationsForMinimizeDurationMS);
163 settings.SetTransitionDuration(duration); 162 settings.SetTransitionDuration(duration);
164 AddLayerAnimationsForMinimize(window, true); 163 AddLayerAnimationsForMinimize(window, true);
165 164
166 // Now that the window has been restored, we need to clear its animation style 165 // Now that the window has been restored, we need to clear its animation style
167 // to default so that normal animation applies. 166 // to default so that normal animation applies.
168 ::wm::SetWindowVisibilityAnimationType( 167 ::wm::SetWindowVisibilityAnimationType(
169 window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 168 window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
170 } 169 }
171 170
172 void AnimateHideWindow_Minimize(aura::Window* window) { 171 void AnimateHideWindow_Minimize(aura::Window* window) {
173 window->layer()->set_delegate(NULL);
174
175 // Property sets within this scope will be implicitly animated. 172 // Property sets within this scope will be implicitly animated.
176 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 173 ::wm::ScopedHidingAnimationSettings hiding_settings(window);
177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 174 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
178 kLayerAnimationsForMinimizeDurationMS); 175 kLayerAnimationsForMinimizeDurationMS);
179 settings.SetTransitionDuration(duration); 176 hiding_settings.layer_animation_settings()->SetTransitionDuration(duration);
180 settings.AddObserver(
181 ::wm::CreateHidingWindowAnimationObserver(window));
182 window->layer()->SetVisible(false); 177 window->layer()->SetVisible(false);
183 178
184 AddLayerAnimationsForMinimize(window, false); 179 AddLayerAnimationsForMinimize(window, false);
185 } 180 }
186 181
187 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, 182 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
188 bool show) { 183 bool show) {
189 window->layer()->set_delegate(window);
190
191 float start_value, end_value; 184 float start_value, end_value;
192 if (show) { 185 if (show) {
193 start_value = kWindowAnimation_HideBrightnessGrayscale; 186 start_value = kWindowAnimation_HideBrightnessGrayscale;
194 end_value = kWindowAnimation_ShowBrightnessGrayscale; 187 end_value = kWindowAnimation_ShowBrightnessGrayscale;
195 } else { 188 } else {
196 start_value = kWindowAnimation_ShowBrightnessGrayscale; 189 start_value = kWindowAnimation_ShowBrightnessGrayscale;
197 end_value = kWindowAnimation_HideBrightnessGrayscale; 190 end_value = kWindowAnimation_HideBrightnessGrayscale;
198 } 191 }
199 192
200 window->layer()->SetLayerBrightness(start_value); 193 window->layer()->SetLayerBrightness(start_value);
201 window->layer()->SetLayerGrayscale(start_value); 194 window->layer()->SetLayerGrayscale(start_value);
202 if (show) { 195 if (show) {
203 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); 196 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
204 window->layer()->SetVisible(true); 197 window->layer()->SetVisible(true);
205 } 198 }
206 199
207 base::TimeDelta duration = 200 base::TimeDelta duration =
208 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); 201 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs);
209 202
210 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 203 if (show) {
211 settings.SetTransitionDuration(duration); 204 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
212 if (!show) { 205 window->layer()->GetAnimator()->
213 settings.AddObserver( 206 ScheduleTogether(
214 ::wm::CreateHidingWindowAnimationObserver(window)); 207 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
215 } 208 } else {
216 209 ::wm::ScopedHidingAnimationSettings hiding_settings(window);
217 window->layer()->GetAnimator()-> 210 window->layer()->GetAnimator()->
218 ScheduleTogether( 211 ScheduleTogether(
219 CreateBrightnessGrayscaleAnimationSequence(end_value, duration)); 212 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
220 if (!show) {
221 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 213 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
222 window->layer()->SetVisible(false); 214 window->layer()->SetVisible(false);
223 } 215 }
224 } 216 }
225 217
226 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { 218 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
227 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); 219 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
228 } 220 }
229 221
230 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { 222 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 490 }
499 491
500 // Assume the shelf is overflowed, zoom off to the bottom right of the 492 // Assume the shelf is overflowed, zoom off to the bottom right of the
501 // work area. 493 // work area.
502 gfx::Rect work_area = 494 gfx::Rect work_area =
503 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); 495 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
504 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); 496 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0);
505 } 497 }
506 498
507 } // namespace ash 499 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_modal_container_layout_manager.cc ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698