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

Side by Side Diff: cc/resources/resource.cc

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix raster-on-demand codepath Created 7 years, 3 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
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 "cc/resources/resource.h" 5 #include "cc/resources/resource.h"
6 #include "third_party/khronos/GLES2/gl2ext.h" 6 #include "third_party/khronos/GLES2/gl2ext.h"
7 7
8 namespace cc { 8 namespace cc {
9 9
10 size_t Resource::bytes() const { 10 size_t Resource::bytes() const {
11 if (size_.IsEmpty()) 11 if (size_.IsEmpty())
12 return 0; 12 return 0;
13 13
14 return MemorySizeBytes(size_, format_); 14 return MemorySizeBytes(size_, format_, is_16_bit_resource_);
15 } 15 }
16 16
17 size_t Resource::BytesPerPixel(GLenum format) { 17 size_t Resource::BytesPerPixel(GLenum format, bool is_16_bit_resource) {
epennerAtGoogle 2013/09/05 01:54:15 Could we just pass in the GL type here rather than
Sami 2013/09/05 14:13:26 +1, I think that would make this a lot cleaner.
kaanb 2013/09/06 02:05:54 On my TODO list for tomorrow.
18 size_t components_per_pixel = 0; 18 size_t components_per_pixel = 0;
19 size_t bytes_per_component = 1; 19 size_t bytes_per_component = 1;
20 switch (format) { 20 switch (format) {
21 case GL_RGBA: 21 case GL_RGBA:
22 components_per_pixel = (is_16_bit_resource) ? 2 : 4;
23 break;
22 case GL_BGRA_EXT: 24 case GL_BGRA_EXT:
23 components_per_pixel = 4; 25 components_per_pixel = 4;
24 break; 26 break;
25 case GL_LUMINANCE: 27 case GL_LUMINANCE:
26 components_per_pixel = 1; 28 components_per_pixel = 1;
27 break; 29 break;
28 default: 30 default:
29 NOTREACHED(); 31 NOTREACHED();
30 } 32 }
31 return components_per_pixel * bytes_per_component; 33 return components_per_pixel * bytes_per_component;
32 } 34 }
33 35
34 size_t Resource::MemorySizeBytes(gfx::Size size, GLenum format) { 36 size_t Resource::MemorySizeBytes(
35 return BytesPerPixel(format) * size.width() * size.height(); 37 gfx::Size size, GLenum format, bool is_16_bit_resource) {
38 return
39 BytesPerPixel(format, is_16_bit_resource) * size.width() * size.height();
36 } 40 }
37 41
38 42
39 } // namespace cc 43 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698