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

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

Issue 14301021: cc: Don't pass simple well-defined classes by reference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/resources/resource.h ('k') | cc/resources/resource_pool.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" 6 #include "third_party/khronos/GLES2/gl2ext.h"
7 7
8 namespace cc { 8 namespace cc {
9 9
10 void Resource::set_dimensions(const gfx::Size& size, GLenum format) {
11 size_ = size;
12 format_ = format;
13 }
14
15 size_t Resource::bytes() const { 10 size_t Resource::bytes() const {
16 if (size_.IsEmpty()) 11 if (size_.IsEmpty())
17 return 0; 12 return 0;
18 13
19 return MemorySizeBytes(size_, format_); 14 return MemorySizeBytes(size_, format_);
20 } 15 }
21 16
22 size_t Resource::BytesPerPixel(GLenum format) { 17 size_t Resource::BytesPerPixel(GLenum format) {
23 size_t components_per_pixel = 0; 18 size_t components_per_pixel = 0;
24 size_t bytes_per_component = 1; 19 size_t bytes_per_component = 1;
25 switch (format) { 20 switch (format) {
26 case GL_RGBA: 21 case GL_RGBA:
27 case GL_BGRA_EXT: 22 case GL_BGRA_EXT:
28 components_per_pixel = 4; 23 components_per_pixel = 4;
29 break; 24 break;
30 case GL_LUMINANCE: 25 case GL_LUMINANCE:
31 components_per_pixel = 1; 26 components_per_pixel = 1;
32 break; 27 break;
33 default: 28 default:
34 NOTREACHED(); 29 NOTREACHED();
35 } 30 }
36 return components_per_pixel * bytes_per_component; 31 return components_per_pixel * bytes_per_component;
37 } 32 }
38 33
39 size_t Resource::MemorySizeBytes(const gfx::Size& size, GLenum format) { 34 size_t Resource::MemorySizeBytes(gfx::Size size, GLenum format) {
40 return BytesPerPixel(format) * size.width() * size.height(); 35 return BytesPerPixel(format) * size.width() * size.height();
41 } 36 }
42 37
43 38
44 } // namespace cc 39 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource.h ('k') | cc/resources/resource_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698