| Index: ui/ozone/platform/drm/gpu/drm_thread.cc
|
| diff --git a/ui/ozone/platform/drm/gpu/drm_thread.cc b/ui/ozone/platform/drm/gpu/drm_thread.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..bd9a1d4a9609fee086fb5628ac98bb6268fb241e
|
| --- /dev/null
|
| +++ b/ui/ozone/platform/drm/gpu/drm_thread.cc
|
| @@ -0,0 +1,86 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/ozone/platform/drm/gpu/drm_thread.h"
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/thread_task_runner_handle.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_buffer.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support_proxy.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_surface_factory.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_window.h"
|
| +#include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
|
| +#include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
|
| +#include "ui/ozone/platform/drm/gpu/screen_manager.h"
|
| +#include "ui/ozone/public/ozone_switches.h"
|
| +
|
| +namespace ui {
|
| +
|
| +DrmThread::DrmThread() : base::Thread("DrmThread") {}
|
| +
|
| +DrmThread::~DrmThread() {
|
| + Stop();
|
| +}
|
| +
|
| +void DrmThread::Start() {
|
| + if (!StartWithOptions(base::Thread::Options(base::MessageLoop::TYPE_IO, 0)))
|
| + LOG(FATAL) << "Failed to create DRM thread";
|
| +}
|
| +
|
| +scoped_ptr<DrmWindowProxy> DrmThread::CreateWindowProxy(
|
| + gfx::AcceleratedWidget widget) const {
|
| + scoped_ptr<DrmWindowProxy> window;
|
| + // It is OK to use base::Unretained() since destroying this object waits for
|
| + // all pending tasks to finish before continuing.
|
| + PostSyncTask(task_runner(),
|
| + base::Bind(&DrmThread::CreateWindowProxyOnThread,
|
| + base::Unretained(this), widget, &window));
|
| + return window.Pass();
|
| +}
|
| +
|
| +scoped_ptr<DrmGpuPlatformSupportProxy>
|
| +DrmThread::CreateGpuPlatformSupportProxy() const {
|
| + scoped_ptr<DrmGpuPlatformSupportProxy> proxy;
|
| + PostSyncTask(task_runner(),
|
| + base::Bind(&DrmThread::CreateGpuPlatformSupportProxyOnThread,
|
| + base::Unretained(this), &proxy));
|
| + return proxy.Pass();
|
| +}
|
| +
|
| +void DrmThread::Init() {
|
| + device_manager_.reset(
|
| + new DrmDeviceManager(make_scoped_ptr(new DrmDeviceGenerator())));
|
| + buffer_generator_.reset(new DrmBufferGenerator());
|
| + screen_manager_.reset(new ScreenManager(buffer_generator_.get()));
|
| +
|
| + scoped_ptr<DrmGpuDisplayManager> display_manager(
|
| + new DrmGpuDisplayManager(screen_manager_.get(), device_manager_.get()));
|
| + gpu_platform_support_.reset(new DrmGpuPlatformSupport(
|
| + device_manager_.get(), screen_manager_.get(), buffer_generator_.get(),
|
| + display_manager.Pass()));
|
| +}
|
| +
|
| +void DrmThread::CreateWindowProxyOnThread(
|
| + gfx::AcceleratedWidget widget,
|
| + scoped_ptr<DrmWindowProxy>* window_proxy) const {
|
| + DrmWindow* window = screen_manager_->GetWindow(widget);
|
| + base::WeakPtr<DrmWindow> weak_window;
|
| + if (window)
|
| + weak_window = window->AsWeakPtr();
|
| +
|
| + window_proxy->reset(new DrmWindowProxy(base::ThreadTaskRunnerHandle::Get(),
|
| + weak_window, widget));
|
| +}
|
| +
|
| +void DrmThread::CreateGpuPlatformSupportProxyOnThread(
|
| + scoped_ptr<DrmGpuPlatformSupportProxy>* proxy) const {
|
| + proxy->reset(new DrmGpuPlatformSupportProxy(
|
| + base::ThreadTaskRunnerHandle::Get(), gpu_platform_support_->AsWeakPtr()));
|
| +}
|
| +
|
| +} // namespace ui
|
|
|