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

Unified Diff: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc

Issue 656133002: Add dmabuf support to ozone scanout buffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h ('k') | ui/ozone/platform/dri/gbm_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
diff --git a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
index c9bee4c558501dc8ff420ef2264a8cb0ae64e231..ce1f9caaff8b438098c730875c1b1cbc0d95684f 100644
--- a/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
+++ b/ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "ui/gl/gl_image_egl.h"
+#include "ui/gl/gl_image_linux_dma_buffer.h"
#include "ui/ozone/public/native_pixmap.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#include "ui/ozone/public/surface_ozone_egl.h"
@@ -16,7 +17,7 @@ class GLImageOzoneNativePixmap : public gfx::GLImageEGL {
public:
explicit GLImageOzoneNativePixmap(const gfx::Size& size) : GLImageEGL(size) {}
- bool Initialize(scoped_refptr<NativePixmap> pixmap) {
+ bool Initialize(NativePixmap* pixmap) {
EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
if (!Initialize(EGL_NATIVE_PIXMAP_KHR, pixmap->GetEGLClientBuffer(), attrs))
return false;
@@ -41,6 +42,38 @@ class GLImageOzoneNativePixmap : public gfx::GLImageEGL {
scoped_refptr<NativePixmap> pixmap_;
};
+class GLImageOzoneNativePixmapDmaBuf : public gfx::GLImageLinuxDMABuffer {
+ public:
+ explicit GLImageOzoneNativePixmapDmaBuf(const gfx::Size& size,
+ unsigned internalformat)
+ : GLImageLinuxDMABuffer(size, internalformat) {}
+
+ bool Initialize(NativePixmap* pixmap,
+ gfx::GpuMemoryBuffer::Format format) {
+ base::FileDescriptor handle(pixmap->GetDmaBufFd(), false);
+ if (!GLImageLinuxDMABuffer::Initialize(
+ handle, format, pixmap->GetDmaBufPitch()))
+ return false;
+ pixmap_ = pixmap;
+ return true;
+ }
+
+ virtual bool ScheduleOverlayPlane(gfx::AcceleratedWidget widget,
+ int z_order,
+ gfx::OverlayTransform transform,
+ const gfx::Rect& bounds_rect,
+ const gfx::RectF& crop_rect) override {
+ return SurfaceFactoryOzone::GetInstance()->ScheduleOverlayPlane(
+ widget, z_order, transform, pixmap_, bounds_rect, crop_rect);
+ }
+
+ protected:
+ virtual ~GLImageOzoneNativePixmapDmaBuf() {}
+
+ private:
+ scoped_refptr<NativePixmap> pixmap_;
+};
+
SurfaceFactoryOzone::BufferFormat GetOzoneFormatFor(
gfx::GpuMemoryBuffer::Format format) {
switch (format) {
@@ -96,17 +129,31 @@ scoped_refptr<gfx::GLImage>
GpuMemoryBufferFactoryOzoneNativeBuffer::CreateImageForGpuMemoryBuffer(
const gfx::GpuMemoryBufferId& id,
const gfx::Size& size,
+ gfx::GpuMemoryBuffer::Format format,
unsigned internalformat) {
BufferToPixmapMap::iterator it = native_pixmap_map_.find(GetIndex(id));
if (it == native_pixmap_map_.end()) {
return scoped_refptr<gfx::GLImage>();
}
- scoped_refptr<GLImageOzoneNativePixmap> image =
- new GLImageOzoneNativePixmap(size);
- if (!image->Initialize(it->second)) {
- return scoped_refptr<gfx::GLImage>();
+ NativePixmap* pixmap = it->second.get();
+ if (pixmap->GetEGLClientBuffer()) {
+ DCHECK_EQ(-1, pixmap->GetDmaBufFd());
+ scoped_refptr<GLImageOzoneNativePixmap> image =
+ new GLImageOzoneNativePixmap(size);
+ if (!image->Initialize(pixmap)) {
+ return scoped_refptr<gfx::GLImage>();
+ }
+ return image;
+ }
+ if (pixmap->GetDmaBufFd() > 0) {
+ scoped_refptr<GLImageOzoneNativePixmapDmaBuf> image =
+ new GLImageOzoneNativePixmapDmaBuf(size, internalformat);
+ if (!image->Initialize(pixmap, format)) {
+ return scoped_refptr<gfx::GLImage>();
+ }
+ return image;
}
- return image;
+ return scoped_refptr<gfx::GLImage>();
}
} // namespace ui
« no previous file with comments | « ui/ozone/gpu/gpu_memory_buffer_factory_ozone_native_buffer.h ('k') | ui/ozone/platform/dri/gbm_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698