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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
16 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 #include "ui/ozone/platform/dri/crtc_controller.h" | 18 #include "ui/ozone/platform/dri/crtc_controller.h" |
19 #include "ui/ozone/platform/dri/dri_buffer.h" | 19 #include "ui/ozone/platform/dri/dri_buffer.h" |
20 #include "ui/ozone/platform/dri/dri_wrapper.h" | 20 #include "ui/ozone/platform/dri/drm_device.h" |
21 #include "ui/ozone/public/native_pixmap.h" | 21 #include "ui/ozone/public/native_pixmap.h" |
22 | 22 |
23 namespace ui { | 23 namespace ui { |
24 | 24 |
25 HardwareDisplayController::PageFlipRequest::PageFlipRequest( | 25 HardwareDisplayController::PageFlipRequest::PageFlipRequest( |
26 const OverlayPlaneList& planes, | 26 const OverlayPlaneList& planes, |
27 bool is_sync, | 27 bool is_sync, |
28 const base::Closure& callback) | 28 const base::Closure& callback) |
29 : planes(planes), is_sync(is_sync), callback(callback) { | 29 : planes(planes), is_sync(is_sync), callback(callback) { |
30 } | 30 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 void HardwareDisplayController::AddCrtc(scoped_ptr<CrtcController> controller) { | 151 void HardwareDisplayController::AddCrtc(scoped_ptr<CrtcController> controller) { |
152 owned_hardware_planes_.add( | 152 owned_hardware_planes_.add( |
153 controller->drm().get(), | 153 controller->drm().get(), |
154 scoped_ptr<HardwareDisplayPlaneList>(new HardwareDisplayPlaneList())); | 154 scoped_ptr<HardwareDisplayPlaneList>(new HardwareDisplayPlaneList())); |
155 controller->AddObserver(this); | 155 controller->AddObserver(this); |
156 crtc_controllers_.push_back(controller.release()); | 156 crtc_controllers_.push_back(controller.release()); |
157 } | 157 } |
158 | 158 |
159 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( | 159 scoped_ptr<CrtcController> HardwareDisplayController::RemoveCrtc( |
160 const scoped_refptr<DriWrapper>& drm, | 160 const scoped_refptr<DrmDevice>& drm, |
161 uint32_t crtc) { | 161 uint32_t crtc) { |
162 for (ScopedVector<CrtcController>::iterator it = crtc_controllers_.begin(); | 162 for (ScopedVector<CrtcController>::iterator it = crtc_controllers_.begin(); |
163 it != crtc_controllers_.end(); ++it) { | 163 it != crtc_controllers_.end(); ++it) { |
164 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { | 164 if ((*it)->drm() == drm && (*it)->crtc() == crtc) { |
165 scoped_ptr<CrtcController> controller(*it); | 165 scoped_ptr<CrtcController> controller(*it); |
166 crtc_controllers_.weak_erase(it); | 166 crtc_controllers_.weak_erase(it); |
167 // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. | 167 // Remove entry from |owned_hardware_planes_| iff no other crtcs share it. |
168 bool found = false; | 168 bool found = false; |
169 for (ScopedVector<CrtcController>::iterator it = | 169 for (ScopedVector<CrtcController>::iterator it = |
170 crtc_controllers_.begin(); | 170 crtc_controllers_.begin(); |
(...skipping 13 matching lines...) Expand all Loading... |
184 if (controller->page_flip_pending()) | 184 if (controller->page_flip_pending()) |
185 OnPageFlipEvent(); | 185 OnPageFlipEvent(); |
186 | 186 |
187 return controller.Pass(); | 187 return controller.Pass(); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 return nullptr; | 191 return nullptr; |
192 } | 192 } |
193 | 193 |
194 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DriWrapper>& drm, | 194 bool HardwareDisplayController::HasCrtc(const scoped_refptr<DrmDevice>& drm, |
195 uint32_t crtc) const { | 195 uint32_t crtc) const { |
196 for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 196 for (size_t i = 0; i < crtc_controllers_.size(); ++i) |
197 if (crtc_controllers_[i]->drm() == drm && | 197 if (crtc_controllers_[i]->drm() == drm && |
198 crtc_controllers_[i]->crtc() == crtc) | 198 crtc_controllers_[i]->crtc() == crtc) |
199 return true; | 199 return true; |
200 | 200 |
201 return false; | 201 return false; |
202 } | 202 } |
203 | 203 |
204 bool HardwareDisplayController::IsMirrored() const { | 204 bool HardwareDisplayController::IsMirrored() const { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 PageFlipRequest request = requests_.front(); | 253 PageFlipRequest request = requests_.front(); |
254 requests_.pop_front(); | 254 requests_.pop_front(); |
255 | 255 |
256 // Normally the caller would handle the error call, but because we're in a | 256 // Normally the caller would handle the error call, but because we're in a |
257 // delayed schedule the initial SchedulePageFlip() already returned true, | 257 // delayed schedule the initial SchedulePageFlip() already returned true, |
258 // thus we need to run the callback. | 258 // thus we need to run the callback. |
259 request.callback.Run(); | 259 request.callback.Run(); |
260 } | 260 } |
261 } | 261 } |
262 | 262 |
263 scoped_refptr<DriWrapper> HardwareDisplayController::GetAllocationDriWrapper() | 263 scoped_refptr<DrmDevice> HardwareDisplayController::GetAllocationDrmDevice() |
264 const { | 264 const { |
265 DCHECK(!crtc_controllers_.empty()); | 265 DCHECK(!crtc_controllers_.empty()); |
266 // TODO(dnicoara) When we support mirroring across DRM devices, figure out | 266 // TODO(dnicoara) When we support mirroring across DRM devices, figure out |
267 // which device should be used for allocations. | 267 // which device should be used for allocations. |
268 return crtc_controllers_[0]->drm(); | 268 return crtc_controllers_[0]->drm(); |
269 } | 269 } |
270 | 270 |
271 bool HardwareDisplayController::HasPendingPageFlips() const { | 271 bool HardwareDisplayController::HasPendingPageFlips() const { |
272 for (size_t i = 0; i < crtc_controllers_.size(); ++i) | 272 for (size_t i = 0; i < crtc_controllers_.size(); ++i) |
273 if (crtc_controllers_[i]->page_flip_pending()) | 273 if (crtc_controllers_[i]->page_flip_pending()) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 319 |
320 void HardwareDisplayController::ClearPendingRequests() { | 320 void HardwareDisplayController::ClearPendingRequests() { |
321 while (!requests_.empty()) { | 321 while (!requests_.empty()) { |
322 PageFlipRequest request = requests_.front(); | 322 PageFlipRequest request = requests_.front(); |
323 requests_.pop_front(); | 323 requests_.pop_front(); |
324 request.callback.Run(); | 324 request.callback.Run(); |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 } // namespace ui | 328 } // namespace ui |
OLD | NEW |