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

Side by Side Diff: ui/ozone/platform/dri/hardware_display_controller.cc

Issue 960273003: ozone: dri: add synchronous SwapBuffers support on surfaceless (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after dnicoara's review Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/dri/hardware_display_controller.h" 5 #include "ui/ozone/platform/dri/hardware_display_controller.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <string.h> 9 #include <string.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 crtc_controllers_[i]->Disable(); 82 crtc_controllers_[i]->Disable();
83 83
84 is_disabled_ = true; 84 is_disabled_ = true;
85 } 85 }
86 86
87 void HardwareDisplayController::QueueOverlayPlane(const OverlayPlane& plane) { 87 void HardwareDisplayController::QueueOverlayPlane(const OverlayPlane& plane) {
88 pending_planes_.push_back(plane); 88 pending_planes_.push_back(plane);
89 } 89 }
90 90
91 bool HardwareDisplayController::SchedulePageFlip( 91 bool HardwareDisplayController::SchedulePageFlip(
92 bool is_sync,
92 const base::Closure& callback) { 93 const base::Closure& callback) {
93 TRACE_EVENT0("dri", "HDC::SchedulePageFlip"); 94 TRACE_EVENT0("dri", "HDC::SchedulePageFlip");
94 95
95 // Ignore requests with no planes to schedule. 96 // Ignore requests with no planes to schedule.
96 if (pending_planes_.empty()) { 97 if (pending_planes_.empty()) {
97 callback.Run(); 98 callback.Run();
98 return true; 99 return true;
99 } 100 }
100 101
101 requests_.push_back(PageFlipRequest(pending_planes_, callback)); 102 requests_.push_back(PageFlipRequest(pending_planes_, callback));
dnicoara 2015/02/26 22:16:29 You'll need to add the |is_sync| param to the Page
llandwerlin-old 2015/02/27 10:56:47 Done.
102 pending_planes_.clear(); 103 pending_planes_.clear();
103 104
104 // A request is being serviced right now. 105 // A request is being serviced right now.
105 if (HasPendingPageFlips()) 106 if (HasPendingPageFlips())
106 return true; 107 return true;
107 108
108 bool status = ActualSchedulePageFlip(); 109 bool status = ActualSchedulePageFlip(is_sync);
109 110
110 // No page flip event on failure so discard failed request. 111 // No page flip event on failure so discard failed request.
111 if (!status) 112 if (!status)
112 requests_.pop_front(); 113 requests_.pop_front();
113 114
114 return status; 115 return status;
115 } 116 }
116 117
117 bool HardwareDisplayController::SetCursor( 118 bool HardwareDisplayController::SetCursor(
118 const scoped_refptr<ScanoutBuffer>& buffer) { 119 const scoped_refptr<ScanoutBuffer>& buffer) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return; 240 return;
240 241
241 if (!requests_.empty()) 242 if (!requests_.empty())
242 ProcessPageFlipRequest(); 243 ProcessPageFlipRequest();
243 244
244 // ProcessPageFlipRequest() consumes a request. 245 // ProcessPageFlipRequest() consumes a request.
245 if (requests_.empty()) 246 if (requests_.empty())
246 return; 247 return;
247 248
248 // At this point we still have requests pending, so schedule the next request. 249 // At this point we still have requests pending, so schedule the next request.
249 bool status = ActualSchedulePageFlip(); 250 bool status = ActualSchedulePageFlip(false);
dnicoara 2015/02/26 22:16:29 Then |is_sync| will be taken from the PageFlipRequ
llandwerlin-old 2015/02/27 10:56:47 Done, thanks a lot.
250 if (!status) { 251 if (!status) {
251 PageFlipRequest request = requests_.front(); 252 PageFlipRequest request = requests_.front();
252 requests_.pop_front(); 253 requests_.pop_front();
253 254
254 // Normally the caller would handle the error call, but because we're in a 255 // Normally the caller would handle the error call, but because we're in a
255 // delayed schedule the initial SchedulePageFlip() already returned true, 256 // delayed schedule the initial SchedulePageFlip() already returned true,
256 // thus we need to run the callback. 257 // thus we need to run the callback.
257 request.callback.Run(); 258 request.callback.Run();
258 } 259 }
259 } 260 }
260 261
261 scoped_refptr<DriWrapper> HardwareDisplayController::GetAllocationDriWrapper() 262 scoped_refptr<DriWrapper> HardwareDisplayController::GetAllocationDriWrapper()
262 const { 263 const {
263 DCHECK(!crtc_controllers_.empty()); 264 DCHECK(!crtc_controllers_.empty());
264 // TODO(dnicoara) When we support mirroring across DRM devices, figure out 265 // TODO(dnicoara) When we support mirroring across DRM devices, figure out
265 // which device should be used for allocations. 266 // which device should be used for allocations.
266 return crtc_controllers_[0]->drm(); 267 return crtc_controllers_[0]->drm();
267 } 268 }
268 269
269 bool HardwareDisplayController::HasPendingPageFlips() const { 270 bool HardwareDisplayController::HasPendingPageFlips() const {
270 for (size_t i = 0; i < crtc_controllers_.size(); ++i) 271 for (size_t i = 0; i < crtc_controllers_.size(); ++i)
271 if (crtc_controllers_[i]->page_flip_pending()) 272 if (crtc_controllers_[i]->page_flip_pending())
272 return true; 273 return true;
273 274
274 return false; 275 return false;
275 } 276 }
276 277
277 bool HardwareDisplayController::ActualSchedulePageFlip() { 278 bool HardwareDisplayController::ActualSchedulePageFlip(bool is_sync) {
278 TRACE_EVENT0("dri", "HDC::ActualSchedulePageFlip"); 279 TRACE_EVENT0("dri", "HDC::ActualSchedulePageFlip");
279 DCHECK(!requests_.empty()); 280 DCHECK(!requests_.empty());
280 281
281 if (is_disabled_) { 282 if (is_disabled_) {
282 ProcessPageFlipRequest(); 283 ProcessPageFlipRequest();
283 return true; 284 return true;
284 } 285 }
285 286
286 OverlayPlaneList pending_planes = requests_.front().planes; 287 OverlayPlaneList pending_planes = requests_.front().planes;
287 std::sort(pending_planes.begin(), pending_planes.end(), 288 std::sort(pending_planes.begin(), pending_planes.end(),
288 [](const OverlayPlane& l, const OverlayPlane& r) { 289 [](const OverlayPlane& l, const OverlayPlane& r) {
289 return l.z_order < r.z_order; 290 return l.z_order < r.z_order;
290 }); 291 });
291 292
292 bool status = true; 293 bool status = true;
293 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { 294 for (size_t i = 0; i < crtc_controllers_.size(); ++i) {
294 status &= crtc_controllers_[i]->SchedulePageFlip( 295 status &= crtc_controllers_[i]->SchedulePageFlip(
295 owned_hardware_planes_.get(crtc_controllers_[i]->drm().get()), 296 owned_hardware_planes_.get(crtc_controllers_[i]->drm().get()),
296 pending_planes); 297 pending_planes);
297 } 298 }
298 299
299 for (const auto& planes : owned_hardware_planes_) { 300 for (const auto& planes : owned_hardware_planes_) {
300 if (!planes.first->plane_manager()->Commit(planes.second)) { 301 if (!planes.first->plane_manager()->Commit(planes.second, is_sync)) {
301 status = false; 302 status = false;
302 } 303 }
303 } 304 }
304 305
305 return status; 306 return status;
306 } 307 }
307 308
308 void HardwareDisplayController::ProcessPageFlipRequest() { 309 void HardwareDisplayController::ProcessPageFlipRequest() {
309 DCHECK(!requests_.empty()); 310 DCHECK(!requests_.empty());
310 PageFlipRequest request = requests_.front(); 311 PageFlipRequest request = requests_.front();
311 requests_.pop_front(); 312 requests_.pop_front();
312 313
313 current_planes_.swap(request.planes); 314 current_planes_.swap(request.planes);
314 request.callback.Run(); 315 request.callback.Run();
315 } 316 }
316 317
317 void HardwareDisplayController::ClearPendingRequests() { 318 void HardwareDisplayController::ClearPendingRequests() {
318 while (!requests_.empty()) { 319 while (!requests_.empty()) {
319 PageFlipRequest request = requests_.front(); 320 PageFlipRequest request = requests_.front();
320 requests_.pop_front(); 321 requests_.pop_front();
321 request.callback.Run(); 322 request.callback.Run();
322 } 323 }
323 } 324 }
324 325
325 } // namespace ui 326 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698