summaryrefslogtreecommitdiffstats
path: root/cc/texture.cc
diff options
context:
space:
mode:
authorsheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 02:03:33 +0000
committersheu@chromium.org <sheu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 02:03:33 +0000
commita43c3b27bc86bd9611fcfefa95b37843f8608f89 (patch)
tree0fd3050ddb6a2079799a332017b210006c7e9be0 /cc/texture.cc
parent869dc70d61b5a80b0e62b485e008458f2c7ff530 (diff)
downloadchromium_src-a43c3b27bc86bd9611fcfefa95b37843f8608f89.zip
chromium_src-a43c3b27bc86bd9611fcfefa95b37843f8608f89.tar.gz
chromium_src-a43c3b27bc86bd9611fcfefa95b37843f8608f89.tar.bz2
Fix glTexSubImage2D for non-32bpp formats.
The non-mapped upload path for glTexSubImage2D is assuming 32bpp blindly, for all formats. TEST=local build, run on ARM (forcing non-mapped path) BUG=None Change-Id: Ib8ac46646b27faeeb8c19ebb519d321e25c1a8cb Review URL: https://chromiumcodereview.appspot.com/11229040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/texture.cc')
-rw-r--r--cc/texture.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/cc/texture.cc b/cc/texture.cc
index 9fd8ebe..f6400eb 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 Texture::bytes() const
return memorySizeBytes(m_size, m_format);
}
-size_t Texture::memorySizeBytes(const IntSize& size, GLenum format)
+size_t Texture::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 Texture::memorySizeBytes(const IntSize& size, GLenum format)
+{
+ return bytesPerPixel(format) * size.width() * size.height();
}
}