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

Side by Side Diff: ui/ozone/platform/dri/hardware_display_controller.cc

Issue 781683005: Ozone: Avoid blocking in Swapbuffer Call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unintended changes. Created 6 years 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 unified diff | Download patch
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 pending_planes_.push_back(plane); 95 pending_planes_.push_back(plane);
96 } 96 }
97 97
98 bool HardwareDisplayController::SchedulePageFlip() { 98 bool HardwareDisplayController::SchedulePageFlip() {
99 DCHECK(!pending_planes_.empty()); 99 DCHECK(!pending_planes_.empty());
100 100
101 if (is_disabled_) 101 if (is_disabled_)
102 return true; 102 return true;
103 103
104 bool status = true; 104 bool status = true;
105 for (size_t i = 0; i < crtc_controllers_.size(); ++i) 105 for (size_t i = 0; i < crtc_controllers_.size(); ++i) {
106 status &= crtc_controllers_[i]->SchedulePageFlip(pending_planes_); 106 status &= crtc_controllers_[i]->SchedulePageFlip(pending_planes_);
107 }
108
109 current_planes_.swap(pending_planes_);
110 pending_planes_.clear();
107 111
108 return status; 112 return status;
109 } 113 }
110 114
111 void HardwareDisplayController::WaitForPageFlipEvent() { 115 void HardwareDisplayController::WaitForPageFlipEvent() {
112 TRACE_EVENT0("dri", "HDC::WaitForPageFlipEvent"); 116 TRACE_EVENT0("dri", "HDC::WaitForPageFlipEvent");
113
114 drmEventContext drm_event; 117 drmEventContext drm_event;
115 drm_event.version = DRM_EVENT_CONTEXT_VERSION; 118 drm_event.version = DRM_EVENT_CONTEXT_VERSION;
116 drm_event.page_flip_handler = HandlePageFlipEvent; 119 drm_event.page_flip_handler = HandlePageFlipEvent;
117 drm_event.vblank_handler = NULL; 120 drm_event.vblank_handler = NULL;
118 121
119 bool has_pending_page_flips = false;
120 // Wait for the page-flips to complete. 122 // Wait for the page-flips to complete.
121 for (size_t i = 0; i < crtc_controllers_.size(); ++i) { 123 for (size_t i = 0; i < crtc_controllers_.size(); ++i) {
122 // In mirror mode the page flip callbacks can happen in different order than 124 // In mirror mode the page flip callbacks can happen in different order than
123 // scheduled, so we need to make sure that the event for the current CRTC is 125 // scheduled, so we need to make sure that the event for the current CRTC is
124 // processed before moving to the next CRTC. 126 // processed before moving to the next CRTC.
125 while (crtc_controllers_[i]->page_flip_pending()) { 127 while (crtc_controllers_[i]->page_flip_pending()) {
126 has_pending_page_flips = true;
127 crtc_controllers_[i]->drm()->HandleEvent(drm_event); 128 crtc_controllers_[i]->drm()->HandleEvent(drm_event);
128 } 129 }
129 } 130 }
130
131 // In case there are no pending pageflips do not replace the current planes
132 // since they are still being used.
133 if (has_pending_page_flips)
134 current_planes_.swap(pending_planes_);
135
136 pending_planes_.clear();
137 } 131 }
138 132
139 bool HardwareDisplayController::SetCursor( 133 bool HardwareDisplayController::SetCursor(
140 const scoped_refptr<ScanoutBuffer>& buffer) { 134 const scoped_refptr<ScanoutBuffer>& buffer) {
141 bool status = true; 135 bool status = true;
142 136
143 if (is_disabled_) 137 if (is_disabled_)
144 return true; 138 return true;
145 139
146 for (size_t i = 0; i < crtc_controllers_.size(); ++i) 140 for (size_t i = 0; i < crtc_controllers_.size(); ++i)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 uint64_t HardwareDisplayController::GetTimeOfLastFlip() const { 203 uint64_t HardwareDisplayController::GetTimeOfLastFlip() const {
210 uint64_t time = 0; 204 uint64_t time = 0;
211 for (size_t i = 0; i < crtc_controllers_.size(); ++i) 205 for (size_t i = 0; i < crtc_controllers_.size(); ++i)
212 if (time < crtc_controllers_[i]->time_of_last_flip()) 206 if (time < crtc_controllers_[i]->time_of_last_flip())
213 time = crtc_controllers_[i]->time_of_last_flip(); 207 time = crtc_controllers_[i]->time_of_last_flip();
214 208
215 return time; 209 return time;
216 } 210 }
217 211
218 } // namespace ui 212 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698