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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_thread.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
(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_window.h"
14 #include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
15 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
16 #include "ui/ozone/platform/drm/gpu/gbm_device.h"
17 #include "ui/ozone/platform/drm/gpu/gbm_surface_factory.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 namespace {
25
26 class GbmBufferGenerator : public ScanoutBufferGenerator {
27 public:
28 GbmBufferGenerator() {}
29 ~GbmBufferGenerator() override {}
30
31 // ScanoutBufferGenerator:
32 scoped_refptr<ScanoutBuffer> Create(const scoped_refptr<DrmDevice>& drm,
33 gfx::BufferFormat format,
34 const gfx::Size& size) override {
35 scoped_refptr<GbmDevice> gbm(static_cast<GbmDevice*>(drm.get()));
36 return GbmBuffer::CreateBuffer(gbm, format, size,
37 gfx::BufferUsage::SCANOUT);
38 }
39
40 protected:
41 DISALLOW_COPY_AND_ASSIGN(GbmBufferGenerator);
42 };
43
44 class GbmDeviceGenerator : public DrmDeviceGenerator {
45 public:
46 GbmDeviceGenerator(bool use_atomic) : use_atomic_(use_atomic) {}
47 ~GbmDeviceGenerator() override {}
48
49 // DrmDeviceGenerator:
50 scoped_refptr<DrmDevice> CreateDevice(const base::FilePath& path,
51 base::File file) override {
52 scoped_refptr<DrmDevice> drm = new GbmDevice(path, file.Pass());
53 if (drm->Initialize(use_atomic_))
54 return drm;
55
56 return nullptr;
57 }
58
59 private:
60 bool use_atomic_;
61
62 DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator);
63 };
64
65 } // namespace
66
67 DrmThread::DrmThread() : base::Thread("DrmThread") {}
68
69 DrmThread::~DrmThread() {
70 Stop();
71 }
72
73 void DrmThread::Start() {
74 if (!StartWithOptions(base::Thread::Options(base::MessageLoop::TYPE_IO, 0)))
75 LOG(FATAL) << "Failed to create DRM thread";
76 }
77
78 void DrmThread::Init() {
79 bool use_atomic = false;
80 #if defined(USE_DRM_ATOMIC)
81 use_atomic = true;
82 #endif
83
84 device_manager_.reset(new DrmDeviceManager(
85 make_scoped_ptr(new GbmDeviceGenerator(use_atomic))));
86 buffer_generator_.reset(new GbmBufferGenerator());
87 screen_manager_.reset(new ScreenManager(buffer_generator_.get()));
88
89 display_manager_.reset(
90 new DrmGpuDisplayManager(screen_manager_.get(), device_manager_.get()));
91 }
92
93 void DrmThread::SchedulePageFlip(gfx::AcceleratedWidget widget,
94 const std::vector<OverlayPlane>& planes,
95 const SwapCompletionCallback& callback) {
96 DrmWindow* window = screen_manager_->GetWindow(widget);
97 if (window)
98 window->SchedulePageFlip(planes, callback);
99 }
100
101 void DrmThread::GetVSyncParameters(
102 gfx::AcceleratedWidget widget,
103 const gfx::VSyncProvider::UpdateVSyncCallback& callback) {
104 DrmWindow* window = screen_manager_->GetWindow(widget);
105 if (window)
106 window->GetVSyncParameters(callback);
107 }
108
109 void DrmThread::CreateWindow(gfx::AcceleratedWidget widget) {
110 scoped_ptr<DrmWindow> window(
111 new DrmWindow(widget, device_manager_.get(), screen_manager_.get()));
112 window->Initialize();
113 screen_manager_->AddWindow(widget, window.Pass());
114 }
115
116 void DrmThread::DestroyWindow(gfx::AcceleratedWidget widget) {
117 scoped_ptr<DrmWindow> window = screen_manager_->RemoveWindow(widget);
118 window->Shutdown();
119 }
120
121 void DrmThread::WindowBoundsChanged(gfx::AcceleratedWidget widget,
122 const gfx::Rect& bounds) {
123 screen_manager_->GetWindow(widget)->OnBoundsChanged(bounds);
124 }
125
126 void DrmThread::CursorSet(gfx::AcceleratedWidget widget,
127 const std::vector<SkBitmap>& bitmaps,
128 const gfx::Point& location,
129 int frame_delay_ms) {
130 screen_manager_->GetWindow(widget)
131 ->SetCursor(bitmaps, location, frame_delay_ms);
132 }
133
134 void DrmThread::CursorMove(gfx::AcceleratedWidget widget,
135 const gfx::Point& location) {
136 screen_manager_->GetWindow(widget)->MoveCursor(location);
137 }
138
139 void DrmThread::CheckOverlayCapabilities(
140 gfx::AcceleratedWidget widget,
141 const std::vector<OverlayCheck_Params>& overlays,
142 const base::Callback<void(gfx::AcceleratedWidget, bool)>& callback) {
143 callback.Run(widget, screen_manager_->GetWindow(widget)
144 ->TestPageFlip(overlays, buffer_generator_.get()));
145 }
146
147 void DrmThread::RefreshNativeDisplays(
148 const base::Callback<void(const std::vector<DisplaySnapshot_Params>&)>&
149 callback) {
150 callback.Run(display_manager_->GetDisplays());
151 }
152
153 void DrmThread::ConfigureNativeDisplay(
154 int64_t id,
155 const DisplayMode_Params& mode,
156 const gfx::Point& origin,
157 const base::Callback<void(int64_t, bool)>& callback) {
158 callback.Run(id, display_manager_->ConfigureDisplay(id, mode, origin));
159 }
160
161 void DrmThread::DisableNativeDisplay(
162 int64_t id,
163 const base::Callback<void(int64_t, bool)>& callback) {
164 callback.Run(id, display_manager_->DisableDisplay(id));
165 }
166
167 void DrmThread::TakeDisplayControl(const base::Callback<void(bool)>& callback) {
168 callback.Run(display_manager_->TakeDisplayControl());
169 }
170
171 void DrmThread::RelinquishDisplayControl(
172 const base::Callback<void(bool)>& callback) {
173 display_manager_->RelinquishDisplayControl();
174 callback.Run(true);
175 }
176
177 void DrmThread::AddGraphicsDevice(const base::FilePath& path,
178 const base::FileDescriptor& fd) {
179 device_manager_->AddDrmDevice(path, fd);
180 }
181
182 void DrmThread::RemoveGraphicsDevice(const base::FilePath& path) {
183 device_manager_->RemoveDrmDevice(path);
184 }
185
186 void DrmThread::GetHDCPState(
187 int64_t display_id,
188 const base::Callback<void(int64_t, bool, HDCPState)>& callback) {
189 HDCPState state = HDCP_STATE_UNDESIRED;
190 bool success = display_manager_->GetHDCPState(display_id, &state);
191 callback.Run(display_id, success, state);
192 }
193
194 void DrmThread::SetHDCPState(
195 int64_t display_id,
196 HDCPState state,
197 const base::Callback<void(int64_t, bool)>& callback) {
198 callback.Run(display_id, display_manager_->SetHDCPState(display_id, state));
199 }
200
201 void DrmThread::SetGammaRamp(int64_t id,
202 const std::vector<GammaRampRGBEntry>& lut) {
203 display_manager_->SetGammaRamp(id, lut);
204 }
205
206 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698