| 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 planes_.push_back(plane.Pass()); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 // crbug.com/464085: if driver reports no primary planes for a crtc, create a | 115 // 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. | 116 // dummy plane for which we can assign exactly one overlay. |
| 117 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 117 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
| 118 // this workaround into HardwareDisplayPlaneLegacy. | 118 // this workaround into HardwareDisplayPlaneLegacy. |
| 119 if (!has_universal_planes) { | 119 if (!has_universal_planes) { |
| 120 for (int i = 0; i < resources->count_crtcs; ++i) { | 120 for (int i = 0; i < resources->count_crtcs; ++i) { |
| 121 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 121 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
| 122 scoped_ptr<HardwareDisplayPlane> dummy_plane( | 122 scoped_ptr<HardwareDisplayPlane> dummy_plane( |
| 123 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 123 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
| 124 dummy_plane->set_is_dummy(true); | 124 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()); | 125 planes_.push_back(dummy_plane.Pass()); |
| 127 } | 126 } |
| 128 } | 127 } |
| 129 } | 128 } |
| 130 } | 129 } |
| 131 | 130 |
| 132 std::sort(planes_.begin(), planes_.end(), | 131 std::sort(planes_.begin(), planes_.end(), |
| 133 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { | 132 [](HardwareDisplayPlane* l, HardwareDisplayPlane* r) { |
| 134 return l->plane_id() < r->plane_id(); | 133 return l->plane_id() < r->plane_id(); |
| 135 }); | 134 }); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 size_t plane_idx = 0; | 185 size_t plane_idx = 0; |
| 187 for (const auto& plane : overlay_list) { | 186 for (const auto& plane : overlay_list) { |
| 188 HardwareDisplayPlane* hw_plane = | 187 HardwareDisplayPlane* hw_plane = |
| 189 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat()); | 188 FindNextUnusedPlane(&plane_idx, crtc_index, plane.buffer->GetFormat()); |
| 190 if (!hw_plane) { | 189 if (!hw_plane) { |
| 191 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; | 190 LOG(ERROR) << "Failed to find a free plane for crtc " << crtc_id; |
| 192 return false; | 191 return false; |
| 193 } | 192 } |
| 194 | 193 |
| 195 gfx::Rect fixed_point_rect; | 194 gfx::Rect fixed_point_rect; |
| 196 if (!hw_plane->is_dummy()) { | 195 if (hw_plane->type() != HardwareDisplayPlane::Dummy) { |
| 197 const gfx::Size& size = plane.buffer->GetSize(); | 196 const gfx::Size& size = plane.buffer->GetSize(); |
| 198 gfx::RectF crop_rect = plane.crop_rect; | 197 gfx::RectF crop_rect = plane.crop_rect; |
| 199 crop_rect.Scale(size.width(), size.height()); | 198 crop_rect.Scale(size.width(), size.height()); |
| 200 | 199 |
| 201 // This returns a number in 16.16 fixed point, required by the DRM overlay | 200 // This returns a number in 16.16 fixed point, required by the DRM overlay |
| 202 // APIs. | 201 // APIs. |
| 203 auto to_fixed_point = | 202 auto to_fixed_point = |
| 204 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; | 203 [](double v) -> uint32_t { return v * kFixedPointScaleValue; }; |
| 205 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), | 204 fixed_point_rect = gfx::Rect(to_fixed_point(crop_rect.x()), |
| 206 to_fixed_point(crop_rect.y()), | 205 to_fixed_point(crop_rect.y()), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 229 if (plane->owning_crtc() == crtc_id) { | 228 if (plane->owning_crtc() == crtc_id) { |
| 230 plane->set_owning_crtc(0); | 229 plane->set_owning_crtc(0); |
| 231 plane->set_in_use(false); | 230 plane->set_in_use(false); |
| 232 } else { | 231 } else { |
| 233 plane_list->old_plane_list.push_back(plane); | 232 plane_list->old_plane_list.push_back(plane); |
| 234 } | 233 } |
| 235 } | 234 } |
| 236 } | 235 } |
| 237 | 236 |
| 238 } // namespace ui | 237 } // namespace ui |
| OLD | NEW |