| 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 bool IsDIPEnabled() OVERRIDE { | 18 virtual bool IsDIPEnabled() OVERRIDE { return true; } |
| 19 return true; | |
| 20 } | |
| 21 | 19 |
| 22 gfx::Point GetCursorScreenPoint() OVERRIDE { | 20 virtual gfx::Point GetCursorScreenPoint() OVERRIDE { return gfx::Point(); } |
| 23 return gfx::Point(); | |
| 24 } | |
| 25 | 21 |
| 26 gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { | 22 virtual gfx::NativeWindow GetWindowAtCursorScreenPoint() OVERRIDE { |
| 27 NOTIMPLEMENTED(); | 23 NOTIMPLEMENTED(); |
| 28 return NULL; | 24 return NULL; |
| 29 } | 25 } |
| 30 | 26 |
| 31 gfx::Display GetPrimaryDisplay() const OVERRIDE { | 27 virtual gfx::Display GetPrimaryDisplay() const OVERRIDE { |
| 32 gfx::DeviceDisplayInfo device_info; | 28 gfx::DeviceDisplayInfo device_info; |
| 33 const float device_scale_factor = device_info.GetDIPScale(); | 29 const float device_scale_factor = device_info.GetDIPScale(); |
| 34 const gfx::Rect bounds_in_pixels = | 30 const gfx::Rect bounds_in_pixels = |
| 35 gfx::Rect( | 31 gfx::Rect( |
| 36 device_info.GetDisplayWidth(), | 32 device_info.GetDisplayWidth(), |
| 37 device_info.GetDisplayHeight()); | 33 device_info.GetDisplayHeight()); |
| 38 const gfx::Rect bounds_in_dip = | 34 const gfx::Rect bounds_in_dip = |
| 39 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize( | 35 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize( |
| 40 bounds_in_pixels.size(), 1.0f / device_scale_factor))); | 36 bounds_in_pixels.size(), 1.0f / device_scale_factor))); |
| 41 gfx::Display display(0, bounds_in_dip); | 37 gfx::Display display(0, bounds_in_dip); |
| 42 display.set_device_scale_factor(device_scale_factor); | 38 display.set_device_scale_factor(device_scale_factor); |
| 43 return display; | 39 return display; |
| 44 } | 40 } |
| 45 | 41 |
| 46 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const OVERRIDE { | 42 virtual gfx::Display GetDisplayNearestWindow( |
| 43 gfx::NativeView view) const OVERRIDE { |
| 47 return GetPrimaryDisplay(); | 44 return GetPrimaryDisplay(); |
| 48 } | 45 } |
| 49 | 46 |
| 50 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const OVERRIDE { | 47 virtual gfx::Display GetDisplayNearestPoint( |
| 48 const gfx::Point& point) const OVERRIDE { |
| 51 return GetPrimaryDisplay(); | 49 return GetPrimaryDisplay(); |
| 52 } | 50 } |
| 53 | 51 |
| 54 int GetNumDisplays() OVERRIDE { | 52 virtual int GetNumDisplays() OVERRIDE { return 1; } |
| 55 return 1; | |
| 56 } | |
| 57 | 53 |
| 58 virtual gfx::Display GetDisplayMatching( | 54 virtual gfx::Display GetDisplayMatching( |
| 59 const gfx::Rect& match_rect) const OVERRIDE { | 55 const gfx::Rect& match_rect) const OVERRIDE { |
| 60 return GetPrimaryDisplay(); | 56 return GetPrimaryDisplay(); |
| 61 } | 57 } |
| 62 | 58 |
| 63 virtual void AddObserver(DisplayObserver* observer) OVERRIDE { | 59 virtual void AddObserver(DisplayObserver* observer) OVERRIDE { |
| 64 // no display change on Android. | 60 // no display change on Android. |
| 65 } | 61 } |
| 66 | 62 |
| 67 virtual void RemoveObserver(DisplayObserver* observer) OVERRIDE { | 63 virtual void RemoveObserver(DisplayObserver* observer) OVERRIDE { |
| 68 // no display change on Android. | 64 // no display change on Android. |
| 69 } | 65 } |
| 70 | 66 |
| 71 private: | 67 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); | 68 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 Screen* CreateNativeScreen() { | 71 Screen* CreateNativeScreen() { |
| 76 return new ScreenAndroid; | 72 return new ScreenAndroid; |
| 77 } | 73 } |
| 78 | 74 |
| 79 } // namespace gfx | 75 } // namespace gfx |
| OLD | NEW |