Chromium Code Reviews| 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::AssignOverlayPlanes( |
| 116 CHECK(surface_); | 117 std::vector<OzoneOverlayPlane>* overlays) { |
|
alexst (slow to review)
2014/07/08 17:22:32
If you are not modifying this vector please pass i
| |
| 117 if (!is_disabled_ && !drm_->PageFlip(crtc_id_, | 118 ScanoutSurface* primary = surface_.get(); |
| 118 surface_->GetFramebufferId(), | 119 if (!overlays) |
| 119 this)) { | 120 return primary; |
| 121 for (size_t i = 0; i < overlays->size(); i++) { | |
| 122 const OzoneOverlayPlane& plane = (*overlays)[i]; | |
| 123 if (plane.z_order == 0) { | |
| 124 primary = plane.scanout; | |
| 125 } else { | |
| 126 // TODO: assign overlay planes. | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 return primary; | |
| 131 } | |
| 132 | |
| 133 bool HardwareDisplayController::SchedulePageFlip( | |
| 134 std::vector<OzoneOverlayPlane>* overlays, | |
| 135 std::vector<scoped_refptr<NativePixmap> >* references) { | |
| 136 ScanoutSurface* primary = AssignOverlayPlanes(overlays); | |
|
alexst (slow to review)
2014/07/08 17:22:32
This is only dealing with one plane right now, can
achaulk
2014/07/08 18:16:37
Alright, but why make more work for the future whe
| |
| 137 CHECK(primary); | |
| 138 | |
| 139 primary->PreSwapBuffers(); | |
| 140 | |
| 141 if (!is_disabled_ && | |
| 142 !drm_->PageFlip(crtc_id_, primary->GetFramebufferId(), this)) { | |
| 120 LOG(ERROR) << "Cannot page flip: " << strerror(errno); | 143 LOG(ERROR) << "Cannot page flip: " << strerror(errno); |
| 121 return false; | 144 return false; |
| 122 } | 145 } |
| 123 | 146 |
| 147 if (overlays) { | |
| 148 CHECK(references); | |
| 149 current_overlay_references_.clear(); | |
| 150 current_overlay_references_.swap(*references); | |
| 151 | |
| 152 for (size_t i = 0; i < overlays->size(); i++) { | |
| 153 const OzoneOverlayPlane& plane = (*overlays)[i]; | |
| 154 if (!plane.overlay_plane) | |
| 155 continue; | |
| 156 if (!drm_->PageFlipOverlay(crtc_id_, | |
| 157 plane.scanout->GetFramebufferId(), | |
| 158 plane.display_bounds, | |
| 159 plane.crop_rect, | |
| 160 plane.overlay_plane)) { | |
| 161 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno); | |
| 162 return false; | |
| 163 } | |
| 164 } | |
| 165 } | |
| 166 | |
| 124 return true; | 167 return true; |
| 125 } | 168 } |
| 126 | 169 |
| 127 void HardwareDisplayController::WaitForPageFlipEvent() { | 170 void HardwareDisplayController::WaitForPageFlipEvent() { |
| 128 TRACE_EVENT0("dri", "WaitForPageFlipEvent"); | 171 TRACE_EVENT0("dri", "WaitForPageFlipEvent"); |
| 129 | 172 |
| 130 if (is_disabled_) | 173 if (is_disabled_) |
| 131 return; | 174 return; |
| 132 | 175 |
| 133 drmEventContext drm_event; | 176 drmEventContext drm_event; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 163 } | 206 } |
| 164 | 207 |
| 165 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { | 208 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { |
| 166 if (is_disabled_) | 209 if (is_disabled_) |
| 167 return true; | 210 return true; |
| 168 | 211 |
| 169 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); | 212 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); |
| 170 } | 213 } |
| 171 | 214 |
| 172 } // namespace ui | 215 } // namespace ui |
| OLD | NEW |