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

Unified Diff: ui/gl/gl_image_native_pixmap.cc

Issue 2801713002: GLImageEGL: add dmabuf queries
Patch Set: remove enum BufferFormatModifier Created 3 years, 8 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/gl/gl_image_native_pixmap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_native_pixmap.cc
diff --git a/ui/gl/gl_image_native_pixmap.cc b/ui/gl/gl_image_native_pixmap.cc
index d29de1caacdfdcd470d9fc28df5cb083128d68dc..944ba84bd8fa59e6b59e51dc4188641fdf05095d 100644
--- a/ui/gl/gl_image_native_pixmap.cc
+++ b/ui/gl/gl_image_native_pixmap.cc
@@ -22,6 +22,7 @@
#define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4')
#define DRM_FORMAT_YVU420 FOURCC('Y', 'V', '1', '2')
#define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2')
+#define DRM_FORMAT_UYVY FOURCC('U', 'Y', 'V', 'Y')
namespace gl {
namespace {
@@ -112,6 +113,33 @@ EGLint FourCC(gfx::BufferFormat format) {
return 0;
}
+gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) {
+ switch (format) {
+ case DRM_FORMAT_R8:
+ return gfx::BufferFormat::R_8;
+ case DRM_FORMAT_GR88:
+ return gfx::BufferFormat::RG_88;
+ case DRM_FORMAT_ABGR8888:
+ return gfx::BufferFormat::RGBA_8888;
+ case DRM_FORMAT_XBGR8888:
+ return gfx::BufferFormat::RGBX_8888;
+ case DRM_FORMAT_ARGB8888:
+ return gfx::BufferFormat::BGRA_8888;
+ case DRM_FORMAT_XRGB8888:
+ return gfx::BufferFormat::BGRX_8888;
+ case DRM_FORMAT_RGB565:
+ return gfx::BufferFormat::BGR_565;
+ case DRM_FORMAT_UYVY:
+ return gfx::BufferFormat::UYVY_422;
+ case DRM_FORMAT_NV12:
+ return gfx::BufferFormat::YUV_420_BIPLANAR;
+ case DRM_FORMAT_YVU420:
+ return gfx::BufferFormat::YVU_420;
+ default:
+ return gfx::BufferFormat::BGRA_8888;
+ }
+}
+
} // namespace
GLImageNativePixmap::GLImageNativePixmap(const gfx::Size& size,
@@ -196,6 +224,24 @@ bool GLImageNativePixmap::Initialize(gfx::NativePixmap* pixmap,
return true;
}
+gfx::GpuMemoryBufferAttribVector
+GLImageNativePixmap::QueryDmaBufFormatsAndModifiers() {
+ bool has_dma_buf_import_modifier = gl::GLSurfaceEGL::HasEGLExtension(
+ "EGL_EXT_image_dma_buf_import_modifiers");
+ std::vector<std::pair<EGLint, EGLuint64KHR>> drm_supported_gmb_attribs;
+ gfx::GpuMemoryBufferAttribVector supported_gmb_attribs;
+
+ if (!has_dma_buf_import_modifier)
+ return supported_gmb_attribs;
+
+ drm_supported_gmb_attribs = GLImageEGL::GetDmaBufFormatsWithModifiers();
+
+ for (auto& elem : drm_supported_gmb_attribs)
+ supported_gmb_attribs.push_back(gfx::GpuMemoryBufferAttrib(
+ GetBufferFormatFromFourCCFormat(elem.first), elem.second));
+ return supported_gmb_attribs;
+}
+
unsigned GLImageNativePixmap::GetInternalFormat() {
return internalformat_;
}
« no previous file with comments | « ui/gl/gl_image_native_pixmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698