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

Side by Side Diff: ash/display/screen_orientation_controller_chromeos.cc

Issue 2270553002: Move ash::DisplayInfo to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/display/screen_orientation_controller_chromeos.h" 5 #include "ash/display/screen_orientation_controller_chromeos.h"
6 6
7 #include "ash/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/display/display_info.h"
9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 8 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
10 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h" 10 #include "ash/common/wm_window.h"
12 #include "ash/display/display_configuration_controller.h" 11 #include "ash/display/display_configuration_controller.h"
13 #include "ash/display/display_manager.h" 12 #include "ash/display/display_manager.h"
14 #include "ash/shell.h" 13 #include "ash/shell.h"
15 #include "base/auto_reset.h" 14 #include "base/auto_reset.h"
16 #include "base/command_line.h" 15 #include "base/command_line.h"
17 #include "chromeos/accelerometer/accelerometer_reader.h" 16 #include "chromeos/accelerometer/accelerometer_reader.h"
18 #include "chromeos/accelerometer/accelerometer_types.h" 17 #include "chromeos/accelerometer/accelerometer_types.h"
19 #include "ui/chromeos/accelerometer/accelerometer_util.h" 18 #include "ui/chromeos/accelerometer/accelerometer_util.h"
20 #include "ui/display/display.h" 19 #include "ui/display/display.h"
20 #include "ui/display/manager/managed_display_info.h"
21 #include "ui/gfx/geometry/size.h" 21 #include "ui/gfx/geometry/size.h"
22 22
23 namespace ash { 23 namespace ash {
24 24
25 namespace { 25 namespace {
26 26
27 // The angle which the screen has to be rotated past before the display will 27 // The angle which the screen has to be rotated past before the display will
28 // rotate to match it (i.e. 45.0f is no stickiness). 28 // rotate to match it (i.e. 45.0f is no stickiness).
29 const float kDisplayRotationStickyAngleDegrees = 60.0f; 29 const float kDisplayRotationStickyAngleDegrees = 60.0f;
30 30
31 // The minimum acceleration in m/s^2 in a direction required to trigger screen 31 // The minimum acceleration in m/s^2 in a direction required to trigger screen
32 // rotation. This prevents rapid toggling of rotation when the device is near 32 // rotation. This prevents rapid toggling of rotation when the device is near
33 // flat and there is very little screen aligned force on it. The value is 33 // flat and there is very little screen aligned force on it. The value is
34 // effectively the sine of the rise angle required times the acceleration due 34 // effectively the sine of the rise angle required times the acceleration due
35 // to gravity, with the current value requiring at least a 25 degree rise. 35 // to gravity, with the current value requiring at least a 25 degree rise.
36 const float kMinimumAccelerationScreenRotation = 4.2f; 36 const float kMinimumAccelerationScreenRotation = 4.2f;
37 37
38 blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() { 38 blink::WebScreenOrientationLockType GetDisplayNaturalOrientation() {
39 if (!display::Display::HasInternalDisplay()) 39 if (!display::Display::HasInternalDisplay())
40 return blink::WebScreenOrientationLockLandscape; 40 return blink::WebScreenOrientationLockLandscape;
41 41
42 DisplayInfo info = 42 display::ManagedDisplayInfo info =
43 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId()); 43 WmShell::Get()->GetDisplayInfo(display::Display::InternalDisplayId());
44 gfx::Size size = info.size_in_pixel(); 44 gfx::Size size = info.size_in_pixel();
45 switch (info.GetActiveRotation()) { 45 switch (info.GetActiveRotation()) {
46 case display::Display::ROTATE_0: 46 case display::Display::ROTATE_0:
47 case display::Display::ROTATE_180: 47 case display::Display::ROTATE_180:
48 return size.height() >= size.width() 48 return size.height() >= size.width()
49 ? blink::WebScreenOrientationLockPortrait 49 ? blink::WebScreenOrientationLockPortrait
50 : blink::WebScreenOrientationLockLandscape; 50 : blink::WebScreenOrientationLockLandscape;
51 case display::Display::ROTATE_90: 51 case display::Display::ROTATE_90:
52 case display::Display::ROTATE_270: 52 case display::Display::ROTATE_270:
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 418 }
419 419
420 bool ScreenOrientationController::CanRotateInLockedState() { 420 bool ScreenOrientationController::CanRotateInLockedState() {
421 return rotation_locked_orientation_ == 421 return rotation_locked_orientation_ ==
422 blink::WebScreenOrientationLockLandscape || 422 blink::WebScreenOrientationLockLandscape ||
423 rotation_locked_orientation_ == 423 rotation_locked_orientation_ ==
424 blink::WebScreenOrientationLockPortrait; 424 blink::WebScreenOrientationLockPortrait;
425 } 425 }
426 426
427 } // namespace ash 427 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/root_window_transformers_unittest.cc ('k') | ash/display/unified_mouse_warp_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698