| OLD | NEW |
| 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 Loading... |
| 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 new PageFlipRequest(crtc_controllers_.size(), callback); | |
| 106 | |
| 107 OverlayPlaneList pending_planes = plane_list; | 105 OverlayPlaneList pending_planes = plane_list; |
| 108 std::sort(pending_planes.begin(), pending_planes.end(), | 106 std::sort(pending_planes.begin(), pending_planes.end(), |
| 109 [](const OverlayPlane& l, const OverlayPlane& r) { | 107 [](const OverlayPlane& l, const OverlayPlane& r) { |
| 110 return l.z_order < r.z_order; | 108 return l.z_order < r.z_order; |
| 111 }); | 109 }); |
| 112 if (pending_planes.front().z_order != 0) { | 110 if (pending_planes.front().z_order != 0) { |
| 113 callback.Run(gfx::SwapResult::SWAP_FAILED); | 111 std::move(callback).Run(gfx::SwapResult::SWAP_FAILED); |
| 114 return false; | 112 return false; |
| 115 } | 113 } |
| 114 scoped_refptr<PageFlipRequest> page_flip_request = |
| 115 new PageFlipRequest(crtc_controllers_.size(), std::move(callback)); |
| 116 | 116 |
| 117 for (const auto& planes : owned_hardware_planes_) | 117 for (const auto& planes : owned_hardware_planes_) |
| 118 planes.first->plane_manager()->BeginFrame(planes.second.get()); | 118 planes.first->plane_manager()->BeginFrame(planes.second.get()); |
| 119 | 119 |
| 120 bool status = true; | 120 bool status = true; |
| 121 for (const auto& controller : crtc_controllers_) { | 121 for (const auto& controller : crtc_controllers_) { |
| 122 status &= controller->SchedulePageFlip( | 122 status &= controller->SchedulePageFlip( |
| 123 owned_hardware_planes_[controller->drm().get()].get(), pending_planes, | 123 owned_hardware_planes_[controller->drm().get()].get(), pending_planes, |
| 124 test_only, page_flip_request); | 124 test_only, page_flip_request); |
| 125 } | 125 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 295 |
| 296 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 296 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() |
| 297 const { | 297 const { |
| 298 DCHECK(!crtc_controllers_.empty()); | 298 DCHECK(!crtc_controllers_.empty()); |
| 299 // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 299 // TODO(dnicoara) When we support mirroring across DRM devices, figure out |
| 300 // which device should be used for allocations. | 300 // which device should be used for allocations. |
| 301 return crtc_controllers_[0]->drm(); | 301 return crtc_controllers_[0]->drm(); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace ui | 304 } // namespace ui |
| OLD | NEW |