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

Side by Side Diff: ui/display/ios/screen_ios.mm

Issue 2491563002: Change ScreenAndroid and ScreenIos to use ScreenBase and DisplayList. (Closed)
Patch Set: public Created 4 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
« no previous file with comments | « ui/display/android/screen_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/display/screen.h"
6
7 #import <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
8 6
9 #include "base/logging.h" 7 #include "base/logging.h"
10 #include "ui/display/display.h" 8 #include "ui/display/display.h"
9 #include "ui/display/screen_base.h"
11 10
12 namespace display { 11 namespace display {
13 namespace { 12 namespace {
14 13
15 class ScreenIos : public Screen { 14 class ScreenIos : public ScreenBase {
15 public:
16 ScreenIos() {
17 UIScreen* mainScreen = [UIScreen mainScreen];
18 CHECK(mainScreen);
19 Display display(0, gfx::Rect(mainScreen.bounds));
20 display.set_device_scale_factor([mainScreen scale]);
21 ProcessDisplayChanged(display, true /* is_primary */);
22 }
23
16 gfx::Point GetCursorScreenPoint() override { 24 gfx::Point GetCursorScreenPoint() override {
17 NOTIMPLEMENTED(); 25 NOTIMPLEMENTED();
18 return gfx::Point(0, 0); 26 return gfx::Point(0, 0);
19 } 27 }
20 28
21 bool IsWindowUnderCursor(gfx::NativeWindow window) override { 29 bool IsWindowUnderCursor(gfx::NativeWindow window) override {
22 NOTIMPLEMENTED(); 30 NOTIMPLEMENTED();
23 return false; 31 return false;
24 } 32 }
25 33
26 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { 34 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
27 NOTIMPLEMENTED(); 35 NOTIMPLEMENTED();
28 return gfx::NativeWindow(); 36 return gfx::NativeWindow();
29 } 37 }
30 38
31 int GetNumDisplays() const override { 39 int GetNumDisplays() const override {
32 #if TARGET_IPHONE_SIMULATOR 40 #if TARGET_IPHONE_SIMULATOR
33 // UIScreen does not reliably return correct results on the simulator. 41 // UIScreen does not reliably return correct results on the simulator.
34 return 1; 42 return 1;
35 #else 43 #else
36 return [[UIScreen screens] count]; 44 return [[UIScreen screens] count];
37 #endif 45 #endif
38 } 46 }
39 47
40 std::vector<Display> GetAllDisplays() const override { 48 private:
41 NOTIMPLEMENTED(); 49 DISALLOW_COPY_AND_ASSIGN(ScreenIos);
42 return std::vector<Display>(1, GetPrimaryDisplay());
43 }
44
45 // Returns the display nearest the specified window.
46 Display GetDisplayNearestWindow(gfx::NativeView view) const override {
47 NOTIMPLEMENTED();
48 return Display();
49 }
50
51 // Returns the the display nearest the specified point.
52 Display GetDisplayNearestPoint(const gfx::Point& point) const override {
53 NOTIMPLEMENTED();
54 return Display();
55 }
56
57 // Returns the display that most closely intersects the provided bounds.
58 Display GetDisplayMatching(const gfx::Rect& match_rect) const override {
59 NOTIMPLEMENTED();
60 return Display();
61 }
62
63 // Returns the primary display.
64 Display GetPrimaryDisplay() const override {
65 UIScreen* mainScreen = [UIScreen mainScreen];
66 CHECK(mainScreen);
67 Display display(0, gfx::Rect(mainScreen.bounds));
68 display.set_device_scale_factor([mainScreen scale]);
69 return display;
70 }
71
72 void AddObserver(DisplayObserver* observer) override {
73 // no display change on iOS.
74 }
75
76 void RemoveObserver(DisplayObserver* observer) override {
77 // no display change on iOS.
78 }
79 }; 50 };
80 51
81 } // namespace 52 } // namespace
82 53
83 Screen* CreateNativeScreen() { 54 Screen* CreateNativeScreen() {
84 return new ScreenIos; 55 return new ScreenIos;
85 } 56 }
86 57
87 } // namespace gfx 58 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/display/android/screen_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698