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

Side by Side Diff: cc/texture.cc

Issue 11228044: Revert 163477 - Fix glTexSubImage2D for non-32bpp formats. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/texture.h ('k') | cc/texture_uploader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/texture.h" 7 #include "cc/texture.h"
8 #include "third_party/khronos/GLES2/gl2ext.h"
9 8
10 namespace cc { 9 namespace cc {
11 10
12 void Texture::setDimensions(const IntSize& size, GLenum format) 11 void Texture::setDimensions(const IntSize& size, GLenum format)
13 { 12 {
14 m_size = size; 13 m_size = size;
15 m_format = format; 14 m_format = format;
16 } 15 }
17 16
18 size_t Texture::bytes() const 17 size_t Texture::bytes() const
19 { 18 {
20 if (m_size.isEmpty()) 19 if (m_size.isEmpty())
21 return 0u; 20 return 0u;
22 21
23 return memorySizeBytes(m_size, m_format); 22 return memorySizeBytes(m_size, m_format);
24 } 23 }
25 24
26 size_t Texture::bytesPerPixel(GLenum format)
27 {
28 unsigned int componentsPerPixel = 0;
29 unsigned int bytesPerComponent = 1;
30 switch (format) {
31 case GL_RGBA:
32 case GL_BGRA_EXT:
33 componentsPerPixel = 4;
34 break;
35 case GL_LUMINANCE:
36 componentsPerPixel = 1;
37 break;
38 default:
39 NOTREACHED();
40 }
41 return componentsPerPixel * bytesPerComponent;
42 }
43
44 size_t Texture::memorySizeBytes(const IntSize& size, GLenum format) 25 size_t Texture::memorySizeBytes(const IntSize& size, GLenum format)
45 { 26 {
46 return bytesPerPixel(format) * size.width() * size.height(); 27 unsigned int componentsPerPixel = 4;
28 unsigned int bytesPerComponent = 1;
29 return componentsPerPixel * bytesPerComponent * size.width() * size.height() ;
47 } 30 }
48 31
49 } 32 }
OLDNEW
« 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