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

Unified Diff: ui/ozone/platform/drm/gpu/gbm_buffer.cc

Issue 2272153002: Add ClientNativePixmap multi-planar support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-native-pixmap-dmabug-multiple-planes
Patch Set: s/cstddef/stddef.h Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/drm/gpu/gbm_buffer.cc
diff --git a/ui/ozone/platform/drm/gpu/gbm_buffer.cc b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
index 8b9a893d2da7e1dad59abeb9f9721d3d319e6396..ffb09d4efde67672717c9faec1c6fcb56e249c26 100644
--- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
@@ -75,6 +75,11 @@ int GbmBuffer::GetOffset(size_t index) const {
return planes_[index].offset;
}
+size_t GbmBuffer::GetSize(size_t index) const {
+ DCHECK_LT(index, planes_.size());
+ return planes_[index].size;
+}
+
uint64_t GbmBuffer::GetFormatModifier(size_t index) const {
DCHECK_LT(index, planes_.size());
return planes_[index].modifier;
@@ -119,20 +124,24 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
DCHECK_EQ(gbm_bo_get_num_planes(bo),
gfx::NumberOfPlanesForBufferFormat(format));
for (size_t i = 0; i < gfx::NumberOfPlanesForBufferFormat(format); ++i) {
- // The fd returned by gbm_bo_get_fd is not ref-counted and need to be
- // kept open for the lifetime of the buffer.
- base::ScopedFD fd(gbm_bo_get_plane_fd(bo, i));
-
- if (!fd.is_valid()) {
- PLOG(ERROR) << "Failed to export buffer to dma_buf";
- gbm_bo_destroy(bo);
- return nullptr;
+ // TODO(dcastagna): support multiple fds.
+ // crbug.com/642410
+ if (!i) {
+ // The fd returned by gbm_bo_get_fd is not ref-counted and need to be
+ // kept open for the lifetime of the buffer.
+ base::ScopedFD fd(gbm_bo_get_plane_fd(bo, i));
Daniele Castagna 2016/09/19 18:26:39 Here on the other hand I'm afraid we were leaking
+
+ if (!fd.is_valid()) {
+ PLOG(ERROR) << "Failed to export buffer to dma_buf";
+ gbm_bo_destroy(bo);
+ return nullptr;
+ }
+ fds.emplace_back(std::move(fd));
}
- fds.emplace_back(std::move(fd));
- planes.emplace_back(gbm_bo_get_plane_stride(bo, i),
- gbm_bo_get_plane_offset(bo, i),
- gbm_bo_get_plane_format_modifier(bo, i));
+ planes.emplace_back(
+ gbm_bo_get_plane_stride(bo, i), gbm_bo_get_plane_offset(bo, i),
+ gbm_bo_get_plane_size(bo, i), gbm_bo_get_plane_format_modifier(bo, i));
}
scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
gbm, bo, format, usage, std::move(fds), size, std::move(planes)));
@@ -216,6 +225,7 @@ gfx::NativePixmapHandle GbmPixmap::ExportHandle() {
base::FileDescriptor(scoped_fd.release(), true /* auto_close */));
}
handle.planes.emplace_back(buffer_->GetStride(i), buffer_->GetOffset(i),
+ buffer_->GetSize(i),
buffer_->GetFormatModifier(i));
}
return handle;

Powered by Google App Engine
This is Rietveld 408576698