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

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

Issue 2761533002: ozone: Import multi-planar GBMs. (Closed)
Patch Set: 0 inzialize struct with {} instead of {0}. Created 3 years, 9 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
« no previous file with comments | « ui/ozone/platform/drm/common/drm_util.cc ('k') | ui/ozone/platform/drm/gpu/gbm_buffer_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gbm_buffer.h" 5 #include "ui/ozone/platform/drm/gpu/gbm_buffer.h"
6 6
7 #include <drm.h> 7 #include <drm.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <gbm.h> 9 #include <gbm.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 uint32_t format, 177 uint32_t format,
178 const gfx::Size& size, 178 const gfx::Size& size,
179 std::vector<base::ScopedFD>&& fds, 179 std::vector<base::ScopedFD>&& fds,
180 const std::vector<gfx::NativePixmapPlane>& planes) { 180 const std::vector<gfx::NativePixmapPlane>& planes) {
181 TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device", 181 TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device",
182 gbm->device_path().value(), "size", size.ToString()); 182 gbm->device_path().value(), "size", size.ToString());
183 DCHECK_LE(fds.size(), planes.size()); 183 DCHECK_LE(fds.size(), planes.size());
184 DCHECK_EQ(planes[0].offset, 0); 184 DCHECK_EQ(planes[0].offset, 0);
185 185
186 // Try to use scanout if supported. 186 // Try to use scanout if supported.
187 bool try_scanout = 187 bool try_scanout = gbm_device_is_format_supported(
188 gbm_device_is_format_supported( 188 gbm->device(), format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
189 gbm->device(), format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING) &&
190 (planes.size() == 1);
191 189
192 gbm_bo* bo = nullptr; 190 gbm_bo* bo = nullptr;
193 if (try_scanout) { 191 if (try_scanout) {
194 struct gbm_import_fd_data fd_data; 192 struct gbm_import_fd_planar_data fd_data {};
reveman 2017/03/21 03:36:09 nit: leave uninitialized so asan can detect if gbm
Daniele Castagna 2017/03/21 03:47:09 Done.
195 fd_data.fd = fds[0].get();
196 fd_data.width = size.width(); 193 fd_data.width = size.width();
197 fd_data.height = size.height(); 194 fd_data.height = size.height();
198 fd_data.stride = planes[0].stride;
199 fd_data.format = format; 195 fd_data.format = format;
200 196
197 DCHECK_LT(planes.size(), 3u);
198 for (size_t i = 0; i < planes.size(); ++i) {
199 fd_data.fds[i] = fds[i < fds.size() ? i : 0].get();
reveman 2017/03/21 03:36:09 what if fds.size() is 2 and planes.size() is 3. do
Daniele Castagna 2017/03/21 03:47:09 This is consistent with what we do for eglCreateIm
200 fd_data.strides[i] = planes[i].stride;
201 fd_data.offsets[i] = planes[i].offset;
202 fd_data.format_modifiers[i] = planes[i].modifier;
203 }
204
201 // The fd passed to gbm_bo_import is not ref-counted and need to be 205 // The fd passed to gbm_bo_import is not ref-counted and need to be
202 // kept open for the lifetime of the buffer. 206 // kept open for the lifetime of the buffer.
203 bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD, &fd_data, 207 bo = gbm_bo_import(gbm->device(), GBM_BO_IMPORT_FD_PLANAR, &fd_data,
204 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); 208 GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
205 if (!bo) { 209 if (!bo) {
206 LOG(ERROR) << "nullptr returned from gbm_bo_import"; 210 LOG(ERROR) << "nullptr returned from gbm_bo_import";
207 return nullptr; 211 return nullptr;
208 } 212 }
209 } 213 }
210 214
211 uint32_t flags = GBM_BO_USE_RENDERING; 215 uint32_t flags = GBM_BO_USE_RENDERING;
212 if (try_scanout) 216 if (try_scanout)
213 flags |= GBM_BO_USE_SCANOUT; 217 flags |= GBM_BO_USE_SCANOUT;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 DCHECK(!processing_callback_.is_null()); 334 DCHECK(!processing_callback_.is_null());
331 if (!processing_callback_.Run(this, processed_pixmap_)) { 335 if (!processing_callback_.Run(this, processed_pixmap_)) {
332 LOG(ERROR) << "Failed processing NativePixmap"; 336 LOG(ERROR) << "Failed processing NativePixmap";
333 return nullptr; 337 return nullptr;
334 } 338 }
335 339
336 return processed_pixmap_->buffer(); 340 return processed_pixmap_->buffer();
337 } 341 }
338 342
339 } // namespace ui 343 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/common/drm_util.cc ('k') | ui/ozone/platform/drm/gpu/gbm_buffer_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698