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

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

Issue 1976703003: Impl mus::mojom::GpuService to enable using Chrome IPC version gpu CmdBuf in mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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/public/cpp/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/clipboard/clipboard_impl.h" 15 #include "components/mus/clipboard/clipboard_impl.h"
16 #include "components/mus/common/switches.h" 16 #include "components/mus/common/switches.h"
17 #include "components/mus/gles2/gpu_impl.h" 17 #include "components/mus/gles2/gpu_impl.h"
18 #include "components/mus/gpu/gpu_service_impl.h"
19 #include "components/mus/gpu/gpu_service_mus.h"
18 #include "components/mus/ws/display.h" 20 #include "components/mus/ws/display.h"
19 #include "components/mus/ws/display_binding.h" 21 #include "components/mus/ws/display_binding.h"
20 #include "components/mus/ws/display_manager.h" 22 #include "components/mus/ws/display_manager.h"
21 #include "components/mus/ws/platform_screen.h" 23 #include "components/mus/ws/platform_screen.h"
22 #include "components/mus/ws/user_display_manager.h" 24 #include "components/mus/ws/user_display_manager.h"
23 #include "components/mus/ws/window_server.h" 25 #include "components/mus/ws/window_server.h"
24 #include "components/mus/ws/window_server_test_impl.h" 26 #include "components/mus/ws/window_server_test_impl.h"
25 #include "components/mus/ws/window_tree.h" 27 #include "components/mus/ws/window_tree.h"
26 #include "components/mus/ws/window_tree_binding.h" 28 #include "components/mus/ws/window_tree_binding.h"
27 #include "components/mus/ws/window_tree_factory.h" 29 #include "components/mus/ws/window_tree_factory.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request; 71 std::unique_ptr<mojo::InterfaceRequest<mojom::WindowTreeFactory>> wtf_request;
70 }; 72 };
71 73
72 struct MusApp::UserState { 74 struct MusApp::UserState {
73 std::unique_ptr<clipboard::ClipboardImpl> clipboard; 75 std::unique_ptr<clipboard::ClipboardImpl> clipboard;
74 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory; 76 std::unique_ptr<ws::WindowTreeHostFactory> window_tree_host_factory;
75 }; 77 };
76 78
77 MusApp::MusApp() 79 MusApp::MusApp()
78 : test_config_(false), 80 : test_config_(false),
81 use_chrome_gpu_command_buffer_(false),
79 platform_screen_(ws::PlatformScreen::Create()), 82 platform_screen_(ws::PlatformScreen::Create()),
80 weak_ptr_factory_(this) {} 83 weak_ptr_factory_(this) {}
81 84
82 MusApp::~MusApp() { 85 MusApp::~MusApp() {
83 // Destroy |window_server_| first, since it depends on |event_source_|. 86 // Destroy |window_server_| first, since it depends on |event_source_|.
84 // WindowServer (or more correctly its Displays) may have state that needs to 87 // WindowServer (or more correctly its Displays) may have state that needs to
85 // be destroyed before GpuState as well. 88 // be destroyed before GpuState as well.
86 window_server_.reset(); 89 window_server_.reset();
87 90
88 if (platform_display_init_params_.gpu_state) 91 if (platform_display_init_params_.gpu_state)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 const shell::Identity& identity, 137 const shell::Identity& identity,
135 uint32_t id) { 138 uint32_t id) {
136 platform_display_init_params_.surfaces_state = new SurfacesState; 139 platform_display_init_params_.surfaces_state = new SurfacesState;
137 140
138 base::PlatformThread::SetName("mus"); 141 base::PlatformThread::SetName("mus");
139 tracing_.Initialize(connector, identity.name()); 142 tracing_.Initialize(connector, identity.name());
140 TRACE_EVENT0("mus", "MusApp::Initialize started"); 143 TRACE_EVENT0("mus", "MusApp::Initialize started");
141 144
142 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch( 145 test_config_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
143 switches::kUseTestConfig); 146 switches::kUseTestConfig);
147 use_chrome_gpu_command_buffer_ =
148 base::CommandLine::ForCurrentProcess()->HasSwitch(
149 switches::kUseChromeGpuCommandBufferInMus);
144 #if defined(USE_X11) 150 #if defined(USE_X11)
145 XInitThreads(); 151 XInitThreads();
146 if (test_config_) 152 if (test_config_)
147 ui::test::SetUseOverrideRedirectWindowByDefault(true); 153 ui::test::SetUseOverrideRedirectWindowByDefault(true);
148 #endif 154 #endif
149 155
150 InitializeResources(connector); 156 InitializeResources(connector);
151 157
152 #if defined(USE_OZONE) 158 #if defined(USE_OZONE)
153 // The ozone platform can provide its own event source. So initialize the 159 // The ozone platform can provide its own event source. So initialize the
(...skipping 13 matching lines...) Expand all
167 DCHECK(ui::ClientNativePixmapFactory::GetInstance()); 173 DCHECK(ui::ClientNativePixmapFactory::GetInstance());
168 #endif 174 #endif
169 175
170 // TODO(rjkroege): Enter sandbox here before we start threads in GpuState 176 // TODO(rjkroege): Enter sandbox here before we start threads in GpuState
171 // http://crbug.com/584532 177 // http://crbug.com/584532
172 178
173 #if !defined(OS_ANDROID) 179 #if !defined(OS_ANDROID)
174 event_source_ = ui::PlatformEventSource::CreateDefault(); 180 event_source_ = ui::PlatformEventSource::CreateDefault();
175 #endif 181 #endif
176 182
177 // TODO(rjkroege): It is possible that we might want to generalize the 183 if (use_chrome_gpu_command_buffer_) {
178 // GpuState object. 184 GpuServiceMus::GetInstance();
179 platform_display_init_params_.gpu_state = new GpuState(); 185 } else {
186 // TODO(rjkroege): It is possible that we might want to generalize the
187 // GpuState object.
188 platform_display_init_params_.gpu_state = new GpuState();
189 }
180 190
181 // Gpu must be running before the PlatformScreen can be initialized. 191 // Gpu must be running before the PlatformScreen can be initialized.
182 platform_screen_->Init(); 192 platform_screen_->Init();
183 window_server_.reset( 193 window_server_.reset(
184 new ws::WindowServer(this, platform_display_init_params_.surfaces_state)); 194 new ws::WindowServer(this, platform_display_init_params_.surfaces_state));
185 } 195 }
186 196
187 bool MusApp::AcceptConnection(Connection* connection) { 197 bool MusApp::AcceptConnection(Connection* connection) {
188 connection->AddInterface<Gpu>(this); 198 connection->AddInterface<Gpu>(this);
189 connection->AddInterface<mojom::Clipboard>(this); 199 connection->AddInterface<mojom::Clipboard>(this);
190 connection->AddInterface<mojom::DisplayManager>(this); 200 connection->AddInterface<mojom::DisplayManager>(this);
191 connection->AddInterface<mojom::UserAccessManager>(this); 201 connection->AddInterface<mojom::UserAccessManager>(this);
192 connection->AddInterface<WindowTreeHostFactory>(this); 202 connection->AddInterface<WindowTreeHostFactory>(this);
193 connection->AddInterface<mojom::WindowManagerFactoryService>(this); 203 connection->AddInterface<mojom::WindowManagerFactoryService>(this);
194 connection->AddInterface<mojom::WindowTreeFactory>(this); 204 connection->AddInterface<mojom::WindowTreeFactory>(this);
195 if (test_config_) 205 if (test_config_)
196 connection->AddInterface<WindowServerTest>(this); 206 connection->AddInterface<WindowServerTest>(this);
207
208 if (use_chrome_gpu_command_buffer_) {
209 connection->AddInterface<mojom::GpuService>(this);
210 } else {
211 connection->AddInterface<Gpu>(this);
212 }
213
197 return true; 214 return true;
198 } 215 }
199 216
200 void MusApp::OnFirstDisplayReady() { 217 void MusApp::OnFirstDisplayReady() {
201 PendingRequests requests; 218 PendingRequests requests;
202 requests.swap(pending_requests_); 219 requests.swap(pending_requests_);
203 for (auto& request : requests) 220 for (auto& request : requests)
204 Create(request->connection, std::move(*request->wtf_request)); 221 Create(request->connection, std::move(*request->wtf_request));
205 } 222 }
206 223
(...skipping 23 matching lines...) Expand all
230 } 247 }
231 248
232 void MusApp::Create(shell::Connection* connection, 249 void MusApp::Create(shell::Connection* connection,
233 mojom::DisplayManagerRequest request) { 250 mojom::DisplayManagerRequest request) {
234 window_server_->display_manager() 251 window_server_->display_manager()
235 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id()) 252 ->GetUserDisplayManager(connection->GetRemoteIdentity().user_id())
236 ->AddDisplayManagerBinding(std::move(request)); 253 ->AddDisplayManagerBinding(std::move(request));
237 } 254 }
238 255
239 void MusApp::Create(shell::Connection* connection, mojom::GpuRequest request) { 256 void MusApp::Create(shell::Connection* connection, mojom::GpuRequest request) {
257 if (use_chrome_gpu_command_buffer_)
258 return;
240 DCHECK(platform_display_init_params_.gpu_state); 259 DCHECK(platform_display_init_params_.gpu_state);
241 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state); 260 new GpuImpl(std::move(request), platform_display_init_params_.gpu_state);
242 } 261 }
243 262
244 void MusApp::Create(shell::Connection* connection, 263 void MusApp::Create(shell::Connection* connection,
264 mojom::GpuServiceRequest request) {
265 if (!use_chrome_gpu_command_buffer_)
266 return;
267 new GpuServiceImpl(std::move(request), connection);
268 }
269
270 void MusApp::Create(shell::Connection* connection,
245 mojom::UserAccessManagerRequest request) { 271 mojom::UserAccessManagerRequest request) {
246 window_server_->user_id_tracker()->Bind(std::move(request)); 272 window_server_->user_id_tracker()->Bind(std::move(request));
247 } 273 }
248 274
249 void MusApp::Create(shell::Connection* connection, 275 void MusApp::Create(shell::Connection* connection,
250 mojom::WindowManagerFactoryServiceRequest request) { 276 mojom::WindowManagerFactoryServiceRequest request) {
251 AddUserIfNecessary(connection); 277 AddUserIfNecessary(connection);
252 window_server_->window_manager_factory_registry()->Register( 278 window_server_->window_manager_factory_registry()->Register(
253 connection->GetRemoteIdentity().user_id(), std::move(request)); 279 connection->GetRemoteIdentity().user_id(), std::move(request));
254 } 280 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 platform_display_init_params_.display_bounds = bounds; 319 platform_display_init_params_.display_bounds = bounds;
294 platform_display_init_params_.display_id = id; 320 platform_display_init_params_.display_id = id;
295 321
296 // Display manages its own lifetime. 322 // Display manages its own lifetime.
297 ws::Display* host_impl = 323 ws::Display* host_impl =
298 new ws::Display(window_server_.get(), platform_display_init_params_); 324 new ws::Display(window_server_.get(), platform_display_init_params_);
299 host_impl->Init(nullptr); 325 host_impl->Init(nullptr);
300 } 326 }
301 327
302 } // namespace mus 328 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/mus_app.h ('k') | components/mus/public/cpp/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698