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

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

Issue 2416403002: Reland of Android: support multiple displays on C++ side (Closed)
Patch Set: JNI generated and registered in ui/android; ensure primary DisplayAndroid by going to app context Created 4 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/display/screen.h"
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"
11 #include "ui/gfx/geometry/size_conversions.h"
12
13 namespace display {
14
15 class ScreenAndroid : public Screen {
16 public:
17 ScreenAndroid() {}
18
19 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
20
21 bool IsWindowUnderCursor(gfx::NativeWindow window) override {
22 NOTIMPLEMENTED();
23 return false;
24 }
25
26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
27 NOTIMPLEMENTED();
28 return NULL;
29 }
30
31 Display GetPrimaryDisplay() const override {
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 }
55
56 Display GetDisplayNearestWindow(gfx::NativeView view) const override {
57 return GetPrimaryDisplay();
58 }
59
60 Display GetDisplayNearestPoint(const gfx::Point& point) const override {
61 return GetPrimaryDisplay();
62 }
63
64 int GetNumDisplays() const override { return 1; }
65
66 std::vector<Display> GetAllDisplays() const override {
67 return std::vector<Display>(1, GetPrimaryDisplay());
68 }
69
70 Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
71 return GetPrimaryDisplay();
72 }
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
86 Screen* CreateNativeScreen() {
87 return new ScreenAndroid;
88 }
89
90 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698