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> |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const uint8_t* data; | 161 const uint8_t* data; |
162 const GLsizei data_size; | 162 const GLsizei data_size; |
163 | 163 |
164 Image(const GLint format, const uint8_t* data, const GLsizei data_size) | 164 Image(const GLint format, const uint8_t* data, const GLsizei data_size) |
165 : format(format), data(data), data_size(data_size) {} | 165 : format(format), data(data), data_size(data_size) {} |
166 }; | 166 }; |
167 std::vector<std::unique_ptr<Image>> supported_formats; | 167 std::vector<std::unique_ptr<Image>> supported_formats; |
168 | 168 |
169 if (GLTestHelper::HasExtension("GL_AMD_compressed_ATC_texture") || | 169 if (GLTestHelper::HasExtension("GL_AMD_compressed_ATC_texture") || |
170 GLTestHelper::HasExtension("GL_ATI_texture_compression_atitc")) { | 170 GLTestHelper::HasExtension("GL_ATI_texture_compression_atitc")) { |
171 supported_formats.push_back(base::WrapUnique(new Image( | 171 supported_formats.push_back(base::MakeUnique<Image>( |
172 GL_ATC_RGB_AMD, kCompressedImageATC, sizeof(kCompressedImageATC)))); | 172 GL_ATC_RGB_AMD, kCompressedImageATC, sizeof(kCompressedImageATC))); |
173 supported_formats.push_back(base::WrapUnique( | 173 supported_formats.push_back(base::MakeUnique<Image>( |
174 new Image(GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, kCompressedImageATCIA, | 174 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, kCompressedImageATCIA, |
175 sizeof(kCompressedImageATCIA)))); | 175 sizeof(kCompressedImageATCIA))); |
176 } | 176 } |
177 if (GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { | 177 if (GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
178 supported_formats.push_back(base::WrapUnique( | 178 supported_formats.push_back(base::MakeUnique<Image>( |
179 new Image(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, kCompressedImageDXT1, | 179 GL_COMPRESSED_RGB_S3TC_DXT1_EXT, kCompressedImageDXT1, |
180 sizeof(kCompressedImageDXT1)))); | 180 sizeof(kCompressedImageDXT1))); |
181 } | 181 } |
182 if (GLTestHelper::HasExtension("GL_ANGLE_texture_compression_dxt5") || | 182 if (GLTestHelper::HasExtension("GL_ANGLE_texture_compression_dxt5") || |
183 GLTestHelper::HasExtension("GL_EXT_texture_compression_s3tc")) { | 183 GLTestHelper::HasExtension("GL_EXT_texture_compression_s3tc")) { |
184 supported_formats.push_back(base::WrapUnique( | 184 supported_formats.push_back(base::MakeUnique<Image>( |
185 new Image(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, kCompressedImageDXT5, | 185 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, kCompressedImageDXT5, |
186 sizeof(kCompressedImageDXT5)))); | 186 sizeof(kCompressedImageDXT5))); |
187 } | 187 } |
188 if (GLTestHelper::HasExtension("GL_OES_compressed_ETC1_RGB8_texture")) { | 188 if (GLTestHelper::HasExtension("GL_OES_compressed_ETC1_RGB8_texture")) { |
189 supported_formats.push_back(base::WrapUnique(new Image( | 189 supported_formats.push_back(base::MakeUnique<Image>( |
190 GL_ETC1_RGB8_OES, kCompressedImageETC1, sizeof(kCompressedImageETC1)))); | 190 GL_ETC1_RGB8_OES, kCompressedImageETC1, sizeof(kCompressedImageETC1))); |
191 } | 191 } |
192 | 192 |
193 for (const auto& image : supported_formats) { | 193 for (const auto& image : supported_formats) { |
194 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 194 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
196 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 196 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
197 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 197 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
198 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 198 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
199 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, | 199 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, |
200 4, 4, 0, image->data_size, image->data); | 200 4, 4, 0, image->data_size, image->data); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 398 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
399 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); | 399 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); |
400 glBindTexture(GL_TEXTURE_2D, 0); | 400 glBindTexture(GL_TEXTURE_2D, 0); |
401 | 401 |
402 glDeleteTextures(2, texture_ids); | 402 glDeleteTextures(2, texture_ids); |
403 | 403 |
404 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 404 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
405 } | 405 } |
406 | 406 |
407 } // namespace gpu | 407 } // namespace gpu |
OLD | NEW |