| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/rotator/screen_rotation_animator.h" | 5 #include "ash/rotator/screen_rotation_animator.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "ash/display/display_info.h" | 11 #include "ash/display/display_info.h" |
| 11 #include "ash/display/display_manager.h" | 12 #include "ash/display/display_manager.h" |
| 12 #include "ash/display/window_tree_host_manager.h" | 13 #include "ash/display/window_tree_host_manager.h" |
| 13 #include "ash/rotator/screen_rotation_animation.h" | 14 #include "ash/rotator/screen_rotation_animation.h" |
| 14 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 // The LayerAnimationSequence that |this| has been attached to. Defaults to | 93 // The LayerAnimationSequence that |this| has been attached to. Defaults to |
| 93 // nullptr. | 94 // nullptr. |
| 94 ui::LayerAnimationSequence* sequence_; | 95 ui::LayerAnimationSequence* sequence_; |
| 95 | 96 |
| 96 DISALLOW_COPY_AND_ASSIGN(LayerCleanupObserver); | 97 DISALLOW_COPY_AND_ASSIGN(LayerCleanupObserver); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 LayerCleanupObserver::LayerCleanupObserver( | 100 LayerCleanupObserver::LayerCleanupObserver( |
| 100 scoped_ptr<ui::LayerTreeOwner> layer_tree_owner) | 101 scoped_ptr<ui::LayerTreeOwner> layer_tree_owner) |
| 101 : layer_tree_owner_(layer_tree_owner.Pass()), sequence_(nullptr) { | 102 : layer_tree_owner_(std::move(layer_tree_owner)), sequence_(nullptr) {} |
| 102 } | |
| 103 | 103 |
| 104 LayerCleanupObserver::~LayerCleanupObserver() { | 104 LayerCleanupObserver::~LayerCleanupObserver() { |
| 105 // We must eplicitly detach from |sequence_| because we return true from | 105 // We must eplicitly detach from |sequence_| because we return true from |
| 106 // RequiresNotificationWhenAnimatorDestroyed. | 106 // RequiresNotificationWhenAnimatorDestroyed. |
| 107 if (sequence_) | 107 if (sequence_) |
| 108 sequence_->RemoveObserver(this); | 108 sequence_->RemoveObserver(this); |
| 109 AbortAnimations(layer_tree_owner_->root()); | 109 AbortAnimations(layer_tree_owner_->root()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 ui::Layer* LayerCleanupObserver::GetRootLayer() { | 112 ui::Layer* LayerCleanupObserver::GetRootLayer() { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const gfx::Tween::Type tween_type = gfx::Tween::FAST_OUT_LINEAR_IN; | 169 const gfx::Tween::Type tween_type = gfx::Tween::FAST_OUT_LINEAR_IN; |
| 170 | 170 |
| 171 scoped_ptr<ui::LayerTreeOwner> old_layer_tree = | 171 scoped_ptr<ui::LayerTreeOwner> old_layer_tree = |
| 172 wm::RecreateLayers(root_window); | 172 wm::RecreateLayers(root_window); |
| 173 | 173 |
| 174 // Add the cloned layer tree in to the root, so it will be rendered. | 174 // Add the cloned layer tree in to the root, so it will be rendered. |
| 175 root_window->layer()->Add(old_layer_tree->root()); | 175 root_window->layer()->Add(old_layer_tree->root()); |
| 176 root_window->layer()->StackAtTop(old_layer_tree->root()); | 176 root_window->layer()->StackAtTop(old_layer_tree->root()); |
| 177 | 177 |
| 178 scoped_ptr<LayerCleanupObserver> layer_cleanup_observer( | 178 scoped_ptr<LayerCleanupObserver> layer_cleanup_observer( |
| 179 new LayerCleanupObserver(old_layer_tree.Pass())); | 179 new LayerCleanupObserver(std::move(old_layer_tree))); |
| 180 | 180 |
| 181 Shell::GetInstance()->display_manager()->SetDisplayRotation( | 181 Shell::GetInstance()->display_manager()->SetDisplayRotation( |
| 182 display_id, new_rotation, source); | 182 display_id, new_rotation, source); |
| 183 | 183 |
| 184 const gfx::Rect rotated_screen_bounds = root_window->GetTargetBounds(); | 184 const gfx::Rect rotated_screen_bounds = root_window->GetTargetBounds(); |
| 185 const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2, | 185 const gfx::Point pivot = gfx::Point(rotated_screen_bounds.width() / 2, |
| 186 rotated_screen_bounds.height() / 2); | 186 rotated_screen_bounds.height() / 2); |
| 187 | 187 |
| 188 // We must animate each non-cloned child layer individually because the cloned | 188 // We must animate each non-cloned child layer individually because the cloned |
| 189 // layer was added as a child to |root_window|'s layer so that it will be | 189 // layer was added as a child to |root_window|'s layer so that it will be |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 const gfx::Display::Rotation current_rotation = | 261 const gfx::Display::Rotation current_rotation = |
| 262 GetCurrentRotation(display_id_); | 262 GetCurrentRotation(display_id_); |
| 263 | 263 |
| 264 if (current_rotation == new_rotation) | 264 if (current_rotation == new_rotation) |
| 265 return; | 265 return; |
| 266 | 266 |
| 267 RotateScreen(display_id_, new_rotation, source); | 267 RotateScreen(display_id_, new_rotation, source); |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace ash | 270 } // namespace ash |
| OLD | NEW |