Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: cc/texture.cc

Issue 11229040: Fix glTexSubImage2D for non-32bpp formats. (Closed) Base URL: https://git.chromium.org/git/chromium/src@git-svn
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/texture.h ('k') | cc/texture_uploader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/texture.cc
diff --git a/cc/texture.cc b/cc/texture.cc
index 9fd8ebe1ff80f235887c22753bec5099e0507318..f6400eb20abcf0f76b2afe15fba636e1de167b0c 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();
}
}
« no previous file with comments | « cc/texture.h ('k') | cc/texture_uploader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698