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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ash/wm/window_animations.h ('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 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int max_area = std::max(old_area, new_area); 78 int max_area = std::max(old_area, new_area);
79 // Avoid divide by zero. 79 // Avoid divide by zero.
80 if (max_area == 0) 80 if (max_area == 0)
81 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS); 81 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
82 82
83 int delta_area = std::abs(old_area - new_area); 83 int delta_area = std::abs(old_area - new_area);
84 // If the area didn't change, the animation is instantaneous. 84 // If the area didn't change, the animation is instantaneous.
85 if (delta_area == 0) 85 if (delta_area == 0)
86 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS); 86 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
87 87
88 float factor = 88 float factor = static_cast<float>(delta_area) / static_cast<float>(max_area);
89 static_cast<float>(delta_area) / static_cast<float>(max_area);
90 const float kRange = kCrossFadeDurationMaxMs - kCrossFadeDurationMinMs; 89 const float kRange = kCrossFadeDurationMaxMs - kCrossFadeDurationMinMs;
91 return base::TimeDelta::FromMilliseconds( 90 return base::TimeDelta::FromMilliseconds(
92 Round64(kCrossFadeDurationMinMs + (factor * kRange))); 91 Round64(kCrossFadeDurationMinMs + (factor * kRange)));
93 } 92 }
94 93
95 } // namespace 94 } // namespace
96 95
97 const int kCrossFadeDurationMS = 200; 96 const int kCrossFadeDurationMS = 200;
98 97
99 void AddLayerAnimationsForMinimize(aura::Window* window, bool show) { 98 void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
(...skipping 11 matching lines...) Expand all
111 gfx::Point3F(1, 1, 1), gfx::Point3F(scale_x, scale_y, 1))); 110 gfx::Point3F(1, 1, 1), gfx::Point3F(scale_x, scale_y, 1)));
112 111
113 std::unique_ptr<ui::InterpolatedTransform> translation( 112 std::unique_ptr<ui::InterpolatedTransform> translation(
114 new ui::InterpolatedTranslation( 113 new ui::InterpolatedTranslation(
115 gfx::PointF(), gfx::PointF(target_bounds.x() - bounds.x(), 114 gfx::PointF(), gfx::PointF(target_bounds.x() - bounds.x(),
116 target_bounds.y() - bounds.y()))); 115 target_bounds.y() - bounds.y())));
117 116
118 scale->SetChild(translation.release()); 117 scale->SetChild(translation.release());
119 scale->SetReversed(show); 118 scale->SetReversed(show);
120 119
121 base::TimeDelta duration = window->layer()->GetAnimator()-> 120 base::TimeDelta duration =
122 GetTransitionDuration(); 121 window->layer()->GetAnimator()->GetTransitionDuration();
123 122
124 std::unique_ptr<ui::LayerAnimationElement> transition( 123 std::unique_ptr<ui::LayerAnimationElement> transition(
125 ui::LayerAnimationElement::CreateInterpolatedTransformElement( 124 ui::LayerAnimationElement::CreateInterpolatedTransformElement(
126 scale.release(), duration)); 125 scale.release(), duration));
127 126
128 transition->set_tween_type( 127 transition->set_tween_type(show ? gfx::Tween::EASE_IN
129 show ? gfx::Tween::EASE_IN : gfx::Tween::EASE_IN_OUT); 128 : gfx::Tween::EASE_IN_OUT);
130 129
131 window->layer()->GetAnimator()->ScheduleAnimation( 130 window->layer()->GetAnimator()->ScheduleAnimation(
132 new ui::LayerAnimationSequence(transition.release())); 131 new ui::LayerAnimationSequence(transition.release()));
133 132
134 // When hiding a window, turn off blending until the animation is 3 / 4 done 133 // When hiding a window, turn off blending until the animation is 3 / 4 done
135 // to save bandwidth and reduce jank. 134 // to save bandwidth and reduce jank.
136 if (!show) { 135 if (!show) {
137 window->layer()->GetAnimator()->SchedulePauseForProperties( 136 window->layer()->GetAnimator()->SchedulePauseForProperties(
138 (duration * 3) / 4, ui::LayerAnimationElement::OPACITY); 137 (duration * 3) / 4, ui::LayerAnimationElement::OPACITY);
139 } 138 }
140 139
141 // Fade in and out quickly when the window is small to reduce jank. 140 // Fade in and out quickly when the window is small to reduce jank.
142 float opacity = show ? 1.0f : 0.0f; 141 float opacity = show ? 1.0f : 0.0f;
143 window->layer()->GetAnimator()->ScheduleAnimation( 142 window->layer()->GetAnimator()->ScheduleAnimation(
144 new ui::LayerAnimationSequence( 143 new ui::LayerAnimationSequence(
145 ui::LayerAnimationElement::CreateOpacityElement( 144 ui::LayerAnimationElement::CreateOpacityElement(opacity,
146 opacity, duration / 4))); 145 duration / 4)));
147 146
148 // Reset the transform to identity when the minimize animation is completed. 147 // Reset the transform to identity when the minimize animation is completed.
149 window->layer()->GetAnimator()->ScheduleAnimation( 148 window->layer()->GetAnimator()->ScheduleAnimation(
150 new ui::LayerAnimationSequence( 149 new ui::LayerAnimationSequence(
151 ui::LayerAnimationElement::CreateTransformElement( 150 ui::LayerAnimationElement::CreateTransformElement(
152 gfx::Transform(), 151 gfx::Transform(), base::TimeDelta())));
153 base::TimeDelta())));
154 } 152 }
155 153
156 void AnimateShowWindow_Minimize(aura::Window* window) { 154 void AnimateShowWindow_Minimize(aura::Window* window) {
157 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 155 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
158 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 156 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
159 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 157 base::TimeDelta duration =
160 kLayerAnimationsForMinimizeDurationMS); 158 base::TimeDelta::FromMilliseconds(kLayerAnimationsForMinimizeDurationMS);
161 settings.SetTransitionDuration(duration); 159 settings.SetTransitionDuration(duration);
162 AddLayerAnimationsForMinimize(window, true); 160 AddLayerAnimationsForMinimize(window, true);
163 161
164 // Now that the window has been restored, we need to clear its animation style 162 // Now that the window has been restored, we need to clear its animation style
165 // to default so that normal animation applies. 163 // to default so that normal animation applies.
166 ::wm::SetWindowVisibilityAnimationType( 164 ::wm::SetWindowVisibilityAnimationType(
167 window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 165 window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
168 } 166 }
169 167
170 void AnimateHideWindow_Minimize(aura::Window* window) { 168 void AnimateHideWindow_Minimize(aura::Window* window) {
171 // Property sets within this scope will be implicitly animated. 169 // Property sets within this scope will be implicitly animated.
172 ::wm::ScopedHidingAnimationSettings hiding_settings(window); 170 ::wm::ScopedHidingAnimationSettings hiding_settings(window);
173 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 171 base::TimeDelta duration =
174 kLayerAnimationsForMinimizeDurationMS); 172 base::TimeDelta::FromMilliseconds(kLayerAnimationsForMinimizeDurationMS);
175 hiding_settings.layer_animation_settings()->SetTransitionDuration(duration); 173 hiding_settings.layer_animation_settings()->SetTransitionDuration(duration);
176 window->layer()->SetVisible(false); 174 window->layer()->SetVisible(false);
177 175
178 AddLayerAnimationsForMinimize(window, false); 176 AddLayerAnimationsForMinimize(window, false);
179 } 177 }
180 178
181 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, 179 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
182 bool show) { 180 bool show) {
183 float start_value, end_value; 181 float start_value, end_value;
184 if (show) { 182 if (show) {
185 start_value = kWindowAnimation_HideBrightnessGrayscale; 183 start_value = kWindowAnimation_HideBrightnessGrayscale;
186 end_value = kWindowAnimation_ShowBrightnessGrayscale; 184 end_value = kWindowAnimation_ShowBrightnessGrayscale;
187 } else { 185 } else {
188 start_value = kWindowAnimation_ShowBrightnessGrayscale; 186 start_value = kWindowAnimation_ShowBrightnessGrayscale;
189 end_value = kWindowAnimation_HideBrightnessGrayscale; 187 end_value = kWindowAnimation_HideBrightnessGrayscale;
190 } 188 }
191 189
192 window->layer()->SetLayerBrightness(start_value); 190 window->layer()->SetLayerBrightness(start_value);
193 window->layer()->SetLayerGrayscale(start_value); 191 window->layer()->SetLayerGrayscale(start_value);
194 if (show) { 192 if (show) {
195 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); 193 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
196 window->layer()->SetVisible(true); 194 window->layer()->SetVisible(true);
197 } 195 }
198 196
199 base::TimeDelta duration = 197 base::TimeDelta duration =
200 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); 198 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs);
201 199
202 if (show) { 200 if (show) {
203 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 201 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
204 window->layer()->GetAnimator()-> 202 window->layer()->GetAnimator()->ScheduleTogether(
205 ScheduleTogether( 203 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
206 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
207 } else { 204 } else {
208 ::wm::ScopedHidingAnimationSettings hiding_settings(window); 205 ::wm::ScopedHidingAnimationSettings hiding_settings(window);
209 window->layer()->GetAnimator()-> 206 window->layer()->GetAnimator()->ScheduleTogether(
210 ScheduleTogether( 207 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
211 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
212 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 208 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
213 window->layer()->SetVisible(false); 209 window->layer()->SetVisible(false);
214 } 210 }
215 } 211 }
216 212
217 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { 213 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
218 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); 214 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
219 } 215 }
220 216
221 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { 217 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
222 AnimateShowHideWindowCommon_BrightnessGrayscale(window, false); 218 AnimateShowHideWindowCommon_BrightnessGrayscale(window, false);
223 } 219 }
224 220
225 bool AnimateShowWindow(aura::Window* window) { 221 bool AnimateShowWindow(aura::Window* window) {
226 if (!::wm::HasWindowVisibilityAnimationTransition( 222 if (!::wm::HasWindowVisibilityAnimationTransition(window,
227 window, ::wm::ANIMATE_SHOW)) { 223 ::wm::ANIMATE_SHOW)) {
228 return false; 224 return false;
229 } 225 }
230 226
231 switch (::wm::GetWindowVisibilityAnimationType(window)) { 227 switch (::wm::GetWindowVisibilityAnimationType(window)) {
232 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: 228 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
233 AnimateShowWindow_Minimize(window); 229 AnimateShowWindow_Minimize(window);
234 return true; 230 return true;
235 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE: 231 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
236 AnimateShowWindow_BrightnessGrayscale(window); 232 AnimateShowWindow_BrightnessGrayscale(window);
237 return true; 233 return true;
238 default: 234 default:
239 NOTREACHED(); 235 NOTREACHED();
240 return false; 236 return false;
241 } 237 }
242 } 238 }
243 239
244 bool AnimateHideWindow(aura::Window* window) { 240 bool AnimateHideWindow(aura::Window* window) {
245 if (!::wm::HasWindowVisibilityAnimationTransition( 241 if (!::wm::HasWindowVisibilityAnimationTransition(window,
246 window, ::wm::ANIMATE_HIDE)) { 242 ::wm::ANIMATE_HIDE)) {
247 return false; 243 return false;
248 } 244 }
249 245
250 switch (::wm::GetWindowVisibilityAnimationType(window)) { 246 switch (::wm::GetWindowVisibilityAnimationType(window)) {
251 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: 247 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
252 AnimateHideWindow_Minimize(window); 248 AnimateHideWindow_Minimize(window);
253 return true; 249 return true;
254 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE: 250 case wm::WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
255 AnimateHideWindow_BrightnessGrayscale(window); 251 AnimateHideWindow_BrightnessGrayscale(window);
256 return true; 252 return true;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 gfx::Transform old_transform(old_layer_owner->root()->transform()); 319 gfx::Transform old_transform(old_layer_owner->root()->transform());
324 gfx::Transform old_transform_in_root; 320 gfx::Transform old_transform_in_root;
325 old_transform_in_root.Translate(old_bounds.x(), old_bounds.y()); 321 old_transform_in_root.Translate(old_bounds.x(), old_bounds.y());
326 old_transform_in_root.PreconcatTransform(old_transform); 322 old_transform_in_root.PreconcatTransform(old_transform);
327 old_transform_in_root.Translate(-old_bounds.x(), -old_bounds.y()); 323 old_transform_in_root.Translate(-old_bounds.x(), -old_bounds.y());
328 old_transform_in_root.TransformRect(&old_transformed_bounds); 324 old_transform_in_root.TransformRect(&old_transformed_bounds);
329 const gfx::Rect new_bounds(window->bounds()); 325 const gfx::Rect new_bounds(window->bounds());
330 const bool old_on_top = (old_bounds.width() > new_bounds.width()); 326 const bool old_on_top = (old_bounds.width() > new_bounds.width());
331 327
332 // Shorten the animation if there's not much visual movement. 328 // Shorten the animation if there's not much visual movement.
333 const base::TimeDelta duration = GetCrossFadeDuration(window, 329 const base::TimeDelta duration =
334 old_transformed_bounds, new_bounds); 330 GetCrossFadeDuration(window, old_transformed_bounds, new_bounds);
335 331
336 // Scale up the old layer while translating to new position. 332 // Scale up the old layer while translating to new position.
337 { 333 {
338 ui::Layer* old_layer = old_layer_owner->root(); 334 ui::Layer* old_layer = old_layer_owner->root();
339 old_layer->GetAnimator()->StopAnimating(); 335 old_layer->GetAnimator()->StopAnimating();
340 old_layer->SetTransform(old_transform); 336 old_layer->SetTransform(old_transform);
341 ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator()); 337 ui::ScopedLayerAnimationSettings settings(old_layer->GetAnimator());
342 338
343 // Animation observer owns the old layer and deletes itself. 339 // Animation observer owns the old layer and deletes itself.
344 settings.AddObserver( 340 settings.AddObserver(
345 new CrossFadeObserver(window, std::move(old_layer_owner))); 341 new CrossFadeObserver(window, std::move(old_layer_owner)));
346 settings.SetTransitionDuration(duration); 342 settings.SetTransitionDuration(duration);
347 settings.SetTweenType(tween_type); 343 settings.SetTweenType(tween_type);
348 gfx::Transform out_transform; 344 gfx::Transform out_transform;
349 float scale_x = static_cast<float>(new_bounds.width()) / 345 float scale_x = static_cast<float>(new_bounds.width()) /
350 static_cast<float>(old_bounds.width()); 346 static_cast<float>(old_bounds.width());
351 float scale_y = static_cast<float>(new_bounds.height()) / 347 float scale_y = static_cast<float>(new_bounds.height()) /
352 static_cast<float>(old_bounds.height()); 348 static_cast<float>(old_bounds.height());
353 out_transform.Translate(new_bounds.x() - old_bounds.x(), 349 out_transform.Translate(new_bounds.x() - old_bounds.x(),
354 new_bounds.y() - old_bounds.y()); 350 new_bounds.y() - old_bounds.y());
355 out_transform.Scale(scale_x, scale_y); 351 out_transform.Scale(scale_x, scale_y);
356 old_layer->SetTransform(out_transform); 352 old_layer->SetTransform(out_transform);
357 if (old_on_top) { 353 if (old_on_top) {
358 // The old layer is on top, and should fade out. The new layer below will 354 // The old layer is on top, and should fade out. The new layer below will
359 // stay opaque to block the desktop. 355 // stay opaque to block the desktop.
360 old_layer->SetOpacity(kWindowAnimation_HideOpacity); 356 old_layer->SetOpacity(kWindowAnimation_HideOpacity);
361 } 357 }
362 // In tests |old_layer| is deleted here, as animations have zero duration. 358 // In tests |old_layer| is deleted here, as animations have zero duration.
363 old_layer = NULL; 359 old_layer = NULL;
364 } 360 }
365 361
366 // Set the new layer's current transform, such that the user sees a scaled 362 // Set the new layer's current transform, such that the user sees a scaled
367 // version of the window with the original bounds at the original position. 363 // version of the window with the original bounds at the original position.
368 gfx::Transform in_transform; 364 gfx::Transform in_transform;
369 const float scale_x = old_transformed_bounds.width() / 365 const float scale_x =
370 static_cast<float>(new_bounds.width()); 366 old_transformed_bounds.width() / static_cast<float>(new_bounds.width());
371 const float scale_y = old_transformed_bounds.height() / 367 const float scale_y =
372 static_cast<float>(new_bounds.height()); 368 old_transformed_bounds.height() / static_cast<float>(new_bounds.height());
373 in_transform.Translate(old_transformed_bounds.x() - new_bounds.x(), 369 in_transform.Translate(old_transformed_bounds.x() - new_bounds.x(),
374 old_transformed_bounds.y() - new_bounds.y()); 370 old_transformed_bounds.y() - new_bounds.y());
375 in_transform.Scale(scale_x, scale_y); 371 in_transform.Scale(scale_x, scale_y);
376 window->layer()->SetTransform(in_transform); 372 window->layer()->SetTransform(in_transform);
377 if (!old_on_top) { 373 if (!old_on_top) {
378 // The new layer is on top and should fade in. The old layer below will 374 // The new layer is on top and should fade in. The old layer below will
379 // stay opaque and block the desktop. 375 // stay opaque and block the desktop.
380 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 376 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
381 } 377 }
382 { 378 {
(...skipping 17 matching lines...) Expand all
400 396
401 // Attempt to run CoreWm supplied animation types. 397 // Attempt to run CoreWm supplied animation types.
402 if (::wm::AnimateOnChildWindowVisibilityChanged(window, visible)) 398 if (::wm::AnimateOnChildWindowVisibilityChanged(window, visible))
403 return true; 399 return true;
404 400
405 // Otherwise try to run an Ash-specific animation. 401 // Otherwise try to run an Ash-specific animation.
406 if (visible) 402 if (visible)
407 return AnimateShowWindow(window); 403 return AnimateShowWindow(window);
408 // Don't start hiding the window again if it's already being hidden. 404 // Don't start hiding the window again if it's already being hidden.
409 return window->layer()->GetTargetOpacity() != 0.0f && 405 return window->layer()->GetTargetOpacity() != 0.0f &&
410 AnimateHideWindow(window); 406 AnimateHideWindow(window);
411 } 407 }
412 408
413 std::vector<ui::LayerAnimationSequence*> 409 std::vector<ui::LayerAnimationSequence*>
414 CreateBrightnessGrayscaleAnimationSequence(float target_value, 410 CreateBrightnessGrayscaleAnimationSequence(float target_value,
415 base::TimeDelta duration) { 411 base::TimeDelta duration) {
416 gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT; 412 gfx::Tween::Type animation_type = gfx::Tween::EASE_OUT;
417 std::unique_ptr<ui::LayerAnimationSequence> brightness_sequence( 413 std::unique_ptr<ui::LayerAnimationSequence> brightness_sequence(
418 new ui::LayerAnimationSequence()); 414 new ui::LayerAnimationSequence());
419 std::unique_ptr<ui::LayerAnimationSequence> grayscale_sequence( 415 std::unique_ptr<ui::LayerAnimationSequence> grayscale_sequence(
420 new ui::LayerAnimationSequence()); 416 new ui::LayerAnimationSequence());
(...skipping 13 matching lines...) Expand all
434 std::vector<ui::LayerAnimationSequence*> animations; 430 std::vector<ui::LayerAnimationSequence*> animations;
435 animations.push_back(brightness_sequence.release()); 431 animations.push_back(brightness_sequence.release());
436 animations.push_back(grayscale_sequence.release()); 432 animations.push_back(grayscale_sequence.release());
437 433
438 return animations; 434 return animations;
439 } 435 }
440 436
441 // Returns scale related to the specified AshWindowScaleType. 437 // Returns scale related to the specified AshWindowScaleType.
442 void SetTransformForScaleAnimation(ui::Layer* layer, 438 void SetTransformForScaleAnimation(ui::Layer* layer,
443 LayerScaleAnimationDirection type) { 439 LayerScaleAnimationDirection type) {
444 const float scale = 440 const float scale = type == LAYER_SCALE_ANIMATION_ABOVE
445 type == LAYER_SCALE_ANIMATION_ABOVE ? kLayerScaleAboveSize : 441 ? kLayerScaleAboveSize
446 kLayerScaleBelowSize; 442 : kLayerScaleBelowSize;
447 gfx::Transform transform; 443 gfx::Transform transform;
448 transform.Translate(-layer->bounds().width() * (scale - 1.0f) / 2, 444 transform.Translate(-layer->bounds().width() * (scale - 1.0f) / 2,
449 -layer->bounds().height() * (scale - 1.0f) / 2); 445 -layer->bounds().height() * (scale - 1.0f) / 2);
450 transform.Scale(scale, scale); 446 transform.Scale(scale, scale);
451 layer->SetTransform(transform); 447 layer->SetTransform(transform);
452 } 448 }
453 449
454 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) { 450 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
455 Shelf* shelf = Shelf::ForWindow(window); 451 Shelf* shelf = Shelf::ForWindow(window);
456 // Shelf is created lazily and can be NULL. 452 // Shelf is created lazily and can be NULL.
(...skipping 29 matching lines...) Expand all
486 gfx::Rect work_area = 482 gfx::Rect work_area =
487 display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area(); 483 display::Screen::GetScreen()->GetDisplayNearestWindow(window).work_area();
488 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x(); 484 int ltr_adjusted_x = base::i18n::IsRTL() ? work_area.right() : work_area.x();
489 return shelf->SelectValueForShelfAlignment( 485 return shelf->SelectValueForShelfAlignment(
490 gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0), 486 gfx::Rect(ltr_adjusted_x, work_area.bottom(), 0, 0),
491 gfx::Rect(work_area.x(), work_area.y(), 0, 0), 487 gfx::Rect(work_area.x(), work_area.y(), 0, 0),
492 gfx::Rect(work_area.right(), work_area.y(), 0, 0)); 488 gfx::Rect(work_area.right(), work_area.y(), 0, 0));
493 } 489 }
494 490
495 } // namespace ash 491 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698