| 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.GetDIPScale(); |
| 34 const gfx::Rect bounds_in_pixels = |
| 35 gfx::Rect( |
| 36 device_info.GetDisplayWidth(), |
| 37 device_info.GetDisplayHeight()); |
| 38 const gfx::Rect bounds_in_dip = |
| 39 gfx::Rect(gfx::ToRoundedSize(gfx::ScaleSize( |
| 40 bounds_in_pixels.size(), 1.0f / device_scale_factor))); |
| 41 gfx::Display display(0, bounds_in_dip); |
| 42 display.set_device_scale_factor(device_scale_factor); |
| 43 return display; |
| 32 } | 44 } |
| 33 | 45 |
| 34 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const OVERRIDE { | 46 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const OVERRIDE { |
| 35 return GetPrimaryDisplay(); | 47 return GetPrimaryDisplay(); |
| 36 } | 48 } |
| 37 | 49 |
| 38 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE { | 50 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE { |
| 39 return GetPrimaryDisplay(); | 51 return GetPrimaryDisplay(); |
| 40 } | 52 } |
| 41 | 53 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 | 70 |
| 59 private: | 71 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); | 72 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); |
| 61 }; | 73 }; |
| 62 | 74 |
| 63 Screen* CreateNativeScreen() { | 75 Screen* CreateNativeScreen() { |
| 64 return new ScreenAndroid; | 76 return new ScreenAndroid; |
| 65 } | 77 } |
| 66 | 78 |
| 67 } // namespace gfx | 79 } // namespace gfx |
| OLD | NEW |