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_controller.h" | 5 #include "ui/ozone/platform/drm/gpu/hardware_display_controller.h" |
6 | 6 |
7 #include <drm.h> | 7 #include <drm.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <xf86drm.h> | 9 #include <xf86drm.h> |
10 #include <utility> | 10 #include <utility> |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace ui { | 24 namespace ui { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 void EmptyFlipCallback(gfx::SwapResult) {} | 28 void EmptyFlipCallback(gfx::SwapResult) {} |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 HardwareDisplayController::HardwareDisplayController( | 32 HardwareDisplayController::HardwareDisplayController( |
33 scoped_ptr<CrtcController> controller, | 33 std::unique_ptr<CrtcController> controller, |
34 const gfx::Point& origin) | 34 const gfx::Point& origin) |
35 : origin_(origin), | 35 : origin_(origin), is_disabled_(controller->is_disabled()) { |
36 is_disabled_(controller->is_disabled()) { | |
37 AddCrtc(std::move(controller)); | 36 AddCrtc(std::move(controller)); |
38 } | 37 } |
39 | 38 |
40 HardwareDisplayController::~HardwareDisplayController() { | 39 HardwareDisplayController::~HardwareDisplayController() { |
41 // Reset the cursor. | 40 // Reset the cursor. |
42 UnsetCursor(); | 41 UnsetCursor(); |
43 } | 42 } |
44 | 43 |
45 bool HardwareDisplayController::Modeset(const OverlayPlane& primary, | 44 bool HardwareDisplayController::Modeset(const OverlayPlane& primary, |
46 drmModeModeInfo mode) { | 45 drmModeModeInfo mode) { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (is_disabled_) | 168 if (is_disabled_) |
170 return true; | 169 return true; |
171 | 170 |
172 bool status = true; | 171 bool status = true; |
173 for (const auto& controller : crtc_controllers_) | 172 for (const auto& controller : crtc_controllers_) |
174 status &= controller->MoveCursor(location); | 173 status &= controller->MoveCursor(location); |
175 | 174 |
176 return status; | 175 return status; |
177 } | 176 } |
178 | 177 |
179 void HardwareDisplayController::AddCrtc(scoped_ptr<CrtcController> controller) { | 178 void HardwareDisplayController::AddCrtc( |
| 179 std::unique_ptr<CrtcController> controller) { |
180 scoped_refptr<DrmDevice> drm = controller->drm(); | 180 scoped_refptr<DrmDevice> drm = controller->drm(); |
181 owned_hardware_planes_.add(drm.get(), scoped_ptr<HardwareDisplayPlaneList>( | 181 owned_hardware_planes_.add(drm.get(), |
182 new HardwareDisplayPlaneList())); | 182 std::unique_ptr<HardwareDisplayPlaneList>( |
| 183 new HardwareDisplayPlaneList())); |
183 | 184 |
184 // Check if this controller owns any planes and ensure we keep track of them. | 185 // Check if this controller owns any planes and ensure we keep track of them. |
185 const std::vector<scoped_ptr<HardwareDisplayPlane>>& all_planes = | 186 const std::vector<std::unique_ptr<HardwareDisplayPlane>>& all_planes = |
186 drm->plane_manager()->planes(); | 187 drm->plane_manager()->planes(); |
187 HardwareDisplayPlaneList* crtc_plane_list = | 188 HardwareDisplayPlaneList* crtc_plane_list = |
188 owned_hardware_planes_.get(drm.get()); | 189 owned_hardware_planes_.get(drm.get()); |
189 uint32_t crtc = controller->crtc(); | 190 uint32_t crtc = controller->crtc(); |
190 for (const auto& plane : all_planes) { | 191 for (const auto& plane : all_planes) { |
191 if (plane->in_use() && (plane->owning_crtc() == crtc)) | 192 if (plane->in_use() && (plane->owning_crtc() == crtc)) |
192 crtc_plane_list->old_plane_list.push_back(plane.get()); | 193 crtc_plane_list->old_plane_list.push_back(plane.get()); |
193 } | 194 } |
194 | 195 |
195 crtc_controllers_.push_back(std::move(controller)); | 196 crtc_controllers_.push_back(std::move(controller)); |
196 } | 197 } |
197 | 198 |
198 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 199 std::unique_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( |
199 const scoped_refptr<DrmDevice>& drm, | 200 const scoped_refptr<DrmDevice>& drm, |
200 uint32_t crtc) { | 201 uint32_t crtc) { |
201 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); | 202 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); |
202 ++it) { | 203 ++it) { |
203 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { | 204 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { |
204 scoped_ptr<CrtcController> controller(std::move(*it)); | 205 std::unique_ptr<CrtcController> controller(std::move(*it)); |
205 crtc_controllers_.erase(it); | 206 crtc_controllers_.erase(it); |
206 | 207 |
207 // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. | 208 // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. |
208 bool found = false; | 209 bool found = false; |
209 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); | 210 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); |
210 ++it) { | 211 ++it) { |
211 if ((*it)->drm() == controller->drm()) { | 212 if ((*it)->drm() == controller->drm()) { |
212 found = true; | 213 found = true; |
213 break; | 214 break; |
214 } | 215 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 270 |
270 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 271 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() |
271 const { | 272 const { |
272 DCHECK(!crtc_controllers_.empty()); | 273 DCHECK(!crtc_controllers_.empty()); |
273 // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 274 // TODO(dnicoara) When we support mirroring across DRM devices, figure out |
274 // which device should be used for allocations. | 275 // which device should be used for allocations. |
275 return crtc_controllers_[0]->drm(); | 276 return crtc_controllers_[0]->drm(); |
276 } | 277 } |
277 | 278 |
278 } // namespace ui | 279 } // namespace ui |
OLD | NEW |