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

Side by Side Diff: ash/rotator/screen_rotation_animator.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « ash/rotator/screen_rotation_animator.h ('k') | ash/screen_util.h » ('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 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 <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/display/display_info.h" 11 #include "ash/display/display_info.h"
12 #include "ash/display/display_manager.h" 12 #include "ash/display/display_manager.h"
13 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
14 #include "ash/rotator/screen_rotation_animation.h" 14 #include "ash/rotator/screen_rotation_animation.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/compositor/layer.h" 19 #include "ui/compositor/layer.h"
20 #include "ui/compositor/layer_animation_observer.h" 20 #include "ui/compositor/layer_animation_observer.h"
21 #include "ui/compositor/layer_animation_sequence.h" 21 #include "ui/compositor/layer_animation_sequence.h"
22 #include "ui/compositor/layer_animator.h" 22 #include "ui/compositor/layer_animator.h"
23 #include "ui/compositor/layer_owner.h" 23 #include "ui/compositor/layer_owner.h"
24 #include "ui/compositor/layer_tree_owner.h" 24 #include "ui/compositor/layer_tree_owner.h"
25 #include "ui/display/display.h"
25 #include "ui/gfx/animation/tween.h" 26 #include "ui/gfx/animation/tween.h"
26 #include "ui/gfx/display.h"
27 #include "ui/gfx/geometry/point.h" 27 #include "ui/gfx/geometry/point.h"
28 #include "ui/gfx/geometry/rect.h" 28 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/rect_f.h" 29 #include "ui/gfx/geometry/rect_f.h"
30 #include "ui/gfx/transform.h" 30 #include "ui/gfx/transform.h"
31 #include "ui/gfx/transform_util.h" 31 #include "ui/gfx/transform_util.h"
32 #include "ui/wm/core/window_util.h" 32 #include "ui/wm/core/window_util.h"
33 33
34 namespace ash { 34 namespace ash {
35 35
36 namespace { 36 namespace {
37 37
38 // The number of degrees that the rotation animations animate through. 38 // The number of degrees that the rotation animations animate through.
39 const int kRotationDegrees = 20; 39 const int kRotationDegrees = 20;
40 40
41 // The time it takes for the rotation animations to run. 41 // The time it takes for the rotation animations to run.
42 const int kRotationDurationInMs = 250; 42 const int kRotationDurationInMs = 250;
43 43
44 // Gets the current display rotation for the display with the specified 44 // Gets the current display rotation for the display with the specified
45 // |display_id|. 45 // |display_id|.
46 gfx::Display::Rotation GetCurrentRotation(int64_t display_id) { 46 display::Display::Rotation GetCurrentRotation(int64_t display_id) {
47 return Shell::GetInstance() 47 return Shell::GetInstance()
48 ->display_manager() 48 ->display_manager()
49 ->GetDisplayInfo(display_id) 49 ->GetDisplayInfo(display_id)
50 .GetActiveRotation(); 50 .GetActiveRotation();
51 } 51 }
52 52
53 // Returns true if the rotation between |initial_rotation| and |new_rotation| is 53 // Returns true if the rotation between |initial_rotation| and |new_rotation| is
54 // 180 degrees. 54 // 180 degrees.
55 bool Is180DegreeFlip(gfx::Display::Rotation initial_rotation, 55 bool Is180DegreeFlip(display::Display::Rotation initial_rotation,
56 gfx::Display::Rotation new_rotation) { 56 display::Display::Rotation new_rotation) {
57 return (initial_rotation + 2) % 4 == new_rotation; 57 return (initial_rotation + 2) % 4 == new_rotation;
58 } 58 }
59 59
60 // A LayerAnimationObserver that will destroy the contained LayerTreeOwner when 60 // A LayerAnimationObserver that will destroy the contained LayerTreeOwner when
61 // notified that a layer animation has ended or was aborted. 61 // notified that a layer animation has ended or was aborted.
62 class LayerCleanupObserver : public ui::LayerAnimationObserver { 62 class LayerCleanupObserver : public ui::LayerAnimationObserver {
63 public: 63 public:
64 explicit LayerCleanupObserver( 64 explicit LayerCleanupObserver(
65 std::unique_ptr<ui::LayerTreeOwner> layer_tree_owner); 65 std::unique_ptr<ui::LayerTreeOwner> layer_tree_owner);
66 ~LayerCleanupObserver() override; 66 ~LayerCleanupObserver() override;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 AbortAnimations(child_layer); 139 AbortAnimations(child_layer);
140 layer->GetAnimator()->AbortAllAnimations(); 140 layer->GetAnimator()->AbortAllAnimations();
141 } 141 }
142 142
143 // Set the screen orientation for the given |display_id| to |new_rotation| and 143 // Set the screen orientation for the given |display_id| to |new_rotation| and
144 // animate the change. The animation will rotate the initial orientation's 144 // animate the change. The animation will rotate the initial orientation's
145 // layer towards the new orientation through |rotation_degrees| while fading 145 // layer towards the new orientation through |rotation_degrees| while fading
146 // out, and the new orientation's layer will be rotated in to the 146 // out, and the new orientation's layer will be rotated in to the
147 // |new_orientation| through |rotation_degrees| arc. 147 // |new_orientation| through |rotation_degrees| arc.
148 void RotateScreen(int64_t display_id, 148 void RotateScreen(int64_t display_id,
149 gfx::Display::Rotation new_rotation, 149 display::Display::Rotation new_rotation,
150 gfx::Display::RotationSource source) { 150 display::Display::RotationSource source) {
151 aura::Window* root_window = Shell::GetInstance() 151 aura::Window* root_window = Shell::GetInstance()
152 ->window_tree_host_manager() 152 ->window_tree_host_manager()
153 ->GetRootWindowForDisplayId(display_id); 153 ->GetRootWindowForDisplayId(display_id);
154 154
155 const gfx::Display::Rotation initial_orientation = 155 const display::Display::Rotation initial_orientation =
156 GetCurrentRotation(display_id); 156 GetCurrentRotation(display_id);
157 157
158 const gfx::Rect original_screen_bounds = root_window->GetTargetBounds(); 158 const gfx::Rect original_screen_bounds = root_window->GetTargetBounds();
159 // 180 degree rotations should animate clock-wise. 159 // 180 degree rotations should animate clock-wise.
160 const int rotation_factor = 160 const int rotation_factor =
161 (initial_orientation + 3) % 4 == new_rotation ? 1 : -1; 161 (initial_orientation + 3) % 4 == new_rotation ? 1 : -1;
162 162
163 const int old_layer_initial_rotation_degrees = 163 const int old_layer_initial_rotation_degrees =
164 (Is180DegreeFlip(initial_orientation, new_rotation) ? 180 : 90); 164 (Is180DegreeFlip(initial_orientation, new_rotation) ? 180 : 90);
165 165
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ScreenRotationAnimator::~ScreenRotationAnimator() { 249 ScreenRotationAnimator::~ScreenRotationAnimator() {
250 } 250 }
251 251
252 bool ScreenRotationAnimator::CanAnimate() const { 252 bool ScreenRotationAnimator::CanAnimate() const {
253 return Shell::GetInstance() 253 return Shell::GetInstance()
254 ->display_manager() 254 ->display_manager()
255 ->GetDisplayForId(display_id_) 255 ->GetDisplayForId(display_id_)
256 .is_valid(); 256 .is_valid();
257 } 257 }
258 258
259 void ScreenRotationAnimator::Rotate(gfx::Display::Rotation new_rotation, 259 void ScreenRotationAnimator::Rotate(display::Display::Rotation new_rotation,
260 gfx::Display::RotationSource source) { 260 display::Display::RotationSource source) {
261 const gfx::Display::Rotation current_rotation = 261 const display::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
OLDNEW
« no previous file with comments | « ash/rotator/screen_rotation_animator.h ('k') | ash/screen_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698