| Index: ui/gl/gl_image_io_surface.mm
|
| diff --git a/ui/gl/gl_image_io_surface.mm b/ui/gl/gl_image_io_surface.mm
|
| index 5d78bc67af769b00f6abd4f1365ddf61f44ec937..2106bd85710c01fc7c7138d765df9b96dde1b8fc 100644
|
| --- a/ui/gl/gl_image_io_surface.mm
|
| +++ b/ui/gl/gl_image_io_surface.mm
|
| @@ -85,6 +85,7 @@ bool ValidFormat(BufferFormat format) {
|
| switch (format) {
|
| case BufferFormat::R_8:
|
| case BufferFormat::BGRA_8888:
|
| + case BufferFormat::BGRX_8888:
|
| case BufferFormat::RGBA_8888:
|
| case BufferFormat::UYVY_422:
|
| case BufferFormat::YUV_420_BIPLANAR:
|
| @@ -96,7 +97,6 @@ bool ValidFormat(BufferFormat format) {
|
| case BufferFormat::ETC1:
|
| case BufferFormat::RGBA_4444:
|
| case BufferFormat::RGBX_8888:
|
| - case BufferFormat::BGRX_8888:
|
| case BufferFormat::YUV_420:
|
| return false;
|
| }
|
| @@ -110,6 +110,7 @@ GLenum TextureFormat(BufferFormat format) {
|
| case BufferFormat::R_8:
|
| return GL_RED;
|
| case BufferFormat::BGRA_8888:
|
| + case BufferFormat::BGRX_8888:
|
| case BufferFormat::RGBA_8888:
|
| return GL_RGBA;
|
| case BufferFormat::UYVY_422:
|
| @@ -123,7 +124,6 @@ GLenum TextureFormat(BufferFormat format) {
|
| case BufferFormat::ETC1:
|
| case BufferFormat::RGBA_4444:
|
| case BufferFormat::RGBX_8888:
|
| - case BufferFormat::BGRX_8888:
|
| case BufferFormat::YUV_420:
|
| NOTREACHED();
|
| return 0;
|
| @@ -138,6 +138,7 @@ GLenum DataFormat(BufferFormat format) {
|
| case BufferFormat::R_8:
|
| return GL_RED;
|
| case BufferFormat::BGRA_8888:
|
| + case BufferFormat::BGRX_8888:
|
| case BufferFormat::RGBA_8888:
|
| return GL_BGRA;
|
| case BufferFormat::UYVY_422:
|
| @@ -149,7 +150,6 @@ GLenum DataFormat(BufferFormat format) {
|
| case BufferFormat::ETC1:
|
| case BufferFormat::RGBA_4444:
|
| case BufferFormat::RGBX_8888:
|
| - case BufferFormat::BGRX_8888:
|
| case BufferFormat::YUV_420:
|
| case BufferFormat::YUV_420_BIPLANAR:
|
| NOTREACHED();
|
| @@ -165,6 +165,7 @@ GLenum DataType(BufferFormat format) {
|
| case BufferFormat::R_8:
|
| return GL_UNSIGNED_BYTE;
|
| case BufferFormat::BGRA_8888:
|
| + case BufferFormat::BGRX_8888:
|
| case BufferFormat::RGBA_8888:
|
| return GL_UNSIGNED_INT_8_8_8_8_REV;
|
| case BufferFormat::UYVY_422:
|
| @@ -177,7 +178,6 @@ GLenum DataType(BufferFormat format) {
|
| case BufferFormat::ETC1:
|
| case BufferFormat::RGBA_4444:
|
| case BufferFormat::RGBX_8888:
|
| - case BufferFormat::BGRX_8888:
|
| case BufferFormat::YUV_420:
|
| case BufferFormat::YUV_420_BIPLANAR:
|
| NOTREACHED();
|
| @@ -188,6 +188,15 @@ GLenum DataType(BufferFormat format) {
|
| return 0;
|
| }
|
|
|
| +// When an IOSurface is bound to a texture with internalformat "GL_RGB", many
|
| +// OpenGL operations are broken. Therefore, never allow an IOSurface to be bound
|
| +// with GL_RGB. https://crbug.com/595948.
|
| +GLenum ConvertRequestedInternalFormat(GLenum internalformat) {
|
| + if (internalformat == GL_RGB)
|
| + return GL_RGBA;
|
| + return internalformat;
|
| +}
|
| +
|
| } // namespace
|
|
|
| class GLImageIOSurface::RGBConverter
|
| @@ -357,7 +366,8 @@ bool GLImageIOSurface::RGBConverter::CopyTexImage(IOSurfaceRef io_surface,
|
| GLImageIOSurface::GLImageIOSurface(const gfx::Size& size,
|
| unsigned internalformat)
|
| : size_(size),
|
| - internalformat_(internalformat),
|
| + internalformat_(ConvertRequestedInternalFormat(internalformat)),
|
| + client_internalformat_(internalformat),
|
| format_(BufferFormat::RGBA_8888) {}
|
|
|
| GLImageIOSurface::~GLImageIOSurface() {
|
| @@ -498,6 +508,10 @@ void GLImageIOSurface::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
|
| pmd->AddOwnershipEdge(dump->guid(), guid);
|
| }
|
|
|
| +bool GLImageIOSurface::EmulatingRGB() const {
|
| + return client_internalformat_ == GL_RGB;
|
| +}
|
| +
|
| base::ScopedCFTypeRef<IOSurfaceRef> GLImageIOSurface::io_surface() {
|
| return io_surface_;
|
| }
|
|
|