OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/test_texture.h" | 5 #include "cc/test/test_texture.h" |
6 | 6 |
7 #include "gpu/GLES2/gl2extchromium.h" | 7 #include "gpu/GLES2/gl2extchromium.h" |
8 #include "third_party/khronos/GLES2/gl2.h" | |
9 #include "third_party/khronos/GLES2/gl2ext.h" | 8 #include "third_party/khronos/GLES2/gl2ext.h" |
10 | 9 |
11 namespace cc { | 10 namespace cc { |
12 | 11 |
13 size_t TextureSizeBytes(gfx::Size size, ResourceFormat format) { | 12 size_t TextureSizeBytes(gfx::Size size, ResourceFormat format) { |
14 unsigned int components_per_pixel = 4; | 13 unsigned int components_per_pixel = 4; |
15 unsigned int bytes_per_component = 1; | 14 unsigned int bytes_per_component = 1; |
16 return size.width() * size.height() * components_per_pixel * | 15 return size.width() * size.height() * components_per_pixel * |
17 bytes_per_component; | 16 bytes_per_component; |
18 } | 17 } |
19 | 18 |
20 TestTexture::TestTexture() : format(RGBA_8888) { | 19 TestTexture::TestTexture() : format(RGBA_8888) { |
21 // Initialize default parameter values. | 20 // Initialize default parameter values. |
22 params[GL_TEXTURE_MAG_FILTER] = GL_LINEAR; | 21 params[GL_TEXTURE_MAG_FILTER] = GL_LINEAR; |
23 params[GL_TEXTURE_MIN_FILTER] = GL_NEAREST_MIPMAP_LINEAR; | 22 params[GL_TEXTURE_MIN_FILTER] = GL_NEAREST_MIPMAP_LINEAR; |
24 params[GL_TEXTURE_WRAP_S] = GL_REPEAT; | 23 params[GL_TEXTURE_WRAP_S] = GL_REPEAT; |
25 params[GL_TEXTURE_WRAP_T] = GL_REPEAT; | 24 params[GL_TEXTURE_WRAP_T] = GL_REPEAT; |
26 params[GL_TEXTURE_POOL_CHROMIUM] = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; | 25 params[GL_TEXTURE_POOL_CHROMIUM] = GL_TEXTURE_POOL_UNMANAGED_CHROMIUM; |
27 params[GL_TEXTURE_USAGE_ANGLE] = GL_NONE; | 26 params[GL_TEXTURE_USAGE_ANGLE] = GL_NONE; |
28 } | 27 } |
29 | 28 |
30 TestTexture::~TestTexture() {} | 29 TestTexture::~TestTexture() {} |
31 | 30 |
32 void TestTexture::Reallocate(gfx::Size size, ResourceFormat format) { | 31 void TestTexture::Reallocate(gfx::Size size, ResourceFormat format) { |
33 this->size = size; | 32 this->size = size; |
34 this->format = format; | 33 this->format = format; |
35 this->data.reset(new uint8_t[TextureSizeBytes(size, format)]); | 34 this->data.reset(new uint8_t[TextureSizeBytes(size, format)]); |
36 } | 35 } |
37 | 36 |
38 bool TestTexture::IsValidParameter(blink::WGC3Denum pname) { | 37 bool TestTexture::IsValidParameter(GLenum pname) { |
39 return params.find(pname) != params.end(); | 38 return params.find(pname) != params.end(); |
40 } | 39 } |
41 | 40 |
42 } // namespace cc | 41 } // namespace cc |
OLD | NEW |