Chromium Code Reviews| 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 if (plane_list->plane_list.empty()) // No assigned planes, nothing to do. | 22 if (plane_list->plane_list.empty()) // No assigned planes, nothing to do. |
| 23 return true; | 23 return true; |
| 24 bool ret = true; | 24 bool ret = true; |
| 25 plane_list->plane_list.swap(plane_list->old_plane_list); | |
| 26 plane_list->plane_list.clear(); | |
| 27 for (const auto& flip : plane_list->legacy_page_flips) { | 25 for (const auto& flip : plane_list->legacy_page_flips) { |
|
dnicoara
2015/01/16 21:40:08
Add a comment before the for-loop mentioning why t
achaulk
2015/01/21 21:50:53
Done.
| |
| 28 // Permission Denied is a legitimate error | 26 // Permission Denied is a legitimate error |
| 27 for (const auto& plane : flip.planes) { | |
| 28 if (!drm_->PageFlipOverlay(flip.crtc_id, plane.framebuffer, plane.bounds, | |
| 29 plane.src_rect, plane.plane)) { | |
| 30 LOG(ERROR) << "Cannot display plane on overlay: error=" | |
| 31 << strerror(errno) << "crtc=" << flip.crtc | |
| 32 << " plane=" << plane.plane; | |
| 33 ret = false; | |
| 34 flip.crtc->PageFlipFailed(); | |
| 35 break; | |
| 36 } | |
| 37 } | |
| 29 if (!drm_->PageFlip(flip.crtc_id, flip.framebuffer, | 38 if (!drm_->PageFlip(flip.crtc_id, flip.framebuffer, |
| 30 base::Bind(&CrtcController::OnPageFlipEvent, | 39 base::Bind(&CrtcController::OnPageFlipEvent, |
| 31 flip.crtc->AsWeakPtr()))) { | 40 flip.crtc->AsWeakPtr()))) { |
| 32 if (errno != EACCES) { | 41 if (errno != EACCES) { |
| 33 LOG(ERROR) << "Cannot page flip: error='" << strerror(errno) << "'" | 42 LOG(ERROR) << "Cannot page flip: error='" << strerror(errno) << "'" |
| 34 << " crtc=" << flip.crtc_id | 43 << " crtc=" << flip.crtc_id |
| 35 << " framebuffer=" << flip.framebuffer; | 44 << " framebuffer=" << flip.framebuffer; |
| 36 LOG(ERROR) << "Failed to commit planes"; | 45 LOG(ERROR) << "Failed to commit planes"; |
| 37 ret = false; | 46 ret = false; |
| 38 } | 47 } |
| 39 flip.crtc->PageFlipFailed(); | 48 flip.crtc->PageFlipFailed(); |
| 40 } else { | 49 } |
| 41 for (const auto& plane : flip.planes) { | 50 } |
| 42 if (!drm_->PageFlipOverlay(flip.crtc_id, plane.framebuffer, | 51 for (HardwareDisplayPlane* plane : plane_list->old_plane_list) { |
|
dnicoara
2015/01/16 21:40:08
Should this be done before the PageFlip()? I think
achaulk
2015/01/21 21:50:53
No, it only changes planes that haven't been re-us
| |
| 43 plane.bounds, plane.src_rect, plane.plane)) { | 52 bool found = |
| 44 LOG(ERROR) << "Cannot display plane on overlay: error=" | 53 std::find(plane_list->plane_list.begin(), plane_list->plane_list.end(), |
| 45 << strerror(errno); | 54 plane) != plane_list->plane_list.end(); |
| 46 ret = false; | 55 if (!found && !plane->in_use()) { |
| 47 flip.crtc->PageFlipFailed(); | 56 // This plane is being released, so we need to zero it. |
| 48 break; | 57 if (!drm_->PageFlipOverlay(plane->owning_crtc(), 0, gfx::Rect(), |
| 49 } | 58 gfx::Rect(), plane->plane_id())) { |
| 59 LOG(ERROR) << "Cannot free overlay: error=" << strerror(errno) | |
| 60 << "crtc=" << plane->owning_crtc() | |
| 61 << " plane=" << plane->plane_id(); | |
| 62 ret = false; | |
| 63 break; | |
| 50 } | 64 } |
| 51 } | 65 } |
| 52 } | 66 } |
| 67 plane_list->plane_list.swap(plane_list->old_plane_list); | |
| 68 plane_list->plane_list.clear(); | |
| 53 plane_list->legacy_page_flips.clear(); | 69 plane_list->legacy_page_flips.clear(); |
| 70 plane_list->committed = true; | |
| 54 return ret; | 71 return ret; |
| 55 } | 72 } |
| 56 | 73 |
| 57 bool HardwareDisplayPlaneManagerLegacy::SetPlaneData( | 74 bool HardwareDisplayPlaneManagerLegacy::SetPlaneData( |
| 58 HardwareDisplayPlaneList* plane_list, | 75 HardwareDisplayPlaneList* plane_list, |
| 59 HardwareDisplayPlane* hw_plane, | 76 HardwareDisplayPlane* hw_plane, |
| 60 const OverlayPlane& overlay, | 77 const OverlayPlane& overlay, |
| 61 uint32_t crtc_id, | 78 uint32_t crtc_id, |
| 62 const gfx::Rect& src_rect, | 79 const gfx::Rect& src_rect, |
| 63 CrtcController* crtc) { | 80 CrtcController* crtc) { |
| 64 if (plane_list->legacy_page_flips.empty() || | 81 if (plane_list->legacy_page_flips.empty() || |
| 65 plane_list->legacy_page_flips.back().crtc_id != crtc_id) { | 82 plane_list->legacy_page_flips.back().crtc_id != crtc_id) { |
| 66 plane_list->legacy_page_flips.push_back( | 83 plane_list->legacy_page_flips.push_back( |
| 67 HardwareDisplayPlaneList::PageFlipInfo( | 84 HardwareDisplayPlaneList::PageFlipInfo( |
| 68 crtc_id, overlay.buffer->GetFramebufferId(), hw_plane->plane_id(), | 85 crtc_id, overlay.buffer->GetFramebufferId(), hw_plane->plane_id(), |
| 69 crtc)); | 86 crtc)); |
| 70 } else { | 87 } else { |
| 71 plane_list->legacy_page_flips.back().planes.push_back( | 88 plane_list->legacy_page_flips.back().planes.push_back( |
| 72 HardwareDisplayPlaneList::PageFlipInfo::Plane( | 89 HardwareDisplayPlaneList::PageFlipInfo::Plane( |
| 73 hw_plane->plane_id(), overlay.buffer->GetFramebufferId(), | 90 hw_plane->plane_id(), overlay.buffer->GetFramebufferId(), |
| 74 overlay.display_bounds, src_rect)); | 91 overlay.display_bounds, src_rect)); |
| 75 } | 92 } |
| 76 return true; | 93 return true; |
| 77 } | 94 } |
| 78 | 95 |
| 79 } // namespace ui | 96 } // namespace ui |
| OLD | NEW |