[iOS] Cleanup ios/chrome/ios_chrome.gyp
[chromium-blink-merge.git] / ui / gfx / screen_android.cc
blobc286e603f2d8b621662a47f7cce4a0755cbd92a0
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.
5 #include "ui/gfx/screen.h"
7 #include "base/logging.h"
8 #include "ui/gfx/android/device_display_info.h"
9 #include "ui/gfx/display.h"
10 #include "ui/gfx/geometry/size_conversions.h"
12 namespace gfx {
14 class ScreenAndroid : public Screen {
15 public:
16 ScreenAndroid() {}
18 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
20 gfx::NativeWindow GetWindowUnderCursor() override {
21 NOTIMPLEMENTED();
22 return NULL;
25 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
26 NOTIMPLEMENTED();
27 return NULL;
30 gfx::Display GetPrimaryDisplay() const override {
31 gfx::DeviceDisplayInfo device_info;
32 const float device_scale_factor = device_info.GetDIPScale();
33 // Note: GetPhysicalDisplayWidth/Height() does not subtract window
34 // decorations etc. Use it instead of GetDisplayWidth/Height() when
35 // available.
36 const gfx::Rect bounds_in_pixels =
37 gfx::Rect(device_info.GetPhysicalDisplayWidth()
38 ? device_info.GetPhysicalDisplayWidth()
39 : device_info.GetDisplayWidth(),
40 device_info.GetPhysicalDisplayHeight()
41 ? device_info.GetPhysicalDisplayHeight()
42 : device_info.GetDisplayHeight());
43 const gfx::Rect bounds_in_dip =
44 gfx::Rect(gfx::ToCeiledSize(gfx::ScaleSize(
45 bounds_in_pixels.size(), 1.0f / device_scale_factor)));
46 gfx::Display display(0, bounds_in_dip);
47 if (!gfx::Display::HasForceDeviceScaleFactor())
48 display.set_device_scale_factor(device_scale_factor);
49 display.SetRotationAsDegree(device_info.GetRotationDegrees());
50 return display;
53 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override {
54 return GetPrimaryDisplay();
57 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
58 return GetPrimaryDisplay();
61 int GetNumDisplays() const override { return 1; }
63 std::vector<gfx::Display> GetAllDisplays() const override {
64 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
67 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
68 return GetPrimaryDisplay();
71 void AddObserver(DisplayObserver* observer) override {
72 // no display change on Android.
75 void RemoveObserver(DisplayObserver* observer) override {
76 // no display change on Android.
79 private:
80 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
83 Screen* CreateNativeScreen() {
84 return new ScreenAndroid;
87 } // namespace gfx