diff options
Diffstat (limited to 'chromium/cc/base/util.h')
-rw-r--r-- | chromium/cc/base/util.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/chromium/cc/base/util.h b/chromium/cc/base/util.h index 1d716ae2a42..bd511786dca 100644 --- a/chromium/cc/base/util.h +++ b/chromium/cc/base/util.h @@ -8,6 +8,9 @@ #include <limits> #include "base/basictypes.h" +#include "cc/resources/resource_provider.h" +#include "third_party/khronos/GLES2/gl2.h" +#include "third_party/khronos/GLES2/gl2ext.h" namespace cc { @@ -24,6 +27,36 @@ template <typename T> T RoundDown(T n, T mul) { : ((n - mul + 1) / mul) * mul; } +inline 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, // LUMINANCE_8 + GL_UNSIGNED_SHORT_5_6_5, // RGB_565, + GL_UNSIGNED_BYTE // ETC1 + }; + return format_gl_data_type[format]; +} + +inline 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_LUMINANCE, // LUMINANCE_8 + GL_RGB, // RGB_565 + GL_ETC1_RGB8_OES // ETC1 + }; + return format_gl_data_format[format]; +} + +inline GLenum GLInternalFormat(ResourceFormat format) { + return GLDataFormat(format); +} + } // namespace cc #endif // CC_BASE_UTIL_H_ |