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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device_manager.cc

Issue 1311043016: Switch DRM platform to using a separate thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mv-drm-calls-on-thread2
Patch Set: added drm_thread_proxy Created 5 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/drm/gpu/drm_device_manager.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
6 6
7 #include "base/file_descriptor_posix.h" 7 #include "base/file_descriptor_posix.h"
8 #include "base/single_thread_task_runner.h" 8 #include "base/single_thread_task_runner.h"
9 #include "ui/ozone/platform/drm/gpu/drm_device.h" 9 #include "ui/ozone/platform/drm/gpu/drm_device.h"
10 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" 10 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return false; 48 return false;
49 } 49 }
50 50
51 scoped_refptr<DrmDevice> device = 51 scoped_refptr<DrmDevice> device =
52 drm_device_generator_->CreateDevice(path, file.Pass()); 52 drm_device_generator_->CreateDevice(path, file.Pass());
53 if (!device) { 53 if (!device) {
54 LOG(ERROR) << "Could not initialize DRM device for " << path.value(); 54 LOG(ERROR) << "Could not initialize DRM device for " << path.value();
55 return false; 55 return false;
56 } 56 }
57 57
58 if (io_task_runner_)
59 device->InitializeTaskRunner(io_task_runner_);
60
61 if (!primary_device_) 58 if (!primary_device_)
62 primary_device_ = device; 59 primary_device_ = device;
63 60
64 devices_.push_back(device); 61 devices_.push_back(device);
65 return true; 62 return true;
66 } 63 }
67 64
68 void DrmDeviceManager::RemoveDrmDevice(const base::FilePath& path) { 65 void DrmDeviceManager::RemoveDrmDevice(const base::FilePath& path) {
69 DCHECK(thread_checker_.CalledOnValidThread()); 66 DCHECK(thread_checker_.CalledOnValidThread());
70 auto it = 67 auto it =
71 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path)); 68 std::find_if(devices_.begin(), devices_.end(), FindByDevicePath(path));
72 if (it == devices_.end()) { 69 if (it == devices_.end()) {
73 VLOG(2) << "Got request to remove non-existent device: " << path.value(); 70 VLOG(2) << "Got request to remove non-existent device: " << path.value();
74 return; 71 return;
75 } 72 }
76 73
77 DCHECK_NE(primary_device_, *it); 74 DCHECK_NE(primary_device_, *it);
78 devices_.erase(it); 75 devices_.erase(it);
79 } 76 }
80 77
81 void DrmDeviceManager::InitializeIOTaskRunner(
82 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
83 DCHECK(thread_checker_.CalledOnValidThread());
84 DCHECK(!io_task_runner_);
85 io_task_runner_ = task_runner;
86 for (const auto& device : devices_)
87 device->InitializeTaskRunner(io_task_runner_);
88 }
89
90 void DrmDeviceManager::UpdateDrmDevice(gfx::AcceleratedWidget widget, 78 void DrmDeviceManager::UpdateDrmDevice(gfx::AcceleratedWidget widget,
91 const scoped_refptr<DrmDevice>& device) { 79 const scoped_refptr<DrmDevice>& device) {
92 base::AutoLock lock(lock_); 80 base::AutoLock lock(lock_);
93 drm_device_map_[widget] = device; 81 drm_device_map_[widget] = device;
94 } 82 }
95 83
96 void DrmDeviceManager::RemoveDrmDevice(gfx::AcceleratedWidget widget) { 84 void DrmDeviceManager::RemoveDrmDevice(gfx::AcceleratedWidget widget) {
97 base::AutoLock lock(lock_); 85 base::AutoLock lock(lock_);
98 auto it = drm_device_map_.find(widget); 86 auto it = drm_device_map_.find(widget);
99 if (it != drm_device_map_.end()) 87 if (it != drm_device_map_.end())
(...skipping 17 matching lines...) Expand all
117 105
118 return it->second; 106 return it->second;
119 } 107 }
120 108
121 const DrmDeviceVector& DrmDeviceManager::GetDrmDevices() const { 109 const DrmDeviceVector& DrmDeviceManager::GetDrmDevices() const {
122 DCHECK(thread_checker_.CalledOnValidThread()); 110 DCHECK(thread_checker_.CalledOnValidThread());
123 return devices_; 111 return devices_;
124 } 112 }
125 113
126 } // namespace ui 114 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698