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

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

Issue 2550933002: Make all LayerAnimationElement::Create*Element return unique_ptr (Closed)
Patch Set: Complete inclusion Created 4 years 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
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/session_state_animator_impl.h" 5 #include "ash/wm/session_state_animator_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/common/wm/wm_window_animations.h" 9 #include "ash/common/wm/wm_window_animations.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "base/memory/ptr_util.h"
12 #include "ui/aura/client/aura_constants.h" 13 #include "ui/aura/client/aura_constants.h"
13 #include "ui/aura/window_event_dispatcher.h" 14 #include "ui/aura/window_event_dispatcher.h"
14 #include "ui/compositor/layer_animation_observer.h" 15 #include "ui/compositor/layer_animation_observer.h"
15 #include "ui/compositor/layer_animation_sequence.h" 16 #include "ui/compositor/layer_animation_sequence.h"
16 #include "ui/compositor/scoped_layer_animation_settings.h" 17 #include "ui/compositor/scoped_layer_animation_settings.h"
17 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
18 19
19 namespace ash { 20 namespace ash {
20 namespace { 21 namespace {
21 22
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // Starts grayscale/brightness animation for |window| over |duration|. Target 248 // Starts grayscale/brightness animation for |window| over |duration|. Target
248 // value for both grayscale and brightness are specified by |target|. 249 // value for both grayscale and brightness are specified by |target|.
249 void StartGrayscaleBrightnessAnimationForWindow( 250 void StartGrayscaleBrightnessAnimationForWindow(
250 aura::Window* window, 251 aura::Window* window,
251 float target, 252 float target,
252 base::TimeDelta duration, 253 base::TimeDelta duration,
253 gfx::Tween::Type tween_type, 254 gfx::Tween::Type tween_type,
254 ui::LayerAnimationObserver* observer) { 255 ui::LayerAnimationObserver* observer) {
255 ui::LayerAnimator* animator = window->layer()->GetAnimator(); 256 ui::LayerAnimator* animator = window->layer()->GetAnimator();
256 257
257 std::unique_ptr<ui::LayerAnimationSequence> brightness_sequence( 258 std::unique_ptr<ui::LayerAnimationSequence> brightness_sequence =
258 new ui::LayerAnimationSequence()); 259 base::MakeUnique<ui::LayerAnimationSequence>();
259 std::unique_ptr<ui::LayerAnimationSequence> grayscale_sequence( 260 std::unique_ptr<ui::LayerAnimationSequence> grayscale_sequence =
260 new ui::LayerAnimationSequence()); 261 base::MakeUnique<ui::LayerAnimationSequence>();
261 262
262 std::unique_ptr<ui::LayerAnimationElement> brightness_element( 263 std::unique_ptr<ui::LayerAnimationElement> brightness_element =
263 ui::LayerAnimationElement::CreateBrightnessElement(target, duration)); 264 ui::LayerAnimationElement::CreateBrightnessElement(target, duration);
264 brightness_element->set_tween_type(tween_type); 265 brightness_element->set_tween_type(tween_type);
265 brightness_sequence->AddElement(brightness_element.release()); 266 brightness_sequence->AddElement(std::move(brightness_element));
266 267
267 std::unique_ptr<ui::LayerAnimationElement> grayscale_element( 268 std::unique_ptr<ui::LayerAnimationElement> grayscale_element =
268 ui::LayerAnimationElement::CreateGrayscaleElement(target, duration)); 269 ui::LayerAnimationElement::CreateGrayscaleElement(target, duration);
269 grayscale_element->set_tween_type(tween_type); 270 grayscale_element->set_tween_type(tween_type);
270 grayscale_sequence->AddElement(grayscale_element.release()); 271 grayscale_sequence->AddElement(std::move(grayscale_element));
271 272
272 std::vector<ui::LayerAnimationSequence*> animations; 273 std::vector<ui::LayerAnimationSequence*> animations;
273 animations.push_back(brightness_sequence.release()); 274 animations.push_back(brightness_sequence.release());
274 animations.push_back(grayscale_sequence.release()); 275 animations.push_back(grayscale_sequence.release());
275 276
276 if (observer) 277 if (observer)
277 animations[0]->AddObserver(observer); 278 animations[0]->AddObserver(observer);
278 279
279 animator->set_preemption_strategy( 280 animator->set_preemption_strategy(
280 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 281 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 gfx::Tween::EASE_IN, observer); 652 gfx::Tween::EASE_IN, observer);
652 break; 653 break;
653 case ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS: 654 case ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS:
654 StartGrayscaleBrightnessAnimationForWindow( 655 StartGrayscaleBrightnessAnimationForWindow(
655 window, 0.0, duration, gfx::Tween::EASE_IN_OUT, observer); 656 window, 0.0, duration, gfx::Tween::EASE_IN_OUT, observer);
656 break; 657 break;
657 } 658 }
658 } 659 }
659 660
660 } // namespace ash 661 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698