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

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: 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return true; 98 return true;
99 } 99 }
100 100
101 requests_.push_back(PageFlipRequest(pending_planes_, callback)); 101 requests_.push_back(PageFlipRequest(pending_planes_, callback));
102 pending_planes_.clear(); 102 pending_planes_.clear();
103 103
104 // A request is being serviced right now. 104 // A request is being serviced right now.
105 if (HasPendingPageFlips()) 105 if (HasPendingPageFlips())
106 return true; 106 return true;
107 107
108 bool status = ActualSchedulePageFlip(); 108 bool status = ActualSchedulePageFlip(false);
109 109
110 // No page flip event on failure so discard failed request. 110 // No page flip event on failure so discard failed request.
111 if (!status) 111 if (!status)
112 requests_.pop_front();
113
114 return status;
115 }
116
117 bool HardwareDisplayController::PageFlip() {
dnicoara 2015/02/26 18:22:21 I think you can just use SchedulePageFlip() for th
118 CHECK(!HasPendingPageFlips());
119 TRACE_EVENT0("dri", "HDC::PageFlip");
120
121 // Ignore requests with no planes to schedule.
122 if (pending_planes_.empty())
123 return true;
124
125 requests_.push_back(
126 PageFlipRequest(pending_planes_, base::Bind(&base::DoNothing)));
127 pending_planes_.clear();
128
129 bool status = ActualSchedulePageFlip(true);
130
131 // No page flip event on failure so discard failed request.
132 if (!status)
112 requests_.pop_front(); 133 requests_.pop_front();
113 134
114 return status; 135 return status;
115 } 136 }
116 137
117 bool HardwareDisplayController::SetCursor( 138 bool HardwareDisplayController::SetCursor(
118 const scoped_refptr<ScanoutBuffer>& buffer) { 139 const scoped_refptr<ScanoutBuffer>& buffer) {
119 bool status = true; 140 bool status = true;
120 141
121 if (is_disabled_) 142 if (is_disabled_)
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return; 260 return;
240 261
241 if (!requests_.empty()) 262 if (!requests_.empty())
242 ProcessPageFlipRequest(); 263 ProcessPageFlipRequest();
243 264
244 // ProcessPageFlipRequest() consumes a request. 265 // ProcessPageFlipRequest() consumes a request.
245 if (requests_.empty()) 266 if (requests_.empty())
246 return; 267 return;
247 268
248 // At this point we still have requests pending, so schedule the next request. 269 // At this point we still have requests pending, so schedule the next request.
249 bool status = ActualSchedulePageFlip(); 270 bool status = ActualSchedulePageFlip(false);
250 if (!status) { 271 if (!status) {
251 PageFlipRequest request = requests_.front(); 272 PageFlipRequest request = requests_.front();
252 requests_.pop_front(); 273 requests_.pop_front();
253 274
254 // Normally the caller would handle the error call, but because we're in a 275 // Normally the caller would handle the error call, but because we're in a
255 // delayed schedule the initial SchedulePageFlip() already returned true, 276 // delayed schedule the initial SchedulePageFlip() already returned true,
256 // thus we need to run the callback. 277 // thus we need to run the callback.
257 request.callback.Run(); 278 request.callback.Run();
258 } 279 }
259 } 280 }
260 281
261 scoped_refptr<DriWrapper> HardwareDisplayController::GetAllocationDriWrapper() 282 scoped_refptr<DriWrapper> HardwareDisplayController::GetAllocationDriWrapper()
262 const { 283 const {
263 DCHECK(!crtc_controllers_.empty()); 284 DCHECK(!crtc_controllers_.empty());
264 // TODO(dnicoara) When we support mirroring across DRM devices, figure out 285 // TODO(dnicoara) When we support mirroring across DRM devices, figure out
265 // which device should be used for allocations. 286 // which device should be used for allocations.
266 return crtc_controllers_[0]->drm(); 287 return crtc_controllers_[0]->drm();
267 } 288 }
268 289
269 bool HardwareDisplayController::HasPendingPageFlips() const { 290 bool HardwareDisplayController::HasPendingPageFlips() const {
270 for (size_t i = 0; i < crtc_controllers_.size(); ++i) 291 for (size_t i = 0; i < crtc_controllers_.size(); ++i)
271 if (crtc_controllers_[i]->page_flip_pending()) 292 if (crtc_controllers_[i]->page_flip_pending())
272 return true; 293 return true;
273 294
274 return false; 295 return false;
275 } 296 }
276 297
277 bool HardwareDisplayController::ActualSchedulePageFlip() { 298 bool HardwareDisplayController::ActualSchedulePageFlip(bool is_sync) {
278 TRACE_EVENT0("dri", "HDC::ActualSchedulePageFlip"); 299 TRACE_EVENT0("dri", "HDC::ActualSchedulePageFlip");
279 DCHECK(!requests_.empty()); 300 DCHECK(!requests_.empty());
280 301
281 if (is_disabled_) { 302 if (is_disabled_) {
282 ProcessPageFlipRequest(); 303 ProcessPageFlipRequest();
283 return true; 304 return true;
284 } 305 }
285 306
286 OverlayPlaneList pending_planes = requests_.front().planes; 307 OverlayPlaneList pending_planes = requests_.front().planes;
287 std::sort(pending_planes.begin(), pending_planes.end(), 308 std::sort(pending_planes.begin(), pending_planes.end(),
288 [](const OverlayPlane& l, const OverlayPlane& r) { 309 [](const OverlayPlane& l, const OverlayPlane& r) {
289 return l.z_order < r.z_order; 310 return l.z_order < r.z_order;
290 }); 311 });
291 312
292 bool status = true; 313 bool status = true;
293 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { 314 for (size_t i = 0; i < crtc_controllers_.size(); ++i) {
294 status &= crtc_controllers_[i]->SchedulePageFlip( 315 status &= crtc_controllers_[i]->SchedulePageFlip(
295 owned_hardware_planes_.get(crtc_controllers_[i]->drm().get()), 316 owned_hardware_planes_.get(crtc_controllers_[i]->drm().get()),
296 pending_planes); 317 pending_planes);
297 } 318 }
298 319
299 for (const auto& planes : owned_hardware_planes_) { 320 for (const auto& planes : owned_hardware_planes_) {
300 if (!planes.first->plane_manager()->Commit(planes.second)) { 321 if (!planes.first->plane_manager()->Commit(planes.second, is_sync)) {
301 status = false; 322 status = false;
302 } 323 }
303 } 324 }
304 325
305 return status; 326 return status;
306 } 327 }
307 328
308 void HardwareDisplayController::ProcessPageFlipRequest() { 329 void HardwareDisplayController::ProcessPageFlipRequest() {
309 DCHECK(!requests_.empty()); 330 DCHECK(!requests_.empty());
310 PageFlipRequest request = requests_.front(); 331 PageFlipRequest request = requests_.front();
311 requests_.pop_front(); 332 requests_.pop_front();
312 333
313 current_planes_.swap(request.planes); 334 current_planes_.swap(request.planes);
314 request.callback.Run(); 335 request.callback.Run();
315 } 336 }
316 337
317 void HardwareDisplayController::ClearPendingRequests() { 338 void HardwareDisplayController::ClearPendingRequests() {
318 while (!requests_.empty()) { 339 while (!requests_.empty()) {
319 PageFlipRequest request = requests_.front(); 340 PageFlipRequest request = requests_.front();
320 requests_.pop_front(); 341 requests_.pop_front();
321 request.callback.Run(); 342 request.callback.Run();
322 } 343 }
323 } 344 }
324 345
325 } // namespace ui 346 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698