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

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: fix test build 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 //
32 // |device| will contain a reference to the |ScanoutSurface| object which 33 // |device| will contain a reference to the |ScanoutSurface| object which
33 // the event belongs to. 34 // the event belongs to.
34 // 35 //
35 // TODO(dnicoara) When we have a FD handler for the DRM calls in the message 36 // TODO(dnicoara) When we have a FD handler for the DRM calls in the message
36 // loop, we can move this function in the handler. 37 // loop, we can move this function in the handler.
37 void HandlePageFlipEvent(int fd, 38 void HandlePageFlipEvent(int fd,
38 unsigned int frame, 39 unsigned int frame,
39 unsigned int seconds, 40 unsigned int seconds,
40 unsigned int useconds, 41 unsigned int useconds,
41 void* controller) { 42 void* controller) {
42 TRACE_EVENT0("dri", "HandlePageFlipEvent"); 43 TRACE_EVENT0("dri", "HandlePageFlipEvent");
43 static_cast<HardwareDisplayController*>(controller) 44 static_cast<HardwareDisplayController*>(controller)
44 ->OnPageFlipEvent(frame, seconds, useconds); 45 ->OnPageFlipEvent(frame, seconds, useconds);
45 } 46 }
46 47
47 } // namespace 48 } // namespace
48 49
50 OzoneOverlayPlane::OzoneOverlayPlane(ScanoutSurface* scanout,
51 int z_order,
52 gfx::OverlayTransform plane_transform,
53 const gfx::Rect& display_bounds,
54 const gfx::RectF& crop_rect)
55 : scanout(scanout),
56 z_order(z_order),
57 plane_transform(plane_transform),
58 display_bounds(display_bounds),
59 crop_rect(crop_rect),
60 overlay_plane(0) {
61 }
62
49 HardwareDisplayController::HardwareDisplayController( 63 HardwareDisplayController::HardwareDisplayController(
50 DriWrapper* drm, 64 DriWrapper* drm,
51 uint32_t connector_id, 65 uint32_t connector_id,
52 uint32_t crtc_id) 66 uint32_t crtc_id)
53 : drm_(drm), 67 : drm_(drm),
54 connector_id_(connector_id), 68 connector_id_(connector_id),
55 crtc_id_(crtc_id), 69 crtc_id_(crtc_id),
56 surface_(), 70 surface_(),
57 time_of_last_flip_(0), 71 time_of_last_flip_(0),
58 is_disabled_(true), 72 is_disabled_(true),
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 119 }
106 120
107 return true; 121 return true;
108 } 122 }
109 123
110 void HardwareDisplayController::Disable() { 124 void HardwareDisplayController::Disable() {
111 drm_->SetCrtc(crtc_id_, 0, 0, NULL); 125 drm_->SetCrtc(crtc_id_, 0, 0, NULL);
112 is_disabled_ = true; 126 is_disabled_ = true;
113 } 127 }
114 128
115 bool HardwareDisplayController::SchedulePageFlip() { 129 ScanoutSurface* HardwareDisplayController::GetPrimaryPlane(
116 CHECK(surface_); 130 const std::vector<OzoneOverlayPlane>& overlays) {
117 if (!is_disabled_ && !drm_->PageFlip(crtc_id_, 131 ScanoutSurface* primary = surface_.get();
118 surface_->GetFramebufferId(), 132 for (size_t i = 0; i < overlays.size(); i++) {
119 this)) { 133 const OzoneOverlayPlane& plane = overlays[i];
134 if (plane.z_order == 0) {
135 return plane.scanout;
136 }
137 }
138
139 return primary;
140 }
141
142 bool HardwareDisplayController::SchedulePageFlip(
143 const std::vector<OzoneOverlayPlane>& overlays,
144 NativePixmapList* references) {
145 ScanoutSurface* primary = GetPrimaryPlane(overlays);
146 CHECK(primary);
147
148 primary->PreSwapBuffers();
149
150 if (!is_disabled_ &&
151 !drm_->PageFlip(crtc_id_, primary->GetFramebufferId(), this)) {
120 LOG(ERROR) << "Cannot page flip: " << strerror(errno); 152 LOG(ERROR) << "Cannot page flip: " << strerror(errno);
121 return false; 153 return false;
122 } 154 }
123 155
156 current_overlay_references_.clear();
157 if (references)
158 current_overlay_references_.swap(*references);
159
160 for (size_t i = 0; i < overlays.size(); i++) {
161 const OzoneOverlayPlane& plane = overlays[i];
162 if (!plane.overlay_plane)
163 continue;
164 const gfx::Size& size = plane.scanout->Size();
165 gfx::RectF crop_rect = plane.crop_rect;
166 crop_rect.Scale(size.width(), size.height());
167 if (!drm_->PageFlipOverlay(crtc_id_,
168 plane.scanout->GetFramebufferId(),
169 plane.display_bounds,
170 crop_rect,
171 plane.overlay_plane)) {
172 LOG(ERROR) << "Cannot display on overlay: " << strerror(errno);
173 return false;
174 }
175 }
176
124 return true; 177 return true;
125 } 178 }
126 179
127 void HardwareDisplayController::WaitForPageFlipEvent() { 180 void HardwareDisplayController::WaitForPageFlipEvent() {
128 TRACE_EVENT0("dri", "WaitForPageFlipEvent"); 181 TRACE_EVENT0("dri", "WaitForPageFlipEvent");
129 182
130 if (is_disabled_) 183 if (is_disabled_)
131 return; 184 return;
132 185
133 drmEventContext drm_event; 186 drmEventContext drm_event;
(...skipping 29 matching lines...) Expand all
163 } 216 }
164 217
165 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) { 218 bool HardwareDisplayController::MoveCursor(const gfx::Point& location) {
166 if (is_disabled_) 219 if (is_disabled_)
167 return true; 220 return true;
168 221
169 return drm_->MoveCursor(crtc_id_, location.x(), location.y()); 222 return drm_->MoveCursor(crtc_id_, location.x(), location.y());
170 } 223 }
171 224
172 } // namespace ui 225 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/hardware_display_controller.h ('k') | ui/ozone/platform/dri/hardware_display_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698