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

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: 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
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 918303275a931692e309cbeab2207dff1b41ff6b..211f15a30db0592c0a7fecc7704fb5420b79a0be 100644
--- a/ui/ozone/platform/drm/gpu/gbm_buffer.cc
+++ b/ui/ozone/platform/drm/gpu/gbm_buffer.cc
@@ -32,13 +32,15 @@ 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>& strides,
+ const std::vector<uint64_t>& modifiers)
: GbmBufferBase(gbm, bo, format, usage),
format_(format),
usage_(usage),
fds_(std::move(fds)),
size_(size),
- strides_(strides) {}
+ strides_(strides),
+ modifiers_(modifiers) {}
GbmBuffer::~GbmBuffer() {
if (bo())
@@ -66,6 +68,11 @@ int GbmBuffer::GetStride(size_t plane) const {
return strides_[plane];
}
+uint64_t GbmBuffer::GetFormatModifier(size_t plane) const {
+ DCHECK_LT(plane, modifiers_.size());
+ return modifiers_[plane];
+}
+
// TODO(reveman): This should not be needed once crbug.com/597932 is fixed,
// as the size would be queried directly from the underlying bo.
gfx::Size GbmBuffer::GetSize() const {
@@ -111,8 +118,10 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(
fds.emplace_back(std::move(fd));
std::vector<int> strides;
strides.push_back(gbm_bo_get_stride(bo));
- scoped_refptr<GbmBuffer> buffer(
- new GbmBuffer(gbm, bo, format, usage, std::move(fds), size, strides));
+ std::vector<uint64_t> modifiers;
+ modifiers.push_back(gbm_bo_get_format_modifier(bo));
+ scoped_refptr<GbmBuffer> buffer(new GbmBuffer(
+ gbm, bo, format, usage, std::move(fds), size, strides, modifiers));
if (usage == gfx::BufferUsage::SCANOUT && !buffer->GetFramebufferId())
return nullptr;
@@ -129,11 +138,12 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferFromFds(
TRACE_EVENT2("drm", "GbmBuffer::CreateBufferFromFD", "device",
gbm->device_path().value(), "size", size.ToString());
DCHECK_EQ(fds.size(), strides.size());
+ std::vector<uint64_t> modifiers;
// 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));
+ return make_scoped_refptr(
+ new GbmBuffer(gbm, nullptr, format, gfx::BufferUsage::GPU_READ,
+ std::move(fds), size, strides, modifiers));
}
GbmPixmap::GbmPixmap(GbmSurfaceFactory* surface_manager,
@@ -181,6 +191,10 @@ int GbmPixmap::GetDmaBufPitch(size_t plane) const {
return buffer_->GetStride(plane);
}
+uint64_t GbmPixmap::GetDmaBufModifier(size_t plane) const {
+ return buffer_->GetFormatModifier(plane);
+}
+
gfx::BufferFormat GbmPixmap::GetBufferFormat() const {
return buffer_->GetFormat();
}

Powered by Google App Engine
This is Rietveld 408576698