OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #ifndef GL_GLEXT_PROTOTYPES | 5 #ifndef GL_GLEXT_PROTOTYPES |
6 #define GL_GLEXT_PROTOTYPES | 6 #define GL_GLEXT_PROTOTYPES |
7 #endif | 7 #endif |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
| 14 #include "base/memory/ptr_util.h" |
14 #include "gpu/command_buffer/tests/gl_manager.h" | 15 #include "gpu/command_buffer/tests/gl_manager.h" |
15 #include "gpu/command_buffer/tests/gl_test_utils.h" | 16 #include "gpu/command_buffer/tests/gl_test_utils.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 #define SHADER(src) #src | 20 #define SHADER(src) #src |
20 | 21 |
21 namespace gpu { | 22 namespace gpu { |
22 | 23 |
23 namespace { | 24 namespace { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 | 155 |
155 TEST_F(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) { | 156 TEST_F(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) { |
156 struct Image { | 157 struct Image { |
157 const GLint format; | 158 const GLint format; |
158 const uint8_t* data; | 159 const uint8_t* data; |
159 const GLsizei data_size; | 160 const GLsizei data_size; |
160 | 161 |
161 Image(const GLint format, const uint8_t* data, const GLsizei data_size) | 162 Image(const GLint format, const uint8_t* data, const GLsizei data_size) |
162 : format(format), data(data), data_size(data_size) {} | 163 : format(format), data(data), data_size(data_size) {} |
163 }; | 164 }; |
164 std::vector<scoped_ptr<Image>> supported_formats; | 165 std::vector<std::unique_ptr<Image>> supported_formats; |
165 | 166 |
166 if (GLTestHelper::HasExtension("GL_AMD_compressed_ATC_texture") || | 167 if (GLTestHelper::HasExtension("GL_AMD_compressed_ATC_texture") || |
167 GLTestHelper::HasExtension("GL_ATI_texture_compression_atitc")) { | 168 GLTestHelper::HasExtension("GL_ATI_texture_compression_atitc")) { |
168 supported_formats.push_back(make_scoped_ptr(new Image( | 169 supported_formats.push_back(base::WrapUnique(new Image( |
169 GL_ATC_RGB_AMD, | 170 GL_ATC_RGB_AMD, kCompressedImageATC, sizeof(kCompressedImageATC)))); |
170 kCompressedImageATC, | 171 supported_formats.push_back(base::WrapUnique( |
171 sizeof(kCompressedImageATC)))); | 172 new Image(GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, kCompressedImageATCIA, |
172 supported_formats.push_back(make_scoped_ptr(new Image( | 173 sizeof(kCompressedImageATCIA)))); |
173 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, | |
174 kCompressedImageATCIA, | |
175 sizeof(kCompressedImageATCIA)))); | |
176 } | 174 } |
177 if (GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { | 175 if (GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
178 supported_formats.push_back(make_scoped_ptr(new Image( | 176 supported_formats.push_back(base::WrapUnique( |
179 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, | 177 new Image(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, kCompressedImageDXT1, |
180 kCompressedImageDXT1, | 178 sizeof(kCompressedImageDXT1)))); |
181 sizeof(kCompressedImageDXT1)))); | |
182 } | 179 } |
183 if (GLTestHelper::HasExtension("GL_ANGLE_texture_compression_dxt5") || | 180 if (GLTestHelper::HasExtension("GL_ANGLE_texture_compression_dxt5") || |
184 GLTestHelper::HasExtension("GL_EXT_texture_compression_s3tc")) { | 181 GLTestHelper::HasExtension("GL_EXT_texture_compression_s3tc")) { |
185 supported_formats.push_back(make_scoped_ptr(new Image( | 182 supported_formats.push_back(base::WrapUnique( |
186 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, | 183 new Image(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, kCompressedImageDXT5, |
187 kCompressedImageDXT5, | 184 sizeof(kCompressedImageDXT5)))); |
188 sizeof(kCompressedImageDXT5)))); | |
189 } | 185 } |
190 if (GLTestHelper::HasExtension("GL_OES_compressed_ETC1_RGB8_texture")) { | 186 if (GLTestHelper::HasExtension("GL_OES_compressed_ETC1_RGB8_texture")) { |
191 supported_formats.push_back(make_scoped_ptr(new Image( | 187 supported_formats.push_back(base::WrapUnique(new Image( |
192 GL_ETC1_RGB8_OES, | 188 GL_ETC1_RGB8_OES, kCompressedImageETC1, sizeof(kCompressedImageETC1)))); |
193 kCompressedImageETC1, | |
194 sizeof(kCompressedImageETC1)))); | |
195 } | 189 } |
196 | 190 |
197 for (const auto& image : supported_formats) { | 191 for (const auto& image : supported_formats) { |
198 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 192 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
199 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 193 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
201 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
202 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 196 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
203 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, | 197 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, |
204 4, 4, 0, image->data_size, image->data); | 198 4, 4, 0, image->data_size, image->data); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 389 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
396 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); | 390 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); |
397 glBindTexture(GL_TEXTURE_2D, 0); | 391 glBindTexture(GL_TEXTURE_2D, 0); |
398 | 392 |
399 glDeleteTextures(2, texture_ids); | 393 glDeleteTextures(2, texture_ids); |
400 | 394 |
401 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 395 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
402 } | 396 } |
403 | 397 |
404 } // namespace gpu | 398 } // namespace gpu |
OLD | NEW |