Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: ui/ozone/platform/drm/gpu/hardware_display_controller.cc

Issue 1091253003: [ozone] Keep the queue of surfaceless buffers inside gl_surface_ozone (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/drm/gpu/hardware_display_controller.cc
diff --git a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
index 278dc156abc6cece1f44b7cbacb1295dddea6df3..1e5b1b8a0b97f27471c488c907bf51ea088e4498 100644
--- a/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
+++ b/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
@@ -33,7 +33,7 @@ HardwareDisplayController::PageFlipRequest::~PageFlipRequest() {
HardwareDisplayController::HardwareDisplayController(
scoped_ptr<CrtcController> controller)
- : is_disabled_(true) {
+ : is_disabled_(true), ignore_page_flip_event_(false) {
memset(&mode_, 0, sizeof(mode_));
AddCrtc(controller.Pass());
}
@@ -41,7 +41,7 @@ HardwareDisplayController::HardwareDisplayController(
HardwareDisplayController::~HardwareDisplayController() {
// Reset the cursor.
UnsetCursor();
- ClearPendingRequests();
+ ProcessPageFlipRequest();
}
bool HardwareDisplayController::Modeset(const OverlayPlane& primary,
@@ -55,14 +55,12 @@ bool HardwareDisplayController::Modeset(const OverlayPlane& primary,
is_disabled_ = false;
mode_ = mode;
- current_planes_ = std::vector<OverlayPlane>(1, primary);
- ClearPendingRequests();
+ ProcessPageFlipRequest();
// Because a page flip is pending we need to leave some state for the
dnicoara 2015/04/21 18:50:42 Could you please update the comment.
- // callback. We use the modeset state since it is the only valid state.
+ // callback.
if (HasPendingPageFlips())
- requests_.push_back(
- PageFlipRequest(current_planes_, false, base::Bind(&base::DoNothing)));
+ ignore_page_flip_event_ = true;
dnicoara 2015/04/21 18:50:42 nit: Simplity it to 'ignore_page_flip_event_ = Has
alexst (slow to review) 2015/04/21 19:19:55 Done.
spang 2015/04/21 19:39:36 This is funky. Could we pass a callback w/ weak p
alexst (slow to review) 2015/04/21 19:46:17 Yes, that's a good idea.
return status;
}
@@ -74,10 +72,7 @@ void HardwareDisplayController::Disable() {
// Don't hold onto any requests because we don't track fron buffer while
// disabled.
- while (requests_.size())
- ProcessPageFlipRequest();
-
- current_planes_.clear();
+ ProcessPageFlipRequest();
is_disabled_ = true;
}
@@ -88,25 +83,19 @@ bool HardwareDisplayController::SchedulePageFlip(
const base::Closure& callback) {
TRACE_EVENT0("drm", "HDC::SchedulePageFlip");
+ // A request is being serviced right now.
dnicoara 2015/04/21 18:50:42 Shouldn't this be reversed? When we schedule the p
alexst (slow to review) 2015/04/21 19:19:55 of course!
+ DCHECK(HasPendingPageFlips());
+ DCHECK(page_flip_request_.get());
+
// Ignore requests with no planes to schedule.
if (plane_list.empty()) {
callback.Run();
return true;
}
- requests_.push_back(PageFlipRequest(plane_list, is_sync, callback));
-
- // A request is being serviced right now.
- if (HasPendingPageFlips())
- return true;
-
- bool status = ActualSchedulePageFlip();
+ page_flip_request_.reset(new PageFlipRequest(plane_list, is_sync, callback));
- // No page flip event on failure so discard failed request.
- if (!status)
- requests_.pop_front();
-
- return status;
+ return ActualSchedulePageFlip();
}
bool HardwareDisplayController::SetCursor(
@@ -233,24 +222,12 @@ void HardwareDisplayController::OnPageFlipEvent() {
if (HasPendingPageFlips())
return;
- if (!requests_.empty())
- ProcessPageFlipRequest();
-
- // ProcessPageFlipRequest() consumes a request.
- if (requests_.empty())
+ if (ignore_page_flip_event_) {
+ ignore_page_flip_event_ = false;
return;
-
- // At this point we still have requests pending, so schedule the next request.
- bool status = ActualSchedulePageFlip();
- if (!status) {
- PageFlipRequest request = requests_.front();
- requests_.pop_front();
-
- // Normally the caller would handle the error call, but because we're in a
- // delayed schedule the initial SchedulePageFlip() already returned true,
- // thus we need to run the callback.
- request.callback.Run();
}
+
+ ProcessPageFlipRequest();
}
scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice()
@@ -271,14 +248,10 @@ bool HardwareDisplayController::HasPendingPageFlips() const {
bool HardwareDisplayController::ActualSchedulePageFlip() {
TRACE_EVENT0("drm", "HDC::ActualSchedulePageFlip");
- DCHECK(!requests_.empty());
-
- if (is_disabled_) {
- ProcessPageFlipRequest();
- return true;
- }
+ DCHECK(page_flip_request_.get());
+ DCHECK(!is_disabled_);
- OverlayPlaneList pending_planes = requests_.front().planes;
+ OverlayPlaneList& pending_planes = page_flip_request_->planes;
std::sort(pending_planes.begin(), pending_planes.end(),
[](const OverlayPlane& l, const OverlayPlane& r) {
return l.z_order < r.z_order;
@@ -291,7 +264,7 @@ bool HardwareDisplayController::ActualSchedulePageFlip() {
pending_planes);
}
- bool is_sync = requests_.front().is_sync;
+ bool is_sync = page_flip_request_->is_sync;
for (const auto& planes : owned_hardware_planes_) {
if (!planes.first->plane_manager()->Commit(planes.second, is_sync)) {
status = false;
@@ -302,19 +275,12 @@ bool HardwareDisplayController::ActualSchedulePageFlip() {
}
void HardwareDisplayController::ProcessPageFlipRequest() {
- DCHECK(!requests_.empty());
- PageFlipRequest request = requests_.front();
- requests_.pop_front();
-
- current_planes_.swap(request.planes);
- request.callback.Run();
-}
-
-void HardwareDisplayController::ClearPendingRequests() {
- while (!requests_.empty()) {
- PageFlipRequest request = requests_.front();
- requests_.pop_front();
- request.callback.Run();
+ if (page_flip_request_.get()) {
+ scoped_ptr<PageFlipRequest> last_request;
+ // We are done with the last request, so clear it before we execute the
+ // callback since it may schedule a new frame.
+ swap(last_request, page_flip_request_);
+ last_request->callback.Run();
}
}
« ui/gl/gl_surface_ozone.cc ('K') | « ui/ozone/platform/drm/gpu/hardware_display_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698