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

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: fixed a signed vs. unsigned comparison in video_resource_updater.cc 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
« no previous file with comments | « cc/resources/resource.h ('k') | cc/resources/resource_format.h » ('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 "cc/resources/resource.h" 5 #include "cc/resources/resource.h"
6 #include "third_party/khronos/GLES2/gl2ext.h"
7 6
8 namespace cc { 7 namespace cc {
9 8
10 size_t Resource::bytes() const { 9 size_t Resource::bytes() const {
11 if (size_.IsEmpty()) 10 if (size_.IsEmpty())
12 return 0; 11 return 0;
13 12
14 return MemorySizeBytes(size_, format_); 13 return MemorySizeBytes(size_, format_);
15 } 14 }
16 15
17 size_t Resource::BytesPerPixel(GLenum format) { 16 size_t Resource::MemorySizeBytes(gfx::Size size, ResourceFormat format) {
18 size_t components_per_pixel = 0; 17 return ResourceProvider::BytesPerPixel(format) * size.width() * size.height();
19 size_t bytes_per_component = 1;
20 switch (format) {
21 case GL_RGBA:
22 case GL_BGRA_EXT:
23 components_per_pixel = 4;
24 break;
25 case GL_LUMINANCE:
26 components_per_pixel = 1;
27 break;
28 default:
29 NOTREACHED();
30 }
31 return components_per_pixel * bytes_per_component;
32 } 18 }
33 19
34 size_t Resource::MemorySizeBytes(gfx::Size size, GLenum format) {
35 return BytesPerPixel(format) * size.width() * size.height();
36 }
37
38
39 } // namespace cc 20 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource.h ('k') | cc/resources/resource_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698