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_info.h" |
8 #include "ui/gfx/display.h" | 9 #include "ui/gfx/display.h" |
| 10 #include "ui/gfx/size_conversions.h" |
9 | 11 |
10 namespace gfx { | 12 namespace gfx { |
11 | 13 |
12 class ScreenAndroid : public Screen { | 14 class ScreenAndroid : public Screen { |
13 public: | 15 public: |
14 ScreenAndroid() {} | 16 ScreenAndroid() {} |
15 | 17 |
16 bool IsDIPEnabled() OVERRIDE { | 18 bool IsDIPEnabled() OVERRIDE { |
17 return false; | 19 return true; |
18 } | 20 } |
19 | 21 |
20 gfx::Point GetCursorScreenPoint() OVERRIDE { | 22 gfx::Point GetCursorScreenPoint() OVERRIDE { |
21 return gfx::Point(); | 23 return gfx::Point(); |
22 } | 24 } |
23 | 25 |
24 gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { | 26 gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { |
25 NOTIMPLEMENTED(); | 27 NOTIMPLEMENTED(); |
26 return NULL; | 28 return NULL; |
27 } | 29 } |
28 | 30 |
29 gfx::Display GetPrimaryDisplay() const OVERRIDE { | 31 gfx::Display GetPrimaryDisplay() const OVERRIDE { |
30 NOTIMPLEMENTED() << "crbug.com/117839 tracks implementation"; | 32 gfx::DeviceInfo device_info; |
31 return gfx::Display(0, gfx::Rect(0, 0, 1, 1)); | 33 const float device_scale_factor = device_info.GetDPIScale(); |
| 34 const gfx::Rect bounds_in_pixels = |
| 35 gfx::Rect(device_info.GetWidth(), device_info.GetHeight()); |
| 36 const gfx::Rect bounds_in_dip = |
| 37 gfx::Rect(gfx::ToRoundedSize(gfx::ScaleSize( |
| 38 bounds_in_pixels.size(), 1.0f / device_scale_factor))); |
| 39 gfx::Display display(0, bounds_in_dip); |
| 40 display.set_device_scale_factor(device_info.GetDPIScale()); |
| 41 return display; |
32 } | 42 } |
33 | 43 |
34 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const OVERRIDE { | 44 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const OVERRIDE { |
35 return GetPrimaryDisplay(); | 45 return GetPrimaryDisplay(); |
36 } | 46 } |
37 | 47 |
38 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE { | 48 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE { |
39 return GetPrimaryDisplay(); | 49 return GetPrimaryDisplay(); |
40 } | 50 } |
41 | 51 |
(...skipping 16 matching lines...) Expand all Loading... |
58 | 68 |
59 private: | 69 private: |
60 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); | 70 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); |
61 }; | 71 }; |
62 | 72 |
63 Screen* CreateNativeScreen() { | 73 Screen* CreateNativeScreen() { |
64 return new ScreenAndroid; | 74 return new ScreenAndroid; |
65 } | 75 } |
66 | 76 |
67 } // namespace gfx | 77 } // namespace gfx |
OLD | NEW |