| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus_thread_proxy.h" | 5 #include "ui/ozone/platform/drm/mus_thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/task_runner.h" | 9 #include "base/task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "ui/ozone/platform/drm/common/drm_util.h" | 11 #include "ui/ozone/platform/drm/common/drm_util.h" |
| 12 #include "ui/ozone/platform/drm/cursor_proxy_mojo.h" |
| 12 #include "ui/ozone/platform/drm/gpu/drm_thread.h" | 13 #include "ui/ozone/platform/drm/gpu/drm_thread.h" |
| 13 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" | 14 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
| 14 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" | 15 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h" |
| 15 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" | 16 #include "ui/ozone/platform/drm/host/drm_overlay_manager.h" |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| 20 namespace { |
| 21 |
| 22 // Forwarding proxy to handle ownership semantics. |
| 23 class CursorProxyThread : public DrmCursorProxy { |
| 24 public: |
| 25 explicit CursorProxyThread(MusThreadProxy* mus_thread_proxy); |
| 26 ~CursorProxyThread() override; |
| 27 |
| 28 private: |
| 29 // DrmCursorProxy. |
| 30 void CursorSet(gfx::AcceleratedWidget window, |
| 31 const std::vector<SkBitmap>& bitmaps, |
| 32 const gfx::Point& point, |
| 33 int frame_delay_ms) override; |
| 34 void Move(gfx::AcceleratedWidget window, const gfx::Point& point) override; |
| 35 void InitializeOnEvdevIfNecessary() override; |
| 36 MusThreadProxy* const mus_thread_proxy_; // Not owned. |
| 37 DISALLOW_COPY_AND_ASSIGN(CursorProxyThread); |
| 38 }; |
| 39 |
| 19 CursorProxyThread::CursorProxyThread(MusThreadProxy* mus_thread_proxy) | 40 CursorProxyThread::CursorProxyThread(MusThreadProxy* mus_thread_proxy) |
| 20 : mus_thread_proxy_(mus_thread_proxy) {} | 41 : mus_thread_proxy_(mus_thread_proxy) {} |
| 21 CursorProxyThread::~CursorProxyThread() {} | 42 CursorProxyThread::~CursorProxyThread() {} |
| 22 | 43 |
| 23 void CursorProxyThread::CursorSet(gfx::AcceleratedWidget window, | 44 void CursorProxyThread::CursorSet(gfx::AcceleratedWidget window, |
| 24 const std::vector<SkBitmap>& bitmaps, | 45 const std::vector<SkBitmap>& bitmaps, |
| 25 const gfx::Point& point, | 46 const gfx::Point& point, |
| 26 int frame_delay_ms) { | 47 int frame_delay_ms) { |
| 27 mus_thread_proxy_->CursorSet(window, bitmaps, point, frame_delay_ms); | 48 mus_thread_proxy_->CursorSet(window, bitmaps, point, frame_delay_ms); |
| 28 } | 49 } |
| 29 void CursorProxyThread::Move(gfx::AcceleratedWidget window, | 50 void CursorProxyThread::Move(gfx::AcceleratedWidget window, |
| 30 const gfx::Point& point) { | 51 const gfx::Point& point) { |
| 31 mus_thread_proxy_->Move(window, point); | 52 mus_thread_proxy_->Move(window, point); |
| 32 } | 53 } |
| 33 void CursorProxyThread::InitializeOnEvdev() { | 54 void CursorProxyThread::InitializeOnEvdevIfNecessary() { |
| 34 mus_thread_proxy_->InitializeOnEvdev(); | 55 mus_thread_proxy_->InitializeOnEvdevIfNecessary(); |
| 35 } | 56 } |
| 36 | 57 |
| 37 MusThreadProxy::MusThreadProxy() | 58 } // namespace |
| 59 |
| 60 MusThreadProxy::MusThreadProxy(DrmCursor* cursor, |
| 61 service_manager::Connector* connector) |
| 38 : ws_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 62 : ws_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 39 drm_thread_(nullptr), | 63 drm_thread_(nullptr), |
| 64 cursor_(cursor), |
| 65 connector_(connector), |
| 40 weak_ptr_factory_(this) {} | 66 weak_ptr_factory_(this) {} |
| 41 | 67 |
| 42 void MusThreadProxy::InitializeOnEvdev() {} | |
| 43 | |
| 44 MusThreadProxy::~MusThreadProxy() { | 68 MusThreadProxy::~MusThreadProxy() { |
| 45 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 69 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 46 for (GpuThreadObserver& observer : gpu_thread_observers_) | 70 for (GpuThreadObserver& observer : gpu_thread_observers_) |
| 47 observer.OnGpuThreadRetired(); | 71 observer.OnGpuThreadRetired(); |
| 48 } | 72 } |
| 49 | 73 |
| 50 // This is configured on the GPU thread. | 74 // This is configured on the GPU thread. |
| 51 void MusThreadProxy::SetDrmThread(DrmThread* thread) { | 75 void MusThreadProxy::SetDrmThread(DrmThread* thread) { |
| 52 base::AutoLock acquire(lock_); | 76 base::AutoLock acquire(lock_); |
| 53 drm_thread_ = thread; | 77 drm_thread_ = thread; |
| 54 } | 78 } |
| 55 | 79 |
| 56 void MusThreadProxy::ProvideManagers(DrmDisplayHostManager* display_manager, | 80 void MusThreadProxy::ProvideManagers(DrmDisplayHostManager* display_manager, |
| 57 DrmOverlayManager* overlay_manager) { | 81 DrmOverlayManager* overlay_manager) { |
| 58 display_manager_ = display_manager; | 82 display_manager_ = display_manager; |
| 59 overlay_manager_ = overlay_manager; | 83 overlay_manager_ = overlay_manager; |
| 60 } | 84 } |
| 61 | 85 |
| 86 // Runs on Gpu thread. |
| 62 void MusThreadProxy::StartDrmThread() { | 87 void MusThreadProxy::StartDrmThread() { |
| 63 DCHECK(drm_thread_); | 88 DCHECK(drm_thread_); |
| 64 drm_thread_->Start(); | 89 drm_thread_->Start(); |
| 65 | 90 |
| 66 drm_thread_->task_runner()->PostTask( | 91 drm_thread_->task_runner()->PostTask( |
| 67 FROM_HERE, base::Bind(&MusThreadProxy::DispatchObserversFromDrmThread, | 92 FROM_HERE, base::Bind(&MusThreadProxy::DispatchObserversFromDrmThread, |
| 68 base::Unretained(this))); | 93 base::Unretained(this))); |
| 69 } | 94 } |
| 70 | 95 |
| 71 void MusThreadProxy::DispatchObserversFromDrmThread() { | 96 void MusThreadProxy::DispatchObserversFromDrmThread() { |
| 72 ws_task_runner_->PostTask(FROM_HERE, base::Bind(&MusThreadProxy::RunObservers, | 97 ws_task_runner_->PostTask(FROM_HERE, base::Bind(&MusThreadProxy::RunObservers, |
| 73 base::Unretained(this))); | 98 base::Unretained(this))); |
| 74 } | 99 } |
| 75 | 100 |
| 76 void MusThreadProxy::RunObservers() { | 101 void MusThreadProxy::RunObservers() { |
| 77 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 102 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 78 for (GpuThreadObserver& observer : gpu_thread_observers_) { | 103 for (GpuThreadObserver& observer : gpu_thread_observers_) { |
| 79 // TODO(rjkroege): This needs to be different when gpu process split | 104 // TODO(rjkroege): This needs to be different when gpu process split |
| 80 // happens. | 105 // happens. |
| 81 observer.OnGpuProcessLaunched(); | 106 observer.OnGpuProcessLaunched(); |
| 82 observer.OnGpuThreadReady(); | 107 observer.OnGpuThreadReady(); |
| 83 } | 108 } |
| 109 |
| 110 // The cursor is special since it will process input events on the IO thread |
| 111 // and can by-pass the UI thread. This means that we need to special case it |
| 112 // and notify it after all other observers/handlers are notified. |
| 113 if (connector_ == nullptr) { |
| 114 // CursorProxyThread does not need to use delegate because the non-mojo |
| 115 // MusThreadProxy is only used in tests that do not operate the cursor. |
| 116 // Future refactoring will unify the mojo and in-process modes. |
| 117 cursor_->SetDrmCursorProxy(base::MakeUnique<CursorProxyThread>(this)); |
| 118 } else { |
| 119 cursor_->SetDrmCursorProxy(base::MakeUnique<CursorProxyMojo>(connector_)); |
| 120 } |
| 121 |
| 122 // TODO(rjkroege): Call ResetDrmCursorProxy when the mojo connection to the |
| 123 // DRM thread is broken. |
| 84 } | 124 } |
| 85 | 125 |
| 86 void MusThreadProxy::AddGpuThreadObserver(GpuThreadObserver* observer) { | 126 void MusThreadProxy::AddGpuThreadObserver(GpuThreadObserver* observer) { |
| 87 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 127 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 88 | 128 |
| 89 gpu_thread_observers_.AddObserver(observer); | 129 gpu_thread_observers_.AddObserver(observer); |
| 90 if (IsConnected()) { | 130 if (IsConnected()) { |
| 91 // TODO(rjkroege): This needs to be different when gpu process split | 131 // TODO(rjkroege): This needs to be different when gpu process split |
| 92 // happens. | 132 // happens. |
| 93 observer->OnGpuProcessLaunched(); | 133 observer->OnGpuProcessLaunched(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 114 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 154 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 115 display_manager_ = handler; | 155 display_manager_ = handler; |
| 116 } | 156 } |
| 117 | 157 |
| 118 void MusThreadProxy::UnRegisterHandlerForDrmDisplayHostManager() { | 158 void MusThreadProxy::UnRegisterHandlerForDrmDisplayHostManager() { |
| 119 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 159 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 120 display_manager_ = nullptr; | 160 display_manager_ = nullptr; |
| 121 } | 161 } |
| 122 | 162 |
| 123 bool MusThreadProxy::GpuCreateWindow(gfx::AcceleratedWidget widget) { | 163 bool MusThreadProxy::GpuCreateWindow(gfx::AcceleratedWidget widget) { |
| 124 DCHECK(drm_thread_->IsRunning()); | |
| 125 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 164 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 165 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 166 return false; |
| 126 drm_thread_->task_runner()->PostTask( | 167 drm_thread_->task_runner()->PostTask( |
| 127 FROM_HERE, base::Bind(&DrmThread::CreateWindow, | 168 FROM_HERE, base::Bind(&DrmThread::CreateWindow, |
| 128 base::Unretained(drm_thread_), widget)); | 169 base::Unretained(drm_thread_), widget)); |
| 129 return true; | 170 return true; |
| 130 } | 171 } |
| 131 | 172 |
| 132 bool MusThreadProxy::GpuDestroyWindow(gfx::AcceleratedWidget widget) { | 173 bool MusThreadProxy::GpuDestroyWindow(gfx::AcceleratedWidget widget) { |
| 133 DCHECK(drm_thread_->IsRunning()); | |
| 134 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 174 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 175 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 176 return false; |
| 135 drm_thread_->task_runner()->PostTask( | 177 drm_thread_->task_runner()->PostTask( |
| 136 FROM_HERE, base::Bind(&DrmThread::DestroyWindow, | 178 FROM_HERE, base::Bind(&DrmThread::DestroyWindow, |
| 137 base::Unretained(drm_thread_), widget)); | 179 base::Unretained(drm_thread_), widget)); |
| 138 return true; | 180 return true; |
| 139 } | 181 } |
| 140 | 182 |
| 141 bool MusThreadProxy::GpuWindowBoundsChanged(gfx::AcceleratedWidget widget, | 183 bool MusThreadProxy::GpuWindowBoundsChanged(gfx::AcceleratedWidget widget, |
| 142 const gfx::Rect& bounds) { | 184 const gfx::Rect& bounds) { |
| 143 DCHECK(drm_thread_->IsRunning()); | |
| 144 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 185 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 186 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 187 return false; |
| 145 drm_thread_->task_runner()->PostTask( | 188 drm_thread_->task_runner()->PostTask( |
| 146 FROM_HERE, base::Bind(&DrmThread::SetWindowBounds, | 189 FROM_HERE, base::Bind(&DrmThread::SetWindowBounds, |
| 147 base::Unretained(drm_thread_), widget, bounds)); | 190 base::Unretained(drm_thread_), widget, bounds)); |
| 148 return true; | 191 return true; |
| 149 } | 192 } |
| 150 | 193 |
| 194 // Services needed for DrmCursorProxy. |
| 151 void MusThreadProxy::CursorSet(gfx::AcceleratedWidget widget, | 195 void MusThreadProxy::CursorSet(gfx::AcceleratedWidget widget, |
| 152 const std::vector<SkBitmap>& bitmaps, | 196 const std::vector<SkBitmap>& bitmaps, |
| 153 const gfx::Point& location, | 197 const gfx::Point& location, |
| 154 int frame_delay_ms) { | 198 int frame_delay_ms) { |
| 155 DCHECK(drm_thread_->IsRunning()); | |
| 156 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 199 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 200 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 201 return; |
| 157 drm_thread_->task_runner()->PostTask( | 202 drm_thread_->task_runner()->PostTask( |
| 158 FROM_HERE, | 203 FROM_HERE, |
| 159 base::Bind(&DrmThread::SetCursor, base::Unretained(drm_thread_), widget, | 204 base::Bind(&DrmThread::SetCursor, base::Unretained(drm_thread_), widget, |
| 160 bitmaps, location, frame_delay_ms)); | 205 bitmaps, location, frame_delay_ms)); |
| 161 } | 206 } |
| 162 | 207 |
| 163 void MusThreadProxy::Move(gfx::AcceleratedWidget widget, | 208 void MusThreadProxy::Move(gfx::AcceleratedWidget widget, |
| 164 const gfx::Point& location) { | 209 const gfx::Point& location) { |
| 165 // NOTE: Input events skip the main thread to avoid jank. | 210 // NOTE: Input events skip the main thread to avoid jank. |
| 166 DCHECK(drm_thread_->IsRunning()); | 211 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 212 return; |
| 167 drm_thread_->task_runner()->PostTask( | 213 drm_thread_->task_runner()->PostTask( |
| 168 FROM_HERE, base::Bind(&DrmThread::MoveCursor, | 214 FROM_HERE, base::Bind(&DrmThread::MoveCursor, |
| 169 base::Unretained(drm_thread_), widget, location)); | 215 base::Unretained(drm_thread_), widget, location)); |
| 170 } | 216 } |
| 171 | 217 |
| 218 void MusThreadProxy::InitializeOnEvdevIfNecessary() {} |
| 219 |
| 172 // Services needed for DrmOverlayManager. | 220 // Services needed for DrmOverlayManager. |
| 173 void MusThreadProxy::RegisterHandlerForDrmOverlayManager( | 221 void MusThreadProxy::RegisterHandlerForDrmOverlayManager( |
| 174 DrmOverlayManager* handler) { | 222 DrmOverlayManager* handler) { |
| 175 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 223 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 176 overlay_manager_ = handler; | 224 overlay_manager_ = handler; |
| 177 } | 225 } |
| 178 | 226 |
| 179 void MusThreadProxy::UnRegisterHandlerForDrmOverlayManager() { | 227 void MusThreadProxy::UnRegisterHandlerForDrmOverlayManager() { |
| 180 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 228 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 181 overlay_manager_ = nullptr; | 229 overlay_manager_ = nullptr; |
| 182 } | 230 } |
| 183 | 231 |
| 184 bool MusThreadProxy::GpuCheckOverlayCapabilities( | 232 bool MusThreadProxy::GpuCheckOverlayCapabilities( |
| 185 gfx::AcceleratedWidget widget, | 233 gfx::AcceleratedWidget widget, |
| 186 const std::vector<OverlayCheck_Params>& overlays) { | 234 const std::vector<OverlayCheck_Params>& overlays) { |
| 187 DCHECK(drm_thread_->IsRunning()); | |
| 188 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 235 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 236 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 237 return false; |
| 189 auto callback = | 238 auto callback = |
| 190 base::BindOnce(&MusThreadProxy::GpuCheckOverlayCapabilitiesCallback, | 239 base::BindOnce(&MusThreadProxy::GpuCheckOverlayCapabilitiesCallback, |
| 191 weak_ptr_factory_.GetWeakPtr()); | 240 weak_ptr_factory_.GetWeakPtr()); |
| 192 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 241 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 193 drm_thread_->task_runner()->PostTask( | 242 drm_thread_->task_runner()->PostTask( |
| 194 FROM_HERE, base::BindOnce(&DrmThread::CheckOverlayCapabilities, | 243 FROM_HERE, base::BindOnce(&DrmThread::CheckOverlayCapabilities, |
| 195 base::Unretained(drm_thread_), widget, overlays, | 244 base::Unretained(drm_thread_), widget, overlays, |
| 196 std::move(safe_callback))); | 245 std::move(safe_callback))); |
| 197 return true; | 246 return true; |
| 198 } | 247 } |
| 199 | 248 |
| 200 bool MusThreadProxy::GpuRefreshNativeDisplays() { | 249 bool MusThreadProxy::GpuRefreshNativeDisplays() { |
| 201 DCHECK(drm_thread_->IsRunning()); | |
| 202 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 250 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 251 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 252 return false; |
| 203 auto callback = | 253 auto callback = |
| 204 base::BindOnce(&MusThreadProxy::GpuRefreshNativeDisplaysCallback, | 254 base::BindOnce(&MusThreadProxy::GpuRefreshNativeDisplaysCallback, |
| 205 weak_ptr_factory_.GetWeakPtr()); | 255 weak_ptr_factory_.GetWeakPtr()); |
| 206 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 256 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 207 drm_thread_->task_runner()->PostTask( | 257 drm_thread_->task_runner()->PostTask( |
| 208 FROM_HERE, | 258 FROM_HERE, |
| 209 base::BindOnce(&DrmThread::RefreshNativeDisplays, | 259 base::BindOnce(&DrmThread::RefreshNativeDisplays, |
| 210 base::Unretained(drm_thread_), std::move(safe_callback))); | 260 base::Unretained(drm_thread_), std::move(safe_callback))); |
| 211 return true; | 261 return true; |
| 212 } | 262 } |
| 213 | 263 |
| 214 bool MusThreadProxy::GpuConfigureNativeDisplay(int64_t id, | 264 bool MusThreadProxy::GpuConfigureNativeDisplay(int64_t id, |
| 215 const DisplayMode_Params& pmode, | 265 const DisplayMode_Params& pmode, |
| 216 const gfx::Point& origin) { | 266 const gfx::Point& origin) { |
| 217 DCHECK(drm_thread_->IsRunning()); | |
| 218 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 267 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 268 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 269 return false; |
| 219 | 270 |
| 220 auto mode = CreateDisplayModeFromParams(pmode); | 271 auto mode = CreateDisplayModeFromParams(pmode); |
| 221 auto callback = | 272 auto callback = |
| 222 base::BindOnce(&MusThreadProxy::GpuConfigureNativeDisplayCallback, | 273 base::BindOnce(&MusThreadProxy::GpuConfigureNativeDisplayCallback, |
| 223 weak_ptr_factory_.GetWeakPtr()); | 274 weak_ptr_factory_.GetWeakPtr()); |
| 224 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 275 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 225 drm_thread_->task_runner()->PostTask( | 276 drm_thread_->task_runner()->PostTask( |
| 226 FROM_HERE, | 277 FROM_HERE, |
| 227 base::BindOnce(&DrmThread::ConfigureNativeDisplay, | 278 base::BindOnce(&DrmThread::ConfigureNativeDisplay, |
| 228 base::Unretained(drm_thread_), id, std::move(mode), origin, | 279 base::Unretained(drm_thread_), id, std::move(mode), origin, |
| 229 std::move(safe_callback))); | 280 std::move(safe_callback))); |
| 230 return true; | 281 return true; |
| 231 } | 282 } |
| 232 | 283 |
| 233 bool MusThreadProxy::GpuDisableNativeDisplay(int64_t id) { | 284 bool MusThreadProxy::GpuDisableNativeDisplay(int64_t id) { |
| 234 DCHECK(drm_thread_->IsRunning()); | |
| 235 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 285 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 286 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 287 return false; |
| 236 auto callback = | 288 auto callback = |
| 237 base::BindOnce(&MusThreadProxy::GpuDisableNativeDisplayCallback, | 289 base::BindOnce(&MusThreadProxy::GpuDisableNativeDisplayCallback, |
| 238 weak_ptr_factory_.GetWeakPtr()); | 290 weak_ptr_factory_.GetWeakPtr()); |
| 239 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 291 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 240 drm_thread_->task_runner()->PostTask( | 292 drm_thread_->task_runner()->PostTask( |
| 241 FROM_HERE, base::BindOnce(&DrmThread::DisableNativeDisplay, | 293 FROM_HERE, base::BindOnce(&DrmThread::DisableNativeDisplay, |
| 242 base::Unretained(drm_thread_), id, | 294 base::Unretained(drm_thread_), id, |
| 243 std::move(safe_callback))); | 295 std::move(safe_callback))); |
| 244 return true; | 296 return true; |
| 245 } | 297 } |
| 246 | 298 |
| 247 bool MusThreadProxy::GpuTakeDisplayControl() { | 299 bool MusThreadProxy::GpuTakeDisplayControl() { |
| 248 DCHECK(drm_thread_->IsRunning()); | |
| 249 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 300 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 301 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 302 return false; |
| 250 auto callback = base::BindOnce(&MusThreadProxy::GpuTakeDisplayControlCallback, | 303 auto callback = base::BindOnce(&MusThreadProxy::GpuTakeDisplayControlCallback, |
| 251 weak_ptr_factory_.GetWeakPtr()); | 304 weak_ptr_factory_.GetWeakPtr()); |
| 252 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 305 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 253 drm_thread_->task_runner()->PostTask( | 306 drm_thread_->task_runner()->PostTask( |
| 254 FROM_HERE, | 307 FROM_HERE, |
| 255 base::BindOnce(&DrmThread::TakeDisplayControl, | 308 base::BindOnce(&DrmThread::TakeDisplayControl, |
| 256 base::Unretained(drm_thread_), std::move(safe_callback))); | 309 base::Unretained(drm_thread_), std::move(safe_callback))); |
| 257 return true; | 310 return true; |
| 258 } | 311 } |
| 259 | 312 |
| 260 bool MusThreadProxy::GpuRelinquishDisplayControl() { | 313 bool MusThreadProxy::GpuRelinquishDisplayControl() { |
| 261 DCHECK(drm_thread_->IsRunning()); | |
| 262 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 314 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 315 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 316 return false; |
| 263 auto callback = | 317 auto callback = |
| 264 base::BindOnce(&MusThreadProxy::GpuRelinquishDisplayControlCallback, | 318 base::BindOnce(&MusThreadProxy::GpuRelinquishDisplayControlCallback, |
| 265 weak_ptr_factory_.GetWeakPtr()); | 319 weak_ptr_factory_.GetWeakPtr()); |
| 266 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 320 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 267 drm_thread_->task_runner()->PostTask( | 321 drm_thread_->task_runner()->PostTask( |
| 268 FROM_HERE, | 322 FROM_HERE, |
| 269 base::BindOnce(&DrmThread::RelinquishDisplayControl, | 323 base::BindOnce(&DrmThread::RelinquishDisplayControl, |
| 270 base::Unretained(drm_thread_), std::move(safe_callback))); | 324 base::Unretained(drm_thread_), std::move(safe_callback))); |
| 271 return true; | 325 return true; |
| 272 } | 326 } |
| 273 | 327 |
| 274 bool MusThreadProxy::GpuAddGraphicsDevice(const base::FilePath& path, | 328 bool MusThreadProxy::GpuAddGraphicsDevice(const base::FilePath& path, |
| 275 const base::FileDescriptor& fd) { | 329 const base::FileDescriptor& fd) { |
| 276 DCHECK(drm_thread_->IsRunning()); | |
| 277 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 330 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 331 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 332 return false; |
| 278 drm_thread_->task_runner()->PostTask( | 333 drm_thread_->task_runner()->PostTask( |
| 279 FROM_HERE, base::Bind(&DrmThread::AddGraphicsDevice, | 334 FROM_HERE, base::Bind(&DrmThread::AddGraphicsDevice, |
| 280 base::Unretained(drm_thread_), path, fd)); | 335 base::Unretained(drm_thread_), path, fd)); |
| 281 return true; | 336 return true; |
| 282 } | 337 } |
| 283 | 338 |
| 284 bool MusThreadProxy::GpuRemoveGraphicsDevice(const base::FilePath& path) { | 339 bool MusThreadProxy::GpuRemoveGraphicsDevice(const base::FilePath& path) { |
| 285 DCHECK(drm_thread_->IsRunning()); | |
| 286 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 340 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 341 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 342 return false; |
| 287 drm_thread_->task_runner()->PostTask( | 343 drm_thread_->task_runner()->PostTask( |
| 288 FROM_HERE, base::Bind(&DrmThread::RemoveGraphicsDevice, | 344 FROM_HERE, base::Bind(&DrmThread::RemoveGraphicsDevice, |
| 289 base::Unretained(drm_thread_), path)); | 345 base::Unretained(drm_thread_), path)); |
| 290 return true; | 346 return true; |
| 291 } | 347 } |
| 292 | 348 |
| 293 bool MusThreadProxy::GpuGetHDCPState(int64_t display_id) { | 349 bool MusThreadProxy::GpuGetHDCPState(int64_t display_id) { |
| 294 DCHECK(drm_thread_->IsRunning()); | |
| 295 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 350 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 351 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 352 return false; |
| 296 auto callback = base::BindOnce(&MusThreadProxy::GpuGetHDCPStateCallback, | 353 auto callback = base::BindOnce(&MusThreadProxy::GpuGetHDCPStateCallback, |
| 297 weak_ptr_factory_.GetWeakPtr()); | 354 weak_ptr_factory_.GetWeakPtr()); |
| 298 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 355 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 299 drm_thread_->task_runner()->PostTask( | 356 drm_thread_->task_runner()->PostTask( |
| 300 FROM_HERE, | 357 FROM_HERE, |
| 301 base::BindOnce(&DrmThread::GetHDCPState, base::Unretained(drm_thread_), | 358 base::BindOnce(&DrmThread::GetHDCPState, base::Unretained(drm_thread_), |
| 302 display_id, std::move(safe_callback))); | 359 display_id, std::move(safe_callback))); |
| 303 return true; | 360 return true; |
| 304 } | 361 } |
| 305 | 362 |
| 306 bool MusThreadProxy::GpuSetHDCPState(int64_t display_id, | 363 bool MusThreadProxy::GpuSetHDCPState(int64_t display_id, |
| 307 display::HDCPState state) { | 364 display::HDCPState state) { |
| 308 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 365 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 309 DCHECK(drm_thread_->IsRunning()); | 366 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 367 return false; |
| 310 auto callback = base::BindOnce(&MusThreadProxy::GpuSetHDCPStateCallback, | 368 auto callback = base::BindOnce(&MusThreadProxy::GpuSetHDCPStateCallback, |
| 311 weak_ptr_factory_.GetWeakPtr()); | 369 weak_ptr_factory_.GetWeakPtr()); |
| 312 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); | 370 auto safe_callback = CreateSafeOnceCallback(std::move(callback)); |
| 313 drm_thread_->task_runner()->PostTask( | 371 drm_thread_->task_runner()->PostTask( |
| 314 FROM_HERE, | 372 FROM_HERE, |
| 315 base::BindOnce(&DrmThread::SetHDCPState, base::Unretained(drm_thread_), | 373 base::BindOnce(&DrmThread::SetHDCPState, base::Unretained(drm_thread_), |
| 316 display_id, state, std::move(safe_callback))); | 374 display_id, state, std::move(safe_callback))); |
| 317 return true; | 375 return true; |
| 318 } | 376 } |
| 319 | 377 |
| 320 bool MusThreadProxy::GpuSetColorCorrection( | 378 bool MusThreadProxy::GpuSetColorCorrection( |
| 321 int64_t id, | 379 int64_t id, |
| 322 const std::vector<display::GammaRampRGBEntry>& degamma_lut, | 380 const std::vector<display::GammaRampRGBEntry>& degamma_lut, |
| 323 const std::vector<display::GammaRampRGBEntry>& gamma_lut, | 381 const std::vector<display::GammaRampRGBEntry>& gamma_lut, |
| 324 const std::vector<float>& correction_matrix) { | 382 const std::vector<float>& correction_matrix) { |
| 325 DCHECK(drm_thread_->IsRunning()); | |
| 326 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 383 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 384 if (!drm_thread_ || !drm_thread_->IsRunning()) |
| 385 return false; |
| 327 drm_thread_->task_runner()->PostTask( | 386 drm_thread_->task_runner()->PostTask( |
| 328 FROM_HERE, | 387 FROM_HERE, |
| 329 base::Bind(&DrmThread::SetColorCorrection, base::Unretained(drm_thread_), | 388 base::Bind(&DrmThread::SetColorCorrection, base::Unretained(drm_thread_), |
| 330 id, degamma_lut, gamma_lut, correction_matrix)); | 389 id, degamma_lut, gamma_lut, correction_matrix)); |
| 331 return true; | 390 return true; |
| 332 } | 391 } |
| 333 | 392 |
| 334 void MusThreadProxy::GpuCheckOverlayCapabilitiesCallback( | 393 void MusThreadProxy::GpuCheckOverlayCapabilitiesCallback( |
| 335 gfx::AcceleratedWidget widget, | 394 gfx::AcceleratedWidget widget, |
| 336 const std::vector<OverlayCheck_Params>& overlays) const { | 395 const std::vector<OverlayCheck_Params>& overlays) const { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 display_manager_->GpuReceivedHDCPState(display_id, success, state); | 432 display_manager_->GpuReceivedHDCPState(display_id, success, state); |
| 374 } | 433 } |
| 375 | 434 |
| 376 void MusThreadProxy::GpuSetHDCPStateCallback(int64_t display_id, | 435 void MusThreadProxy::GpuSetHDCPStateCallback(int64_t display_id, |
| 377 bool success) const { | 436 bool success) const { |
| 378 DCHECK(on_window_server_thread_.CalledOnValidThread()); | 437 DCHECK(on_window_server_thread_.CalledOnValidThread()); |
| 379 display_manager_->GpuUpdatedHDCPState(display_id, success); | 438 display_manager_->GpuUpdatedHDCPState(display_id, success); |
| 380 } | 439 } |
| 381 | 440 |
| 382 } // namespace ui | 441 } // namespace ui |
| OLD | NEW |