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