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

Side by Side Diff: cc/resource.cc

Issue 12471007: Part 8 of cc/ directory shuffles: resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/resource.h ('k') | cc/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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "cc/resource.h"
6 #include "third_party/khronos/GLES2/gl2ext.h"
7
8 namespace cc {
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 {
16 if (size_.IsEmpty())
17 return 0;
18
19 return MemorySizeBytes(size_, format_);
20 }
21
22 size_t Resource::BytesPerPixel(GLenum format) {
23 size_t components_per_pixel = 0;
24 size_t bytes_per_component = 1;
25 switch (format) {
26 case GL_RGBA:
27 case GL_BGRA_EXT:
28 components_per_pixel = 4;
29 break;
30 case GL_LUMINANCE:
31 components_per_pixel = 1;
32 break;
33 default:
34 NOTREACHED();
35 }
36 return components_per_pixel * bytes_per_component;
37 }
38
39 size_t Resource::MemorySizeBytes(const gfx::Size& size, GLenum format) {
40 return BytesPerPixel(format) * size.width() * size.height();
41 }
42
43
44 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource.h ('k') | cc/resource_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698