Chromium Code Reviews| 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 ed721b9b265a9c304b3493789442f81e279132db..e48fba86ce7448686bf445216fbe5e77ef301b28 100644 |
| --- a/ui/gl/gl_image_ozone_native_pixmap.cc |
| +++ b/ui/gl/gl_image_ozone_native_pixmap.cc |
| @@ -19,13 +19,23 @@ |
| namespace gl { |
| namespace { |
| -bool ValidInternalFormat(unsigned internalformat) { |
| +bool ValidInternalFormat(unsigned internalformat, gfx::BufferFormat format) { |
| switch (internalformat) { |
| case GL_RGB: |
|
reveman
2016/06/03 23:33:01
maybe we should be even more restrictive here and
Daniele Castagna
2016/06/03 23:45:29
Made validation as restrictive as possible.
|
| case GL_RGBA: |
| case GL_BGRA_EXT: |
| + switch (format) { |
| + 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: |
| + return true; |
| + default: |
| + return false; |
| + } |
| case GL_RED_EXT: |
| - return true; |
| + return format == gfx::BufferFormat::R_8; |
| default: |
| return false; |
| } |
| @@ -106,16 +116,18 @@ bool GLImageOzoneNativePixmap::Initialize(ui::NativePixmap* pixmap, |
| return false; |
| } |
| } else if (pixmap->AreDmaBufFdsValid()) { |
| - if (!ValidInternalFormat(internalformat_)) { |
| - LOG(ERROR) << "Invalid internalformat: " << internalformat_; |
| - return false; |
| - } |
| if (!ValidFormat(format)) { |
| LOG(ERROR) << "Invalid format: " << static_cast<int>(format); |
| return false; |
| } |
| + if (!ValidInternalFormat(internalformat_, format)) { |
| + LOG(ERROR) << "Invalid internalformat: " << internalformat_ |
| + << " for format: " << static_cast<int>(format); |
| + return false; |
| + } |
| + |
| // Note: If eglCreateImageKHR is successful for a EGL_LINUX_DMA_BUF_EXT |
| // target, the EGL will take a reference to the dma_buf. |
| std::vector<EGLint> attrs; |
| @@ -188,4 +200,34 @@ void GLImageOzoneNativePixmap::OnMemoryDump( |
| // TODO(ericrk): Implement GLImage OnMemoryDump. crbug.com/514914 |
| } |
| +// static |
| +unsigned GLImageOzoneNativePixmap::GetInternalFormatForTesting( |
| + gfx::BufferFormat format) { |
| + DCHECK(ValidFormat(format)); |
| + switch (format) { |
| + case gfx::BufferFormat::R_8: |
| + return GL_RED_EXT; |
| + 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: |
| + return GL_RGBA; |
| + 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: |
| + case gfx::BufferFormat::YUV_420_BIPLANAR: |
| + case gfx::BufferFormat::UYVY_422: |
| + NOTREACHED(); |
| + return GL_NONE; |
| + } |
| + |
| + NOTREACHED(); |
| + return GL_NONE; |
| +} |
| + |
| } // namespace gl |