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

Side by Side Diff: ui/display/android/screen_android.cc

Issue 2428383006: Decouple VR Shell DPR and CSS size from Physical Displays. (Closed)
Patch Set: Created 4 years, 2 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 | « ui/display/android/screen_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/display/screen.h" 5 #include "ui/display/android/screen_android.h"
6 6
7 #include "base/logging.h"
8 #include "base/macros.h"
9 #include "ui/display/display.h"
10 #include "ui/gfx/android/device_display_info.h" 7 #include "ui/gfx/android/device_display_info.h"
11 #include "ui/gfx/geometry/size_conversions.h" 8 #include "ui/gfx/geometry/size_conversions.h"
12 9
13 namespace display { 10 namespace display {
14 11
15 class ScreenAndroid : public Screen { 12 ScreenAndroid::ScreenAndroid() {}
16 public: 13 ScreenAndroid::~ScreenAndroid() {}
17 ScreenAndroid() {}
18 14
19 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); } 15 gfx::Point ScreenAndroid::GetCursorScreenPoint() { return gfx::Point(); }
20 16
21 bool IsWindowUnderCursor(gfx::NativeWindow window) override { 17 bool ScreenAndroid::IsWindowUnderCursor(gfx::NativeWindow window) {
22 NOTIMPLEMENTED(); 18 NOTIMPLEMENTED();
23 return false; 19 return false;
20 }
21
22 gfx::NativeWindow ScreenAndroid::GetWindowAtScreenPoint(
23 const gfx::Point& point) {
24 NOTIMPLEMENTED();
25 return NULL;
26 }
27
28 Display ScreenAndroid::GetPrimaryDisplay() const {
29 if (vr_display_map_.size() > 0) {
mthiesse 2016/10/20 22:01:37 Whoops meant to revert some changes in this file t
30 return dislpay_;
24 } 31 }
32 gfx::DeviceDisplayInfo device_info;
33 const float device_scale_factor = device_info.GetDIPScale();
34 // Note: GetPhysicalDisplayWidth/Height() does not subtract window
35 // decorations etc. Use it instead of GetDisplayWidth/Height() when
36 // available.
37 const gfx::Rect bounds_in_pixels =
38 gfx::Rect(device_info.GetPhysicalDisplayWidth()
39 ? device_info.GetPhysicalDisplayWidth()
40 : device_info.GetDisplayWidth(),
41 device_info.GetPhysicalDisplayHeight()
42 ? device_info.GetPhysicalDisplayHeight()
43 : device_info.GetDisplayHeight());
44 const gfx::Rect bounds_in_dip = gfx::Rect(gfx::ScaleToCeiledSize(
45 bounds_in_pixels.size(), 1.0f / device_scale_factor));
46 Display display(0, bounds_in_dip);
47 if (!Display::HasForceDeviceScaleFactor())
48 display.set_device_scale_factor(device_scale_factor);
49 display.SetRotationAsDegree(device_info.GetRotationDegrees());
50 display.set_color_depth(device_info.GetBitsPerPixel());
51 display.set_depth_per_component(device_info.GetBitsPerComponent());
52 display.set_is_monochrome(device_info.GetBitsPerComponent() == 0);
53 return display;
54 }
25 55
26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { 56 void ScreenAndroid::SetDisplayForWindow(gfx::NativeView view,
27 NOTIMPLEMENTED(); 57 const Display& display) {
28 return NULL; 58 dislpay_ = display;
59 base::AutoLock autolock(vr_display_lock_);
60 vr_display_map_[view] = display;
61 }
62
63 void ScreenAndroid::ClearDisplayForWindow(gfx::NativeView view) {
64 base::AutoLock autolock(vr_display_lock_);
65 vr_display_map_.erase(view);
66 }
67
68 Display ScreenAndroid::GetDisplayNearestWindow(gfx::NativeView view) const {
69 base::AutoLock autolock(vr_display_lock_);
70 auto iter = vr_display_map_.find(view);
71 if (iter == vr_display_map_.end()) {
72 return GetPrimaryDisplay();
73 } else {
74 return iter->second;
29 } 75 }
76 }
30 77
31 Display GetPrimaryDisplay() const override { 78 Display ScreenAndroid::GetDisplayNearestPoint(const gfx::Point& point) const {
32 gfx::DeviceDisplayInfo device_info; 79 return GetPrimaryDisplay();
33 const float device_scale_factor = device_info.GetDIPScale(); 80 }
34 // Note: GetPhysicalDisplayWidth/Height() does not subtract window
35 // decorations etc. Use it instead of GetDisplayWidth/Height() when
36 // available.
37 const gfx::Rect bounds_in_pixels =
38 gfx::Rect(device_info.GetPhysicalDisplayWidth()
39 ? device_info.GetPhysicalDisplayWidth()
40 : device_info.GetDisplayWidth(),
41 device_info.GetPhysicalDisplayHeight()
42 ? device_info.GetPhysicalDisplayHeight()
43 : device_info.GetDisplayHeight());
44 const gfx::Rect bounds_in_dip = gfx::Rect(gfx::ScaleToCeiledSize(
45 bounds_in_pixels.size(), 1.0f / device_scale_factor));
46 Display display(0, bounds_in_dip);
47 if (!Display::HasForceDeviceScaleFactor())
48 display.set_device_scale_factor(device_scale_factor);
49 display.SetRotationAsDegree(device_info.GetRotationDegrees());
50 display.set_color_depth(device_info.GetBitsPerPixel());
51 display.set_depth_per_component(device_info.GetBitsPerComponent());
52 display.set_is_monochrome(device_info.GetBitsPerComponent() == 0);
53 return display;
54 }
55 81
56 Display GetDisplayNearestWindow(gfx::NativeView view) const override { 82 int ScreenAndroid::GetNumDisplays() const { return 1; }
57 return GetPrimaryDisplay();
58 }
59 83
60 Display GetDisplayNearestPoint(const gfx::Point& point) const override { 84 std::vector<Display> ScreenAndroid::GetAllDisplays() const {
61 return GetPrimaryDisplay(); 85 return std::vector<Display>(1, GetPrimaryDisplay());
62 } 86 }
63 87
64 int GetNumDisplays() const override { return 1; } 88 Display ScreenAndroid::GetDisplayMatching(const gfx::Rect& match_rect) const {
89 return GetPrimaryDisplay();
90 }
65 91
66 std::vector<Display> GetAllDisplays() const override { 92 void ScreenAndroid::AddObserver(DisplayObserver* observer) {
67 return std::vector<Display>(1, GetPrimaryDisplay()); 93 // no display change on Android.
68 } 94 }
69 95
70 Display GetDisplayMatching(const gfx::Rect& match_rect) const override { 96 void ScreenAndroid::RemoveObserver(DisplayObserver* observer) {
71 return GetPrimaryDisplay(); 97 // no display change on Android.
72 } 98 }
73
74 void AddObserver(DisplayObserver* observer) override {
75 // no display change on Android.
76 }
77
78 void RemoveObserver(DisplayObserver* observer) override {
79 // no display change on Android.
80 }
81
82 private:
83 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
84 };
85 99
86 Screen* CreateNativeScreen() { 100 Screen* CreateNativeScreen() {
87 return new ScreenAndroid; 101 return new ScreenAndroid;
88 } 102 }
89 103
90 } // namespace display 104 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/android/screen_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698