Chromium Code Reviews| Index: ui/ozone/platform/dri/native_display_delegate_dri.cc |
| diff --git a/ui/ozone/platform/dri/native_display_delegate_dri.cc b/ui/ozone/platform/dri/native_display_delegate_dri.cc |
| index ff55ef4a78c672f9a961bc199cee816717af1799..307ed5d1e4d86967ff255e8166257bd9290a78c2 100644 |
| --- a/ui/ozone/platform/dri/native_display_delegate_dri.cc |
| +++ b/ui/ozone/platform/dri/native_display_delegate_dri.cc |
| @@ -6,6 +6,8 @@ |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| +#include "base/file_descriptor_posix.h" |
| +#include "base/files/file.h" |
| #include "base/single_thread_task_runner.h" |
| #include "ui/display/types/native_display_observer.h" |
| #include "ui/events/ozone/device/device_event.h" |
| @@ -14,6 +16,7 @@ |
| #include "ui/ozone/platform/dri/display_snapshot_dri.h" |
| #include "ui/ozone/platform/dri/dri_util.h" |
| #include "ui/ozone/platform/dri/dri_wrapper.h" |
| +#include "ui/ozone/platform/dri/drm_device_generator.h" |
| #include "ui/ozone/platform/dri/screen_manager.h" |
| #include "ui/ozone/public/ozone_switches.h" |
| @@ -74,12 +77,26 @@ class DisplaySnapshotComparator { |
| uint32_t connector_; |
| }; |
| +class FindByDevicePath { |
| + public: |
| + explicit FindByDevicePath(const base::FilePath& path) : path_(path) {} |
| + |
| + bool operator()(const scoped_refptr<DriWrapper>& device) { |
| + return device->device_path() == path_; |
| + } |
| + |
| + private: |
| + base::FilePath path_; |
| +}; |
| + |
| } // namespace |
| NativeDisplayDelegateDri::NativeDisplayDelegateDri( |
| ScreenManager* screen_manager, |
| - const scoped_refptr<DriWrapper>& primary_device) |
| - : screen_manager_(screen_manager) { |
| + const scoped_refptr<DriWrapper>& primary_device, |
| + scoped_ptr<DrmDeviceGenerator> drm_device_generator) |
| + : screen_manager_(screen_manager), |
| + drm_device_generator_(drm_device_generator.Pass()) { |
| devices_.push_back(primary_device); |
| } |
| @@ -195,13 +212,33 @@ bool NativeDisplayDelegateDri::RelinquishDisplayControl() { |
| return true; |
| } |
| -void NativeDisplayDelegateDri::AddGraphicsDevice(const base::FilePath& path) { |
| - NOTIMPLEMENTED(); |
| +void NativeDisplayDelegateDri::AddGraphicsDevice( |
| + const base::FilePath& path, |
| + const base::FileDescriptor& fd) { |
| + base::File file(fd.fd); |
| + auto it = |
| + std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); |
| + if (it != devices_.end()) |
|
spang
2015/02/12 18:02:46
maybe warn?
dnicoara
2015/02/12 18:11:19
Done.
|
| + return; |
| + |
| + scoped_refptr<DriWrapper> device = |
| + drm_device_generator_->CreateDevice(path, file.Pass()); |
| + devices_.push_back(device); |
| + if (io_task_runner_) |
| + device->InitializeTaskRunner(io_task_runner_); |
| } |
| void NativeDisplayDelegateDri::RemoveGraphicsDevice( |
| const base::FilePath& path) { |
| - NOTIMPLEMENTED(); |
| + auto it = |
| + std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); |
| + if (it == devices_.end()) { |
| + LOG(ERROR) << "Got request to remove non-existent device '" << path.value() |
| + << "'"; |
| + return; |
| + } |
| + |
| + devices_.erase(it); |
| } |
| DisplaySnapshotDri* NativeDisplayDelegateDri::FindDisplaySnapshot(int64_t id) { |