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

Side by Side Diff: athena/screen/screen_animator_impl.cc

Issue 451753002: Add fade to white animation when power button is pressed on Athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/screen/screen_animator_impl.h"
6
7 #include "ui/aura/window.h"
8 #include "ui/compositor/layer.h"
9 #include "ui/compositor/layer_animation_observer.h"
10 #include "ui/compositor/scoped_layer_animation_settings.h"
11 #include "ui/gfx/animation/tween.h"
12
13 namespace athena {
14 namespace {
15
16 // Duration of the shutdown animation.
17 const int kShutdownDurationMs = 1000;
18
19 // Duration of the cancel shutdown animation.
20 const int kCancelShutdownDurationMs = 500;
21
22 // Animates |window|'s grayscale and brightness to |target|. If non-NULL,
23 // |observer| will be notified when the animation completes.
24 void StartGrayscaleAndBrightnessAnimation(
25 aura::Window* window,
26 float target,
27 int duration_ms,
28 gfx::Tween::Type tween_type,
29 ui::ImplicitAnimationObserver* observer) {
30 ui::Layer* layer = window->layer();
31 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
32 settings.SetTransitionDuration(
33 base::TimeDelta::FromMilliseconds(duration_ms));
34 settings.SetTweenType(tween_type);
35 settings.SetPreemptionStrategy(
36 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
37 if (observer)
38 settings.AddObserver(observer);
39
40 layer->SetLayerBrightness(target);
41 layer->SetLayerGrayscale(target);
42 }
43
44 } // namespace
45
46 ScreenAnimatorImpl::ScreenAnimatorImpl(aura::Window* root_window)
47 : root_window_(root_window) {
48 }
49
50 ScreenAnimatorImpl::~ScreenAnimatorImpl() {
51 }
52
53 void ScreenAnimatorImpl::StartAnimation(
54 AnimationType type,
55 ui::ImplicitAnimationObserver* observer) {
56 switch (type) {
57 case ANIMATION_SHUTDOWN:
58 StartGrayscaleAndBrightnessAnimation(root_window_,
59 1.0f,
60 kShutdownDurationMs,
61 gfx::Tween::EASE_IN,
62 observer);
63 break;
64 case ANIMATION_CANCEL_SHUTDOWN:
65 StartGrayscaleAndBrightnessAnimation(root_window_,
66 0.0f,
67 kCancelShutdownDurationMs,
68 gfx::Tween::EASE_IN_OUT,
69 observer);
70 break;
71 }
72 }
73
74 } // namespace athena
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698