Index: cc/resources/resource_format.cc |
diff --git a/cc/resources/resource_format.cc b/cc/resources/resource_format.cc |
index 2d139ab5c0465e910b289844893c6acb63a3653f..1461e23908707ba0b544946615e1533948fe6152 100644 |
--- a/cc/resources/resource_format.cc |
+++ b/cc/resources/resource_format.cc |
@@ -17,6 +17,7 @@ int BitsPerPixel(ResourceFormat format) { |
return 32; |
case RGBA_4444: |
case RGB_565: |
+ case RG_88: |
case LUMINANCE_F16: |
return 16; |
case ALPHA_8: |
@@ -41,6 +42,7 @@ GLenum GLDataType(ResourceFormat format) { |
GL_UNSIGNED_SHORT_5_6_5, // RGB_565, |
GL_UNSIGNED_BYTE, // ETC1 |
GL_UNSIGNED_BYTE, // RED_8 |
+ GL_UNSIGNED_BYTE, // RG_88 |
GL_HALF_FLOAT_OES, // LUMINANCE_F16 |
}; |
static_assert(arraysize(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1), |
@@ -60,6 +62,7 @@ GLenum GLDataFormat(ResourceFormat format) { |
GL_RGB, // RGB_565 |
GL_ETC1_RGB8_OES, // ETC1 |
GL_RED_EXT, // RED_8 |
+ GL_RG_EXT, // RG_88 |
GL_LUMINANCE, // LUMINANCE_F16 |
}; |
static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), |
@@ -70,7 +73,23 @@ GLenum GLDataFormat(ResourceFormat format) { |
GLenum GLInternalFormat(ResourceFormat format) { |
// In GLES2, the internal format must match the texture format. (It no longer |
// is true in GLES3, however it still holds for the BGRA extension.) |
- return GLDataFormat(format); |
+ DCHECK_LE(format, RESOURCE_FORMAT_MAX); |
+ static const GLenum internal_format_gl_data_format[] = { |
+ GL_RGBA, // RGBA_8888 |
+ GL_RGBA, // RGBA_4444 |
+ GL_BGRA_EXT, // BGRA_8888 |
+ GL_ALPHA, // ALPHA_8 |
+ GL_LUMINANCE, // LUMINANCE_8 |
+ GL_RGB, // RGB_565 |
+ GL_ETC1_RGB8_OES, // ETC1 |
+ GL_R8_EXT, // RED_8 |
+ GL_RG8_EXT, // RG_88 |
+ GL_LUMINANCE, // LUMINANCE_F16 |
+ }; |
+ static_assert( |
+ arraysize(internal_format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), |
+ "internal_format_gl_data_format does not handle all cases."); |
+ return internal_format_gl_data_format[format]; |
} |
GLenum GLCopyTextureInternalFormat(ResourceFormat format) { |
@@ -89,7 +108,8 @@ GLenum GLCopyTextureInternalFormat(ResourceFormat format) { |
GL_LUMINANCE, // LUMINANCE_8 |
GL_RGB, // RGB_565 |
GL_RGB, // ETC1 |
- GL_LUMINANCE, // RED_8 |
+ GL_R8_EXT, // RED_8 |
+ GL_RG8_EXT, // RG_88: |
GL_LUMINANCE, // LUMINANCE_F16 |
}; |
static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), |
@@ -103,6 +123,8 @@ gfx::BufferFormat BufferFormat(ResourceFormat format) { |
return gfx::BufferFormat::BGRA_8888; |
case RED_8: |
return gfx::BufferFormat::R_8; |
+ case RG_88: |
+ return gfx::BufferFormat::RG_88; |
case RGBA_4444: |
return gfx::BufferFormat::RGBA_4444; |
case RGBA_8888: |
@@ -134,6 +156,7 @@ bool DoesResourceFormatSupportAlpha(ResourceFormat format) { |
case RGB_565: |
case ETC1: |
case RED_8: |
+ case RG_88: |
case LUMINANCE_F16: |
return false; |
} |