| Index: cc/texture.cc
|
| diff --git a/cc/texture.cc b/cc/texture.cc
|
| index 34138620f476360689640f39a157b0438f45e910..42aa0f1dbf1176203724916b973848f7745b2102 100644
|
| --- a/cc/texture.cc
|
| +++ b/cc/texture.cc
|
| @@ -5,6 +5,7 @@
|
| #include "config.h"
|
|
|
| #include "cc/texture.h"
|
| +#include "third_party/khronos/GLES2/gl2ext.h"
|
|
|
| namespace cc {
|
|
|
| @@ -22,11 +23,27 @@ size_t CCTexture::bytes() const
|
| return memorySizeBytes(m_size, m_format);
|
| }
|
|
|
| -size_t CCTexture::memorySizeBytes(const IntSize& size, GLenum format)
|
| +size_t CCTexture::bytesPerPixel(GLenum format)
|
| {
|
| - unsigned int componentsPerPixel = 4;
|
| + unsigned int componentsPerPixel = 0;
|
| unsigned int bytesPerComponent = 1;
|
| - return componentsPerPixel * bytesPerComponent * size.width() * size.height();
|
| + switch (format) {
|
| + case GL_RGBA:
|
| + case GL_BGRA_EXT:
|
| + componentsPerPixel = 4;
|
| + break;
|
| + case GL_LUMINANCE:
|
| + componentsPerPixel = 1;
|
| + break;
|
| + default:
|
| + NOTREACHED();
|
| + }
|
| + return componentsPerPixel * bytesPerComponent;
|
| +}
|
| +
|
| +size_t CCTexture::memorySizeBytes(const IntSize& size, GLenum format)
|
| +{
|
| + return bytesPerPixel(format) * size.width() * size.height();
|
| }
|
|
|
| }
|
|
|