| Index: gpu/command_buffer/common/gles2_cmd_utils.cc
|
| diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc
|
| index 0c2f493c6e63592321dd41f5167d6ca7834282f5..164981e75a4cbd4a9662fb103dcf6d438a3add01 100644
|
| --- a/gpu/command_buffer/common/gles2_cmd_utils.cc
|
| +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc
|
| @@ -468,6 +468,76 @@ bool GLES2Util::ComputeImageDataSizes(
|
| return true;
|
| }
|
|
|
| +namespace {
|
| +
|
| +const int kS3TCBlockWidth = 4;
|
| +const int kS3TCBlockHeight = 4;
|
| +const int kS3TCDXT1BlockSize = 8;
|
| +const int kS3TCDXT3AndDXT5BlockSize = 16;
|
| +const int kETC1BlockWidth = 4;
|
| +const int kETC1BlockHeight = 4;
|
| +const int kETC1BlockSize = 8;
|
| +
|
| +bool IsValidDXTSize(GLint level, GLsizei size) {
|
| + return (size == 1) || (size == 2) || !(size % kS3TCBlockWidth);
|
| +}
|
| +
|
| +} // anonymous namespace.
|
| +
|
| +bool GLES2Util::ComputeCompressedImageSize(int width,
|
| + int height,
|
| + int format,
|
| + int* ret_size) {
|
| + switch (format) {
|
| + case GL_ATC_RGB_AMD:
|
| + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: {
|
| + int num_blocks_across = (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth;
|
| + int num_blocks_down = (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight;
|
| + int num_blocks = num_blocks_across * num_blocks_down;
|
| + *ret_size = num_blocks * kS3TCDXT1BlockSize;
|
| + return true;
|
| + }
|
| + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: {
|
| + int num_blocks_across = (width + kS3TCBlockWidth - 1) / kS3TCBlockWidth;
|
| + int num_blocks_down = (height + kS3TCBlockHeight - 1) / kS3TCBlockHeight;
|
| + int num_blocks = num_blocks_across * num_blocks_down;
|
| + *ret_size = num_blocks * kS3TCDXT3AndDXT5BlockSize;
|
| + return true;
|
| + }
|
| + case GL_ETC1_RGB8_OES: {
|
| + int num_blocks_across = (width + kETC1BlockWidth - 1) / kETC1BlockWidth;
|
| + int num_blocks_down = (height + kETC1BlockHeight - 1) / kETC1BlockHeight;
|
| + int num_blocks = num_blocks_across * num_blocks_down;
|
| + *ret_size = num_blocks * kETC1BlockSize;
|
| + return true;
|
| + }
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| +bool GLES2Util::IsValidCompressedImageSize(int level,
|
| + int width,
|
| + int height,
|
| + int format) {
|
| + switch (format) {
|
| + case GL_ATC_RGB_AMD:
|
| + case GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD:
|
| + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
| + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
| + return IsValidDXTSize(level, width) && IsValidDXTSize(level, height);
|
| + case GL_ETC1_RGB8_OES:
|
| + return width > 0 && height > 0;
|
| + default:
|
| + return false;
|
| + }
|
| +}
|
| +
|
| size_t GLES2Util::RenderbufferBytesPerPixel(int format) {
|
| switch (format) {
|
| case GL_STENCIL_INDEX8:
|
|
|