In iossim, ignore harmless messages from launchd.
[chromium-blink-merge.git] / cc / resource.cc
blob1fca7d756ced323448f3f4fed55be3c555f80d08
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.
5 #include "cc/resource.h"
6 #include "third_party/khronos/GLES2/gl2ext.h"
8 namespace cc {
10 void Resource::set_dimensions(const gfx::Size& size, GLenum format) {
11 size_ = size;
12 format_ = format;
15 size_t Resource::bytes() const {
16 if (size_.IsEmpty())
17 return 0;
19 return MemorySizeBytes(size_, format_);
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();
36 return components_per_pixel * bytes_per_component;
39 size_t Resource::MemorySizeBytes(const gfx::Size& size, GLenum format) {
40 return BytesPerPixel(format) * size.width() * size.height();
44 } // namespace cc