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

Side by Side Diff: components/mus/mus_app.cc

Issue 1899923002: Basic display management for mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix chromecast build Created 4 years, 7 months 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 | « components/mus/mus_app.h ('k') | components/mus/ws/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/mus/mus_app.h" 5 #include "components/mus/mus_app.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/platform_thread.h" 13 #include "base/threading/platform_thread.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "components/mus/common/args.h" 15 #include "components/mus/common/args.h"
16 #include "components/mus/gles2/gpu_impl.h" 16 #include "components/mus/gles2/gpu_impl.h"
17 #include "components/mus/ws/display.h" 17 #include "components/mus/ws/display.h"
18 #include "components/mus/ws/display_binding.h" 18 #include "components/mus/ws/display_binding.h"
19 #include "components/mus/ws/display_manager.h" 19 #include "components/mus/ws/display_manager.h"
20 #include "components/mus/ws/platform_screen.h"
20 #include "components/mus/ws/user_display_manager.h" 21 #include "components/mus/ws/user_display_manager.h"
21 #include "components/mus/ws/window_server.h" 22 #include "components/mus/ws/window_server.h"
22 #include "components/mus/ws/window_server_test_impl.h" 23 #include "components/mus/ws/window_server_test_impl.h"
23 #include "components/mus/ws/window_tree.h" 24 #include "components/mus/ws/window_tree.h"
24 #include "components/mus/ws/window_tree_binding.h" 25 #include "components/mus/ws/window_tree_binding.h"
25 #include "components/mus/ws/window_tree_factory.h" 26 #include "components/mus/ws/window_tree_factory.h"
26 #include "components/mus/ws/window_tree_host_factory.h" 27 #include "components/mus/ws/window_tree_host_factory.h"
27 #include "components/resource_provider/public/cpp/resource_loader.h" 28 #include "components/resource_provider/public/cpp/resource_loader.h"
28 #include "mojo/public/c/system/main.h" 29 #include "mojo/public/c/system/main.h"
29 #include "services/shell/public/cpp/connection.h" 30 #include "services/shell/public/cpp/connection.h"
30 #include "services/shell/public/cpp/connector.h" 31 #include "services/shell/public/cpp/connector.h"
31 #include "services/tracing/public/cpp/tracing_impl.h" 32 #include "services/tracing/public/cpp/tracing_impl.h"
32 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/base/ui_base_paths.h" 34 #include "ui/base/ui_base_paths.h"
34 #include "ui/events/event_switches.h" 35 #include "ui/events/event_switches.h"
35 #include "ui/events/platform/platform_event_source.h" 36 #include "ui/events/platform/platform_event_source.h"
37 #include "ui/gfx/geometry/rect.h"
36 #include "ui/gl/gl_surface.h" 38 #include "ui/gl/gl_surface.h"
37 39
38 #if defined(USE_X11) 40 #if defined(USE_X11)
39 #include <X11/Xlib.h> 41 #include <X11/Xlib.h>
40 #include "ui/platform_window/x11/x11_window.h" 42 #include "ui/platform_window/x11/x11_window.h"
41 #elif defined(USE_OZONE) 43 #elif defined(USE_OZONE)
42 #include "ui/events/ozone/layout/keyboard_layout_engine.h" 44 #include "ui/events/ozone/layout/keyboard_layout_engine.h"
43 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 45 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
44 #include "ui/ozone/public/ozone_platform.h" 46 #include "ui/ozone/public/ozone_platform.h"
45 #endif 47 #endif
(...skipping 17 matching lines...) Expand all
63 // TODO(sky): this is a pretty typical pattern, make it easier to do. 65 // TODO(sky): this is a pretty typical pattern, make it easier to do.
64 struct MandolineUIServicesApp::PendingRequest { 66 struct MandolineUIServicesApp::PendingRequest {
65 shell::Connection* connection; 67 shell::Connection* connection;
66 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; 68 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request;
67 }; 69 };
68 70
69 struct MandolineUIServicesApp::UserState { 71 struct MandolineUIServicesApp::UserState {
70 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; 72 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory;
71 }; 73 };
72 74
73 MandolineUIServicesApp::MandolineUIServicesApp() : test_config_(false) {} 75 MandolineUIServicesApp::MandolineUIServicesApp()
76 : test_config_(false),
77 platform_screen_(ws::PlatformScreen::Create()),
78 weak_ptr_factory_(this) {}
74 79
75 MandolineUIServicesApp::~MandolineUIServicesApp() { 80 MandolineUIServicesApp::~MandolineUIServicesApp() {
76 // Destroy |window_server_| first, since it depends on |event_source_|. 81 // Destroy |window_server_| first, since it depends on |event_source_|.
77 // WindowServer (or more correctly its Displays) may have state that needs to 82 // WindowServer (or more correctly its Displays) may have state that needs to
78 // be destroyed before GpuState as well. 83 // be destroyed before GpuState as well.
79 window_server_.reset(); 84 window_server_.reset();
80 85
81 if (platform_display_init_params_.gpu_state) 86 if (platform_display_init_params_.gpu_state)
82 platform_display_init_params_.gpu_state->StopThreads(); 87 platform_display_init_params_.gpu_state->StopThreads();
83 } 88 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // TODO(rjkroege): Enter sandbox here before we start threads in GpuState 168 // TODO(rjkroege): Enter sandbox here before we start threads in GpuState
164 // http://crbug.com/584532 169 // http://crbug.com/584532
165 170
166 #if !defined(OS_ANDROID) 171 #if !defined(OS_ANDROID)
167 event_source_ = ui::PlatformEventSource::CreateDefault(); 172 event_source_ = ui::PlatformEventSource::CreateDefault();
168 #endif 173 #endif
169 174
170 // TODO(rjkroege): It is possible that we might want to generalize the 175 // TODO(rjkroege): It is possible that we might want to generalize the
171 // GpuState object. 176 // GpuState object.
172 platform_display_init_params_.gpu_state = new GpuState(); 177 platform_display_init_params_.gpu_state = new GpuState();
178
179 // Gpu must be running before the PlatformScreen can be initialized.
180 platform_screen_->Init();
173 window_server_.reset( 181 window_server_.reset(
174 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); 182 new ws::WindowServer(this, platform_display_init_params_.surfaces_state));
175 } 183 }
176 184
177 bool MandolineUIServicesApp::AcceptConnection(Connection* connection) { 185 bool MandolineUIServicesApp::AcceptConnection(Connection* connection) {
178 connection->AddInterface<Gpu>(this); 186 connection->AddInterface<Gpu>(this);
179 connection->AddInterface<mojom::DisplayManager>(this); 187 connection->AddInterface<mojom::DisplayManager>(this);
180 connection->AddInterface<mojom::UserAccessManager>(this); 188 connection->AddInterface<mojom::UserAccessManager>(this);
181 connection->AddInterface<WindowTreeHostFactory>(this); 189 connection->AddInterface<WindowTreeHostFactory>(this);
182 connection->AddInterface<mojom::WindowManagerFactoryService>(this); 190 connection->AddInterface<mojom::WindowManagerFactoryService>(this);
(...skipping 14 matching lines...) Expand all
197 // We may get here from the destructor, in which case there is no messageloop. 205 // We may get here from the destructor, in which case there is no messageloop.
198 if (base::MessageLoop::current()) 206 if (base::MessageLoop::current())
199 base::MessageLoop::current()->QuitWhenIdle(); 207 base::MessageLoop::current()->QuitWhenIdle();
200 } 208 }
201 209
202 bool MandolineUIServicesApp::IsTestConfig() const { 210 bool MandolineUIServicesApp::IsTestConfig() const {
203 return test_config_; 211 return test_config_;
204 } 212 }
205 213
206 void MandolineUIServicesApp::CreateDefaultDisplays() { 214 void MandolineUIServicesApp::CreateDefaultDisplays() {
207 // Display manages its own lifetime. 215 // An asynchronous callback will create the Displays once the physical
208 ws::Display* host_impl = 216 // displays are ready.
209 new ws::Display(window_server_.get(), platform_display_init_params_); 217 platform_screen_->ConfigurePhysicalDisplay(
210 host_impl->Init(nullptr); 218 base::Bind(&MandolineUIServicesApp::OnCreatedPhysicalDisplay,
219 weak_ptr_factory_.GetWeakPtr()));
211 } 220 }
212 221
213 void MandolineUIServicesApp::Create(shell::Connection* connection, 222 void MandolineUIServicesApp::Create(shell::Connection* connection,
214 mojom::DisplayManagerRequest request) { 223 mojom::DisplayManagerRequest request) {
215 window_server_->display_manager() 224 window_server_->display_manager()
216 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) 225 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id())
217 ->AddDisplayManagerBinding(std::move(request)); 226 ->AddDisplayManagerBinding(std::move(request));
218 } 227 }
219 228
220 void MandolineUIServicesApp::Create(shell::Connection* connection, 229 void MandolineUIServicesApp::Create(shell::Connection* connection,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return; 275 return;
267 new ws::WindowServerTestImpl(window_server_.get(), std::move(request)); 276 new ws::WindowServerTestImpl(window_server_.get(), std::move(request));
268 } 277 }
269 278
270 void MandolineUIServicesApp::Create(shell::Connection* connection, 279 void MandolineUIServicesApp::Create(shell::Connection* connection,
271 mojom::GpuRequest request) { 280 mojom::GpuRequest request) {
272 DCHECK(platform_display_init_params_.gpu_state); 281 DCHECK(platform_display_init_params_.gpu_state);
273 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); 282 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state);
274 } 283 }
275 284
285 void MandolineUIServicesApp::OnCreatedPhysicalDisplay(int64_t id,
286 const gfx::Rect& bounds) {
287 platform_display_init_params_.display_bounds = bounds;
288 platform_display_init_params_.display_id = id;
289
290 // Display manages its own lifetime.
291 ws::Display* host_impl =
292 new ws::Display(window_server_.get(), platform_display_init_params_);
293 host_impl->Init(nullptr);
294 }
295
276 } // namespace mus 296 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/mus_app.h ('k') | components/mus/ws/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698