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 549b067782d11ffd1dc69067ccdc11ccab5d1224..bdd9baac3a6d97075ded62ae3d41198c902c5722 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::GbmBufferPlane>&& 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::GbmBufferPlane> 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,16 +140,15 @@ 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::GbmBufferPlane>& planes) { |
TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device", |
gbm->device_path().value(), "size", size.ToString()); |
- DCHECK_EQ(fds.size(), strides.size()); |
+ DCHECK_EQ(fds.size(), planes.size()); |
// TODO(reveman): Use gbm_bo_import after making buffers survive |
// GPU process crashes. crbug.com/597932 |
return make_scoped_refptr( |
new GbmBuffer(gbm, nullptr, format, gfx::BufferUsage::GPU_READ, |
- std::move(fds), size, strides, offsets)); |
+ std::move(fds), size, std::move(planes))); |
} |
GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager, |
@@ -174,8 +175,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; |
} |
@@ -207,6 +208,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(); |
} |