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

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

Issue 371813004: ozone: gbm: Add overlay support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months 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>
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
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) {
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 gfx::RectF crop_rect = plane.crop_rect;
153 crop_rect.Scale(size.width(), size.height());
154 if (!drm_->PageFlipOverlay(crtc_id_,
155 plane.scanout->GetFramebufferId(),
156 plane.display_bounds,
157 crop_rect,
158 plane.overlay_plane)) {
159 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno);
160 return false;
161 }
162 }
163
124 return true; 164 return true;
125 } 165 }
126 166
127 void HardwareDisplayController::WaitForPageFlipEvent() { 167 void HardwareDisplayController::WaitForPageFlipEvent() {
128 TRACE_EVENT0("dri", "WaitForPageFlipEvent"); 168 TRACE_EVENT0("dri", "WaitForPageFlipEvent");
129 169
130 if (is_disabled_) 170 if (is_disabled_)
131 return; 171 return;
132 172
133 drmEventContext drm_event; 173 drmEventContext drm_event;
(...skipping 29 matching lines...) Expand all
163 } 203 }
164 204
165 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { 205 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) {
166 if (is_disabled_) 206 if (is_disabled_)
167 return true; 207 return true;
168 208
169 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); 209 return drm_->MoveCursor(crtc_id_, location.x(), location.y());
170 } 210 }
171 211
172 } // namespace ui 212 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698