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

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

Issue 2434923002: Handle modified displays in mustash. (Closed)
Patch Set: Fix PlatformScreenStub for tests. 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
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_PLATFORM_SCREEN_OZONE_H_ 5 #ifndef SERVICES_UI_DISPLAY_PLATFORM_SCREEN_OZONE_H_
6 #define SERVICES_UI_DISPLAY_PLATFORM_SCREEN_OZONE_H_ 6 #define SERVICES_UI_DISPLAY_PLATFORM_SCREEN_OZONE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "mojo/public/cpp/bindings/binding_set.h" 15 #include "mojo/public/cpp/bindings/binding_set.h"
16 #include "services/service_manager/public/cpp/connection.h" 16 #include "services/service_manager/public/cpp/connection.h"
17 #include "services/service_manager/public/cpp/interface_factory.h" 17 #include "services/service_manager/public/cpp/interface_factory.h"
18 #include "services/ui/display/platform_screen.h" 18 #include "services/ui/display/platform_screen.h"
19 #include "services/ui/display/viewport_metrics.h"
19 #include "services/ui/public/interfaces/display/display_controller.mojom.h" 20 #include "services/ui/public/interfaces/display/display_controller.mojom.h"
20 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h" 21 #include "services/ui/public/interfaces/display/test_display_controller.mojom.h"
21 #include "ui/display/chromeos/display_configurator.h" 22 #include "ui/display/chromeos/display_configurator.h"
22 #include "ui/display/display.h" 23 #include "ui/display/display.h"
23 #include "ui/display/types/fake_display_controller.h" 24 #include "ui/display/types/fake_display_controller.h"
24 25
25 namespace display { 26 namespace display {
26 27
27 // PlatformScreenOzone provides the necessary functionality to configure all 28 // PlatformScreenOzone provides the necessary functionality to configure all
28 // attached physical displays on the ozone platform. 29 // attached physical displays on the ozone platform.
29 class PlatformScreenOzone 30 class PlatformScreenOzone
30 : public PlatformScreen, 31 : public PlatformScreen,
31 public ui::DisplayConfigurator::Observer, 32 public ui::DisplayConfigurator::Observer,
33 public ui::DisplayConfigurator::StateController,
32 public service_manager::InterfaceFactory<mojom::DisplayController>, 34 public service_manager::InterfaceFactory<mojom::DisplayController>,
33 public service_manager::InterfaceFactory<mojom::TestDisplayController>, 35 public service_manager::InterfaceFactory<mojom::TestDisplayController>,
34 public mojom::DisplayController, 36 public mojom::DisplayController,
35 public mojom::TestDisplayController { 37 public mojom::TestDisplayController {
36 public: 38 public:
37 PlatformScreenOzone(); 39 PlatformScreenOzone();
38 ~PlatformScreenOzone() override; 40 ~PlatformScreenOzone() override;
39 41
40 // PlatformScreen: 42 // PlatformScreen:
41 void AddInterfaces(service_manager::InterfaceRegistry* registry) override; 43 void AddInterfaces(service_manager::InterfaceRegistry* registry) override;
42 void Init(PlatformScreenDelegate* delegate) override; 44 void Init(PlatformScreenDelegate* delegate) override;
43 void RequestCloseDisplay(int64_t display_id) override; 45 void RequestCloseDisplay(int64_t display_id) override;
44 int64_t GetPrimaryDisplayId() const override; 46 int64_t GetPrimaryDisplayId() const override;
45 47
46 // mojom::TestDisplayController: 48 // mojom::TestDisplayController:
47 void ToggleAddRemoveDisplay() override; 49 void ToggleAddRemoveDisplay() override;
50 void ToggleDisplayResolution() override;
48 51
49 // mojom::DisplayController: 52 // mojom::DisplayController:
50 void SwapPrimaryDisplay() override; 53 void SwapPrimaryDisplay() override;
51 void SetDisplayWorkArea(int64_t display_id, 54 void SetDisplayWorkArea(int64_t display_id,
52 const gfx::Size& size, 55 const gfx::Size& size,
53 const gfx::Insets& insets) override; 56 const gfx::Insets& insets) override;
54 57
55 private: 58 private:
56 // TODO(kylechar): This struct is just temporary until we migrate 59 // TODO(kylechar): This struct is just temporary until we migrate
57 // DisplayManager code out of ash so it can be used here. 60 // DisplayManager code out of ash so it can be used here.
58 struct DisplayInfo { 61 struct DisplayInfo {
62 DisplayInfo();
63 DisplayInfo(const DisplayInfo& other);
64 ~DisplayInfo();
65
59 int64_t id = Display::kInvalidDisplayID; 66 int64_t id = Display::kInvalidDisplayID;
60 // The display bounds in DIP. 67 // Information about display viewport.
61 gfx::Rect bounds; 68 ViewportMetrics metrics;
62 // Display size in DDP. 69 // Last insets received from WM.
63 gfx::Size pixel_size; 70 gfx::Insets last_work_area_insets;
64 // The display device pixel scale factor, either 1 or 2. 71
65 float device_scale_factor = 1.0f; 72 // Temporary hack to allow changing display resolution.
73 std::vector<gfx::Size> supported_sizes;
74 gfx::Size requested_size;
75
66 // The display bounds have been modified and delegate should be updated. 76 // The display bounds have been modified and delegate should be updated.
67 bool modified = false; 77 bool modified = false;
68 // The display has been removed and delegate should be updated. 78 // The display has been removed and delegate should be updated.
69 bool removed = false; 79 bool removed = false;
70 }; 80 };
71 using CachedDisplayIterator = std::vector<DisplayInfo>::iterator; 81 using CachedDisplayIterator = std::vector<DisplayInfo>::iterator;
72 82
73 // Processes list of display snapshots and sets |removed| on any displays that 83 // Processes list of display snapshots and sets |removed| on any displays that
74 // have been removed. Updates |primary_display_id_| if the primary display was 84 // have been removed. Updates |primary_display_id_| if the primary display was
75 // removed. Does not remove displays from |cached_displays_| or send updates 85 // removed. Does not remove displays from |cached_displays_| or send updates
(...skipping 17 matching lines...) Expand all
93 103
94 // Processes list of display snapshots and adds any new displays to 104 // Processes list of display snapshots and adds any new displays to
95 // |cached_displays_|. Updates delegate by calling OnDisplayAdded(). 105 // |cached_displays_|. Updates delegate by calling OnDisplayAdded().
96 void AddNewDisplays( 106 void AddNewDisplays(
97 const ui::DisplayConfigurator::DisplayStateList& snapshots); 107 const ui::DisplayConfigurator::DisplayStateList& snapshots);
98 108
99 // Returns an iterator to the cached display with |display_id| or an end 109 // Returns an iterator to the cached display with |display_id| or an end
100 // iterator if there is no display with that id. 110 // iterator if there is no display with that id.
101 CachedDisplayIterator GetCachedDisplayIterator(int64_t display_id); 111 CachedDisplayIterator GetCachedDisplayIterator(int64_t display_id);
102 112
103 // Converts |snapshot| into a DisplayInfo. 113 // Converts |snapshot| into ViewportMetrics.
104 DisplayInfo DisplayInfoFromSnapshot(const ui::DisplaySnapshot& snapshot); 114 ViewportMetrics MetricsFromSnapshot(const ui::DisplaySnapshot& snapshot,
115 const gfx::Point& origin);
105 116
106 // ui::DisplayConfigurator::Observer: 117 // ui::DisplayConfigurator::Observer:
107 void OnDisplayModeChanged( 118 void OnDisplayModeChanged(
108 const ui::DisplayConfigurator::DisplayStateList& displays) override; 119 const ui::DisplayConfigurator::DisplayStateList& displays) override;
109 void OnDisplayModeChangeFailed( 120 void OnDisplayModeChangeFailed(
110 const ui::DisplayConfigurator::DisplayStateList& displays, 121 const ui::DisplayConfigurator::DisplayStateList& displays,
111 ui::MultipleDisplayState failed_new_state) override; 122 ui::MultipleDisplayState failed_new_state) override;
112 123
124 // ui::DisplayConfigurator::StateController:
125 ui::MultipleDisplayState GetStateForDisplayIds(
126 const ui::DisplayConfigurator::DisplayStateList& display_states)
127 const override;
128 bool GetResolutionForDisplayId(int64_t display_id,
129 gfx::Size* size) const override;
130
113 // mojo::InterfaceFactory<mojom::DisplayController>: 131 // mojo::InterfaceFactory<mojom::DisplayController>:
114 void Create(const service_manager::Identity& remote_identity, 132 void Create(const service_manager::Identity& remote_identity,
115 mojom::DisplayControllerRequest request) override; 133 mojom::DisplayControllerRequest request) override;
116 134
117 // mojo::InterfaceFactory<mojom::TestDisplayController>: 135 // mojo::InterfaceFactory<mojom::TestDisplayController>:
118 void Create(const service_manager::Identity& remote_identity, 136 void Create(const service_manager::Identity& remote_identity,
119 mojom::TestDisplayControllerRequest request) override; 137 mojom::TestDisplayControllerRequest request) override;
120 138
121 ui::DisplayConfigurator display_configurator_; 139 ui::DisplayConfigurator display_configurator_;
122 PlatformScreenDelegate* delegate_ = nullptr; 140 PlatformScreenDelegate* delegate_ = nullptr;
(...skipping 13 matching lines...) Expand all
136 154
137 mojo::BindingSet<mojom::DisplayController> controller_bindings_; 155 mojo::BindingSet<mojom::DisplayController> controller_bindings_;
138 mojo::BindingSet<mojom::TestDisplayController> test_bindings_; 156 mojo::BindingSet<mojom::TestDisplayController> test_bindings_;
139 157
140 DISALLOW_COPY_AND_ASSIGN(PlatformScreenOzone); 158 DISALLOW_COPY_AND_ASSIGN(PlatformScreenOzone);
141 }; 159 };
142 160
143 } // namespace display 161 } // namespace display
144 162
145 #endif // SERVICES_UI_DISPLAY_PLATFORM_SCREEN_OZONE_H_ 163 #endif // SERVICES_UI_DISPLAY_PLATFORM_SCREEN_OZONE_H_
OLDNEW
« no previous file with comments | « services/ui/display/platform_screen_delegate.h ('k') | services/ui/display/platform_screen_ozone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698