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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_window.cc

Issue 1157793004: ozone: Add overlay candidate implementation that queries support via IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing license header Created 5 years, 6 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/drm/gpu/drm_window.h" 5 #include "ui/ozone/platform/drm/gpu/drm_window.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkDevice.h" 9 #include "third_party/skia/include/core/SkDevice.h"
10 #include "third_party/skia/include/core/SkSurface.h" 10 #include "third_party/skia/include/core/SkSurface.h"
11 #include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
11 #include "ui/ozone/platform/drm/gpu/drm_buffer.h" 12 #include "ui/ozone/platform/drm/gpu/drm_buffer.h"
12 #include "ui/ozone/platform/drm/gpu/drm_device.h" 13 #include "ui/ozone/platform/drm/gpu/drm_device.h"
13 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h" 14 #include "ui/ozone/platform/drm/gpu/drm_device_manager.h"
15 #include "ui/ozone/platform/drm/gpu/scanout_buffer.h"
14 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 16 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
15 17
16 namespace ui { 18 namespace ui {
17 19
18 namespace { 20 namespace {
19 21
20 #ifndef DRM_CAP_CURSOR_WIDTH 22 #ifndef DRM_CAP_CURSOR_WIDTH
21 #define DRM_CAP_CURSOR_WIDTH 0x8 23 #define DRM_CAP_CURSOR_WIDTH 0x8
22 #endif 24 #endif
23 25
24 #ifndef DRM_CAP_CURSOR_HEIGHT 26 #ifndef DRM_CAP_CURSOR_HEIGHT
25 #define DRM_CAP_CURSOR_HEIGHT 0x9 27 #define DRM_CAP_CURSOR_HEIGHT 0x9
26 #endif 28 #endif
27 29
30 void EmptyFlipCallback(gfx::SwapResult) {
31 }
32
28 void UpdateCursorImage(DrmBuffer* cursor, const SkBitmap& image) { 33 void UpdateCursorImage(DrmBuffer* cursor, const SkBitmap& image) {
29 SkRect damage; 34 SkRect damage;
30 image.getBounds(&damage); 35 image.getBounds(&damage);
31 36
32 // Clear to transparent in case |image| is smaller than the canvas. 37 // Clear to transparent in case |image| is smaller than the canvas.
33 SkCanvas* canvas = cursor->GetCanvas(); 38 SkCanvas* canvas = cursor->GetCanvas();
34 canvas->clear(SK_ColorTRANSPARENT); 39 canvas->clear(SK_ColorTRANSPARENT);
35 40
36 SkRect clip; 41 SkRect clip;
37 clip.set(0, 0, canvas->getDeviceSize().width(), 42 clip.set(0, 0, canvas->getDeviceSize().width(),
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 137
133 if (controller_) { 138 if (controller_) {
134 return controller_->SchedulePageFlip(last_submitted_planes_, is_sync, false, 139 return controller_->SchedulePageFlip(last_submitted_planes_, is_sync, false,
135 callback); 140 callback);
136 } 141 }
137 142
138 callback.Run(gfx::SwapResult::SWAP_ACK); 143 callback.Run(gfx::SwapResult::SWAP_ACK);
139 return true; 144 return true;
140 } 145 }
141 146
147 bool DrmWindow::TestPageFlip(const std::vector<OverlayCheck_Params>& overlays,
148 ScanoutBufferGenerator* buffer_generator) {
149 if (!controller_)
150 return true;
151 for (const auto& overlay : overlays) {
152 // It is possible that the cc rect we get actually falls off the edge of
153 // the screen. Usually this is prevented via things like status bars
154 // blocking overlaying or cc clipping it, but in case it wasn't properly
155 // clipped (since GL will render this situation fine) just ignore it here.
156 // This should be an extremely rare occurrance.
157 if (overlay.plane_z_order != 0 && !bounds().Contains(overlay.display_rect))
158 return false;
159 }
160
161 scoped_refptr<DrmDevice> drm = controller_->GetAllocationDrmDevice();
162 OverlayPlaneList planes;
163 for (const auto& overlay : overlays) {
164 gfx::Size size =
165 (overlay.plane_z_order == 0) ? bounds().size() : overlay.buffer_size;
166 scoped_refptr<ScanoutBuffer> buffer = buffer_generator->Create(drm, size);
167 if (!buffer)
168 return false;
169 planes.push_back(OverlayPlane(buffer, overlay.plane_z_order,
170 overlay.transform, overlay.display_rect,
171 gfx::RectF(gfx::Size(1, 1))));
172 }
173 return controller_->SchedulePageFlip(planes, true, true,
174 base::Bind(&EmptyFlipCallback));
175 }
176
142 const OverlayPlane* DrmWindow::GetLastModesetBuffer() { 177 const OverlayPlane* DrmWindow::GetLastModesetBuffer() {
143 return OverlayPlane::GetPrimaryPlane(last_submitted_planes_); 178 return OverlayPlane::GetPrimaryPlane(last_submitted_planes_);
144 } 179 }
145 180
146 void DrmWindow::ResetCursor(bool bitmap_only) { 181 void DrmWindow::ResetCursor(bool bitmap_only) {
147 if (!controller_) 182 if (!controller_)
148 return; 183 return;
149 184
150 if (cursor_bitmaps_.size()) { 185 if (cursor_bitmaps_.size()) {
151 // Draw new cursor into backbuffer. 186 // Draw new cursor into backbuffer.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 if (!cursor_buffers_[i]->Initialize( 240 if (!cursor_buffers_[i]->Initialize(
206 info, false /* should_register_framebuffer */)) { 241 info, false /* should_register_framebuffer */)) {
207 LOG(FATAL) << "Failed to initialize cursor buffer"; 242 LOG(FATAL) << "Failed to initialize cursor buffer";
208 return; 243 return;
209 } 244 }
210 } 245 }
211 } 246 }
212 } 247 }
213 248
214 } // namespace ui 249 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/drm_window.h ('k') | ui/ozone/platform/drm/host/drm_overlay_candidates_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698