| OLD | NEW |
| 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/screen_dimmer.h" | 5 #include "ash/wm/screen_dimmer.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "ui/aura/root_window.h" | 9 #include "ui/aura/root_window.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 } | 32 } |
| 33 | 33 |
| 34 ScreenDimmer::~ScreenDimmer() { | 34 ScreenDimmer::~ScreenDimmer() { |
| 35 root_window_->RemoveRootWindowObserver(this); | 35 root_window_->RemoveRootWindowObserver(this); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ScreenDimmer::SetDimming(bool should_dim) { | 38 void ScreenDimmer::SetDimming(bool should_dim) { |
| 39 if (should_dim == currently_dimming_) | 39 if (should_dim == currently_dimming_) |
| 40 return; | 40 return; |
| 41 | 41 |
| 42 if (!dimming_layer_.get()) { | 42 if (!dimming_layer_) { |
| 43 dimming_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); | 43 dimming_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); |
| 44 dimming_layer_->SetColor(SK_ColorBLACK); | 44 dimming_layer_->SetColor(SK_ColorBLACK); |
| 45 dimming_layer_->SetOpacity(0.0f); | 45 dimming_layer_->SetOpacity(0.0f); |
| 46 ui::Layer* root_layer = root_window_->layer(); | 46 ui::Layer* root_layer = root_window_->layer(); |
| 47 dimming_layer_->SetBounds(root_layer->bounds()); | 47 dimming_layer_->SetBounds(root_layer->bounds()); |
| 48 root_layer->Add(dimming_layer_.get()); | 48 root_layer->Add(dimming_layer_.get()); |
| 49 root_layer->StackAtTop(dimming_layer_.get()); | 49 root_layer->StackAtTop(dimming_layer_.get()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 currently_dimming_ = should_dim; | 52 currently_dimming_ = should_dim; |
| 53 | 53 |
| 54 ui::ScopedLayerAnimationSettings scoped_settings( | 54 ui::ScopedLayerAnimationSettings scoped_settings( |
| 55 dimming_layer_->GetAnimator()); | 55 dimming_layer_->GetAnimator()); |
| 56 scoped_settings.SetTransitionDuration( | 56 scoped_settings.SetTransitionDuration( |
| 57 base::TimeDelta::FromMilliseconds(kDimmingTransitionMs)); | 57 base::TimeDelta::FromMilliseconds(kDimmingTransitionMs)); |
| 58 dimming_layer_->SetOpacity(should_dim ? kDimmingLayerOpacity : 0.0f); | 58 dimming_layer_->SetOpacity(should_dim ? kDimmingLayerOpacity : 0.0f); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ScreenDimmer::OnRootWindowResized(const aura::RootWindow* root, | 61 void ScreenDimmer::OnRootWindowResized(const aura::RootWindow* root, |
| 62 const gfx::Size& old_size) { | 62 const gfx::Size& old_size) { |
| 63 if (dimming_layer_.get()) | 63 if (dimming_layer_) |
| 64 dimming_layer_->SetBounds(gfx::Rect(root->bounds().size())); | 64 dimming_layer_->SetBounds(gfx::Rect(root->bounds().size())); |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace internal | 67 } // namespace internal |
| 68 } // namespace ash | 68 } // namespace ash |
| OLD | NEW |