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

Unified Diff: content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc

Issue 1134993003: ozone: Implement zero/one-copy texture for Ozone GBM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: open VGEM device in renderer in ad-hoc manner Created 5 years, 4 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: content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc
diff --git a/content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc b/content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc
index d3e0576124a9be60c8f6e67f2dddfbc0ca0f63d8..990d0e2dc9d3f15f6482d394d7aac5a334c1e88d 100644
--- a/content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc
+++ b/content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.cc
@@ -4,6 +4,7 @@
#include "content/common/gpu/gpu_memory_buffer_factory_ozone_native_pixmap.h"
+#include "base/posix/eintr_wrapper.h"
#include "ui/gl/gl_image_ozone_native_pixmap.h"
#include "ui/ozone/public/client_native_pixmap_factory.h"
#include "ui/ozone/public/ozone_platform.h"
@@ -24,6 +25,18 @@ void GetSupportedConfigurations(
}
}
+bool ShareToClientProcess(int fd, base::FileDescriptor* new_handle) {
+ int duped_handle = HANDLE_EINTR(dup(fd));
+ if (duped_handle < 0) {
+ DPLOG(ERROR) << "dup() failed.";
+ *new_handle = base::FileDescriptor();
+ return false;
+ }
+
+ *new_handle = base::FileDescriptor(duped_handle, true);
+ return true;
+}
+
} // namespace
GpuMemoryBufferFactoryOzoneNativePixmap::
@@ -79,6 +92,14 @@ GpuMemoryBufferFactoryOzoneNativePixmap::CreateGpuMemoryBuffer(
gfx::GpuMemoryBufferHandle handle;
handle.type = gfx::OZONE_NATIVE_PIXMAP;
handle.id = id;
+ if (usage == gfx::BufferUsage::MAP) {
+ base::FileDescriptor dma_buf;
+ if (!ShareToClientProcess(pixmap->GetDmaBufFd(), &dma_buf)) {
+ DLOG(ERROR) << "Fail to duplicate a DMA-BUF file descriptor";
+ return gfx::GpuMemoryBufferHandle();
+ }
+ handle.handle = dma_buf;
+ }
return handle;
}

Powered by Google App Engine
This is Rietveld 408576698