| Index: cc/resources/resource_format.cc
|
| diff --git a/cc/resources/resource_format.cc b/cc/resources/resource_format.cc
|
| index 45581b800f140f3b6725a6bae4959686e66f03d0..c964691db78f4edea458918cd4c5502461fea546 100644
|
| --- a/cc/resources/resource_format.cc
|
| +++ b/cc/resources/resource_format.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "cc/resources/resource_format.h"
|
|
|
| +#include "third_party/khronos/GLES2/gl2.h"
|
| +#include "third_party/khronos/GLES2/gl2ext.h"
|
| +
|
| namespace cc {
|
|
|
| SkColorType ResourceFormatToSkColorType(ResourceFormat format) {
|
| @@ -25,4 +28,57 @@ SkColorType ResourceFormatToSkColorType(ResourceFormat format) {
|
| return kN32_SkColorType;
|
| }
|
|
|
| +int BitsPerPixel(ResourceFormat format) {
|
| + switch (format) {
|
| + case BGRA_8888:
|
| + case RGBA_8888:
|
| + return 32;
|
| + case RGBA_4444:
|
| + case RGB_565:
|
| + return 16;
|
| + case ALPHA_8:
|
| + case LUMINANCE_8:
|
| + case RED_8:
|
| + return 8;
|
| + case ETC1:
|
| + return 4;
|
| + }
|
| + NOTREACHED();
|
| + return 0;
|
| +}
|
| +
|
| +GLenum GLDataType(ResourceFormat format) {
|
| + DCHECK_LE(format, RESOURCE_FORMAT_MAX);
|
| + static const unsigned format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = {
|
| + GL_UNSIGNED_BYTE, // RGBA_8888
|
| + GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444
|
| + GL_UNSIGNED_BYTE, // BGRA_8888
|
| + GL_UNSIGNED_BYTE, // ALPHA_8
|
| + GL_UNSIGNED_BYTE, // LUMINANCE_8
|
| + GL_UNSIGNED_SHORT_5_6_5, // RGB_565,
|
| + GL_UNSIGNED_BYTE, // ETC1
|
| + GL_UNSIGNED_BYTE // RED_8
|
| + };
|
| + return format_gl_data_type[format];
|
| +}
|
| +
|
| +GLenum GLDataFormat(ResourceFormat format) {
|
| + DCHECK_LE(format, RESOURCE_FORMAT_MAX);
|
| + static const unsigned format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = {
|
| + 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_RED_EXT // RED_8
|
| + };
|
| + return format_gl_data_format[format];
|
| +}
|
| +
|
| +GLenum GLInternalFormat(ResourceFormat format) {
|
| + return GLDataFormat(format);
|
| +}
|
| +
|
| } // namespace cc
|
|
|