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

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

Issue 1964153002: Move Screen, its impls, DisplayObserver and DisplayChangeNotifier to ui/display (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
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/gfx/screen.h" 5 #include "ui/display/screen.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/display/display.h"
9 #include "ui/gfx/android/device_display_info.h" 10 #include "ui/gfx/android/device_display_info.h"
10 #include "ui/gfx/display.h"
11 #include "ui/gfx/geometry/size_conversions.h" 11 #include "ui/gfx/geometry/size_conversions.h"
12 12
13 namespace gfx { 13 namespace display {
14 14
15 class ScreenAndroid : public Screen { 15 class ScreenAndroid : public Screen {
16 public: 16 public:
17 ScreenAndroid() {} 17 ScreenAndroid() {}
18 18
19 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); } 19 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
20 20
21 bool IsWindowUnderCursor(gfx::NativeWindow window) override { 21 bool IsWindowUnderCursor(gfx::NativeWindow window) override {
22 NOTIMPLEMENTED(); 22 NOTIMPLEMENTED();
23 return false; 23 return false;
24 } 24 }
25 25
26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { 26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
27 NOTIMPLEMENTED(); 27 NOTIMPLEMENTED();
28 return NULL; 28 return NULL;
29 } 29 }
30 30
31 gfx::Display GetPrimaryDisplay() const override { 31 Display GetPrimaryDisplay() const override {
32 gfx::DeviceDisplayInfo device_info; 32 gfx::DeviceDisplayInfo device_info;
33 const float device_scale_factor = device_info.GetDIPScale(); 33 const float device_scale_factor = device_info.GetDIPScale();
34 // Note: GetPhysicalDisplayWidth/Height() does not subtract window 34 // Note: GetPhysicalDisplayWidth/Height() does not subtract window
35 // decorations etc. Use it instead of GetDisplayWidth/Height() when 35 // decorations etc. Use it instead of GetDisplayWidth/Height() when
36 // available. 36 // available.
37 const gfx::Rect bounds_in_pixels = 37 const gfx::Rect bounds_in_pixels =
38 gfx::Rect(device_info.GetPhysicalDisplayWidth() 38 gfx::Rect(device_info.GetPhysicalDisplayWidth()
39 ? device_info.GetPhysicalDisplayWidth() 39 ? device_info.GetPhysicalDisplayWidth()
40 : device_info.GetDisplayWidth(), 40 : device_info.GetDisplayWidth(),
41 device_info.GetPhysicalDisplayHeight() 41 device_info.GetPhysicalDisplayHeight()
42 ? device_info.GetPhysicalDisplayHeight() 42 ? device_info.GetPhysicalDisplayHeight()
43 : device_info.GetDisplayHeight()); 43 : device_info.GetDisplayHeight());
44 const gfx::Rect bounds_in_dip = gfx::Rect(gfx::ScaleToCeiledSize( 44 const gfx::Rect bounds_in_dip = gfx::Rect(gfx::ScaleToCeiledSize(
45 bounds_in_pixels.size(), 1.0f / device_scale_factor)); 45 bounds_in_pixels.size(), 1.0f / device_scale_factor));
46 gfx::Display display(0, bounds_in_dip); 46 Display display(0, bounds_in_dip);
47 if (!gfx::Display::HasForceDeviceScaleFactor()) 47 if (!Display::HasForceDeviceScaleFactor())
48 display.set_device_scale_factor(device_scale_factor); 48 display.set_device_scale_factor(device_scale_factor);
49 display.SetRotationAsDegree(device_info.GetRotationDegrees()); 49 display.SetRotationAsDegree(device_info.GetRotationDegrees());
50 return display; 50 return display;
51 } 51 }
52 52
53 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override { 53 Display GetDisplayNearestWindow(gfx::NativeView view) const override {
54 return GetPrimaryDisplay(); 54 return GetPrimaryDisplay();
55 } 55 }
56 56
57 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override { 57 Display GetDisplayNearestPoint(const gfx::Point& point) const override {
58 return GetPrimaryDisplay(); 58 return GetPrimaryDisplay();
59 } 59 }
60 60
61 int GetNumDisplays() const override { return 1; } 61 int GetNumDisplays() const override { return 1; }
62 62
63 std::vector<gfx::Display> GetAllDisplays() const override { 63 std::vector<Display> GetAllDisplays() const override {
64 return std::vector<gfx::Display>(1, GetPrimaryDisplay()); 64 return std::vector<Display>(1, GetPrimaryDisplay());
65 } 65 }
66 66
67 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override { 67 Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
68 return GetPrimaryDisplay(); 68 return GetPrimaryDisplay();
69 } 69 }
70 70
71 void AddObserver(DisplayObserver* observer) override { 71 void AddObserver(DisplayObserver* observer) override {
72 // no display change on Android. 72 // no display change on Android.
73 } 73 }
74 74
75 void RemoveObserver(DisplayObserver* observer) override { 75 void RemoveObserver(DisplayObserver* observer) override {
76 // no display change on Android. 76 // no display change on Android.
77 } 77 }
78 78
79 private: 79 private:
80 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); 80 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
81 }; 81 };
82 82
83 Screen* CreateNativeScreen() { 83 Screen* CreateNativeScreen() {
84 return new ScreenAndroid; 84 return new ScreenAndroid;
85 } 85 }
86 86
87 } // namespace gfx 87 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698