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

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

Issue 2039813002: Add format modifier IDs for EGL_EXT_image_dma_buf_import extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add format modifier IDs for EGL_EXT_image_dma_buf_import extension Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer.h ('k') | ui/ozone/platform/drm/gpu/gbm_surface_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b6d2af7ecd07aeed2d7c66cbfd5d30e2f0b1254c..4f4ff472b616cd21f9d5aa62d831bbd91951b7d1 100644
--- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
@@ -32,15 +32,13 @@ GbmBuffer::GbmBuffer(const scoped_refptr<GbmDevice>& gbm,
gfx::BufferUsage usage,
std::vector<base::ScopedFD>&& fds,
const gfx::Size& size,
- const std::vector<int>& strides,
- const std::vector<int>& offsets)
+ const std::vector<gfx::NativePixmapPlane>&& planes)
: GbmBufferBase(gbm, bo, format, usage),
format_(format),
usage_(usage),
fds_(std::move(fds)),
size_(size),
- strides_(strides),
- offsets_(offsets) {}
+ planes_(std::move(planes)) {}
GbmBuffer::~GbmBuffer() {
if (bo())
@@ -62,19 +60,24 @@ size_t GbmBuffer::GetFdCount() const {
return fds_.size();
}
-int GbmBuffer::GetFd(size_t plane) const {
- DCHECK_LT(plane, fds_.size());
- return fds_[plane].get();
+int GbmBuffer::GetFd(size_t index) const {
+ DCHECK_LT(index, fds_.size());
+ return fds_[index].get();
}
-int GbmBuffer::GetStride(size_t plane) const {
- DCHECK_LT(plane, strides_.size());
- return strides_[plane];
+int GbmBuffer::GetStride(size_t index) const {
+ DCHECK_LT(index, planes_.size());
+ return planes_[index].stride;
}
-int GbmBuffer::GetOffset(size_t plane) const {
- DCHECK_LT(plane, offsets_.size());
- return offsets_[plane];
+int GbmBuffer::GetOffset(size_t index) const {
+ DCHECK_LT(index, planes_.size());
+ return planes_[index].offset;
+}
+
+uint64_t GbmBuffer::GetFormatModifier(size_t index) const {
+ DCHECK_LT(index, planes_.size());
+ return planes_[index].modifier;
}
// TODO(reveman): This should not be needed once crbug.com/597932 is fixed,
@@ -120,12 +123,11 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
}
std::vector<base::ScopedFD> fds;
fds.emplace_back(std::move(fd));
- std::vector<int> strides;
- strides.push_back(gbm_bo_get_stride(bo));
- std::vector<int> offsets;
- offsets.push_back(gbm_bo_get_plane_offset(bo, 0));
+ std::vector<gfx::NativePixmapPlane> planes;
+ planes.emplace_back(gbm_bo_get_stride(bo), gbm_bo_get_plane_offset(bo, 0),
+ gbm_bo_get_format_modifier(bo));
scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
- gbm, bo, format, usage, std::move(fds), size, strides, offsets));
+ gbm, bo, format, usage, std::move(fds), size, std::move(planes)));
if (usage == gfx::BufferUsage::SCANOUT && !buffer->GetFramebufferId())
return nullptr;
@@ -138,13 +140,11 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds(
gfx::BufferFormat format,
const gfx::Size& size,
std::vector<base::ScopedFD>&& fds,
- const std::vector<int>& strides,
- const std::vector<int>& offsets) {
+ const std::vector<gfx::NativePixmapPlane>& planes) {
TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device",
gbm->device_path().value(), "size", size.ToString());
- DCHECK_LE(fds.size(), strides.size());
- DCHECK_EQ(strides.size(), offsets.size());
- DCHECK_EQ(offsets[0], 0);
+ DCHECK_LE(fds.size(), planes.size());
+ DCHECK_EQ(planes[0].offset, 0);
uint32_t fourcc_format = GetFourCCFormatFromBufferFormat(format);
@@ -158,7 +158,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds(
fd_data.fd = fds[0].get();
fd_data.width = size.width();
fd_data.height = size.height();
- fd_data.stride = strides[0];
+ fd_data.stride = planes[0].stride;
fd_data.format = fourcc_format;
// The fd passed to gbm_bo_import is not ref-counted and need to be
@@ -174,7 +174,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds(
scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
gbm, bo, format,
use_scanout ? gfx::BufferUsage::SCANOUT : gfx::BufferUsage::GPU_READ,
- std::move(fds), size, strides, offsets));
+ std::move(fds), size, std::move(planes)));
// If scanout support for buffer is expected then make sure we managed to
// create a framebuffer for it as otherwise using it for scanout will fail.
if (use_scanout && !buffer->GetFramebufferId())
@@ -207,8 +207,8 @@ gfx::NativePixmapHandle GbmPixmap::ExportHandle() {
handle.fds.emplace_back(
base::FileDescriptor(scoped_fd.release(), true /* auto_close */));
}
- handle.strides_and_offsets.emplace_back(buffer_->GetStride(i),
- buffer_->GetOffset(i));
+ handle.planes.emplace_back(buffer_->GetStride(i), buffer_->GetOffset(i),
+ buffer_->GetFormatModifier(i));
}
return handle;
}
@@ -240,6 +240,10 @@ int GbmPixmap::GetDmaBufOffset(size_t plane) const {
return buffer_->GetOffset(plane);
}
+uint64_t GbmPixmap::GetDmaBufModifier(size_t plane) const {
+ return buffer_->GetFormatModifier(plane);
+}
+
gfx::BufferFormat GbmPixmap::GetBufferFormat() const {
return buffer_->GetFormat();
}
« no previous file with comments | « ui/ozone/platform/drm/gpu/gbm_buffer.h ('k') | ui/ozone/platform/drm/gpu/gbm_surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698