| 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 | 11 |
| 11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 14 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
| 15 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
| 16 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 17 #include "ui/gfx/swap_result.h" | 18 #include "ui/gfx/swap_result.h" |
| 18 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" | 19 #include "ui/ozone/platform/drm/gpu/crtc_controller.h" |
| 19 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" | 20 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" |
| 20 #include "ui/ozone/platform/drm/gpu/drm_device.h" | 21 #include "ui/ozone/platform/drm/gpu/drm_device.h" |
| 21 #include "ui/ozone/platform/drm/gpu/page_flip_request.h" | 22 #include "ui/ozone/platform/drm/gpu/page_flip_request.h" |
| 22 #include "ui/ozone/public/native_pixmap.h" | 23 #include "ui/ozone/public/native_pixmap.h" |
| 23 | 24 |
| 24 namespace ui { | 25 namespace ui { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 void EmptyFlipCallback(gfx::SwapResult) {} | 29 void EmptyFlipCallback(gfx::SwapResult) {} |
| 29 | 30 |
| 30 } // namespace | 31 } // namespace |
| 31 | 32 |
| 32 HardwareDisplayController::HardwareDisplayController( | 33 HardwareDisplayController::HardwareDisplayController( |
| 33 scoped_ptr<CrtcController> controller, | 34 scoped_ptr<CrtcController> controller, |
| 34 const gfx::Point& origin) | 35 const gfx::Point& origin) |
| 35 : origin_(origin), | 36 : origin_(origin), |
| 36 is_disabled_(controller->is_disabled()) { | 37 is_disabled_(controller->is_disabled()) { |
| 37 AddCrtc(controller.Pass()); | 38 AddCrtc(std::move(controller)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 HardwareDisplayController::~HardwareDisplayController() { | 41 HardwareDisplayController::~HardwareDisplayController() { |
| 41 // Reset the cursor. | 42 // Reset the cursor. |
| 42 UnsetCursor(); | 43 UnsetCursor(); |
| 43 } | 44 } |
| 44 | 45 |
| 45 bool HardwareDisplayController::Modeset(const OverlayPlane& primary, | 46 bool HardwareDisplayController::Modeset(const OverlayPlane& primary, |
| 46 drmModeModeInfo mode) { | 47 drmModeModeInfo mode) { |
| 47 TRACE_EVENT0("drm", "HDC::Modeset"); | 48 TRACE_EVENT0("drm", "HDC::Modeset"); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 const std::vector<scoped_ptr<HardwareDisplayPlane>>& all_planes = | 195 const std::vector<scoped_ptr<HardwareDisplayPlane>>& all_planes = |
| 195 drm->plane_manager()->planes(); | 196 drm->plane_manager()->planes(); |
| 196 HardwareDisplayPlaneList* crtc_plane_list = | 197 HardwareDisplayPlaneList* crtc_plane_list = |
| 197 owned_hardware_planes_.get(drm.get()); | 198 owned_hardware_planes_.get(drm.get()); |
| 198 uint32_t crtc = controller->crtc(); | 199 uint32_t crtc = controller->crtc(); |
| 199 for (const auto& plane : all_planes) { | 200 for (const auto& plane : all_planes) { |
| 200 if (plane->in_use() && (plane->owning_crtc() == crtc)) | 201 if (plane->in_use() && (plane->owning_crtc() == crtc)) |
| 201 crtc_plane_list->old_plane_list.push_back(plane.get()); | 202 crtc_plane_list->old_plane_list.push_back(plane.get()); |
| 202 } | 203 } |
| 203 | 204 |
| 204 crtc_controllers_.push_back(controller.Pass()); | 205 crtc_controllers_.push_back(std::move(controller)); |
| 205 } | 206 } |
| 206 | 207 |
| 207 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 208 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( |
| 208 const scoped_refptr<DrmDevice>& drm, | 209 const scoped_refptr<DrmDevice>& drm, |
| 209 uint32_t crtc) { | 210 uint32_t crtc) { |
| 210 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); | 211 for (auto it = crtc_controllers_.begin(); it != crtc_controllers_.end(); |
| 211 ++it) { | 212 ++it) { |
| 212 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { | 213 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { |
| 213 scoped_ptr<CrtcController> controller(std::move(*it)); | 214 scoped_ptr<CrtcController> controller(std::move(*it)); |
| 214 crtc_controllers_.erase(it); | 215 crtc_controllers_.erase(it); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 228 owned_hardware_planes_.get(drm.get()); | 229 owned_hardware_planes_.get(drm.get()); |
| 229 all_planes.swap(plane_list->old_plane_list); | 230 all_planes.swap(plane_list->old_plane_list); |
| 230 for (auto* plane : all_planes) { | 231 for (auto* plane : all_planes) { |
| 231 if (plane->owning_crtc() != crtc) | 232 if (plane->owning_crtc() != crtc) |
| 232 plane_list->old_plane_list.push_back(plane); | 233 plane_list->old_plane_list.push_back(plane); |
| 233 } | 234 } |
| 234 } else { | 235 } else { |
| 235 owned_hardware_planes_.erase(controller->drm().get()); | 236 owned_hardware_planes_.erase(controller->drm().get()); |
| 236 } | 237 } |
| 237 | 238 |
| 238 return controller.Pass(); | 239 return controller; |
| 239 } | 240 } |
| 240 } | 241 } |
| 241 | 242 |
| 242 return nullptr; | 243 return nullptr; |
| 243 } | 244 } |
| 244 | 245 |
| 245 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, | 246 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, |
| 246 uint32_t crtc) const { | 247 uint32_t crtc) const { |
| 247 for (const auto& controller : crtc_controllers_) { | 248 for (const auto& controller : crtc_controllers_) { |
| 248 if (controller->drm() == drm && controller->crtc() == crtc) | 249 if (controller->drm() == drm && controller->crtc() == crtc) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 278 | 279 |
| 279 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() | 280 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() |
| 280 const { | 281 const { |
| 281 DCHECK(!crtc_controllers_.empty()); | 282 DCHECK(!crtc_controllers_.empty()); |
| 282 // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 283 // TODO(dnicoara) When we support mirroring across DRM devices, figure out |
| 283 // which device should be used for allocations. | 284 // which device should be used for allocations. |
| 284 return crtc_controllers_[0]->drm(); | 285 return crtc_controllers_[0]->drm(); |
| 285 } | 286 } |
| 286 | 287 |
| 287 } // namespace ui | 288 } // namespace ui |
| OLD | NEW |