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

Side by Side Diff: ui/wm/core/window_animations.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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 | « ui/wm/core/visibility_controller_unittest.cc ('k') | ui/wm/core/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 "ui/wm/core/window_animations.h" 5 #include "ui/wm/core/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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void WindowInvalid() { 127 void WindowInvalid() {
128 layer_owner_->root()->SuppressPaint(); 128 layer_owner_->root()->SuppressPaint();
129 129
130 window_->RemoveObserver(this); 130 window_->RemoveObserver(this);
131 window_ = NULL; 131 window_ = NULL;
132 } 132 }
133 133
134 aura::Window* window_; 134 aura::Window* window_;
135 135
136 // The owner of detached layers. 136 // The owner of detached layers.
137 scoped_ptr<ui::LayerTreeOwner> layer_owner_; 137 std::unique_ptr<ui::LayerTreeOwner> layer_owner_;
138 138
139 DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserverBase); 139 DISALLOW_COPY_AND_ASSIGN(HidingWindowAnimationObserverBase);
140 }; 140 };
141 141
142 } // namespace 142 } // namespace
143 143
144 DEFINE_WINDOW_PROPERTY_KEY(int, 144 DEFINE_WINDOW_PROPERTY_KEY(int,
145 kWindowVisibilityAnimationTypeKey, 145 kWindowVisibilityAnimationTypeKey,
146 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 146 WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
147 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0); 147 DEFINE_WINDOW_PROPERTY_KEY(int, kWindowVisibilityAnimationDurationKey, 0);
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 void AnimateShowWindow_Fade(aura::Window* window) { 342 void AnimateShowWindow_Fade(aura::Window* window) {
343 AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform()); 343 AnimateShowWindowCommon(window, gfx::Transform(), gfx::Transform());
344 } 344 }
345 345
346 void AnimateHideWindow_Fade(aura::Window* window) { 346 void AnimateHideWindow_Fade(aura::Window* window) {
347 AnimateHideWindowCommon(window, gfx::Transform()); 347 AnimateHideWindowCommon(window, gfx::Transform());
348 } 348 }
349 349
350 ui::LayerAnimationElement* CreateGrowShrinkElement( 350 ui::LayerAnimationElement* CreateGrowShrinkElement(
351 aura::Window* window, bool grow) { 351 aura::Window* window, bool grow) {
352 scoped_ptr<ui::InterpolatedTransform> scale(new ui::InterpolatedScale( 352 std::unique_ptr<ui::InterpolatedTransform> scale(
353 gfx::Point3F(kWindowAnimation_Bounce_Scale, 353 new ui::InterpolatedScale(gfx::Point3F(kWindowAnimation_Bounce_Scale,
354 kWindowAnimation_Bounce_Scale, 354 kWindowAnimation_Bounce_Scale, 1),
355 1), 355 gfx::Point3F(1, 1, 1)));
356 gfx::Point3F(1, 1, 1))); 356 std::unique_ptr<ui::InterpolatedTransform> scale_about_pivot(
357 scoped_ptr<ui::InterpolatedTransform> scale_about_pivot(
358 new ui::InterpolatedTransformAboutPivot( 357 new ui::InterpolatedTransformAboutPivot(
359 gfx::Point(window->bounds().width() * 0.5, 358 gfx::Point(window->bounds().width() * 0.5,
360 window->bounds().height() * 0.5), 359 window->bounds().height() * 0.5),
361 scale.release())); 360 scale.release()));
362 scale_about_pivot->SetReversed(grow); 361 scale_about_pivot->SetReversed(grow);
363 scoped_ptr<ui::LayerAnimationElement> transition( 362 std::unique_ptr<ui::LayerAnimationElement> transition(
364 ui::LayerAnimationElement::CreateInterpolatedTransformElement( 363 ui::LayerAnimationElement::CreateInterpolatedTransformElement(
365 scale_about_pivot.release(), 364 scale_about_pivot.release(),
366 base::TimeDelta::FromMilliseconds( 365 base::TimeDelta::FromMilliseconds(
367 kWindowAnimation_Bounce_DurationMS * 366 kWindowAnimation_Bounce_DurationMS *
368 kWindowAnimation_Bounce_GrowShrinkDurationPercent / 100))); 367 kWindowAnimation_Bounce_GrowShrinkDurationPercent / 100)));
369 transition->set_tween_type(grow ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN); 368 transition->set_tween_type(grow ? gfx::Tween::EASE_OUT : gfx::Tween::EASE_IN);
370 return transition.release(); 369 return transition.release();
371 } 370 }
372 371
373 void AnimateBounce(aura::Window* window) { 372 void AnimateBounce(aura::Window* window) {
374 ui::ScopedLayerAnimationSettings scoped_settings( 373 ui::ScopedLayerAnimationSettings scoped_settings(
375 window->layer()->GetAnimator()); 374 window->layer()->GetAnimator());
376 scoped_settings.SetPreemptionStrategy( 375 scoped_settings.SetPreemptionStrategy(
377 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); 376 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
378 scoped_ptr<ui::LayerAnimationSequence> sequence( 377 std::unique_ptr<ui::LayerAnimationSequence> sequence(
379 new ui::LayerAnimationSequence); 378 new ui::LayerAnimationSequence);
380 sequence->AddElement(CreateGrowShrinkElement(window, true)); 379 sequence->AddElement(CreateGrowShrinkElement(window, true));
381 sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement( 380 sequence->AddElement(ui::LayerAnimationElement::CreatePauseElement(
382 ui::LayerAnimationElement::BOUNDS, 381 ui::LayerAnimationElement::BOUNDS,
383 base::TimeDelta::FromMilliseconds( 382 base::TimeDelta::FromMilliseconds(
384 kWindowAnimation_Bounce_DurationMS * 383 kWindowAnimation_Bounce_DurationMS *
385 (100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) / 384 (100 - 2 * kWindowAnimation_Bounce_GrowShrinkDurationPercent) /
386 100))); 385 100)));
387 sequence->AddElement(CreateGrowShrinkElement(window, false)); 386 sequence->AddElement(CreateGrowShrinkElement(window, false));
388 window->layer()->GetAnimator()->StartAnimation(sequence.release()); 387 window->layer()->GetAnimator()->StartAnimation(sequence.release());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 kWindowAnimation_Rotate_DurationMS); 425 kWindowAnimation_Rotate_DurationMS);
427 426
428 RotateHidingWindowAnimationObserver* observer = NULL; 427 RotateHidingWindowAnimationObserver* observer = NULL;
429 428
430 if (!show) { 429 if (!show) {
431 observer = new RotateHidingWindowAnimationObserver(window); 430 observer = new RotateHidingWindowAnimationObserver(window);
432 window->layer()->GetAnimator()->SchedulePauseForProperties( 431 window->layer()->GetAnimator()->SchedulePauseForProperties(
433 duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100, 432 duration * (100 - kWindowAnimation_Rotate_OpacityDurationPercent) / 100,
434 ui::LayerAnimationElement::OPACITY); 433 ui::LayerAnimationElement::OPACITY);
435 } 434 }
436 scoped_ptr<ui::LayerAnimationElement> opacity( 435 std::unique_ptr<ui::LayerAnimationElement> opacity(
437 ui::LayerAnimationElement::CreateOpacityElement( 436 ui::LayerAnimationElement::CreateOpacityElement(
438 show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity, 437 show ? kWindowAnimation_ShowOpacity : kWindowAnimation_HideOpacity,
439 duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100)); 438 duration * kWindowAnimation_Rotate_OpacityDurationPercent / 100));
440 opacity->set_tween_type(gfx::Tween::EASE_IN_OUT); 439 opacity->set_tween_type(gfx::Tween::EASE_IN_OUT);
441 window->layer()->GetAnimator()->ScheduleAnimation( 440 window->layer()->GetAnimator()->ScheduleAnimation(
442 new ui::LayerAnimationSequence(opacity.release())); 441 new ui::LayerAnimationSequence(opacity.release()));
443 442
444 float xcenter = window->bounds().width() * 0.5; 443 float xcenter = window->bounds().width() * 0.5;
445 444
446 gfx::Transform transform; 445 gfx::Transform transform;
447 transform.Translate(xcenter, 0); 446 transform.Translate(xcenter, 0);
448 transform.ApplyPerspectiveDepth(kWindowAnimation_Rotate_PerspectiveDepth); 447 transform.ApplyPerspectiveDepth(kWindowAnimation_Rotate_PerspectiveDepth);
449 transform.Translate(-xcenter, 0); 448 transform.Translate(-xcenter, 0);
450 scoped_ptr<ui::InterpolatedTransform> perspective( 449 std::unique_ptr<ui::InterpolatedTransform> perspective(
451 new ui::InterpolatedConstantTransform(transform)); 450 new ui::InterpolatedConstantTransform(transform));
452 451
453 scoped_ptr<ui::InterpolatedTransform> scale( 452 std::unique_ptr<ui::InterpolatedTransform> scale(
454 new ui::InterpolatedScale(1, kWindowAnimation_Rotate_ScaleFactor)); 453 new ui::InterpolatedScale(1, kWindowAnimation_Rotate_ScaleFactor));
455 scoped_ptr<ui::InterpolatedTransform> scale_about_pivot( 454 std::unique_ptr<ui::InterpolatedTransform> scale_about_pivot(
456 new ui::InterpolatedTransformAboutPivot( 455 new ui::InterpolatedTransformAboutPivot(
457 gfx::Point(xcenter, kWindowAnimation_Rotate_TranslateY), 456 gfx::Point(xcenter, kWindowAnimation_Rotate_TranslateY),
458 scale.release())); 457 scale.release()));
459 458
460 scoped_ptr<ui::InterpolatedTransform> translation( 459 std::unique_ptr<ui::InterpolatedTransform> translation(
461 new ui::InterpolatedTranslation( 460 new ui::InterpolatedTranslation(
462 gfx::PointF(), gfx::PointF(0, kWindowAnimation_Rotate_TranslateY))); 461 gfx::PointF(), gfx::PointF(0, kWindowAnimation_Rotate_TranslateY)));
463 462
464 scoped_ptr<ui::InterpolatedTransform> rotation( 463 std::unique_ptr<ui::InterpolatedTransform> rotation(
465 new ui::InterpolatedAxisAngleRotation( 464 new ui::InterpolatedAxisAngleRotation(gfx::Vector3dF(1, 0, 0), 0,
466 gfx::Vector3dF(1, 0, 0), 0, kWindowAnimation_Rotate_DegreesX)); 465 kWindowAnimation_Rotate_DegreesX));
467 466
468 scale_about_pivot->SetChild(perspective.release()); 467 scale_about_pivot->SetChild(perspective.release());
469 translation->SetChild(scale_about_pivot.release()); 468 translation->SetChild(scale_about_pivot.release());
470 rotation->SetChild(translation.release()); 469 rotation->SetChild(translation.release());
471 rotation->SetReversed(show); 470 rotation->SetReversed(show);
472 471
473 scoped_ptr<ui::LayerAnimationElement> transition( 472 std::unique_ptr<ui::LayerAnimationElement> transition(
474 ui::LayerAnimationElement::CreateInterpolatedTransformElement( 473 ui::LayerAnimationElement::CreateInterpolatedTransformElement(
475 rotation.release(), duration)); 474 rotation.release(), duration));
476 ui::LayerAnimationSequence* last_sequence = 475 ui::LayerAnimationSequence* last_sequence =
477 new ui::LayerAnimationSequence(transition.release()); 476 new ui::LayerAnimationSequence(transition.release());
478 window->layer()->GetAnimator()->ScheduleAnimation(last_sequence); 477 window->layer()->GetAnimator()->ScheduleAnimation(last_sequence);
479 478
480 if (observer) { 479 if (observer) {
481 observer->SetLastSequence(last_sequence); 480 observer->SetLastSequence(last_sequence);
482 observer->DetachAndRecreateLayers(); 481 observer->DetachAndRecreateLayers();
483 } 482 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 // being accessed via Remote Desktop. 656 // being accessed via Remote Desktop.
658 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() == 657 if (ui::ScopedAnimationDurationScaleMode::duration_scale_mode() ==
659 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION) 658 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION)
660 return false; 659 return false;
661 660
662 // Let the user decide whether or not to play the animation. 661 // Let the user decide whether or not to play the animation.
663 return !gfx::Animation::ShouldRenderRichAnimation(); 662 return !gfx::Animation::ShouldRenderRichAnimation();
664 } 663 }
665 664
666 } // namespace wm 665 } // namespace wm
OLDNEW
« no previous file with comments | « ui/wm/core/visibility_controller_unittest.cc ('k') | ui/wm/core/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698