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"
10 void Resource::set_dimensions(const gfx::Size
& size
, GLenum format
) {
15 size_t Resource::bytes() const {
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;
28 components_per_pixel
= 4;
31 components_per_pixel
= 1;
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();