Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: ui/gfx/screen_android.cc

Issue 1409833004: Add DeviceDisplayInfo getter in WindowAndroid. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass display area instead of NativeWindow to GLHelperHolder. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "ui/gfx/screen.h"
6
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"
11
12 namespace gfx {
13
14 class ScreenAndroid : public Screen {
15 public:
16 ScreenAndroid() {}
17
18 gfx::Point GetCursorScreenPoint() override { return gfx::Point(); }
19
20 gfx::NativeWindow GetWindowUnderCursor() override {
21 NOTIMPLEMENTED();
22 return NULL;
23 }
24
25 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
26 NOTIMPLEMENTED();
27 return NULL;
28 }
29
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 = gfx::Rect(gfx::ScaleToCeiledSize(
44 bounds_in_pixels.size(), 1.0f / device_scale_factor));
45 gfx::Display display(0, bounds_in_dip);
46 if (!gfx::Display::HasForceDeviceScaleFactor())
47 display.set_device_scale_factor(device_scale_factor);
48 display.SetRotationAsDegree(device_info.GetRotationDegrees());
49 return display;
50 }
51
52 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override {
53 return GetPrimaryDisplay();
54 }
55
56 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override {
57 return GetPrimaryDisplay();
58 }
59
60 int GetNumDisplays() const override { return 1; }
61
62 std::vector<gfx::Display> GetAllDisplays() const override {
63 return std::vector<gfx::Display>(1, GetPrimaryDisplay());
64 }
65
66 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
67 return GetPrimaryDisplay();
68 }
69
70 void AddObserver(DisplayObserver* observer) override {
71 // no display change on Android.
72 }
73
74 void RemoveObserver(DisplayObserver* observer) override {
75 // no display change on Android.
76 }
77
78 private:
79 DISALLOW_COPY_AND_ASSIGN(ScreenAndroid);
80 };
81
82 Screen* CreateNativeScreen() {
83 return new ScreenAndroid;
sadrul 2015/11/03 18:14:27 You still need to define CreateNativeScreen() in t
gsennton 2015/12/14 18:10:32 Right, I've added the stub implementation but I am
84 }
85
86 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698