| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "base/macros.h" | |
| 7 #include "ui/display/display.h" | |
| 8 #include "ui/display/screen_base.h" | |
| 9 #include "ui/gfx/android/device_display_info.h" | |
| 10 #include "ui/gfx/geometry/size_conversions.h" | |
| 11 | |
| 12 namespace display { | |
| 13 | |
| 14 class ScreenAndroid : public ScreenBase { | |
| 15 public: | |
| 16 ScreenAndroid() { | |
| 17 gfx::DeviceDisplayInfo device_info; | |
| 18 const float device_scale_factor = device_info.GetDIPScale(); | |
| 19 // Note: GetPhysicalDisplayWidth/Height() does not subtract window | |
| 20 // decorations etc. Use it instead of GetDisplayWidth/Height() when | |
| 21 // available. | |
| 22 const gfx::Rect bounds_in_pixels = | |
| 23 gfx::Rect(device_info.GetPhysicalDisplayWidth() | |
| 24 ? device_info.GetPhysicalDisplayWidth() | |
| 25 : device_info.GetDisplayWidth(), | |
| 26 device_info.GetPhysicalDisplayHeight() | |
| 27 ? device_info.GetPhysicalDisplayHeight() | |
| 28 : device_info.GetDisplayHeight()); | |
| 29 const gfx::Rect bounds_in_dip = gfx::Rect(gfx::ScaleToCeiledSize( | |
| 30 bounds_in_pixels.size(), 1.0f / device_scale_factor)); | |
| 31 Display display(0, bounds_in_dip); | |
| 32 if (!Display::HasForceDeviceScaleFactor()) | |
| 33 display.set_device_scale_factor(device_scale_factor); | |
| 34 display.SetRotationAsDegree(device_info.GetRotationDegrees()); | |
| 35 display.set_color_depth(device_info.GetBitsPerPixel()); | |
| 36 display.set_depth_per_component(device_info.GetBitsPerComponent()); | |
| 37 display.set_is_monochrome(device_info.GetBitsPerComponent() == 0); | |
| 38 ProcessDisplayChanged(display, true /* is_primary */); | |
| 39 } | |
| 40 | |
| 41 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); } | |
| 42 | |
| 43 bool IsWindowUnderCursor(gfx::NativeWindow window) override { | |
| 44 NOTIMPLEMENTED(); | |
| 45 return false; | |
| 46 } | |
| 47 | |
| 48 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { | |
| 49 NOTIMPLEMENTED(); | |
| 50 return NULL; | |
| 51 } | |
| 52 | |
| 53 Display GetDisplayNearestWindow(gfx::NativeView view) const override { | |
| 54 return GetPrimaryDisplay(); | |
| 55 } | |
| 56 | |
| 57 private: | |
| 58 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid); | |
| 59 }; | |
| 60 | |
| 61 Screen* CreateNativeScreen() { | |
| 62 return new ScreenAndroid; | |
| 63 } | |
| 64 | |
| 65 } // namespace display | |
| OLD | NEW |