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