| 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/dri/hardware_display_controller.h" | 5 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 6 | 6 |
| 7 #include <drm.h> | 7 #include <drm.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <xf86drm.h> | 10 #include <xf86drm.h> |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 HardwareDisplayController::~HardwareDisplayController() { | 91 HardwareDisplayController::~HardwareDisplayController() { |
| 92 // Reset the cursor. | 92 // Reset the cursor. |
| 93 UnsetCursor(); | 93 UnsetCursor(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 bool HardwareDisplayController::Modeset(const OverlayPlane& primary, | 96 bool HardwareDisplayController::Modeset(const OverlayPlane& primary, |
| 97 drmModeModeInfo mode) { | 97 drmModeModeInfo mode) { |
| 98 TRACE_EVENT0("dri", "HDC::Modeset"); | 98 TRACE_EVENT0("dri", "HDC::Modeset"); |
| 99 DCHECK(primary.buffer); | 99 DCHECK(primary.buffer.get()); |
| 100 pending_page_flips_ = 0; | 100 pending_page_flips_ = 0; |
| 101 bool status = true; | 101 bool status = true; |
| 102 for (size_t i = 0; i < crtc_states_.size(); ++i) { | 102 for (size_t i = 0; i < crtc_states_.size(); ++i) { |
| 103 status &= ModesetCrtc(primary.buffer, mode, crtc_states_[i]); | 103 status &= ModesetCrtc(primary.buffer, mode, crtc_states_[i]); |
| 104 crtc_states_[i]->set_is_disabled(false); | 104 crtc_states_[i]->set_is_disabled(false); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Since a subset of controllers may be actively using |primary|, just keep | 107 // Since a subset of controllers may be actively using |primary|, just keep |
| 108 // track of it. | 108 // track of it. |
| 109 current_planes_ = std::vector<OverlayPlane>(1, primary); | 109 current_planes_ = std::vector<OverlayPlane>(1, primary); |
| 110 pending_planes_.clear(); | 110 pending_planes_.clear(); |
| 111 is_disabled_ = false; | 111 is_disabled_ = false; |
| 112 mode_ = mode; | 112 mode_ = mode; |
| 113 return status; | 113 return status; |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool HardwareDisplayController::Enable() { | 116 bool HardwareDisplayController::Enable() { |
| 117 TRACE_EVENT0("dri", "HDC::Enable"); | 117 TRACE_EVENT0("dri", "HDC::Enable"); |
| 118 DCHECK(!current_planes_.empty()); | 118 DCHECK(!current_planes_.empty()); |
| 119 OverlayPlane primary = GetPrimaryPlane(current_planes_); | 119 OverlayPlane primary = GetPrimaryPlane(current_planes_); |
| 120 DCHECK(primary.buffer); | 120 DCHECK(primary.buffer.get()); |
| 121 pending_page_flips_ = 0; | 121 pending_page_flips_ = 0; |
| 122 bool status = true; | 122 bool status = true; |
| 123 for (size_t i = 0; i < crtc_states_.size(); ++i) | 123 for (size_t i = 0; i < crtc_states_.size(); ++i) |
| 124 status &= ModesetCrtc(primary.buffer, mode_, crtc_states_[i]); | 124 status &= ModesetCrtc(primary.buffer, mode_, crtc_states_[i]); |
| 125 | 125 |
| 126 return status; | 126 return status; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void HardwareDisplayController::Disable() { | 129 void HardwareDisplayController::Disable() { |
| 130 TRACE_EVENT0("dri", "HDC::Disable"); | 130 TRACE_EVENT0("dri", "HDC::Disable"); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 return false; | 279 return false; |
| 280 } | 280 } |
| 281 | 281 |
| 282 return true; | 282 return true; |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool HardwareDisplayController::SchedulePageFlipOnCrtc( | 285 bool HardwareDisplayController::SchedulePageFlipOnCrtc( |
| 286 const OverlayPlaneList& overlays, | 286 const OverlayPlaneList& overlays, |
| 287 CrtcState* state) { | 287 CrtcState* state) { |
| 288 const OverlayPlane& primary = GetPrimaryPlane(overlays); | 288 const OverlayPlane& primary = GetPrimaryPlane(overlays); |
| 289 DCHECK(primary.buffer); | 289 DCHECK(primary.buffer.get()); |
| 290 | 290 |
| 291 if (primary.buffer->GetSize() != gfx::Size(mode_.hdisplay, mode_.vdisplay)) { | 291 if (primary.buffer->GetSize() != gfx::Size(mode_.hdisplay, mode_.vdisplay)) { |
| 292 LOG(WARNING) << "Trying to pageflip a buffer with the wrong size. Expected " | 292 LOG(WARNING) << "Trying to pageflip a buffer with the wrong size. Expected " |
| 293 << mode_.hdisplay << "x" << mode_.vdisplay | 293 << mode_.hdisplay << "x" << mode_.vdisplay |
| 294 << " got " << primary.buffer->GetSize().ToString() << " for" | 294 << " got " << primary.buffer->GetSize().ToString() << " for" |
| 295 << " crtc=" << state->crtc() | 295 << " crtc=" << state->crtc() |
| 296 << " connector=" << state->connector(); | 296 << " connector=" << state->connector(); |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 | 299 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 324 plane.overlay_plane)) { | 324 plane.overlay_plane)) { |
| 325 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno); | 325 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno); |
| 326 return false; | 326 return false; |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 | 329 |
| 330 return true; | 330 return true; |
| 331 } | 331 } |
| 332 | 332 |
| 333 } // namespace ui | 333 } // namespace ui |
| OLD | NEW |