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

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

Issue 1409833004: Add DeviceDisplayInfo getter in WindowAndroid. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix failing bot, revert RWHVA changes, add NOTIMPLEMENTED to some functions in screen_android Created 4 years, 9 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/android/screen_android.h ('k') | ui/android/ui_android.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "base/macros.h"
7 #include "ui/android/screen_android.h"
8 #include "ui/android/view_android.h"
9 #include "ui/android/window_android.h"
10 #include "ui/gfx/android/device_display_info.h"
11 #include "ui/gfx/display.h"
12
13 namespace ui {
14
15 namespace {
16
17 gfx::Display DisplayFromDeviceDisplayInfo(
18 const gfx::DeviceDisplayInfo& device_info) {
19 const float device_scale_factor = device_info.GetDIPScale();
20 // Note: GetPhysicalDisplayWidth/Height() does not subtract window
21 // decorations etc. Use it instead of GetDisplayWidth/Height() when
22 // available.
23 const gfx::Rect bounds_in_pixels =
24 gfx::Rect(device_info.GetPhysicalDisplayWidth()
25 ? device_info.GetPhysicalDisplayWidth()
26 : device_info.GetDisplayWidth(),
27 device_info.GetPhysicalDisplayHeight()
28 ? device_info.GetPhysicalDisplayHeight()
29 : device_info.GetDisplayHeight());
30 const gfx::Rect bounds_in_dip = gfx::Rect(gfx::ScaleToCeiledSize(
31 bounds_in_pixels.size(), 1.0f / device_scale_factor));
32 gfx::Display display(0, bounds_in_dip);
33 if (!gfx::Display::HasForceDeviceScaleFactor())
34 display.set_device_scale_factor(device_scale_factor);
35 display.SetRotationAsDegree(device_info.GetRotationDegrees());
36 return display;
37 }
38
39 } // namespace
40
41 class ScreenAndroid : public gfx::Screen {
42 public:
43 ScreenAndroid() {}
44
45 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
46
47 gfx::NativeWindow GetWindowUnderCursor() override {
48 NOTIMPLEMENTED();
49 return nullptr;
50 }
51
52 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
53 NOTIMPLEMENTED();
54 return nullptr;
55 }
56
57 gfx::Display GetPrimaryDisplay() const override {
58 gfx::DeviceDisplayInfo device_info;
59 return DisplayFromDeviceDisplayInfo(device_info);
60 }
61
62 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override {
63 if (view) {
64 return DisplayFromDeviceDisplayInfo(
65 view->GetWindowAndroid()->GetDeviceDisplayInfo());
66 }
67 return GetPrimaryDisplay();
68 }
69
70 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
71 NOTIMPLEMENTED();
72 return gfx::Display();
73 }
74
75 int GetNumDisplays() const override { return 1; }
76
77 std::vector<gfx::Display> GetAllDisplays() const override {
78 NOTIMPLEMENTED();
79 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
80 }
81
82 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
83 NOTIMPLEMENTED();
84 return gfx::Display();
85 }
86
87 void AddObserver(gfx::DisplayObserver* observer) override {
88 // no display change on Android.
89 }
90
91 void RemoveObserver(gfx::DisplayObserver* observer) override {
92 // no display change on Android.
93 }
94
95 private:
96 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
97 };
98
99 gfx::Screen* CreateScreenAndroid() {
100 return new ScreenAndroid;
101 }
102
103 } // namespace ui
OLDNEW
« no previous file with comments | « ui/android/screen_android.h ('k') | ui/android/ui_android.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698