OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/ozone/platform/drm/gpu/drm_thread.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" |
| 10 #include "ui/ozone/platform/drm/gpu/drm_device_generator.h" |
| 11 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" |
| 12 #include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h" |
| 13 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h" |
| 14 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.h" |
| 15 #include "ui/ozone/platform/drm/gpu/drm_surface_factory.h" |
| 16 #include "ui/ozone/platform/drm/gpu/drm_window.h" |
| 17 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h" |
| 18 #include "ui/ozone/platform/drm/gpu/proxy_helpers.h" |
| 19 #include "ui/ozone/platform/drm/gpu/screen_manager.h" |
| 20 #include "ui/ozone/public/ozone_switches.h" |
| 21 |
| 22 namespace ui { |
| 23 |
| 24 DrmThread::DrmThread() : base::Thread("DrmThread") {} |
| 25 |
| 26 DrmThread::~DrmThread() { |
| 27 Stop(); |
| 28 } |
| 29 |
| 30 void DrmThread::Start() { |
| 31 if (!StartWithOptions(base::Thread::Options(base::MessageLoop::TYPE_IO, 0))) |
| 32 LOG(FATAL) << "Failed to create DRM thread"; |
| 33 } |
| 34 |
| 35 scoped_ptr<DrmWindowProxy> DrmThread::CreateWindowProxy( |
| 36 gfx::AcceleratedWidget widget) const { |
| 37 scoped_ptr<DrmWindowProxy> window; |
| 38 // It is OK to use base::Unretained() since destroying this object waits for |
| 39 // all pending tasks to finish before continuing. |
| 40 PostSyncTask(task_runner(), |
| 41 base::Bind(&DrmThread::CreateWindowProxyOnThread, |
| 42 base::Unretained(this), widget, &window)); |
| 43 return window.Pass(); |
| 44 } |
| 45 |
| 46 scoped_ptr<DrmGpuPlatformSupportProxy> |
| 47 DrmThread::CreateGpuPlatformSupportProxy() const { |
| 48 scoped_ptr<DrmGpuPlatformSupportProxy> proxy; |
| 49 PostSyncTask(task_runner(), |
| 50 base::Bind(&DrmThread::CreateGpuPlatformSupportProxyOnThread, |
| 51 base::Unretained(this), &proxy)); |
| 52 return proxy.Pass(); |
| 53 } |
| 54 |
| 55 void DrmThread::Init() { |
| 56 device_manager_.reset( |
| 57 new DrmDeviceManager(make_scoped_ptr(new DrmDeviceGenerator()))); |
| 58 buffer_generator_.reset(new DrmBufferGenerator()); |
| 59 screen_manager_.reset(new ScreenManager(buffer_generator_.get())); |
| 60 |
| 61 scoped_ptr<DrmGpuDisplayManager> display_manager( |
| 62 new DrmGpuDisplayManager(screen_manager_.get(), device_manager_.get())); |
| 63 gpu_platform_support_.reset(new DrmGpuPlatformSupport( |
| 64 device_manager_.get(), screen_manager_.get(), buffer_generator_.get(), |
| 65 display_manager.Pass())); |
| 66 } |
| 67 |
| 68 void DrmThread::CreateWindowProxyOnThread( |
| 69 gfx::AcceleratedWidget widget, |
| 70 scoped_ptr<DrmWindowProxy>* window_proxy) const { |
| 71 DrmWindow* window = screen_manager_->GetWindow(widget); |
| 72 base::WeakPtr<DrmWindow> weak_window; |
| 73 if (window) |
| 74 weak_window = window->AsWeakPtr(); |
| 75 |
| 76 window_proxy->reset(new DrmWindowProxy(base::ThreadTaskRunnerHandle::Get(), |
| 77 weak_window, widget)); |
| 78 } |
| 79 |
| 80 void DrmThread::CreateGpuPlatformSupportProxyOnThread( |
| 81 scoped_ptr<DrmGpuPlatformSupportProxy>* proxy) const { |
| 82 proxy->reset(new DrmGpuPlatformSupportProxy( |
| 83 base::ThreadTaskRunnerHandle::Get(), gpu_platform_support_->AsWeakPtr())); |
| 84 } |
| 85 |
| 86 } // namespace ui |
OLD | NEW |