| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 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 |
| 37 // decorations etc. Use it instead of GetDisplayWidth/Height() when |
| 38 // available. |
| 36 const gfx::Rect bounds_in_pixels = | 39 const gfx::Rect bounds_in_pixels = |
| 37 gfx::Rect( | 40 gfx::Rect(device_info.GetPhysicalDisplayWidth() |
| 38 device_info.GetDisplayWidth(), | 41 ? device_info.GetPhysicalDisplayWidth() |
| 39 device_info.GetDisplayHeight()); | 42 : device_info.GetDisplayWidth(), |
| 43 device_info.GetPhysicalDisplayHeight() |
| 44 ? device_info.GetPhysicalDisplayHeight() |
| 45 : device_info.GetDisplayHeight()); |
| 40 const gfx::Rect bounds_in_dip = | 46 const gfx::Rect bounds_in_dip = |
| 41 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize( | 47 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize( |
| 42 bounds_in_pixels.size(), 1.0f / device_scale_factor))); | 48 bounds_in_pixels.size(), 1.0f / device_scale_factor))); |
| 43 gfx::Display display(0, bounds_in_dip); | 49 gfx::Display display(0, bounds_in_dip); |
| 44 if (!gfx::Display::HasForceDeviceScaleFactor()) | 50 if (!gfx::Display::HasForceDeviceScaleFactor()) |
| 45 display.set_device_scale_factor(device_scale_factor); | 51 display.set_device_scale_factor(device_scale_factor); |
| 46 display.SetRotationAsDegree(device_info.GetRotationDegrees()); | 52 display.SetRotationAsDegree(device_info.GetRotationDegrees()); |
| 47 return display; | 53 return display; |
| 48 } | 54 } |
| 49 | 55 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 | 84 |
| 79 private: | 85 private: |
| 80 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); | 86 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); |
| 81 }; | 87 }; |
| 82 | 88 |
| 83 Screen* CreateNativeScreen() { | 89 Screen* CreateNativeScreen() { |
| 84 return new ScreenAndroid; | 90 return new ScreenAndroid; |
| 85 } | 91 } |
| 86 | 92 |
| 87 } // namespace gfx | 93 } // namespace gfx |
| OLD | NEW |