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

Side by Side Diff: ui/ozone/platform/dri/dri_gpu_platform_support.cc

Issue 905873003: [8/8][Ozone-Dri] Pass DRM FD to GPU process on hotplug event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@udl2.9-allow-ndd-to-handle-multiple-drm-devices
Patch Set: Rebased Created 5 years, 10 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
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 "ui/ozone/platform/dri/dri_gpu_platform_support.h" 5 #include "ui/ozone/platform/dri/dri_gpu_platform_support.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
11 #include "ui/display/types/display_mode.h" 11 #include "ui/display/types/display_mode.h"
12 #include "ui/display/types/display_snapshot.h" 12 #include "ui/display/types/display_snapshot.h"
13 #include "ui/ozone/common/display_util.h" 13 #include "ui/ozone/common/display_util.h"
14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h" 14 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
15 #include "ui/ozone/common/gpu/ozone_gpu_messages.h" 15 #include "ui/ozone/common/gpu/ozone_gpu_messages.h"
16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h" 16 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
17 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h" 17 #include "ui/ozone/platform/dri/dri_window_delegate_manager.h"
18 #include "ui/ozone/platform/dri/dri_wrapper.h" 18 #include "ui/ozone/platform/dri/dri_wrapper.h"
19 #include "ui/ozone/platform/dri/dri_wrapper_generator.h"
19 #include "ui/ozone/platform/dri/native_display_delegate_dri.h" 20 #include "ui/ozone/platform/dri/native_display_delegate_dri.h"
20 #include "ui/ozone/public/ozone_switches.h" 21 #include "ui/ozone/public/ozone_switches.h"
21 22
22 namespace ui { 23 namespace ui {
23 24
24 namespace { 25 namespace {
25 26
26 void MessageProcessedOnMain( 27 void MessageProcessedOnMain(
27 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner, 28 scoped_refptr<base::SingleThreadTaskRunner> io_thread_task_runner,
28 const base::Closure& io_thread_task) { 29 const base::Closure& io_thread_task) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 int32 pending_main_thread_operations_; 167 int32 pending_main_thread_operations_;
167 bool cursor_animating_; 168 bool cursor_animating_;
168 }; 169 };
169 } 170 }
170 171
171 DriGpuPlatformSupport::DriGpuPlatformSupport( 172 DriGpuPlatformSupport::DriGpuPlatformSupport(
172 const scoped_refptr<DriWrapper>& drm, 173 const scoped_refptr<DriWrapper>& drm,
173 DrmDeviceManager* drm_device_manager, 174 DrmDeviceManager* drm_device_manager,
174 DriWindowDelegateManager* window_manager, 175 DriWindowDelegateManager* window_manager,
175 ScreenManager* screen_manager, 176 ScreenManager* screen_manager,
176 scoped_ptr<NativeDisplayDelegateDri> ndd) 177 scoped_ptr<NativeDisplayDelegateDri> ndd,
178 scoped_ptr<DriWrapperGenerator> wrapper_generator)
177 : sender_(NULL), 179 : sender_(NULL),
178 drm_(drm),
179 drm_device_manager_(drm_device_manager), 180 drm_device_manager_(drm_device_manager),
180 window_manager_(window_manager), 181 window_manager_(window_manager),
181 screen_manager_(screen_manager), 182 screen_manager_(screen_manager),
182 ndd_(ndd.Pass()) { 183 ndd_(ndd.Pass()),
183 ndd_->AddGraphicsDevice(drm_); 184 wrapper_generator_(wrapper_generator.Pass()) {
185 wrappers_[drm->device_path()] = drm;
186 ndd_->AddGraphicsDevice(drm);
spang 2015/02/11 21:13:21 Why are the open devices tracked both in DriGpuPla
dnicoara 2015/02/11 22:21:14 Just to have the list handy for the operations. Wo
spang 2015/02/11 22:47:56 It's more than just dropping inheritance. We also
spang 2015/02/11 22:52:54 I would ideally hope these configuration tasks wou
dnicoara 2015/02/11 23:04:40 I'm sorry, I was too vague. The only configuration
spang 2015/02/11 23:11:55 There's plenty of business logic for display confi
184 filter_ = new DriGpuPlatformSupportMessageFilter( 187 filter_ = new DriGpuPlatformSupportMessageFilter(
185 window_manager, base::Bind(&DriGpuPlatformSupport::SetIOTaskRunner, 188 window_manager, base::Bind(&DriGpuPlatformSupport::SetIOTaskRunner,
186 base::Unretained(this)), 189 base::Unretained(this)),
187 this); 190 this);
188 } 191 }
189 192
190 DriGpuPlatformSupport::~DriGpuPlatformSupport() { 193 DriGpuPlatformSupport::~DriGpuPlatformSupport() {
191 } 194 }
192 195
193 void DriGpuPlatformSupport::AddHandler(scoped_ptr<GpuPlatformSupport> handler) { 196 void DriGpuPlatformSupport::AddHandler(scoped_ptr<GpuPlatformSupport> handler) {
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 } 343 }
341 344
342 void DriGpuPlatformSupport::OnTakeDisplayControl() { 345 void DriGpuPlatformSupport::OnTakeDisplayControl() {
343 ndd_->TakeDisplayControl(); 346 ndd_->TakeDisplayControl();
344 } 347 }
345 348
346 void DriGpuPlatformSupport::OnRelinquishDisplayControl() { 349 void DriGpuPlatformSupport::OnRelinquishDisplayControl() {
347 ndd_->RelinquishDisplayControl(); 350 ndd_->RelinquishDisplayControl();
348 } 351 }
349 352
350 void DriGpuPlatformSupport::OnAddGraphicsDevice(const base::FilePath& path) { 353 void DriGpuPlatformSupport::OnAddGraphicsDevice(
351 NOTIMPLEMENTED(); 354 const base::FilePath& path,
355 const base::FileDescriptor& fd) {
356 base::File file(fd.fd);
357 auto it = wrappers_.find(path);
358 // Device already registered.
359 if (it != wrappers_.end())
360 return;
361
362 scoped_refptr<DriWrapper> wrapper =
363 wrapper_generator_->CreateWrapper(path, file.Pass());
364 wrappers_[path] = wrapper;
365 if (io_task_runner_)
366 wrapper->InitializeTaskRunner(io_task_runner_);
367
368 ndd_->AddGraphicsDevice(wrapper);
352 } 369 }
353 370
354 void DriGpuPlatformSupport::OnRemoveGraphicsDevice(const base::FilePath& path) { 371 void DriGpuPlatformSupport::OnRemoveGraphicsDevice(const base::FilePath& path) {
355 NOTIMPLEMENTED(); 372 auto it = wrappers_.find(path);
373 if (it == wrappers_.end()) {
374 LOG(ERROR) << "Got message to remove non-existent device '" << path.value()
375 << "'";
376 return;
377 }
378
379 ndd_->RemoveGraphicsDevice(it->second);
380 wrappers_.erase(it);
356 } 381 }
357 382
358 void DriGpuPlatformSupport::RelinquishGpuResources( 383 void DriGpuPlatformSupport::RelinquishGpuResources(
359 const base::Closure& callback) { 384 const base::Closure& callback) {
360 callback.Run(); 385 callback.Run();
361 } 386 }
362 387
363 void DriGpuPlatformSupport::SetIOTaskRunner( 388 void DriGpuPlatformSupport::SetIOTaskRunner(
364 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { 389 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) {
365 io_task_runner_ = io_task_runner; 390 io_task_runner_ = io_task_runner;
366 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); 391 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
367 // Only surfaceless path supports async page flips. 392 // Only surfaceless path supports async page flips.
368 if (cmd->HasSwitch(switches::kOzoneUseSurfaceless)) { 393 if (cmd->HasSwitch(switches::kOzoneUseSurfaceless)) {
369 drm_->InitializeTaskRunner(io_task_runner_); 394 for (const auto& pair : wrappers_)
395 pair.second->InitializeTaskRunner(io_task_runner_);
370 } 396 }
371 } 397 }
372 398
373 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() { 399 IPC::MessageFilter* DriGpuPlatformSupport::GetMessageFilter() {
374 return filter_.get(); 400 return filter_.get();
375 } 401 }
376 402
377 } // namespace ui 403 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698