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 | 11 |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 14 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
14 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" | 15 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h" |
15 | 16 |
16 namespace ui { | 17 namespace ui { |
17 namespace { | 18 namespace { |
18 | 19 |
19 const float kFixedPointScaleValue = 65536.0f; | 20 const float kFixedPointScaleValue = 65536.0f; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 102 |
102 std::vector<uint32_t> supported_formats(formats_size); | 103 std::vector<uint32_t> supported_formats(formats_size); |
103 for (uint32_t j = 0; j < formats_size; j++) | 104 for (uint32_t j = 0; j < formats_size; j++) |
104 supported_formats[j] = drm_plane->formats[j]; | 105 supported_formats[j] = drm_plane->formats[j]; |
105 | 106 |
106 if (plane->Initialize(drm, supported_formats, false, false)) { | 107 if (plane->Initialize(drm, supported_formats, false, false)) { |
107 // CRTC controllers always assume they have a cursor plane and the cursor | 108 // CRTC controllers always assume they have a cursor plane and the cursor |
108 // plane is updated via cursor specific DRM API. Hence, we dont keep | 109 // plane is updated via cursor specific DRM API. Hence, we dont keep |
109 // track of Cursor plane here to avoid re-using it for any other purpose. | 110 // track of Cursor plane here to avoid re-using it for any other purpose. |
110 if (plane->type() != HardwareDisplayPlane::kCursor) | 111 if (plane->type() != HardwareDisplayPlane::kCursor) |
111 planes_.push_back(plane.Pass()); | 112 planes_.push_back(std::move(plane)); |
112 } | 113 } |
113 } | 114 } |
114 | 115 |
115 // crbug.com/464085: if driver reports no primary planes for a crtc, create a | 116 // 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. | 117 // dummy plane for which we can assign exactly one overlay. |
117 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move | 118 // TODO(dnicoara): refactor this to simplify AssignOverlayPlanes and move |
118 // this workaround into HardwareDisplayPlaneLegacy. | 119 // this workaround into HardwareDisplayPlaneLegacy. |
119 if (!has_universal_planes) { | 120 if (!has_universal_planes) { |
120 for (int i = 0; i < resources->count_crtcs; ++i) { | 121 for (int i = 0; i < resources->count_crtcs; ++i) { |
121 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { | 122 if (plane_ids.find(resources->crtcs[i] - 1) == plane_ids.end()) { |
122 scoped_ptr<HardwareDisplayPlane> dummy_plane( | 123 scoped_ptr<HardwareDisplayPlane> dummy_plane( |
123 CreatePlane(resources->crtcs[i] - 1, (1 << i))); | 124 CreatePlane(resources->crtcs[i] - 1, (1 << i))); |
124 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true, | 125 if (dummy_plane->Initialize(drm, std::vector<uint32_t>(), true, |
125 false)) { | 126 false)) { |
126 planes_.push_back(dummy_plane.Pass()); | 127 planes_.push_back(std::move(dummy_plane)); |
127 } | 128 } |
128 } | 129 } |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 std::sort(planes_.begin(), planes_.end(), | 133 std::sort(planes_.begin(), planes_.end(), |
133 [](const scoped_ptr<HardwareDisplayPlane>& l, | 134 [](const scoped_ptr<HardwareDisplayPlane>& l, |
134 const scoped_ptr<HardwareDisplayPlane>& r) { | 135 const scoped_ptr<HardwareDisplayPlane>& r) { |
135 return l->plane_id() < r->plane_id(); | 136 return l->plane_id() < r->plane_id(); |
136 }); | 137 }); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 std::vector<uint32_t> plane_ids; | 293 std::vector<uint32_t> plane_ids; |
293 for (const auto& hardware_plane : planes_) { | 294 for (const auto& hardware_plane : planes_) { |
294 if (IsCompatible(hardware_plane.get(), plane, crtc_index)) | 295 if (IsCompatible(hardware_plane.get(), plane, crtc_index)) |
295 plane_ids.push_back(hardware_plane->plane_id()); | 296 plane_ids.push_back(hardware_plane->plane_id()); |
296 } | 297 } |
297 | 298 |
298 return plane_ids; | 299 return plane_ids; |
299 } | 300 } |
300 | 301 |
301 } // namespace ui | 302 } // namespace ui |
OLD | NEW |