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

Side by Side Diff: cc/resource.cc

Issue 11412022: Switched cc::Resource and cc::ScopedResource to Chrome coding style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests. Created 8 years, 1 month 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/resource.h ('k') | cc/scoped_resource.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/resource.h" 5 #include "cc/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 void Resource::setDimensions(const gfx::Size& size, GLenum format) 10 void Resource::set_dimensions(const gfx::Size& size, GLenum format) {
11 { 11 size_ = size;
12 m_size = size; 12 format_ = format;
13 m_format = format;
14 } 13 }
15 14
16 size_t Resource::bytes() const 15 size_t Resource::bytes() const {
17 { 16 if (size_.IsEmpty())
18 if (m_size.IsEmpty()) 17 return 0;
19 return 0u;
20 18
21 return memorySizeBytes(m_size, m_format); 19 return MemorySizeBytes(size_, format_);
22 } 20 }
23 21
24 size_t Resource::bytesPerPixel(GLenum format) 22 size_t Resource::BytesPerPixel(GLenum format) {
25 { 23 size_t components_per_pixel = 0;
26 unsigned int componentsPerPixel = 0; 24 size_t bytes_per_component = 1;
27 unsigned int bytesPerComponent = 1; 25 switch (format) {
28 switch (format) {
29 case GL_RGBA: 26 case GL_RGBA:
30 case GL_BGRA_EXT: 27 case GL_BGRA_EXT:
31 componentsPerPixel = 4; 28 components_per_pixel = 4;
32 break; 29 break;
33 case GL_LUMINANCE: 30 case GL_LUMINANCE:
34 componentsPerPixel = 1; 31 components_per_pixel = 1;
35 break; 32 break;
36 default: 33 default:
37 NOTREACHED(); 34 NOTREACHED();
38 } 35 }
39 return componentsPerPixel * bytesPerComponent; 36 return components_per_pixel * bytes_per_component;
40 } 37 }
41 38
42 size_t Resource::memorySizeBytes(const gfx::Size& size, GLenum format) 39 size_t Resource::MemorySizeBytes(const gfx::Size& size, GLenum format) {
43 { 40 return BytesPerPixel(format) * size.width() * size.height();
44 return bytesPerPixel(format) * size.width() * size.height();
45 } 41 }
46 42
43
47 } // namespace cc 44 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource.h ('k') | cc/scoped_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698