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

Side by Side Diff: ui/ozone/platform/drm/gpu/hardware_display_controller.cc

Issue 2886503002: Convert additional ozone/drm callbacks to OnceCallback (Closed)
Patch Set: Created 3 years, 7 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/drm/gpu/hardware_display_controller.h" 5 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <string.h> 8 #include <string.h>
9 #include <xf86drm.h> 9 #include <xf86drm.h>
10 #include <utility> 10 #include <utility>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 void HardwareDisplayController::Disable() { 70 void HardwareDisplayController::Disable() {
71 TRACE_EVENT0("drm", "HDC::Disable"); 71 TRACE_EVENT0("drm", "HDC::Disable");
72 for (const auto& controller : crtc_controllers_) 72 for (const auto& controller : crtc_controllers_)
73 controller->Disable(); 73 controller->Disable();
74 74
75 is_disabled_ = true; 75 is_disabled_ = true;
76 } 76 }
77 77
78 void HardwareDisplayController::SchedulePageFlip( 78 void HardwareDisplayController::SchedulePageFlip(
79 const OverlayPlaneList& plane_list, 79 const OverlayPlaneList& plane_list,
80 const PageFlipCallback& callback) { 80 SwapCompletionOnceCallback callback) {
81 ActualSchedulePageFlip(plane_list, false /* test_only */, callback); 81 ActualSchedulePageFlip(plane_list, false /* test_only */,
82 std::move(callback));
82 } 83 }
83 84
84 bool HardwareDisplayController::TestPageFlip( 85 bool HardwareDisplayController::TestPageFlip(
85 const OverlayPlaneList& plane_list) { 86 const OverlayPlaneList& plane_list) {
86 return ActualSchedulePageFlip(plane_list, true /* test_only */, 87 return ActualSchedulePageFlip(plane_list, true /* test_only */,
87 base::Bind(&EmptyFlipCallback)); 88 base::BindOnce(&EmptyFlipCallback));
88 } 89 }
89 90
90 bool HardwareDisplayController::ActualSchedulePageFlip( 91 bool HardwareDisplayController::ActualSchedulePageFlip(
91 const OverlayPlaneList& plane_list, 92 const OverlayPlaneList& plane_list,
92 bool test_only, 93 bool test_only,
93 const PageFlipCallback& callback) { 94 SwapCompletionOnceCallback callback) {
94 TRACE_EVENT0("drm", "HDC::SchedulePageFlip"); 95 TRACE_EVENT0("drm", "HDC::SchedulePageFlip");
95 96
96 DCHECK(!is_disabled_); 97 DCHECK(!is_disabled_);
97 98
98 // Ignore requests with no planes to schedule. 99 // Ignore requests with no planes to schedule.
99 if (plane_list.empty()) { 100 if (plane_list.empty()) {
100 callback.Run(gfx::SwapResult::SWAP_ACK); 101 std::move(callback).Run(gfx::SwapResult::SWAP_ACK);
101 return true; 102 return true;
102 } 103 }
103 104
104 scoped_refptr<PageFlipRequest> page_flip_request = 105 scoped_refptr<PageFlipRequest> page_flip_request =
105 new PageFlipRequest(crtc_controllers_.size(), callback); 106 new PageFlipRequest(crtc_controllers_.size(), std::move(callback));
106 107
107 OverlayPlaneList pending_planes = plane_list; 108 OverlayPlaneList pending_planes = plane_list;
108 std::sort(pending_planes.begin(), pending_planes.end(), 109 std::sort(pending_planes.begin(), pending_planes.end(),
109 [](const OverlayPlane& l, const OverlayPlane& r) { 110 [](const OverlayPlane& l, const OverlayPlane& r) {
110 return l.z_order < r.z_order; 111 return l.z_order < r.z_order;
111 }); 112 });
112 if (pending_planes.front().z_order != 0) { 113 if (pending_planes.front().z_order != 0) {
113 callback.Run(gfx::SwapResult::SWAP_FAILED); 114 std::move(callback).Run(gfx::SwapResult::SWAP_FAILED);
114 return false; 115 return false;
115 } 116 }
116 117
117 for (const auto& planes : owned_hardware_planes_) 118 for (const auto& planes : owned_hardware_planes_)
118 planes.first->plane_manager()->BeginFrame(planes.second.get()); 119 planes.first->plane_manager()->BeginFrame(planes.second.get());
119 120
120 bool status = true; 121 bool status = true;
121 for (const auto& controller : crtc_controllers_) { 122 for (const auto& controller : crtc_controllers_) {
122 status &= controller->SchedulePageFlip( 123 status &= controller->SchedulePageFlip(
123 owned_hardware_planes_[controller->drm().get()].get(), pending_planes, 124 owned_hardware_planes_[controller->drm().get()].get(), pending_planes,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 296
296 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() 297 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice()
297 const { 298 const {
298 DCHECK(!crtc_controllers_.empty()); 299 DCHECK(!crtc_controllers_.empty());
299 // TODO(dnicoara) When we support mirroring across DRM devices, figure out 300 // TODO(dnicoara) When we support mirroring across DRM devices, figure out
300 // which device should be used for allocations. 301 // which device should be used for allocations.
301 return crtc_controllers_[0]->drm(); 302 return crtc_controllers_[0]->drm();
302 } 303 }
303 304
304 } // namespace ui 305 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698