Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 12 |
| 13 #include "gpu/command_buffer/tests/gl_manager.h" | 13 #include "gpu/command_buffer/tests/gl_manager.h" |
| 14 #include "gpu/command_buffer/tests/gl_test_utils.h" | 14 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 17 |
| 18 namespace gpu { | 18 namespace gpu { |
| 19 | 19 |
| 20 namespace { | |
| 21 enum CopyType { TexImage, TexSubImage }; | |
| 22 const CopyType kCopyTypes[] = { | |
| 23 TexImage, | |
| 24 TexSubImage, | |
| 25 }; | |
| 26 } | |
| 27 | |
| 20 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. | 28 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. |
| 21 class GLCopyTextureCHROMIUMTest : public testing::Test { | 29 class GLCopyTextureCHROMIUMTest |
| 30 : public testing::Test, | |
| 31 public ::testing::WithParamInterface<CopyType> { | |
| 22 protected: | 32 protected: |
| 23 void SetUp() override { | 33 void SetUp() override { |
| 24 gl_.Initialize(GLManager::Options()); | 34 gl_.Initialize(GLManager::Options()); |
| 25 | 35 |
| 26 glGenTextures(2, textures_); | 36 glGenTextures(2, textures_); |
| 27 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 37 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 28 | 38 |
| 29 // Some drivers (NVidia/SGX) require texture settings to be a certain way or | 39 // Some drivers (NVidia/SGX) require texture settings to be a certain way or |
| 30 // they won't report FRAMEBUFFER_COMPLETE. | 40 // they won't report FRAMEBUFFER_COMPLETE. |
| 31 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 41 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 43 glDeleteTextures(2, textures_); | 53 glDeleteTextures(2, textures_); |
| 44 glDeleteFramebuffers(1, &framebuffer_id_); | 54 glDeleteFramebuffers(1, &framebuffer_id_); |
| 45 gl_.Destroy(); | 55 gl_.Destroy(); |
| 46 } | 56 } |
| 47 | 57 |
| 48 GLManager gl_; | 58 GLManager gl_; |
| 49 GLuint textures_[2]; | 59 GLuint textures_[2]; |
| 50 GLuint framebuffer_id_; | 60 GLuint framebuffer_id_; |
| 51 }; | 61 }; |
| 52 | 62 |
| 63 INSTANTIATE_TEST_CASE_P(CopyType, | |
| 64 GLCopyTextureCHROMIUMTest, | |
| 65 ::testing::ValuesIn(kCopyTypes)); | |
| 66 | |
| 53 // Test to ensure that the basic functionality of the extension works. | 67 // Test to ensure that the basic functionality of the extension works. |
| 54 TEST_F(GLCopyTextureCHROMIUMTest, Basic) { | 68 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { |
| 69 CopyType copy_type = GetParam(); | |
| 55 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 70 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 56 | 71 |
| 57 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 72 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 58 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 73 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 59 pixels); | 74 pixels); |
| 60 | 75 |
| 61 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 76 if (copy_type == TexImage) { |
| 62 GL_UNSIGNED_BYTE); | 77 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 78 GL_UNSIGNED_BYTE); | |
| 79 } else { | |
| 80 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 81 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 82 nullptr); | |
| 83 | |
| 84 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 85 0); | |
| 86 } | |
| 63 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 87 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 64 | 88 |
| 65 // Check the FB is still bound. | 89 // Check the FB is still bound. |
| 66 GLint value = 0; | 90 GLint value = 0; |
| 67 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 91 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 68 GLuint fb_id = value; | 92 GLuint fb_id = value; |
| 69 EXPECT_EQ(framebuffer_id_, fb_id); | 93 EXPECT_EQ(framebuffer_id_, fb_id); |
| 70 | 94 |
| 71 // Check that FB is complete. | 95 // Check that FB is complete. |
| 72 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 96 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 73 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 97 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 74 | 98 |
| 75 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); | 99 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); |
| 76 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 100 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 77 } | 101 } |
| 78 | 102 |
| 79 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormat) { | 103 TEST_P(GLCopyTextureCHROMIUMTest, Level) { |
|
dshwang
2015/02/10 18:11:55
add new test for level > 0
| |
| 104 CopyType copy_type = GetParam(); | |
| 105 uint8 pixels[1 * 4] = {255u, 0u, 0u, 255u}; | |
| 106 | |
| 107 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 108 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 109 pixels); | |
| 110 | |
| 111 int max_level = 5; | |
| 112 for (int level = 0; level < max_level; level++) { | |
| 113 if (copy_type == TexImage) { | |
| 114 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], level, | |
| 115 GL_RGBA, GL_UNSIGNED_BYTE); | |
| 116 } else { | |
| 117 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 118 glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, 1, 1, 0, GL_RGBA, | |
| 119 GL_UNSIGNED_BYTE, nullptr); | |
| 120 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], level, | |
| 121 0, 0); | |
| 122 } | |
| 123 // The level parameter must be 0. | |
| 124 if (level) { | |
| 125 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | |
| 126 } | |
| 127 } | |
| 128 } | |
| 129 | |
| 130 TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) { | |
| 131 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { | |
| 132 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; | |
| 133 return; | |
| 134 } | |
| 135 CopyType copy_type = GetParam(); | |
| 136 | |
| 137 uint8 pixels[1 * 4] = {255u, 0u, 0u, 255u}; | |
| 138 | |
| 139 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 140 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); | |
| 141 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 142 pixels); | |
| 143 | |
| 144 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 145 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); | |
| 146 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | |
| 147 textures_[1], 0); | |
| 148 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | |
| 149 | |
| 150 if (copy_type == TexImage) { | |
| 151 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | |
| 152 GL_UNSIGNED_BYTE); | |
| 153 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); | |
| 154 } else { | |
| 155 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 156 0); | |
| 157 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | |
| 158 | |
| 159 // Check the FB is still bound. | |
| 160 GLint value = 0; | |
| 161 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | |
| 162 GLuint fb_id = value; | |
| 163 EXPECT_EQ(framebuffer_id_, fb_id); | |
| 164 | |
| 165 // Check that FB is complete. | |
| 166 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | |
| 167 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | |
| 168 | |
| 169 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); | |
| 170 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 171 } | |
| 172 } | |
| 173 | |
| 174 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) { | |
| 175 CopyType copy_type = GetParam(); | |
| 80 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, | 176 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, |
| 81 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; | 177 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; |
| 82 GLint dest_formats[] = {GL_RGB, GL_RGBA}; | 178 GLint dest_formats[] = {GL_RGB, GL_RGBA}; |
| 83 | 179 |
| 84 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { | 180 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { |
| 85 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); | 181 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); |
| 86 dest_index++) { | 182 dest_index++) { |
| 87 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 183 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 88 glTexImage2D(GL_TEXTURE_2D, | 184 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, |
| 89 0, | 185 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); |
| 90 src_formats[src_index], | |
| 91 1, | |
| 92 1, | |
| 93 0, | |
| 94 src_formats[src_index], | |
| 95 GL_UNSIGNED_BYTE, | |
| 96 NULL); | |
| 97 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 186 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 98 | 187 |
| 99 glCopyTextureCHROMIUM(GL_TEXTURE_2D, | 188 if (copy_type == TexImage) { |
| 100 textures_[0], | 189 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, |
| 101 textures_[1], | 190 dest_formats[dest_index], GL_UNSIGNED_BYTE); |
| 102 0, | 191 } else { |
| 103 dest_formats[dest_index], | 192 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 104 GL_UNSIGNED_BYTE); | 193 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, |
| 194 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); | |
| 195 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 196 | |
| 197 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | |
| 198 0, 0); | |
| 199 } | |
| 200 | |
| 105 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index | 201 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index |
| 106 << " dest_index:" << dest_index; | 202 << " dest_index:" << dest_index; |
| 107 } | 203 } |
| 108 } | 204 } |
| 109 } | 205 } |
| 110 | 206 |
| 111 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { | 207 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { |
| 208 CopyType copy_type = GetParam(); | |
| 112 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 209 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 113 glTexImage2D( | 210 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 114 GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 211 nullptr); |
| 115 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 212 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 116 | 213 |
| 117 // Check unsupported format reports error. | 214 // Check unsupported format reports error. |
| 118 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE, | 215 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE, |
| 119 GL_LUMINANCE_ALPHA}; | 216 GL_LUMINANCE_ALPHA}; |
| 120 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); | 217 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); |
| 121 dest_index++) { | 218 dest_index++) { |
| 122 glCopyTextureCHROMIUM(GL_TEXTURE_2D, | 219 if (copy_type == TexImage) { |
| 123 textures_[0], | 220 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, |
| 124 textures_[1], | 221 unsupported_dest_formats[dest_index], |
| 125 0, | 222 GL_UNSIGNED_BYTE); |
| 126 unsupported_dest_formats[dest_index], | 223 } else { |
| 127 GL_UNSIGNED_BYTE); | 224 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 225 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, | |
| 226 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, | |
| 227 nullptr); | |
| 228 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 229 0); | |
| 230 } | |
| 128 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) | 231 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) |
| 129 << "dest_index:" << dest_index; | 232 << "dest_index:" << dest_index; |
| 130 } | 233 } |
| 131 } | 234 } |
| 132 | 235 |
| 133 // Test to ensure that the destination texture is redefined if the properties | 236 // Test to ensure that the destination texture is redefined if the properties |
| 134 // are different. | 237 // are different. |
| 135 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { | 238 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { |
| 136 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, | 239 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, |
| 137 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; | 240 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 | 285 |
| 183 // Check that FB is complete. | 286 // Check that FB is complete. |
| 184 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 287 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 185 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 288 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 186 | 289 |
| 187 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); | 290 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); |
| 188 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 291 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 189 } | 292 } |
| 190 | 293 |
| 191 // Test that the extension respects the flip-y pixel storage setting. | 294 // Test that the extension respects the flip-y pixel storage setting. |
| 192 TEST_F(GLCopyTextureCHROMIUMTest, FlipY) { | 295 TEST_P(GLCopyTextureCHROMIUMTest, FlipY) { |
| 296 CopyType copy_type = GetParam(); | |
| 193 uint8 pixels[2][2][4]; | 297 uint8 pixels[2][2][4]; |
| 194 for (int x = 0; x < 2; ++x) { | 298 for (int x = 0; x < 2; ++x) { |
| 195 for (int y = 0; y < 2; ++y) { | 299 for (int y = 0; y < 2; ++y) { |
| 196 pixels[y][x][0] = x + y; | 300 pixels[y][x][0] = x + y; |
| 197 pixels[y][x][1] = x + y; | 301 pixels[y][x][1] = x + y; |
| 198 pixels[y][x][2] = x + y; | 302 pixels[y][x][2] = x + y; |
| 199 pixels[y][x][3] = 255u; | 303 pixels[y][x][3] = 255u; |
| 200 } | 304 } |
| 201 } | 305 } |
| 202 | 306 |
| 203 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 307 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 204 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 308 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 205 pixels); | 309 pixels); |
| 206 | 310 |
| 207 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 311 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 208 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 312 |
| 209 GL_UNSIGNED_BYTE); | 313 if (copy_type == TexImage) { |
| 314 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | |
| 315 GL_UNSIGNED_BYTE); | |
| 316 } else { | |
| 317 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 318 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 319 nullptr); | |
| 320 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 321 0); | |
| 322 } | |
| 210 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 323 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 211 | 324 |
| 212 uint8 copied_pixels[2][2][4] = {{{0}}}; | 325 uint8 copied_pixels[2][2][4] = {{{0}}}; |
| 213 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 326 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 214 for (int x = 0; x < 2; ++x) { | 327 for (int x = 0; x < 2; ++x) { |
| 215 for (int y = 0; y < 2; ++y) { | 328 for (int y = 0; y < 2; ++y) { |
| 216 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]); | 329 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]); |
| 217 EXPECT_EQ(pixels[1-y][x][1], copied_pixels[y][x][1]); | 330 EXPECT_EQ(pixels[1-y][x][1], copied_pixels[y][x][1]); |
| 218 EXPECT_EQ(pixels[1-y][x][2], copied_pixels[y][x][2]); | 331 EXPECT_EQ(pixels[1-y][x][2], copied_pixels[y][x][2]); |
| 219 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | 332 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 220 } | 333 } |
| 221 } | 334 } |
| 222 | 335 |
| 223 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 336 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 224 } | 337 } |
| 225 | 338 |
| 226 // Test that the extension respects the GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM | 339 // Test that the extension respects the GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM |
| 227 // storage setting. | 340 // storage setting. |
| 228 TEST_F(GLCopyTextureCHROMIUMTest, PremultiplyAlpha) { | 341 TEST_P(GLCopyTextureCHROMIUMTest, PremultiplyAlpha) { |
| 342 CopyType copy_type = GetParam(); | |
| 229 uint8 pixels[1 * 4] = { 2, 2, 2, 128 }; | 343 uint8 pixels[1 * 4] = { 2, 2, 2, 128 }; |
| 230 | 344 |
| 231 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 345 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 232 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 346 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 233 pixels); | 347 pixels); |
| 234 | 348 |
| 235 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 349 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 236 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 350 if (copy_type == TexImage) { |
| 237 GL_UNSIGNED_BYTE); | 351 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 352 GL_UNSIGNED_BYTE); | |
| 353 } else { | |
| 354 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 355 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 356 nullptr); | |
| 357 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 358 0); | |
| 359 } | |
| 238 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 360 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 239 | 361 |
| 240 uint8 copied_pixels[1 * 4] = {0}; | 362 uint8 copied_pixels[1 * 4] = {0}; |
| 241 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 363 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 242 EXPECT_EQ(1u, copied_pixels[0]); | 364 EXPECT_EQ(1u, copied_pixels[0]); |
| 243 EXPECT_EQ(1u, copied_pixels[1]); | 365 EXPECT_EQ(1u, copied_pixels[1]); |
| 244 EXPECT_EQ(1u, copied_pixels[2]); | 366 EXPECT_EQ(1u, copied_pixels[2]); |
| 245 EXPECT_EQ(128u, copied_pixels[3]); | 367 EXPECT_EQ(128u, copied_pixels[3]); |
| 246 | 368 |
| 247 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 369 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 248 } | 370 } |
| 249 | 371 |
| 250 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM | 372 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM |
| 251 // storage setting. | 373 // storage setting. |
| 252 TEST_F(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { | 374 TEST_P(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { |
| 375 CopyType copy_type = GetParam(); | |
| 253 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; | 376 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; |
| 254 | 377 |
| 255 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 378 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 256 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 379 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 257 pixels); | 380 pixels); |
| 258 | 381 |
| 259 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 382 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 260 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 383 if (copy_type == TexImage) { |
| 261 GL_UNSIGNED_BYTE); | 384 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 385 GL_UNSIGNED_BYTE); | |
| 386 } else { | |
| 387 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 388 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 389 nullptr); | |
| 390 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 391 0); | |
| 392 } | |
| 262 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 393 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 263 | 394 |
| 264 uint8 copied_pixels[1 * 4] = {0}; | 395 uint8 copied_pixels[1 * 4] = {0}; |
| 265 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 396 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 266 EXPECT_EQ(32u, copied_pixels[0]); | 397 EXPECT_EQ(32u, copied_pixels[0]); |
| 267 EXPECT_EQ(32u, copied_pixels[1]); | 398 EXPECT_EQ(32u, copied_pixels[1]); |
| 268 EXPECT_EQ(32u, copied_pixels[2]); | 399 EXPECT_EQ(32u, copied_pixels[2]); |
| 269 EXPECT_EQ(128u, copied_pixels[3]); | 400 EXPECT_EQ(128u, copied_pixels[3]); |
| 270 | 401 |
| 271 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 402 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 272 } | 403 } |
| 273 | 404 |
| 274 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { | 405 TEST_P(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { |
| 406 CopyType copy_type = GetParam(); | |
| 275 uint8 pixels[2][2][4]; | 407 uint8 pixels[2][2][4]; |
| 276 for (int x = 0; x < 2; ++x) { | 408 for (int x = 0; x < 2; ++x) { |
| 277 for (int y = 0; y < 2; ++y) { | 409 for (int y = 0; y < 2; ++y) { |
| 278 uint8 color = 16 * x + 16 * y; | 410 uint8 color = 16 * x + 16 * y; |
| 279 pixels[y][x][0] = color; | 411 pixels[y][x][0] = color; |
| 280 pixels[y][x][1] = color; | 412 pixels[y][x][1] = color; |
| 281 pixels[y][x][2] = color; | 413 pixels[y][x][2] = color; |
| 282 pixels[y][x][3] = 128u; | 414 pixels[y][x][3] = 128u; |
| 283 } | 415 } |
| 284 } | 416 } |
| 285 | 417 |
| 286 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 418 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 287 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 419 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 288 pixels); | 420 pixels); |
| 289 | 421 |
| 290 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 422 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 291 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 423 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 292 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 424 if (copy_type == TexImage) { |
| 293 GL_UNSIGNED_BYTE); | 425 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 426 GL_UNSIGNED_BYTE); | |
| 427 } else { | |
| 428 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 429 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 430 nullptr); | |
| 431 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 432 0); | |
| 433 } | |
| 294 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 434 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 295 | 435 |
| 296 uint8 copied_pixels[2][2][4] = {{{0}}}; | 436 uint8 copied_pixels[2][2][4] = {{{0}}}; |
| 297 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 437 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 298 for (int x = 0; x < 2; ++x) { | 438 for (int x = 0; x < 2; ++x) { |
| 299 for (int y = 0; y < 2; ++y) { | 439 for (int y = 0; y < 2; ++y) { |
| 300 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); | 440 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); |
| 301 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); | 441 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); |
| 302 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); | 442 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); |
| 303 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | 443 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 304 } | 444 } |
| 305 } | 445 } |
| 306 | 446 |
| 307 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 447 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 308 } | 448 } |
| 309 | 449 |
| 310 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { | 450 TEST_P(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { |
| 451 CopyType copy_type = GetParam(); | |
| 311 uint8 pixels[2][2][4]; | 452 uint8 pixels[2][2][4]; |
| 312 for (int x = 0; x < 2; ++x) { | 453 for (int x = 0; x < 2; ++x) { |
| 313 for (int y = 0; y < 2; ++y) { | 454 for (int y = 0; y < 2; ++y) { |
| 314 uint8 color = 16 * x + 16 * y; | 455 uint8 color = 16 * x + 16 * y; |
| 315 pixels[y][x][0] = color; | 456 pixels[y][x][0] = color; |
| 316 pixels[y][x][1] = color; | 457 pixels[y][x][1] = color; |
| 317 pixels[y][x][2] = color; | 458 pixels[y][x][2] = color; |
| 318 pixels[y][x][3] = 128u; | 459 pixels[y][x][3] = 128u; |
| 319 } | 460 } |
| 320 } | 461 } |
| 321 | 462 |
| 322 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 463 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 323 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 464 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 324 pixels); | 465 pixels); |
| 325 | 466 |
| 326 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 467 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 327 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 468 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 328 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 469 if (copy_type == TexImage) { |
| 329 GL_UNSIGNED_BYTE); | 470 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 471 GL_UNSIGNED_BYTE); | |
| 472 } else { | |
| 473 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 474 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 475 nullptr); | |
| 476 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 477 0); | |
| 478 } | |
| 330 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 479 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 331 | 480 |
| 332 uint8 copied_pixels[2][2][4] = {{{0}}}; | 481 uint8 copied_pixels[2][2][4] = {{{0}}}; |
| 333 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 482 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 334 for (int x = 0; x < 2; ++x) { | 483 for (int x = 0; x < 2; ++x) { |
| 335 for (int y = 0; y < 2; ++y) { | 484 for (int y = 0; y < 2; ++y) { |
| 336 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); | 485 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); |
| 337 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]); | 486 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]); |
| 338 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]); | 487 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]); |
| 339 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | 488 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 340 } | 489 } |
| 341 } | 490 } |
| 342 | 491 |
| 343 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 492 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 344 } | 493 } |
| 345 | 494 |
| 346 namespace { | 495 namespace { |
| 347 | 496 |
| 348 void glEnableDisable(GLint param, GLboolean value) { | 497 void glEnableDisable(GLint param, GLboolean value) { |
| 349 if (value) | 498 if (value) |
| 350 glEnable(param); | 499 glEnable(param); |
| 351 else | 500 else |
| 352 glDisable(param); | 501 glDisable(param); |
| 353 } | 502 } |
| 354 | 503 |
| 355 } // unnamed namespace | 504 } // unnamed namespace |
| 356 | 505 |
| 357 // Validate that some basic GL state is not touched upon execution of | 506 // Validate that some basic GL state is not touched upon execution of |
| 358 // the extension. | 507 // the extension. |
| 359 TEST_F(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { | 508 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { |
| 509 CopyType copy_type = GetParam(); | |
| 360 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 510 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 361 | 511 |
| 362 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 512 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 363 | 513 |
| 364 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 514 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 365 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 515 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 366 pixels); | 516 pixels); |
| 367 | 517 |
| 518 if (copy_type == TexSubImage) { | |
| 519 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 520 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 521 nullptr); | |
| 522 } | |
| 523 | |
| 368 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; | 524 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; |
| 369 for (int x = 0; x < 2; ++x) { | 525 for (int x = 0; x < 2; ++x) { |
| 370 GLboolean setting = reference_settings[x]; | 526 GLboolean setting = reference_settings[x]; |
| 371 glEnableDisable(GL_DEPTH_TEST, setting); | 527 glEnableDisable(GL_DEPTH_TEST, setting); |
| 372 glEnableDisable(GL_SCISSOR_TEST, setting); | 528 glEnableDisable(GL_SCISSOR_TEST, setting); |
| 373 glEnableDisable(GL_STENCIL_TEST, setting); | 529 glEnableDisable(GL_STENCIL_TEST, setting); |
| 374 glEnableDisable(GL_CULL_FACE, setting); | 530 glEnableDisable(GL_CULL_FACE, setting); |
| 375 glEnableDisable(GL_BLEND, setting); | 531 glEnableDisable(GL_BLEND, setting); |
| 376 glColorMask(setting, setting, setting, setting); | 532 glColorMask(setting, setting, setting, setting); |
| 377 glDepthMask(setting); | 533 glDepthMask(setting); |
| 378 | 534 |
| 379 glActiveTexture(GL_TEXTURE1 + x); | 535 glActiveTexture(GL_TEXTURE1 + x); |
| 380 | 536 |
| 381 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | 537 if (copy_type == TexImage) { |
| 382 GL_RGBA, GL_UNSIGNED_BYTE); | 538 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, |
| 539 GL_RGBA, GL_UNSIGNED_BYTE); | |
| 540 } else { | |
| 541 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 542 0); | |
| 543 } | |
| 383 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 544 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 384 | 545 |
| 385 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); | 546 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); |
| 386 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); | 547 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); |
| 387 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); | 548 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); |
| 388 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); | 549 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); |
| 389 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); | 550 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); |
| 390 | 551 |
| 391 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; | 552 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; |
| 392 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); | 553 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); |
| 393 EXPECT_EQ(setting, bool_array[0]); | 554 EXPECT_EQ(setting, bool_array[0]); |
| 394 | 555 |
| 395 bool_array[0] = GL_FALSE; | 556 bool_array[0] = GL_FALSE; |
| 396 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); | 557 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); |
| 397 EXPECT_EQ(setting, bool_array[0]); | 558 EXPECT_EQ(setting, bool_array[0]); |
| 398 EXPECT_EQ(setting, bool_array[1]); | 559 EXPECT_EQ(setting, bool_array[1]); |
| 399 EXPECT_EQ(setting, bool_array[2]); | 560 EXPECT_EQ(setting, bool_array[2]); |
| 400 EXPECT_EQ(setting, bool_array[3]); | 561 EXPECT_EQ(setting, bool_array[3]); |
| 401 | 562 |
| 402 GLint active_texture = 0; | 563 GLint active_texture = 0; |
| 403 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 564 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
| 404 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); | 565 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); |
| 405 } | 566 } |
| 406 | 567 |
| 407 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 568 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 408 }; | 569 }; |
| 409 | 570 |
| 410 // Verify that invocation of the extension does not modify the bound | 571 // Verify that invocation of the extension does not modify the bound |
| 411 // texture state. | 572 // texture state. |
| 412 TEST_F(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { | 573 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { |
| 574 CopyType copy_type = GetParam(); | |
| 413 // Setup the texture used for the extension invocation. | 575 // Setup the texture used for the extension invocation. |
| 414 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 576 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 415 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 577 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 416 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 578 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 417 pixels); | 579 pixels); |
| 418 | 580 |
| 581 if (copy_type == TexSubImage) { | |
| 582 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 583 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 584 nullptr); | |
| 585 } | |
| 586 | |
| 419 GLuint texture_ids[2]; | 587 GLuint texture_ids[2]; |
| 420 glGenTextures(2, texture_ids); | 588 glGenTextures(2, texture_ids); |
| 421 | 589 |
| 422 glActiveTexture(GL_TEXTURE0); | 590 glActiveTexture(GL_TEXTURE0); |
| 423 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); | 591 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); |
| 424 | 592 |
| 425 glActiveTexture(GL_TEXTURE1); | 593 glActiveTexture(GL_TEXTURE1); |
| 426 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); | 594 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); |
| 427 | 595 |
| 428 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | 596 if (copy_type == TexImage) { |
| 429 GL_RGBA, GL_UNSIGNED_BYTE); | 597 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 598 GL_UNSIGNED_BYTE); | |
| 599 } else { | |
| 600 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 601 0); | |
| 602 } | |
| 430 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 603 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 431 | 604 |
| 432 GLint active_texture = 0; | 605 GLint active_texture = 0; |
| 433 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 606 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
| 434 EXPECT_EQ(GL_TEXTURE1, active_texture); | 607 EXPECT_EQ(GL_TEXTURE1, active_texture); |
| 435 | 608 |
| 436 GLint bound_texture = 0; | 609 GLint bound_texture = 0; |
| 437 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 610 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 438 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); | 611 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); |
| 439 glBindTexture(GL_TEXTURE_2D, 0); | 612 glBindTexture(GL_TEXTURE_2D, 0); |
| 440 | 613 |
| 441 bound_texture = 0; | 614 bound_texture = 0; |
| 442 glActiveTexture(GL_TEXTURE0); | 615 glActiveTexture(GL_TEXTURE0); |
| 443 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 616 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 444 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); | 617 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); |
| 445 glBindTexture(GL_TEXTURE_2D, 0); | 618 glBindTexture(GL_TEXTURE_2D, 0); |
| 446 | 619 |
| 447 glDeleteTextures(2, texture_ids); | 620 glDeleteTextures(2, texture_ids); |
| 448 | 621 |
| 449 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 622 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 450 } | 623 } |
| 451 | 624 |
| 452 // Verify that invocation of the extension does not perturb the currently | 625 // Verify that invocation of the extension does not perturb the currently |
| 453 // bound FBO state. | 626 // bound FBO state. |
| 454 TEST_F(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { | 627 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { |
| 628 CopyType copy_type = GetParam(); | |
| 455 // Setup the texture used for the extension invocation. | 629 // Setup the texture used for the extension invocation. |
| 456 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 630 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 457 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 631 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 458 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 632 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 459 pixels); | 633 pixels); |
| 460 | 634 |
| 635 if (copy_type == TexSubImage) { | |
| 636 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 637 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 638 nullptr); | |
| 639 } | |
| 640 | |
| 461 GLuint texture_id; | 641 GLuint texture_id; |
| 462 glGenTextures(1, &texture_id); | 642 glGenTextures(1, &texture_id); |
| 463 glBindTexture(GL_TEXTURE_2D, texture_id); | 643 glBindTexture(GL_TEXTURE_2D, texture_id); |
| 464 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 644 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 465 0); | 645 0); |
| 466 | 646 |
| 467 GLuint renderbuffer_id; | 647 GLuint renderbuffer_id; |
| 468 glGenRenderbuffers(1, &renderbuffer_id); | 648 glGenRenderbuffers(1, &renderbuffer_id); |
| 469 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id); | 649 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id); |
| 470 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 1, 1); | 650 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 1, 1); |
| 471 | 651 |
| 472 GLuint framebuffer_id; | 652 GLuint framebuffer_id; |
| 473 glGenFramebuffers(1, &framebuffer_id); | 653 glGenFramebuffers(1, &framebuffer_id); |
| 474 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); | 654 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); |
| 475 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 655 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 476 texture_id, 0); | 656 texture_id, 0); |
| 477 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, | 657 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
| 478 GL_RENDERBUFFER, renderbuffer_id); | 658 GL_RENDERBUFFER, renderbuffer_id); |
| 479 EXPECT_TRUE( | 659 EXPECT_TRUE( |
| 480 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 660 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 481 | 661 |
| 482 // Test that we can write to the bound framebuffer | 662 // Test that we can write to the bound framebuffer |
| 483 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; | 663 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; |
| 484 glClearColor(1.0, 1.0, 0, 1.0); | 664 glClearColor(1.0, 1.0, 0, 1.0); |
| 485 glClear(GL_COLOR_BUFFER_BIT); | 665 glClear(GL_COLOR_BUFFER_BIT); |
| 486 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); | 666 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); |
| 487 | 667 |
| 488 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | 668 if (copy_type == TexImage) { |
| 489 GL_RGBA, GL_UNSIGNED_BYTE); | 669 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 670 GL_UNSIGNED_BYTE); | |
| 671 } else { | |
| 672 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 673 0); | |
| 674 } | |
| 490 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 675 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 491 | 676 |
| 492 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); | 677 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); |
| 493 | 678 |
| 494 // Ensure that reading from the framebuffer produces correct pixels. | 679 // Ensure that reading from the framebuffer produces correct pixels. |
| 495 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); | 680 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); |
| 496 | 681 |
| 497 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; | 682 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; |
| 498 glClearColor(1.0, 0, 1.0, 1.0); | 683 glClearColor(1.0, 0, 1.0, 1.0); |
| 499 glClear(GL_COLOR_BUFFER_BIT); | 684 glClear(GL_COLOR_BUFFER_BIT); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 527 &fbo_params); | 712 &fbo_params); |
| 528 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); | 713 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); |
| 529 | 714 |
| 530 glDeleteRenderbuffers(1, &renderbuffer_id); | 715 glDeleteRenderbuffers(1, &renderbuffer_id); |
| 531 glDeleteTextures(1, &texture_id); | 716 glDeleteTextures(1, &texture_id); |
| 532 glDeleteFramebuffers(1, &framebuffer_id); | 717 glDeleteFramebuffers(1, &framebuffer_id); |
| 533 | 718 |
| 534 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 719 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 535 } | 720 } |
| 536 | 721 |
| 537 TEST_F(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { | 722 TEST_P(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { |
| 723 CopyType copy_type = GetParam(); | |
| 538 // unbind the one created in setup. | 724 // unbind the one created in setup. |
| 539 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 725 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 540 glBindTexture(GL_TEXTURE_2D, 0); | 726 glBindTexture(GL_TEXTURE_2D, 0); |
| 541 | 727 |
| 542 GLManager gl2; | 728 GLManager gl2; |
| 543 GLManager::Options options; | 729 GLManager::Options options; |
| 544 options.size = gfx::Size(16, 16); | 730 options.size = gfx::Size(16, 16); |
| 545 options.share_group_manager = &gl_; | 731 options.share_group_manager = &gl_; |
| 546 gl2.Initialize(options); | 732 gl2.Initialize(options); |
| 547 gl_.MakeCurrent(); | 733 gl_.MakeCurrent(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 glClear(GL_COLOR_BUFFER_BIT); | 767 glClear(GL_COLOR_BUFFER_BIT); |
| 582 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); | 768 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); |
| 583 glDrawArrays(GL_TRIANGLES, 0, 6); | 769 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 584 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 770 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
| 585 | 771 |
| 586 // Call copyTextureCHROMIUM | 772 // Call copyTextureCHROMIUM |
| 587 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 773 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 588 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 774 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 589 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 775 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 590 pixels); | 776 pixels); |
| 591 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 777 if (copy_type == TexImage) { |
| 592 GL_UNSIGNED_BYTE); | 778 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 779 GL_UNSIGNED_BYTE); | |
| 780 } else { | |
| 781 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 782 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 783 nullptr); | |
| 784 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 785 0); | |
| 786 } | |
| 593 | 787 |
| 594 // test using program after | 788 // test using program after |
| 595 glClear(GL_COLOR_BUFFER_BIT); | 789 glClear(GL_COLOR_BUFFER_BIT); |
| 596 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); | 790 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); |
| 597 glDrawArrays(GL_TRIANGLES, 0, 6); | 791 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 598 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 792 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
| 599 | 793 |
| 600 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 794 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 601 | 795 |
| 602 gl2.MakeCurrent(); | 796 gl2.MakeCurrent(); |
| 603 gl2.Destroy(); | 797 gl2.Destroy(); |
| 604 gl_.MakeCurrent(); | 798 gl_.MakeCurrent(); |
| 605 } | 799 } |
| 606 | 800 |
| 607 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. | 801 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. |
| 608 TEST_F(GLCopyTextureCHROMIUMTest, UninitializedSource) { | 802 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { |
| 803 CopyType copy_type = GetParam(); | |
| 609 const GLsizei kWidth = 64, kHeight = 64; | 804 const GLsizei kWidth = 64, kHeight = 64; |
| 610 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 805 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 611 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, | 806 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 612 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 807 GL_UNSIGNED_BYTE, nullptr); |
| 613 | 808 |
| 614 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 809 if (copy_type == TexImage) { |
| 615 GL_UNSIGNED_BYTE); | 810 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, |
| 811 GL_UNSIGNED_BYTE); | |
| 812 } else { | |
| 813 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 814 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | |
| 815 GL_UNSIGNED_BYTE, nullptr); | |
| 816 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, | |
| 817 0); | |
| 818 } | |
| 616 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 819 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 617 | 820 |
| 618 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; | 821 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; |
| 619 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 822 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 620 for (int x = 0; x < kWidth; ++x) { | 823 for (int x = 0; x < kWidth; ++x) { |
| 621 for (int y = 0; y < kHeight; ++y) { | 824 for (int y = 0; y < kHeight; ++y) { |
| 622 EXPECT_EQ(0, pixels[y][x][0]); | 825 EXPECT_EQ(0, pixels[y][x][0]); |
| 623 EXPECT_EQ(0, pixels[y][x][1]); | 826 EXPECT_EQ(0, pixels[y][x][1]); |
| 624 EXPECT_EQ(0, pixels[y][x][2]); | 827 EXPECT_EQ(0, pixels[y][x][2]); |
| 625 EXPECT_EQ(0, pixels[y][x][3]); | 828 EXPECT_EQ(0, pixels[y][x][3]); |
| 626 } | 829 } |
| 627 } | 830 } |
| 628 | 831 |
| 629 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 832 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 630 } | 833 } |
| 631 | 834 |
| 835 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { | |
| 836 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 837 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 838 nullptr); | |
| 839 | |
| 840 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 841 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 842 nullptr); | |
| 843 | |
| 844 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 1, 1); | |
| 845 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 846 | |
| 847 // xoffset < 0 | |
| 848 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, -1, 1); | |
| 849 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | |
| 850 | |
| 851 // xoffset + source_width > dest_width | |
| 852 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 2, 2); | |
| 853 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | |
| 854 } | |
| 855 | |
| 856 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { | |
| 857 uint8 red[1 * 4] = {255u, 0u, 0u, 255u}; | |
| 858 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 859 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 860 red); | |
| 861 | |
| 862 uint8 transparent_pixel[4 * 4] = {0u, 0u, 0u, 0u, | |
| 863 0u, 0u, 0u, 0u, | |
| 864 0u, 0u, 0u, 0u, | |
| 865 0u, 0u, 0u, 0u}; | |
| 866 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 867 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 868 transparent_pixel); | |
| 869 | |
| 870 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 1, 1); | |
| 871 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | |
| 872 | |
| 873 // Check the FB is still bound. | |
| 874 GLint value = 0; | |
| 875 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | |
| 876 GLuint fb_id = value; | |
| 877 EXPECT_EQ(framebuffer_id_, fb_id); | |
| 878 | |
| 879 // Check that FB is complete. | |
| 880 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | |
| 881 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | |
| 882 | |
| 883 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u}; | |
| 884 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); | |
| 885 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); | |
| 886 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 887 } | |
| 888 | |
| 632 } // namespace gpu | 889 } // namespace gpu |
| OLD | NEW |