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/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "third_party/skia/include/core/SkCanvas.h" | 16 #include "third_party/skia/include/core/SkCanvas.h" |
17 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.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/dri_wrapper.h" |
21 #include "ui/ozone/platform/dri/scanout_surface.h" | 21 #include "ui/ozone/platform/dri/scanout_surface.h" |
22 #include "ui/ozone/public/native_pixmap.h" | |
22 | 23 |
23 namespace ui { | 24 namespace ui { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // DRM callback on page flip events. This callback is triggered after the | 28 // DRM callback on page flip events. This callback is triggered after the |
28 // page flip has happened and the backbuffer is now the new frontbuffer | 29 // page flip has happened and the backbuffer is now the new frontbuffer |
29 // The old frontbuffer is no longer used by the hardware and can be used for | 30 // The old frontbuffer is no longer used by the hardware and can be used for |
30 // future draw operations. | 31 // future draw operations. |
31 // | 32 // |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 } | 106 } |
106 | 107 |
107 return true; | 108 return true; |
108 } | 109 } |
109 | 110 |
110 void HardwareDisplayController::Disable() { | 111 void HardwareDisplayController::Disable() { |
111 drm_->SetCrtc(crtc_id_, 0, 0, NULL); | 112 drm_->SetCrtc(crtc_id_, 0, 0, NULL); |
112 is_disabled_ = true; | 113 is_disabled_ = true; |
113 } | 114 } |
114 | 115 |
115 bool HardwareDisplayController::SchedulePageFlip() { | 116 ScanoutSurface* HardwareDisplayController::GetPrimaryPlane( |
116 CHECK(surface_); | 117 const std::vector<OzoneOverlayPlane>& overlays) { |
117 if (!is_disabled_ && !drm_->PageFlip(crtc_id_, | 118 ScanoutSurface* primary = surface_.get(); |
118 surface_->GetFramebufferId(), | 119 for (size_t i = 0; i < overlays.size(); i++) { |
119 this)) { | 120 const OzoneOverlayPlane& plane = overlays[i]; |
121 if (plane.z_order == 0) { | |
dnicoara
2014/07/10 17:00:56
Should replace |surface_| in this case otherwise l
achaulk
2014/07/10 17:07:50
We could NULL it, but we can't store any of the ov
dnicoara
2014/07/10 17:25:47
You can't NULL it otherwise SchedulePageFlip will
achaulk
2014/07/10 17:42:29
References are only taken on NativePixmap objects
dnicoara
2014/07/10 19:17:13
We clarified this offline :)
| |
122 return plane.scanout; | |
123 } | |
124 } | |
125 | |
126 return primary; | |
127 } | |
128 | |
129 bool HardwareDisplayController::SchedulePageFlip( | |
130 const std::vector<OzoneOverlayPlane>& overlays, | |
131 NativePixmapList* references) { | |
132 ScanoutSurface* primary = GetPrimaryPlane(overlays); | |
133 CHECK(primary); | |
134 | |
135 primary->PreSwapBuffers(); | |
136 | |
137 if (!is_disabled_ && | |
138 !drm_->PageFlip(crtc_id_, primary->GetFramebufferId(), this)) { | |
120 LOG(ERROR) << "Cannot page flip: " << strerror(errno); | 139 LOG(ERROR) << "Cannot page flip: " << strerror(errno); |
121 return false; | 140 return false; |
122 } | 141 } |
123 | 142 |
143 current_overlay_references_.clear(); | |
144 if (references) | |
145 current_overlay_references_.swap(*references); | |
146 | |
147 for (size_t i = 0; i < overlays.size(); i++) { | |
148 const OzoneOverlayPlane& plane = overlays[i]; | |
149 if (!plane.overlay_plane) | |
150 continue; | |
151 const gfx::Size& size = plane.scanout->Size(); | |
152 const gfx::SizeF sizef(size.width(), size.height()); | |
153 const gfx::RectF& crop_rect = plane.crop_rect; | |
154 gfx::RectF draw_rect(crop_rect.x() * sizef.width(), | |
dnicoara
2014/07/10 19:53:52
I think you can just make crop_rect non-const and
achaulk
2014/07/11 16:57:49
Acknowledged.
| |
155 crop_rect.y() * sizef.height(), | |
156 crop_rect.width() * sizef.width(), | |
157 crop_rect.height() * sizef.height()); | |
158 if (!drm_->PageFlipOverlay(crtc_id_, | |
159 plane.scanout->GetFramebufferId(), | |
160 plane.display_bounds, | |
161 draw_rect, | |
162 plane.overlay_plane)) { | |
163 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno); | |
164 return false; | |
165 } | |
166 } | |
167 | |
124 return true; | 168 return true; |
125 } | 169 } |
126 | 170 |
127 void HardwareDisplayController::WaitForPageFlipEvent() { | 171 void HardwareDisplayController::WaitForPageFlipEvent() { |
128 TRACE_EVENT0("dri", "WaitForPageFlipEvent"); | 172 TRACE_EVENT0("dri", "WaitForPageFlipEvent"); |
129 | 173 |
130 if (is_disabled_) | 174 if (is_disabled_) |
131 return; | 175 return; |
132 | 176 |
133 drmEventContext drm_event; | 177 drmEventContext drm_event; |
(...skipping 29 matching lines...) Expand all Loading... | |
163 } | 207 } |
164 | 208 |
165 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { | 209 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { |
166 if (is_disabled_) | 210 if (is_disabled_) |
167 return true; | 211 return true; |
168 | 212 |
169 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); | 213 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); |
170 } | 214 } |
171 | 215 |
172 } // namespace ui | 216 } // namespace ui |
OLD | NEW |