| 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_plane_manager_legacy.h" | 5 #include "ui/ozone/platform/dri/hardware_display_plane_manager_legacy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ui/ozone/platform/dri/crtc_controller.h" | 8 #include "ui/ozone/platform/dri/crtc_controller.h" |
| 9 #include "ui/ozone/platform/dri/dri_wrapper.h" | 9 #include "ui/ozone/platform/dri/dri_wrapper.h" |
| 10 #include "ui/ozone/platform/dri/scanout_buffer.h" | 10 #include "ui/ozone/platform/dri/scanout_buffer.h" |
| 11 | 11 |
| 12 namespace ui { | 12 namespace ui { |
| 13 | 13 |
| 14 HardwareDisplayPlaneManagerLegacy::HardwareDisplayPlaneManagerLegacy() { | 14 HardwareDisplayPlaneManagerLegacy::HardwareDisplayPlaneManagerLegacy() { |
| 15 } | 15 } |
| 16 | 16 |
| 17 HardwareDisplayPlaneManagerLegacy::~HardwareDisplayPlaneManagerLegacy() { | 17 HardwareDisplayPlaneManagerLegacy::~HardwareDisplayPlaneManagerLegacy() { |
| 18 } | 18 } |
| 19 | 19 |
| 20 bool HardwareDisplayPlaneManagerLegacy::Commit( | 20 bool HardwareDisplayPlaneManagerLegacy::Commit( |
| 21 HardwareDisplayPlaneList* plane_list) { | 21 HardwareDisplayPlaneList* plane_list, |
| 22 bool is_sync) { |
| 22 if (plane_list->plane_list.empty()) // No assigned planes, nothing to do. | 23 if (plane_list->plane_list.empty()) // No assigned planes, nothing to do. |
| 23 return true; | 24 return true; |
| 24 bool ret = true; | 25 bool ret = true; |
| 25 // The order of operations here (set new planes, pageflip, clear old planes) | 26 // The order of operations here (set new planes, pageflip, clear old planes) |
| 26 // is designed to minimze the chance of a significant artifact occurring. | 27 // is designed to minimze the chance of a significant artifact occurring. |
| 27 // The planes must be updated first because the main plane no longer contains | 28 // The planes must be updated first because the main plane no longer contains |
| 28 // their content. The old planes are removed last because the previous primary | 29 // their content. The old planes are removed last because the previous primary |
| 29 // plane used them as overlays and thus didn't contain their content, so we | 30 // plane used them as overlays and thus didn't contain their content, so we |
| 30 // must first flip to the new primary plane, which does. The error here will | 31 // must first flip to the new primary plane, which does. The error here will |
| 31 // be the delta of (new contents, old contents), but it should be barely | 32 // be the delta of (new contents, old contents), but it should be barely |
| 32 // noticeable. | 33 // noticeable. |
| 33 for (const auto& flip : plane_list->legacy_page_flips) { | 34 for (const auto& flip : plane_list->legacy_page_flips) { |
| 34 // Permission Denied is a legitimate error | 35 // Permission Denied is a legitimate error |
| 35 for (const auto& plane : flip.planes) { | 36 for (const auto& plane : flip.planes) { |
| 36 if (!drm_->PageFlipOverlay(flip.crtc_id, plane.framebuffer, plane.bounds, | 37 if (!drm_->PageFlipOverlay(flip.crtc_id, plane.framebuffer, plane.bounds, |
| 37 plane.src_rect, plane.plane)) { | 38 plane.src_rect, plane.plane)) { |
| 38 LOG(ERROR) << "Cannot display plane on overlay: error=" | 39 LOG(ERROR) << "Cannot display plane on overlay: error=" |
| 39 << strerror(errno) << "crtc=" << flip.crtc | 40 << strerror(errno) << "crtc=" << flip.crtc |
| 40 << " plane=" << plane.plane; | 41 << " plane=" << plane.plane; |
| 41 ret = false; | 42 ret = false; |
| 42 flip.crtc->PageFlipFailed(); | 43 flip.crtc->PageFlipFailed(); |
| 43 break; | 44 break; |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 if (!drm_->PageFlip(flip.crtc_id, flip.framebuffer, | 47 if (!drm_->PageFlip(flip.crtc_id, flip.framebuffer, is_sync, |
| 47 base::Bind(&CrtcController::OnPageFlipEvent, | 48 base::Bind(&CrtcController::OnPageFlipEvent, |
| 48 flip.crtc->AsWeakPtr()))) { | 49 flip.crtc->AsWeakPtr()))) { |
| 49 if (errno != EACCES) { | 50 if (errno != EACCES) { |
| 50 LOG(ERROR) << "Cannot page flip: error='" << strerror(errno) << "'" | 51 LOG(ERROR) << "Cannot page flip: error='" << strerror(errno) << "'" |
| 51 << " crtc=" << flip.crtc_id | 52 << " crtc=" << flip.crtc_id |
| 52 << " framebuffer=" << flip.framebuffer; | 53 << " framebuffer=" << flip.framebuffer |
| 54 << " is_sync=" << is_sync; |
| 53 LOG(ERROR) << "Failed to commit planes"; | 55 LOG(ERROR) << "Failed to commit planes"; |
| 54 ret = false; | 56 ret = false; |
| 55 } | 57 } |
| 56 flip.crtc->PageFlipFailed(); | 58 flip.crtc->PageFlipFailed(); |
| 57 } | 59 } |
| 58 } | 60 } |
| 59 // For each element in |old_plane_list|, if it hasn't been reclaimed (by | 61 // For each element in |old_plane_list|, if it hasn't been reclaimed (by |
| 60 // this or any other HDPL), clear the overlay contents. | 62 // this or any other HDPL), clear the overlay contents. |
| 61 for (HardwareDisplayPlane* plane : plane_list->old_plane_list) { | 63 for (HardwareDisplayPlane* plane : plane_list->old_plane_list) { |
| 62 if (!plane->in_use()) { | 64 if (!plane->in_use()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 } else { | 96 } else { |
| 95 plane_list->legacy_page_flips.back().planes.push_back( | 97 plane_list->legacy_page_flips.back().planes.push_back( |
| 96 HardwareDisplayPlaneList::PageFlipInfo::Plane( | 98 HardwareDisplayPlaneList::PageFlipInfo::Plane( |
| 97 hw_plane->plane_id(), overlay.buffer->GetFramebufferId(), | 99 hw_plane->plane_id(), overlay.buffer->GetFramebufferId(), |
| 98 overlay.display_bounds, src_rect)); | 100 overlay.display_bounds, src_rect)); |
| 99 } | 101 } |
| 100 return true; | 102 return true; |
| 101 } | 103 } |
| 102 | 104 |
| 103 } // namespace ui | 105 } // namespace ui |
| OLD | NEW |