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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 const OverlayPlaneList& overlay_list, | 225 const OverlayPlaneList& overlay_list, |
226 uint32_t crtc_id, | 226 uint32_t crtc_id, |
227 CrtcController* crtc) { | 227 CrtcController* crtc) { |
228 int crtc_index = LookupCrtcIndex(crtc_id); | 228 int crtc_index = LookupCrtcIndex(crtc_id); |
229 if (crtc_index < 0) { | 229 if (crtc_index < 0) { |
230 LOG(ERROR) << "Cannot find crtc " << crtc_id; | 230 LOG(ERROR) << "Cannot find crtc " << crtc_id; |
231 return false; | 231 return false; |
232 } | 232 } |
233 | 233 |
234 size_t plane_idx = 0; | 234 size_t plane_idx = 0; |
235 HardwareDisplayPlane* primary_plane = nullptr; | |
236 gfx::Rect primary_display_bounds; | |
237 for (const auto& plane : overlay_list) { | 235 for (const auto& plane : overlay_list) { |
238 HardwareDisplayPlane* hw_plane = | 236 HardwareDisplayPlane* hw_plane = |
239 FindNextUnusedPlane(&plane_idx, crtc_index, plane); | 237 FindNextUnusedPlane(&plane_idx, crtc_index, plane); |
240 if (!hw_plane) { | 238 if (!hw_plane) { |
241 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; | 239 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; |
242 ResetCurrentPlaneList(plane_list); | 240 ResetCurrentPlaneList(plane_list); |
243 return false; | 241 return false; |
244 } | 242 } |
245 | 243 |
246 gfx::Rect fixed_point_rect; | 244 gfx::Rect fixed_point_rect; |
247 uint32_t fourcc_format = plane.buffer->GetFramebufferPixelFormat(); | |
248 if (hw_plane->type() != HardwareDisplayPlane::kDummy) { | 245 if (hw_plane->type() != HardwareDisplayPlane::kDummy) { |
249 const gfx::Size& size = plane.buffer->GetSize(); | 246 const gfx::Size& size = plane.buffer->GetSize(); |
250 gfx::RectF crop_rect = plane.crop_rect; | 247 gfx::RectF crop_rect = plane.crop_rect; |
251 crop_rect.Scale(size.width(), size.height()); | 248 crop_rect.Scale(size.width(), size.height()); |
252 | 249 |
253 // This returns a number in 16.16 fixed point, required by the DRM overlay | 250 // This returns a number in 16.16 fixed point, required by the DRM overlay |
254 // APIs. | 251 // APIs. |
255 auto to_fixed_point = | 252 auto to_fixed_point = |
256 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; | 253 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; |
257 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), | 254 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), |
258 to_fixed_point(crop_rect.y()), | 255 to_fixed_point(crop_rect.y()), |
259 to_fixed_point(crop_rect.width()), | 256 to_fixed_point(crop_rect.width()), |
260 to_fixed_point(crop_rect.height())); | 257 to_fixed_point(crop_rect.height())); |
261 } | 258 } |
262 | 259 |
263 // If Overlay completely covers primary and isn't transparent, than use | |
264 // it as primary. This reduces the no of planes which need to be read in | |
265 // display controller side. | |
266 if (primary_plane) { | |
267 // TODO(dcastagna): Check if we can move this optimization to | |
268 // GLRenderer::ScheduleOverlays. | |
269 // Note that Chromium compositor promotes buffers to overlays (ABGR | |
270 // ones too) only if blending is not needed. | |
271 // TODO(dcastagna): this should check if the format is the same as | |
272 // primary_plane->format minus alpha. Changing the format of the primary | |
273 // plane currently works on rockchip with 3.14 kernel and won't work with | |
274 // newer kernels. Remove this hack as soon as we can switch the primary | |
275 // plane format to match overlay buffers formats. | |
276 if ((fourcc_format == DRM_FORMAT_XBGR8888 || | |
277 fourcc_format == DRM_FORMAT_ABGR8888 || | |
278 fourcc_format == DRM_FORMAT_XRGB8888 || | |
279 fourcc_format == DRM_FORMAT_ARGB8888) && | |
280 primary_display_bounds == plane.display_bounds) { | |
281 ResetCurrentPlaneList(plane_list); | |
282 hw_plane = primary_plane; | |
283 } | |
284 } else { | |
285 primary_plane = hw_plane; | |
286 primary_display_bounds = plane.display_bounds; | |
287 } | |
288 | |
289 if (!SetPlaneData(plane_list, hw_plane, plane, crtc_id, fixed_point_rect, | 260 if (!SetPlaneData(plane_list, hw_plane, plane, crtc_id, fixed_point_rect, |
290 crtc)) { | 261 crtc)) { |
291 ResetCurrentPlaneList(plane_list); | 262 ResetCurrentPlaneList(plane_list); |
292 return false; | 263 return false; |
293 } | 264 } |
294 | 265 |
295 plane_list->plane_list.push_back(hw_plane); | 266 plane_list->plane_list.push_back(hw_plane); |
296 hw_plane->set_owning_crtc(crtc_id); | 267 hw_plane->set_owning_crtc(crtc_id); |
297 hw_plane->set_in_use(true); | 268 hw_plane->set_in_use(true); |
298 } | 269 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 break; | 302 break; |
332 } else { | 303 } else { |
333 plane_z_order++; | 304 plane_z_order++; |
334 } | 305 } |
335 } | 306 } |
336 | 307 |
337 return format_supported; | 308 return format_supported; |
338 } | 309 } |
339 | 310 |
340 } // namespace ui | 311 } // namespace ui |
OLD | NEW |