| 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_plane_manager.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" |
| 6 | 6 |
| 7 #include <drm_fourcc.h> | 7 #include <drm_fourcc.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 for (uint32_t i = 0; i < num_planes; ++i) { | 93 for (uint32_t i = 0; i < num_planes; ++i) { |
| 94 ScopedDrmPlanePtr drm_plane( | 94 ScopedDrmPlanePtr drm_plane( |
| 95 drmModeGetPlane(drm->get_fd(), plane_resources->planes[i])); | 95 drmModeGetPlane(drm->get_fd(), plane_resources->planes[i])); |
| 96 if (!drm_plane) { | 96 if (!drm_plane) { |
| 97 PLOG(ERROR) << "Failed to get plane " << i; | 97 PLOG(ERROR) << "Failed to get plane " << i; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 uint32_t formats_size = drm_plane->count_formats; | 101 uint32_t formats_size = drm_plane->count_formats; |
| 102 plane_ids.insert(drm_plane->plane_id); | 102 plane_ids.insert(drm_plane->plane_id); |
| 103 scoped_ptr<HardwareDisplayPlane> plane( | 103 std::unique_ptr<HardwareDisplayPlane> plane( |
| 104 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); | 104 CreatePlane(drm_plane->plane_id, drm_plane->possible_crtcs)); |
| 105 | 105 |
| 106 std::vector<uint32_t> supported_formats(formats_size); | 106 std::vector<uint32_t> supported_formats(formats_size); |
| 107 for (uint32_t j = 0; j < formats_size; j++) | 107 for (uint32_t j = 0; j < formats_size; j++) |
| 108 supported_formats[j] = drm_plane->formats[j]; | 108 supported_formats[j] = drm_plane->formats[j]; |
| 109 | 109 |
| 110 if (plane->Initialize(drm, supported_formats, false, false)) { | 110 if (plane->Initialize(drm, supported_formats, false, false)) { |
| 111 // CRTC controllers always assume they have a cursor plane and the cursor | 111 // CRTC controllers always assume they have a cursor plane and the cursor |
| 112 // plane is updated via cursor specific DRM API. Hence, we dont keep | 112 // plane is updated via cursor specific DRM API. Hence, we dont keep |
| 113 // track of Cursor plane here to avoid re-using it for any other purpose. | 113 // track of Cursor plane here to avoid re-using it for any other purpose. |
| 114 if (plane->type() != HardwareDisplayPlane::kCursor) | 114 if (plane->type() != HardwareDisplayPlane::kCursor) |
| 115 planes_.push_back(std::move(plane)); | 115 planes_.push_back(std::move(plane)); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 // crbug.com/464085: if driver reports no primary planes for a crtc, create a | 119 // crbug.com/464085: if driver reports no primary planes for a crtc, create a |
| 120 // dummy plane for which we can assign exactly one overlay. | 120 // dummy plane for which we can assign exactly one overlay. |
| 121 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 121 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
| 122 // this workaround into HardwareDisplayPlaneLegacy. | 122 // this workaround into HardwareDisplayPlaneLegacy. |
| 123 if (!has_universal_planes) { | 123 if (!has_universal_planes) { |
| 124 for (int i = 0; i < resources->count_crtcs; ++i) { | 124 for (int i = 0; i < resources->count_crtcs; ++i) { |
| 125 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 125 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
| 126 scoped_ptr<HardwareDisplayPlane> dummy_plane( | 126 std::unique_ptr<HardwareDisplayPlane> dummy_plane( |
| 127 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 127 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
| 128 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true, | 128 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true, |
| 129 false)) { | 129 false)) { |
| 130 planes_.push_back(std::move(dummy_plane)); | 130 planes_.push_back(std::move(dummy_plane)); |
| 131 } | 131 } |
| 132 } | 132 } |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 std::sort(planes_.begin(), planes_.end(), | 136 std::sort(planes_.begin(), planes_.end(), |
| 137 [](const scoped_ptr<HardwareDisplayPlane>& l, | 137 [](const std::unique_ptr<HardwareDisplayPlane>& l, |
| 138 const scoped_ptr<HardwareDisplayPlane>& r) { | 138 const std::unique_ptr<HardwareDisplayPlane>& r) { |
| 139 return l->plane_id() < r->plane_id(); | 139 return l->plane_id() < r->plane_id(); |
| 140 }); | 140 }); |
| 141 | 141 |
| 142 PopulateSupportedFormats(); | 142 PopulateSupportedFormats(); |
| 143 return true; | 143 return true; |
| 144 } | 144 } |
| 145 | 145 |
| 146 scoped_ptr<HardwareDisplayPlane> HardwareDisplayPlaneManager::CreatePlane( | 146 std::unique_ptr<HardwareDisplayPlane> HardwareDisplayPlaneManager::CreatePlane( |
| 147 uint32_t plane_id, | 147 uint32_t plane_id, |
| 148 uint32_t possible_crtcs) { | 148 uint32_t possible_crtcs) { |
| 149 return scoped_ptr<HardwareDisplayPlane>( | 149 return std::unique_ptr<HardwareDisplayPlane>( |
| 150 new HardwareDisplayPlane(plane_id, possible_crtcs)); | 150 new HardwareDisplayPlane(plane_id, possible_crtcs)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 HardwareDisplayPlane* HardwareDisplayPlaneManager::FindNextUnusedPlane( | 153 HardwareDisplayPlane* HardwareDisplayPlaneManager::FindNextUnusedPlane( |
| 154 size_t* index, | 154 size_t* index, |
| 155 uint32_t crtc_index, | 155 uint32_t crtc_index, |
| 156 const OverlayPlane& overlay) const { | 156 const OverlayPlane& overlay) const { |
| 157 for (size_t i = *index; i < planes_.size(); ++i) { | 157 for (size_t i = *index; i < planes_.size(); ++i) { |
| 158 auto plane = planes_[i].get(); | 158 auto plane = planes_[i].get(); |
| 159 if (!plane->in_use() && IsCompatible(plane, overlay, crtc_index)) { | 159 if (!plane->in_use() && IsCompatible(plane, overlay, crtc_index)) { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 break; | 326 break; |
| 327 } else { | 327 } else { |
| 328 plane_z_order++; | 328 plane_z_order++; |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 return format_supported; | 332 return format_supported; |
| 333 } | 333 } |
| 334 | 334 |
| 335 } // namespace ui | 335 } // namespace ui |
| OLD | NEW |