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

Side by Side Diff: services/ui/display/screen_manager_ozone.h

Issue 2476663003: PlatformScreenOzone using DisplayManager (Closed)
Patch Set: Cleanup. Created 4 years 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_H_ 5 #ifndef SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_H_
6 #define SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_H_ 6 #define SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <memory>
11 #include <vector>
12 11
13 #include "base/callback.h"
14 #include "base/macros.h" 12 #include "base/macros.h"
15 #include "mojo/public/cpp/bindings/binding_set.h" 13 #include "mojo/public/cpp/bindings/binding_set.h"
16 #include "services/service_manager/public/cpp/connection.h" 14 #include "services/service_manager/public/cpp/connection.h"
17 #include "services/service_manager/public/cpp/interface_factory.h" 15 #include "services/service_manager/public/cpp/interface_factory.h"
18 #include "services/ui/display/screen_manager.h" 16 #include "services/ui/display/screen_manager.h"
19 #include "services/ui/display/viewport_metrics.h" 17 #include "services/ui/display/viewport_metrics.h"
20 #include "services/ui/public/interfaces/display/display_controller.mojom.h" 18 #include "services/ui/public/interfaces/display/display_controller.mojom.h"
21 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h" 19 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h"
22 #include "ui/display/display.h" 20 #include "ui/display/display.h"
21 #include "ui/display/display_observer.h"
23 #include "ui/display/manager/chromeos/display_configurator.h" 22 #include "ui/display/manager/chromeos/display_configurator.h"
23 #include "ui/display/manager/display_manager.h"
24 #include "ui/display/types/display_constants.h" 24 #include "ui/display/types/display_constants.h"
25 #include "ui/display/types/fake_display_controller.h"
26 25
27 namespace display { 26 namespace display {
28 27
28 class DisplayChangeObserver;
29 class FakeDisplayController;
30 class ScreenBase;
31
29 // ScreenManagerOzone provides the necessary functionality to configure all 32 // ScreenManagerOzone provides the necessary functionality to configure all
30 // attached physical displays on the ozone platform. 33 // attached physical displays on the ozone platform.
31 class ScreenManagerOzone 34 class ScreenManagerOzone
32 : public ScreenManager, 35 : public ScreenManager,
33 public ui::DisplayConfigurator::Observer, 36 public DisplayObserver,
34 public ui::DisplayConfigurator::StateController, 37 public DisplayManager::Delegate,
35 public service_manager::InterfaceFactory<mojom::DisplayController>, 38 public service_manager::InterfaceFactory<mojom::DisplayController>,
36 public service_manager::InterfaceFactory<mojom::TestDisplayController>, 39 public service_manager::InterfaceFactory<mojom::TestDisplayController>,
37 public mojom::DisplayController, 40 public mojom::DisplayController,
38 public mojom::TestDisplayController { 41 public mojom::TestDisplayController {
39 public: 42 public:
40 ScreenManagerOzone(); 43 ScreenManagerOzone();
41 ~ScreenManagerOzone() override; 44 ~ScreenManagerOzone() override;
42 45
46 void SetPrimaryDisplayId(int64_t display_id);
47
43 // ScreenManager: 48 // ScreenManager:
44 void AddInterfaces(service_manager::InterfaceRegistry* registry) override; 49 void AddInterfaces(service_manager::InterfaceRegistry* registry) override;
45 void Init(ScreenManagerDelegate* delegate) override; 50 void Init(ScreenManagerDelegate* delegate) override;
46 void RequestCloseDisplay(int64_t display_id) override; 51 void RequestCloseDisplay(int64_t display_id) override;
47 int64_t GetPrimaryDisplayId() const override; 52 int64_t GetPrimaryDisplayId() const override;
48 53
49 // mojom::TestDisplayController: 54 // mojom::TestDisplayController:
50 void ToggleAddRemoveDisplay() override; 55 void ToggleAddRemoveDisplay() override;
51 void ToggleDisplayResolution() override; 56 void ToggleDisplayResolution() override;
52 57
53 // mojom::DisplayController: 58 // mojom::DisplayController:
54 void IncreaseInternalDisplayZoom() override; 59 void IncreaseInternalDisplayZoom() override;
55 void DecreaseInternalDisplayZoom() override; 60 void DecreaseInternalDisplayZoom() override;
56 void ResetInternalDisplayZoom() override; 61 void ResetInternalDisplayZoom() override;
57 void RotateCurrentDisplayCW() override; 62 void RotateCurrentDisplayCW() override;
58 void SwapPrimaryDisplay() override; 63 void SwapPrimaryDisplay() override;
59 void ToggleMirrorMode() override; 64 void ToggleMirrorMode() override;
60 void SetDisplayWorkArea(int64_t display_id, 65 void SetDisplayWorkArea(int64_t display_id,
61 const gfx::Size& size, 66 const gfx::Size& size,
62 const gfx::Insets& insets) override; 67 const gfx::Insets& insets) override;
63 68
64 private: 69 private:
65 friend class ScreenManagerOzoneTest; 70 friend class ScreenManagerOzoneTest;
66 71
67 // TODO(kylechar): This struct is just temporary until we migrate 72 ViewportMetrics GetViewportMetricsForDisplay(const Display& display);
68 // DisplayManager code out of ash so it can be used here.
69 struct DisplayInfo {
70 DisplayInfo();
71 DisplayInfo(const DisplayInfo& other);
72 ~DisplayInfo();
73
74 int64_t id = kInvalidDisplayId;
75 // Information about display viewport.
76 ViewportMetrics metrics;
77 // Last insets received from WM.
78 gfx::Insets last_work_area_insets;
79
80 // Temporary hack to allow changing display resolution.
81 std::vector<gfx::Size> supported_sizes;
82 gfx::Size requested_size;
83
84 // The display bounds have been modified and delegate should be updated.
85 bool modified = false;
86 // The display has been removed and delegate should be updated.
87 bool removed = false;
88 };
89 using CachedDisplayIterator = std::vector<DisplayInfo>::iterator;
90
91 // Processes list of display snapshots and sets |removed| on any displays that
92 // have been removed. Updates |primary_display_id_| if the primary display was
93 // removed. Does not remove displays from |cached_displays_| or send updates
94 // to delegate.
95 void ProcessRemovedDisplays(
96 const ui::DisplayConfigurator::DisplayStateList& snapshots);
97
98 // Processes list of display snapshots and updates the bounds of any displays
99 // in |cached_displays_| that have changed size. Does not send updates to
100 // delegate.
101 void ProcessModifiedDisplays(
102 const ui::DisplayConfigurator::DisplayStateList& snapshots);
103
104 // Looks at |cached_displays_| for modified or removed displays. Also updates
105 // display bounds in response to modified or removed displays. Sends updates
106 // to the delegate when appropriate by calling OnDisplayModified() or
107 // OnDisplayRemoved(). Makes at most one call to delegate per display.
108 //
109 // Usually used after ProcessRemovedDisplays() and ProcessModifiedDisplays().
110 void UpdateCachedDisplays();
111
112 // Processes list of display snapshots and adds any new displays to
113 // |cached_displays_|. Updates delegate by calling OnDisplayAdded().
114 void AddNewDisplays(
115 const ui::DisplayConfigurator::DisplayStateList& snapshots);
116
117 // Returns an iterator to the cached display with |display_id| or an end
118 // iterator if there is no display with that id.
119 CachedDisplayIterator GetCachedDisplayIterator(int64_t display_id);
120
121 // Converts |snapshot| into ViewportMetrics.
122 ViewportMetrics MetricsFromSnapshot(const ui::DisplaySnapshot& snapshot,
123 const gfx::Point& origin);
124
125 // ui::DisplayConfigurator::Observer:
126 void OnDisplayModeChanged(
127 const ui::DisplayConfigurator::DisplayStateList& displays) override;
128 void OnDisplayModeChangeFailed(
129 const ui::DisplayConfigurator::DisplayStateList& displays,
130 ui::MultipleDisplayState failed_new_state) override;
131
132 // ui::DisplayConfigurator::StateController:
133 ui::MultipleDisplayState GetStateForDisplayIds(
134 const ui::DisplayConfigurator::DisplayStateList& display_states)
135 const override;
136 bool GetResolutionForDisplayId(int64_t display_id,
137 gfx::Size* size) const override;
138 73
139 // mojo::InterfaceFactory<mojom::DisplayController>: 74 // mojo::InterfaceFactory<mojom::DisplayController>:
140 void Create(const service_manager::Identity& remote_identity, 75 void Create(const service_manager::Identity& remote_identity,
141 mojom::DisplayControllerRequest request) override; 76 mojom::DisplayControllerRequest request) override;
142 77
143 // mojo::InterfaceFactory<mojom::TestDisplayController>: 78 // mojo::InterfaceFactory<mojom::TestDisplayController>:
144 void Create(const service_manager::Identity& remote_identity, 79 void Create(const service_manager::Identity& remote_identity,
145 mojom::TestDisplayControllerRequest request) override; 80 mojom::TestDisplayControllerRequest request) override;
146 81
82 // DisplayManager::Delegate:
msw 2016/12/19 20:02:52 optional nit: match the order of overrides with th
kylechar 2016/12/20 15:19:46 Done.
83 void CreateOrUpdateMirroringDisplay(
84 const DisplayInfoList& display_info_list) override;
85 void CloseMirroringDisplayIfNotNecessary() override;
86 void PreDisplayConfigurationChange(bool clear_focus) override;
87 void PostDisplayConfigurationChange(bool must_clear_window) override;
88 ui::DisplayConfigurator* display_configurator() override;
89
90 // DisplayObserver:
91 void OnDisplayAdded(const Display& new_display) override;
92 void OnDisplayRemoved(const Display& old_display) override;
93 void OnDisplayMetricsChanged(const Display& display,
94 uint32_t changed_metrics) override;
95
147 ui::DisplayConfigurator display_configurator_; 96 ui::DisplayConfigurator display_configurator_;
97 std::unique_ptr<DisplayManager> display_manager_;
98 std::unique_ptr<DisplayChangeObserver> display_change_observer_;
99
100 ScreenBase* screen_ = nullptr;
148 ScreenManagerDelegate* delegate_ = nullptr; 101 ScreenManagerDelegate* delegate_ = nullptr;
149 102
103 std::unique_ptr<ui::NativeDisplayDelegate> native_display_delegate_;
104
150 // If not null it provides a way to modify the display state when running off 105 // If not null it provides a way to modify the display state when running off
151 // device (eg. running mustash on Linux). 106 // device (eg. running mustash on Linux).
152 FakeDisplayController* fake_display_controller_ = nullptr; 107 FakeDisplayController* fake_display_controller_ = nullptr;
153 108
154 // Tracks if we've made a display configuration change and want to wait for 109 int64_t primary_display_id_ = kInvalidDisplayId;
155 // the display configuration to update before making further changes.
156 bool wait_for_display_config_update_ = false;
157
158 // TODO(kylechar): These values can/should be replaced by DisplayLayout.
159 int64_t primary_display_id_ = display::kInvalidDisplayId;
160 std::vector<DisplayInfo> cached_displays_;
161 gfx::Point next_display_origin_;
162 110
163 mojo::BindingSet<mojom::DisplayController> controller_bindings_; 111 mojo::BindingSet<mojom::DisplayController> controller_bindings_;
164 mojo::BindingSet<mojom::TestDisplayController> test_bindings_; 112 mojo::BindingSet<mojom::TestDisplayController> test_bindings_;
165 113
166 DISALLOW_COPY_AND_ASSIGN(ScreenManagerOzone); 114 DISALLOW_COPY_AND_ASSIGN(ScreenManagerOzone);
167 }; 115 };
168 116
169 } // namespace display 117 } // namespace display
170 118
171 #endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_H_ 119 #endif // SERVICES_UI_DISPLAY_SCREEN_MANAGER_OZONE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698