| 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> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
| 16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/swap_result.h" | 18 #include "ui/gfx/swap_result.h" |
| 18 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" | 19 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" |
| 19 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" | 20 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" |
| 20 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 21 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| 21 #include "ui/ozone/platform/drm/gpu/page_flip_request.h" | 22 #include "ui/ozone/platform/drm/gpu/page_flip_request.h" |
| 22 #include "ui/ozone/public/native_pixmap.h" | 23 #include "ui/ozone/public/native_pixmap.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 std::sort(pending_planes.begin(), pending_planes.end(), | 108 std::sort(pending_planes.begin(), pending_planes.end(), |
| 108 [](const OverlayPlane& l, const OverlayPlane& r) { | 109 [](const OverlayPlane& l, const OverlayPlane& r) { |
| 109 return l.z_order < r.z_order; | 110 return l.z_order < r.z_order; |
| 110 }); | 111 }); |
| 111 if (pending_planes.front().z_order != 0) { | 112 if (pending_planes.front().z_order != 0) { |
| 112 callback.Run(gfx::SwapResult::SWAP_FAILED); | 113 callback.Run(gfx::SwapResult::SWAP_FAILED); |
| 113 return false; | 114 return false; |
| 114 } | 115 } |
| 115 | 116 |
| 116 for (const auto& planes : owned_hardware_planes_) | 117 for (const auto& planes : owned_hardware_planes_) |
| 117 planes.first->plane_manager()->BeginFrame(planes.second); | 118 planes.first->plane_manager()->BeginFrame(planes.second.get()); |
| 118 | 119 |
| 119 bool status = true; | 120 bool status = true; |
| 120 for (const auto& controller : crtc_controllers_) { | 121 for (const auto& controller : crtc_controllers_) { |
| 121 status &= controller->SchedulePageFlip( | 122 status &= controller->SchedulePageFlip( |
| 122 owned_hardware_planes_.get(controller->drm().get()), pending_planes, | 123 owned_hardware_planes_[controller->drm().get()].get(), pending_planes, |
| 123 test_only, page_flip_request); | 124 test_only, page_flip_request); |
| 124 } | 125 } |
| 125 | 126 |
| 126 for (const auto& planes : owned_hardware_planes_) { | 127 for (const auto& planes : owned_hardware_planes_) { |
| 127 if (!planes.first->plane_manager()->Commit(planes.second, test_only)) { | 128 if (!planes.first->plane_manager()->Commit(planes.second.get(), |
| 129 test_only)) { |
| 128 status = false; | 130 status = false; |
| 129 } | 131 } |
| 130 } | 132 } |
| 131 | 133 |
| 132 return status; | 134 return status; |
| 133 } | 135 } |
| 134 | 136 |
| 135 bool HardwareDisplayController::IsFormatSupported(uint32_t fourcc_format, | 137 bool HardwareDisplayController::IsFormatSupported(uint32_t fourcc_format, |
| 136 uint32_t z_order) const { | 138 uint32_t z_order) const { |
| 137 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { | 139 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 bool status = true; | 173 bool status = true; |
| 172 for (const auto& controller : crtc_controllers_) | 174 for (const auto& controller : crtc_controllers_) |
| 173 status &= controller->MoveCursor(location); | 175 status &= controller->MoveCursor(location); |
| 174 | 176 |
| 175 return status; | 177 return status; |
| 176 } | 178 } |
| 177 | 179 |
| 178 void HardwareDisplayController::AddCrtc( | 180 void HardwareDisplayController::AddCrtc( |
| 179 std::unique_ptr<CrtcController> controller) { | 181 std::unique_ptr<CrtcController> controller) { |
| 180 scoped_refptr<DrmDevice> drm = controller->drm(); | 182 scoped_refptr<DrmDevice> drm = controller->drm(); |
| 181 owned_hardware_planes_.add(drm.get(), | 183 owned_hardware_planes_[drm.get()] = |
| 182 std::unique_ptr<HardwareDisplayPlaneList>( | 184 base::MakeUnique<HardwareDisplayPlaneList>(); |
| 183 new HardwareDisplayPlaneList())); | |
| 184 | 185 |
| 185 // Check if this controller owns any planes and ensure we keep track of them. | 186 // Check if this controller owns any planes and ensure we keep track of them. |
| 186 const std::vector<std::unique_ptr<HardwareDisplayPlane>>& all_planes = | 187 const std::vector<std::unique_ptr<HardwareDisplayPlane>>& all_planes = |
| 187 drm->plane_manager()->planes(); | 188 drm->plane_manager()->planes(); |
| 188 HardwareDisplayPlaneList* crtc_plane_list = | 189 HardwareDisplayPlaneList* crtc_plane_list = |
| 189 owned_hardware_planes_.get(drm.get()); | 190 owned_hardware_planes_[drm.get()].get(); |
| 190 uint32_t crtc = controller->crtc(); | 191 uint32_t crtc = controller->crtc(); |
| 191 for (const auto& plane : all_planes) { | 192 for (const auto& plane : all_planes) { |
| 192 if (plane->in_use() && (plane->owning_crtc() == crtc)) | 193 if (plane->in_use() && (plane->owning_crtc() == crtc)) |
| 193 crtc_plane_list->old_plane_list.push_back(plane.get()); | 194 crtc_plane_list->old_plane_list.push_back(plane.get()); |
| 194 } | 195 } |
| 195 | 196 |
| 196 crtc_controllers_.push_back(std::move(controller)); | 197 crtc_controllers_.push_back(std::move(controller)); |
| 197 } | 198 } |
| 198 | 199 |
| 199 std::unique_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 200 std::unique_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 210 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); | 211 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); |
| 211 ++it) { | 212 ++it) { |
| 212 if ((*it)->drm() == controller->drm()) { | 213 if ((*it)->drm() == controller->drm()) { |
| 213 found = true; | 214 found = true; |
| 214 break; | 215 break; |
| 215 } | 216 } |
| 216 } | 217 } |
| 217 if (found) { | 218 if (found) { |
| 218 std::vector<HardwareDisplayPlane*> all_planes; | 219 std::vector<HardwareDisplayPlane*> all_planes; |
| 219 HardwareDisplayPlaneList* plane_list = | 220 HardwareDisplayPlaneList* plane_list = |
| 220 owned_hardware_planes_.get(drm.get()); | 221 owned_hardware_planes_[drm.get()].get(); |
| 221 all_planes.swap(plane_list->old_plane_list); | 222 all_planes.swap(plane_list->old_plane_list); |
| 222 for (auto* plane : all_planes) { | 223 for (auto* plane : all_planes) { |
| 223 if (plane->owning_crtc() != crtc) | 224 if (plane->owning_crtc() != crtc) |
| 224 plane_list->old_plane_list.push_back(plane); | 225 plane_list->old_plane_list.push_back(plane); |
| 225 } | 226 } |
| 226 } else { | 227 } else { |
| 227 owned_hardware_planes_.erase(controller->drm().get()); | 228 owned_hardware_planes_.erase(controller->drm().get()); |
| 228 } | 229 } |
| 229 | 230 |
| 230 return controller; | 231 return controller; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 271 |
| 271 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 272 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() |
| 272 const { | 273 const { |
| 273 DCHECK(!crtc_controllers_.empty()); | 274 DCHECK(!crtc_controllers_.empty()); |
| 274 // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 275 // TODO(dnicoara) When we support mirroring across DRM devices, figure out |
| 275 // which device should be used for allocations. | 276 // which device should be used for allocations. |
| 276 return crtc_controllers_[0]->drm(); | 277 return crtc_controllers_[0]->drm(); |
| 277 } | 278 } |
| 278 | 279 |
| 279 } // namespace ui | 280 } // namespace ui |
| OLD | NEW |