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.h> | 7 #include <drm.h> |
8 #include <xf86drm.h> | 8 #include <xf86drm.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 scoped_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.push_back(drm_plane->formats[j]); | 108 supported_formats.push_back(drm_plane->formats[j]); |
109 | 109 |
110 if (plane->Initialize(drm, supported_formats)) { | 110 if (plane->Initialize(drm, supported_formats, false)) { |
111 planes_.push_back(plane.Pass()); | 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 |
| 113 // track of Cursor plane here to avoid re-using it for any other purpose. |
| 114 if (plane->type() != HardwareDisplayPlane::kCursor) |
| 115 planes_.push_back(plane.Pass()); |
112 } | 116 } |
113 } | 117 } |
114 | 118 |
115 // 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 |
116 // dummy plane for which we can assign exactly one overlay. | 120 // dummy plane for which we can assign exactly one overlay. |
117 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 121 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
118 // this workaround into HardwareDisplayPlaneLegacy. | 122 // this workaround into HardwareDisplayPlaneLegacy. |
119 if (!has_universal_planes) { | 123 if (!has_universal_planes) { |
120 for (int i = 0; i < resources->count_crtcs; ++i) { | 124 for (int i = 0; i < resources->count_crtcs; ++i) { |
121 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 125 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
122 scoped_ptr<HardwareDisplayPlane> dummy_plane( | 126 scoped_ptr<HardwareDisplayPlane> dummy_plane( |
123 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 127 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
124 dummy_plane->set_is_dummy(true); | 128 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true)) { |
125 if (dummy_plane->Initialize(drm, std::vector<uint32_t>())) { | |
126 planes_.push_back(dummy_plane.Pass()); | 129 planes_.push_back(dummy_plane.Pass()); |
127 } | 130 } |
128 } | 131 } |
129 } | 132 } |
130 } | 133 } |
131 | 134 |
132 std::sort(planes_.begin(), planes_.end(), | 135 std::sort(planes_.begin(), planes_.end(), |
133 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { | 136 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { |
134 return l->plane_id() < r->plane_id(); | 137 return l->plane_id() < r->plane_id(); |
135 }); | 138 }); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 size_t plane_idx = 0; | 189 size_t plane_idx = 0; |
187 for (const auto& plane : overlay_list) { | 190 for (const auto& plane : overlay_list) { |
188 HardwareDisplayPlane* hw_plane = | 191 HardwareDisplayPlane* hw_plane = |
189 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat()); | 192 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat()); |
190 if (!hw_plane) { | 193 if (!hw_plane) { |
191 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; | 194 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; |
192 return false; | 195 return false; |
193 } | 196 } |
194 | 197 |
195 gfx::Rect fixed_point_rect; | 198 gfx::Rect fixed_point_rect; |
196 if (!hw_plane->is_dummy()) { | 199 if (hw_plane->type() != HardwareDisplayPlane::kDummy) { |
197 const gfx::Size& size = plane.buffer->GetSize(); | 200 const gfx::Size& size = plane.buffer->GetSize(); |
198 gfx::RectF crop_rect = plane.crop_rect; | 201 gfx::RectF crop_rect = plane.crop_rect; |
199 crop_rect.Scale(size.width(), size.height()); | 202 crop_rect.Scale(size.width(), size.height()); |
200 | 203 |
201 // This returns a number in 16.16 fixed point, required by the DRM overlay | 204 // This returns a number in 16.16 fixed point, required by the DRM overlay |
202 // APIs. | 205 // APIs. |
203 auto to_fixed_point = | 206 auto to_fixed_point = |
204 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; | 207 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; |
205 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), | 208 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), |
206 to_fixed_point(crop_rect.y()), | 209 to_fixed_point(crop_rect.y()), |
(...skipping 22 matching lines...) Expand all Loading... |
229 if (plane->owning_crtc() == crtc_id) { | 232 if (plane->owning_crtc() == crtc_id) { |
230 plane->set_owning_crtc(0); | 233 plane->set_owning_crtc(0); |
231 plane->set_in_use(false); | 234 plane->set_in_use(false); |
232 } else { | 235 } else { |
233 plane_list->old_plane_list.push_back(plane); | 236 plane_list->old_plane_list.push_back(plane); |
234 } | 237 } |
235 } | 238 } |
236 } | 239 } |
237 | 240 |
238 } // namespace ui | 241 } // namespace ui |
OLD | NEW |