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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Since a subset of controllers may be actively using |primary|, just keep | 104 // Since a subset of controllers may be actively using |primary|, just keep |
105 // track of it. | 105 // track of it. |
106 current_planes_ = std::vector<OverlayPlane>(1, primary); | 106 current_planes_ = std::vector<OverlayPlane>(1, primary); |
107 pending_planes_.clear(); | 107 pending_planes_.clear(); |
108 mode_ = mode; | 108 mode_ = mode; |
109 return status; | 109 return status; |
110 } | 110 } |
111 | 111 |
112 bool HardwareDisplayController::Enable() { | 112 bool HardwareDisplayController::Enable() { |
113 TRACE_EVENT0("dri", "HDC::Enable"); | 113 TRACE_EVENT0("dri", "HDC::Enable"); |
| 114 DCHECK(!current_planes_.empty()); |
114 OverlayPlane primary = GetPrimaryPlane(current_planes_); | 115 OverlayPlane primary = GetPrimaryPlane(current_planes_); |
115 DCHECK(primary.buffer); | 116 DCHECK(primary.buffer); |
116 pending_page_flips_ = 0; | 117 pending_page_flips_ = 0; |
117 bool status = true; | 118 bool status = true; |
118 for (size_t i = 0; i < crtc_states_.size(); ++i) | 119 for (size_t i = 0; i < crtc_states_.size(); ++i) |
119 status &= ModesetCrtc(primary.buffer, mode_, crtc_states_[i]); | 120 status &= ModesetCrtc(primary.buffer, mode_, crtc_states_[i]); |
120 | 121 |
121 return status; | 122 return status; |
122 } | 123 } |
123 | 124 |
124 void HardwareDisplayController::Disable() { | 125 void HardwareDisplayController::Disable() { |
125 TRACE_EVENT0("dri", "HDC::Disable"); | 126 TRACE_EVENT0("dri", "HDC::Disable"); |
126 pending_page_flips_ = 0; | 127 pending_page_flips_ = 0; |
127 for (size_t i = 0; i < crtc_states_.size(); ++i) { | 128 for (size_t i = 0; i < crtc_states_.size(); ++i) { |
128 drm_->DisableCrtc(crtc_states_[i]->crtc()); | 129 drm_->DisableCrtc(crtc_states_[i]->crtc()); |
129 crtc_states_[i]->set_is_disabled(true); | 130 crtc_states_[i]->set_is_disabled(true); |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 bool HardwareDisplayController::SchedulePageFlip( | 134 void HardwareDisplayController::QueueOverlayPlane(const OverlayPlane& plane) { |
134 const OverlayPlaneList& overlays) { | 135 pending_planes_.push_back(plane); |
135 DCHECK_LE(1u, overlays.size()); | 136 } |
| 137 |
| 138 bool HardwareDisplayController::SchedulePageFlip() { |
| 139 DCHECK(!pending_planes_.empty()); |
136 DCHECK_EQ(0u, pending_page_flips_); | 140 DCHECK_EQ(0u, pending_page_flips_); |
137 | 141 |
138 pending_planes_ = overlays; | |
139 bool status = true; | 142 bool status = true; |
140 for (size_t i = 0; i < crtc_states_.size(); ++i) { | 143 for (size_t i = 0; i < crtc_states_.size(); ++i) { |
141 if (crtc_states_[i]->is_disabled()) | 144 if (crtc_states_[i]->is_disabled()) |
142 continue; | 145 continue; |
143 | 146 |
144 status &= SchedulePageFlipOnCrtc(overlays, crtc_states_[i]); | 147 status &= SchedulePageFlipOnCrtc(pending_planes_, crtc_states_[i]); |
145 } | 148 } |
146 | 149 |
147 return status; | 150 return status; |
148 } | 151 } |
149 | 152 |
150 void HardwareDisplayController::WaitForPageFlipEvent() { | 153 void HardwareDisplayController::WaitForPageFlipEvent() { |
151 TRACE_EVENT1("dri", "HDC::WaitForPageFlipEvent", | 154 TRACE_EVENT1("dri", "HDC::WaitForPageFlipEvent", |
152 "pending_pageflips", pending_page_flips_); | 155 "pending_pageflips", pending_page_flips_); |
153 | 156 |
154 bool has_pending_page_flips = pending_page_flips_ != 0; | 157 bool has_pending_page_flips = pending_page_flips_ != 0; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 plane.overlay_plane)) { | 313 plane.overlay_plane)) { |
311 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno); | 314 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno); |
312 return false; | 315 return false; |
313 } | 316 } |
314 } | 317 } |
315 | 318 |
316 return true; | 319 return true; |
317 } | 320 } |
318 | 321 |
319 } // namespace ui | 322 } // namespace ui |
OLD | NEW |