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

Unified Diff: ui/gl/gl_image_ozone_native_pixmap.cc

Issue 2334143003: ozone: Sort U and V plane when creating an image. (Closed)
Patch Set: Add missing attribute. Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_image_ozone_native_pixmap.cc
diff --git a/ui/gl/gl_image_ozone_native_pixmap.cc b/ui/gl/gl_image_ozone_native_pixmap.cc
index 977f02e424ff06f389098e1a4094bc4dfa6da31a..86e13b25b861e59e81478d29412f7367300b39bb 100644
--- a/ui/gl/gl_image_ozone_native_pixmap.cc
+++ b/ui/gl/gl_image_ozone_native_pixmap.cc
@@ -96,6 +96,32 @@ EGLint FourCC(gfx::BufferFormat format) {
return 0;
}
+#if !defined(ARCH_CPU_X86_FAMILY)
+bool IsFormatCrCb(gfx::BufferFormat format) {
+ switch (format) {
+ case gfx::BufferFormat::YVU_420:
+ return true;
+ case gfx::BufferFormat::R_8:
+ case gfx::BufferFormat::BGR_565:
+ case gfx::BufferFormat::RGBA_8888:
+ case gfx::BufferFormat::RGBX_8888:
+ case gfx::BufferFormat::BGRA_8888:
+ case gfx::BufferFormat::BGRX_8888:
+ case gfx::BufferFormat::ATC:
+ case gfx::BufferFormat::ATCIA:
+ case gfx::BufferFormat::DXT1:
+ case gfx::BufferFormat::DXT5:
+ case gfx::BufferFormat::ETC1:
+ case gfx::BufferFormat::RGBA_4444:
+ case gfx::BufferFormat::YUV_420_BIPLANAR:
+ case gfx::BufferFormat::UYVY_422:
+ return false;
+ }
+ NOTREACHED();
+ return false;
+}
+#endif
+
} // namespace
GLImageOzoneNativePixmap::GLImageOzoneNativePixmap(const gfx::Size& size,
@@ -137,16 +163,34 @@ bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap,
attrs.push_back(EGL_LINUX_DRM_FOURCC_EXT);
attrs.push_back(FourCC(format));
- for (size_t plane = 0;
- plane < gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
- ++plane) {
- attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + plane * 3);
- attrs.push_back(
- pixmap->GetDmaBufFd(plane < pixmap->GetDmaBufFdCount() ? plane : 0));
- attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + plane * 3);
- attrs.push_back(pixmap->GetDmaBufOffset(plane));
- attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + plane * 3);
- attrs.push_back(pixmap->GetDmaBufPitch(plane));
+ for (size_t attrs_plane = 0;
+ attrs_plane <
+ gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat());
+ ++attrs_plane) {
+ attrs.push_back(EGL_DMA_BUF_PLANE0_FD_EXT + attrs_plane * 3);
+
+ size_t pixmap_plane = attrs_plane;
+
+// TODO(dcastagna): Intel mesa flips V and U when the fourcc format is a
+// CrCb format therefore we don't need to.
+// Once crbug.com/646137 is addressed this ifdef (but not its content) can be
+// removed.
+#if !defined(ARCH_CPU_X86_FAMILY)
+ // EGL_EXT_image_dma_buf_import always expects U and V as plane 1 and 2 in
+ // case of a YUV/YVU format. We swap U and V plane indexes for CrCb
+ // multi-planar formats.
+ if (IsFormatCrCb(format) &&
+ gfx::NumberOfPlanesForBufferFormat(pixmap->GetBufferFormat()) == 3 &&
+ attrs_plane) {
+ pixmap_plane = 3 - attrs_plane;
+ }
+#endif
+ attrs.push_back(pixmap->GetDmaBufFd(
+ pixmap_plane < pixmap->GetDmaBufFdCount() ? pixmap_plane : 0));
+ attrs.push_back(EGL_DMA_BUF_PLANE0_OFFSET_EXT + attrs_plane * 3);
+ attrs.push_back(pixmap->GetDmaBufOffset(pixmap_plane));
+ attrs.push_back(EGL_DMA_BUF_PLANE0_PITCH_EXT + attrs_plane * 3);
+ attrs.push_back(pixmap->GetDmaBufPitch(pixmap_plane));
}
attrs.push_back(EGL_NONE);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698