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 return CommitInternal(plane_list, false); |
| 23 } |
| 24 |
| 25 bool HardwareDisplayPlaneManagerLegacy::CommitSync( |
| 26 HardwareDisplayPlaneList* plane_list) { |
| 27 return CommitInternal(plane_list, true); |
| 28 } |
| 29 |
| 30 bool HardwareDisplayPlaneManagerLegacy::SetPlaneData( |
| 31 HardwareDisplayPlaneList* plane_list, |
| 32 HardwareDisplayPlane* hw_plane, |
| 33 const OverlayPlane& overlay, |
| 34 uint32_t crtc_id, |
| 35 const gfx::Rect& src_rect, |
| 36 CrtcController* crtc) { |
| 37 if (plane_list->legacy_page_flips.empty() || |
| 38 plane_list->legacy_page_flips.back().crtc_id != crtc_id) { |
| 39 plane_list->legacy_page_flips.push_back( |
| 40 HardwareDisplayPlaneList::PageFlipInfo( |
| 41 crtc_id, overlay.buffer->GetFramebufferId(), hw_plane->plane_id(), |
| 42 crtc)); |
| 43 } else { |
| 44 plane_list->legacy_page_flips.back().planes.push_back( |
| 45 HardwareDisplayPlaneList::PageFlipInfo::Plane( |
| 46 hw_plane->plane_id(), overlay.buffer->GetFramebufferId(), |
| 47 overlay.display_bounds, src_rect)); |
| 48 } |
| 49 return true; |
| 50 } |
| 51 |
| 52 bool HardwareDisplayPlaneManagerLegacy::CommitInternal( |
| 53 HardwareDisplayPlaneList* plane_list, |
| 54 bool sync) { |
22 if (plane_list->plane_list.empty()) // No assigned planes, nothing to do. | 55 if (plane_list->plane_list.empty()) // No assigned planes, nothing to do. |
23 return true; | 56 return true; |
24 bool ret = true; | 57 bool ret = true; |
25 // The order of operations here (set new planes, pageflip, clear old planes) | 58 // The order of operations here (set new planes, pageflip, clear old planes) |
26 // is designed to minimze the chance of a significant artifact occurring. | 59 // 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 | 60 // 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 | 61 // 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 | 62 // 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 | 63 // 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 | 64 // be the delta of (new contents, old contents), but it should be barely |
32 // noticeable. | 65 // noticeable. |
33 for (const auto& flip : plane_list->legacy_page_flips) { | 66 for (const auto& flip : plane_list->legacy_page_flips) { |
34 // Permission Denied is a legitimate error | 67 // Permission Denied is a legitimate error |
35 for (const auto& plane : flip.planes) { | 68 for (const auto& plane : flip.planes) { |
36 if (!drm_->PageFlipOverlay(flip.crtc_id, plane.framebuffer, plane.bounds, | 69 if (!drm_->PageFlipOverlay(flip.crtc_id, plane.framebuffer, plane.bounds, |
37 plane.src_rect, plane.plane)) { | 70 plane.src_rect, plane.plane)) { |
38 LOG(ERROR) << "Cannot display plane on overlay: error=" | 71 LOG(ERROR) << "Cannot display plane on overlay: error=" |
39 << strerror(errno) << "crtc=" << flip.crtc | 72 << strerror(errno) << "crtc=" << flip.crtc |
40 << " plane=" << plane.plane; | 73 << " plane=" << plane.plane; |
41 ret = false; | 74 ret = false; |
42 flip.crtc->PageFlipFailed(); | 75 flip.crtc->PageFlipFailed(); |
43 break; | 76 break; |
44 } | 77 } |
45 } | 78 } |
46 if (!drm_->PageFlip(flip.crtc_id, flip.framebuffer, | 79 bool page_flip_success; |
47 base::Bind(&CrtcController::OnPageFlipEvent, | 80 if (sync) |
48 flip.crtc->AsWeakPtr()))) { | 81 page_flip_success = drm_->PageFlipSync( |
| 82 flip.crtc_id, flip.framebuffer, |
| 83 base::Bind(&CrtcController::OnPageFlipEvent, flip.crtc->AsWeakPtr())); |
| 84 else |
| 85 page_flip_success = drm_->PageFlip( |
| 86 flip.crtc_id, flip.framebuffer, |
| 87 base::Bind(&CrtcController::OnPageFlipEvent, flip.crtc->AsWeakPtr())); |
| 88 if (!page_flip_success) { |
49 if (errno != EACCES) { | 89 if (errno != EACCES) { |
50 LOG(ERROR) << "Cannot page flip: error='" << strerror(errno) << "'" | 90 LOG(ERROR) << "Cannot page flip: error='" << strerror(errno) << "'" |
51 << " crtc=" << flip.crtc_id | 91 << " crtc=" << flip.crtc_id |
52 << " framebuffer=" << flip.framebuffer; | 92 << " framebuffer=" << flip.framebuffer; |
53 LOG(ERROR) << "Failed to commit planes"; | 93 LOG(ERROR) << "Failed to commit planes"; |
54 ret = false; | 94 ret = false; |
55 } | 95 } |
56 flip.crtc->PageFlipFailed(); | 96 flip.crtc->PageFlipFailed(); |
57 } | 97 } |
58 } | 98 } |
(...skipping 12 matching lines...) Expand all Loading... |
71 } | 111 } |
72 } | 112 } |
73 } | 113 } |
74 plane_list->plane_list.swap(plane_list->old_plane_list); | 114 plane_list->plane_list.swap(plane_list->old_plane_list); |
75 plane_list->plane_list.clear(); | 115 plane_list->plane_list.clear(); |
76 plane_list->legacy_page_flips.clear(); | 116 plane_list->legacy_page_flips.clear(); |
77 plane_list->committed = true; | 117 plane_list->committed = true; |
78 return ret; | 118 return ret; |
79 } | 119 } |
80 | 120 |
81 bool HardwareDisplayPlaneManagerLegacy::SetPlaneData( | |
82 HardwareDisplayPlaneList* plane_list, | |
83 HardwareDisplayPlane* hw_plane, | |
84 const OverlayPlane& overlay, | |
85 uint32_t crtc_id, | |
86 const gfx::Rect& src_rect, | |
87 CrtcController* crtc) { | |
88 if (plane_list->legacy_page_flips.empty() || | |
89 plane_list->legacy_page_flips.back().crtc_id != crtc_id) { | |
90 plane_list->legacy_page_flips.push_back( | |
91 HardwareDisplayPlaneList::PageFlipInfo( | |
92 crtc_id, overlay.buffer->GetFramebufferId(), hw_plane->plane_id(), | |
93 crtc)); | |
94 } else { | |
95 plane_list->legacy_page_flips.back().planes.push_back( | |
96 HardwareDisplayPlaneList::PageFlipInfo::Plane( | |
97 hw_plane->plane_id(), overlay.buffer->GetFramebufferId(), | |
98 overlay.display_bounds, src_rect)); | |
99 } | |
100 return true; | |
101 } | |
102 | |
103 } // namespace ui | 121 } // namespace ui |
OLD | NEW |