| 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], 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 } |
| 63 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 86 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 64 | 87 |
| 65 // Check the FB is still bound. | 88 // Check the FB is still bound. |
| 66 GLint value = 0; | 89 GLint value = 0; |
| 67 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 90 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 68 GLuint fb_id = value; | 91 GLuint fb_id = value; |
| 69 EXPECT_EQ(framebuffer_id_, fb_id); | 92 EXPECT_EQ(framebuffer_id_, fb_id); |
| 70 | 93 |
| 71 // Check that FB is complete. | 94 // Check that FB is complete. |
| 72 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 95 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 73 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 96 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 74 | 97 |
| 75 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); | 98 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); |
| 76 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 99 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 77 } | 100 } |
| 78 | 101 |
| 79 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormat) { | 102 TEST_P(GLCopyTextureCHROMIUMTest, ImmutableTexture) { |
| 103 if (!GLTestHelper::HasExtension("GL_EXT_texture_storage")) { |
| 104 LOG(INFO) << "GL_EXT_texture_storage not supported. Skipping test..."; |
| 105 return; |
| 106 } |
| 107 CopyType copy_type = GetParam(); |
| 108 |
| 109 uint8 pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
| 110 |
| 111 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 112 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); |
| 113 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, |
| 114 pixels); |
| 115 |
| 116 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 117 glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, 1, 1); |
| 118 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 119 textures_[1], 0); |
| 120 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 121 |
| 122 if (copy_type == TexImage) { |
| 123 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 124 GL_UNSIGNED_BYTE); |
| 125 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); |
| 126 } else { |
| 127 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 128 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 129 |
| 130 // Check the FB is still bound. |
| 131 GLint value = 0; |
| 132 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 133 GLuint fb_id = value; |
| 134 EXPECT_EQ(framebuffer_id_, fb_id); |
| 135 |
| 136 // Check that FB is complete. |
| 137 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 138 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 139 |
| 140 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); |
| 141 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 142 } |
| 143 } |
| 144 |
| 145 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) { |
| 146 CopyType copy_type = GetParam(); |
| 80 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, | 147 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, |
| 81 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; | 148 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; |
| 82 GLint dest_formats[] = {GL_RGB, GL_RGBA}; | 149 GLint dest_formats[] = {GL_RGB, GL_RGBA}; |
| 83 | 150 |
| 84 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { | 151 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); | 152 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); |
| 86 dest_index++) { | 153 dest_index++) { |
| 87 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 154 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 88 glTexImage2D(GL_TEXTURE_2D, | 155 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, |
| 89 0, | 156 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()); | 157 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 98 | 158 |
| 99 glCopyTextureCHROMIUM(GL_TEXTURE_2D, | 159 if (copy_type == TexImage) { |
| 100 textures_[0], | 160 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], |
| 101 textures_[1], | 161 dest_formats[dest_index], GL_UNSIGNED_BYTE); |
| 102 0, | 162 } else { |
| 103 dest_formats[dest_index], | 163 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 104 GL_UNSIGNED_BYTE); | 164 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, |
| 165 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); |
| 166 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 167 |
| 168 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, |
| 169 0); |
| 170 } |
| 171 |
| 105 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index | 172 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index |
| 106 << " dest_index:" << dest_index; | 173 << " dest_index:" << dest_index; |
| 107 } | 174 } |
| 108 } | 175 } |
| 109 } | 176 } |
| 110 | 177 |
| 111 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { | 178 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { |
| 179 CopyType copy_type = GetParam(); |
| 112 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 180 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 113 glTexImage2D( | 181 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); | 182 nullptr); |
| 115 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 183 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 116 | 184 |
| 117 // Check unsupported format reports error. | 185 // Check unsupported format reports error. |
| 118 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE, | 186 GLint unsupported_dest_formats[] = {GL_ALPHA, GL_LUMINANCE, |
| 119 GL_LUMINANCE_ALPHA}; | 187 GL_LUMINANCE_ALPHA}; |
| 120 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); | 188 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); |
| 121 dest_index++) { | 189 dest_index++) { |
| 122 glCopyTextureCHROMIUM(GL_TEXTURE_2D, | 190 if (copy_type == TexImage) { |
| 123 textures_[0], | 191 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], |
| 124 textures_[1], | 192 unsupported_dest_formats[dest_index], |
| 125 0, | 193 GL_UNSIGNED_BYTE); |
| 126 unsupported_dest_formats[dest_index], | 194 } else { |
| 127 GL_UNSIGNED_BYTE); | 195 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 196 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, |
| 197 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, |
| 198 nullptr); |
| 199 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 200 } |
| 128 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) | 201 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) |
| 129 << "dest_index:" << dest_index; | 202 << "dest_index:" << dest_index; |
| 130 } | 203 } |
| 131 } | 204 } |
| 132 | 205 |
| 133 // Test to ensure that the destination texture is redefined if the properties | 206 // Test to ensure that the destination texture is redefined if the properties |
| 134 // are different. | 207 // are different. |
| 135 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { | 208 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { |
| 136 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, | 209 uint8 pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, |
| 137 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; | 210 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 156 glTexSubImage2D( | 229 glTexSubImage2D( |
| 157 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 230 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 158 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); | 231 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); |
| 159 // GL_INVALID_VALUE due to bad dimensions. | 232 // GL_INVALID_VALUE due to bad dimensions. |
| 160 glTexSubImage2D( | 233 glTexSubImage2D( |
| 161 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); | 234 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 162 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 235 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 163 | 236 |
| 164 // If the dest texture has different properties, glCopyTextureCHROMIUM() | 237 // If the dest texture has different properties, glCopyTextureCHROMIUM() |
| 165 // redefines them. | 238 // redefines them. |
| 166 glCopyTextureCHROMIUM( | 239 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 167 GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, GL_UNSIGNED_BYTE); | 240 GL_UNSIGNED_BYTE); |
| 168 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 241 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 169 | 242 |
| 170 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 | 243 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 |
| 171 // dimension and GL_RGBA format. | 244 // dimension and GL_RGBA format. |
| 172 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 245 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 173 glTexSubImage2D( | 246 glTexSubImage2D( |
| 174 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 247 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 175 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 248 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 176 | 249 |
| 177 // Check the FB is still bound. | 250 // Check the FB is still bound. |
| 178 GLint value = 0; | 251 GLint value = 0; |
| 179 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 252 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 180 GLuint fb_id = value; | 253 GLuint fb_id = value; |
| 181 EXPECT_EQ(framebuffer_id_, fb_id); | 254 EXPECT_EQ(framebuffer_id_, fb_id); |
| 182 | 255 |
| 183 // Check that FB is complete. | 256 // Check that FB is complete. |
| 184 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 257 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 185 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 258 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 186 | 259 |
| 187 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); | 260 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); |
| 188 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 261 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 189 } | 262 } |
| 190 | 263 |
| 191 // Test that the extension respects the flip-y pixel storage setting. | 264 // Test that the extension respects the flip-y pixel storage setting. |
| 192 TEST_F(GLCopyTextureCHROMIUMTest, FlipY) { | 265 TEST_P(GLCopyTextureCHROMIUMTest, FlipY) { |
| 266 CopyType copy_type = GetParam(); |
| 193 uint8 pixels[2][2][4]; | 267 uint8 pixels[2][2][4]; |
| 194 for (int x = 0; x < 2; ++x) { | 268 for (int x = 0; x < 2; ++x) { |
| 195 for (int y = 0; y < 2; ++y) { | 269 for (int y = 0; y < 2; ++y) { |
| 196 pixels[y][x][0] = x + y; | 270 pixels[y][x][0] = x + y; |
| 197 pixels[y][x][1] = x + y; | 271 pixels[y][x][1] = x + y; |
| 198 pixels[y][x][2] = x + y; | 272 pixels[y][x][2] = x + y; |
| 199 pixels[y][x][3] = 255u; | 273 pixels[y][x][3] = 255u; |
| 200 } | 274 } |
| 201 } | 275 } |
| 202 | 276 |
| 203 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 277 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 204 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 278 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 205 pixels); | 279 pixels); |
| 206 | 280 |
| 207 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 281 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 208 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 282 |
| 209 GL_UNSIGNED_BYTE); | 283 if (copy_type == TexImage) { |
| 284 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 285 GL_UNSIGNED_BYTE); |
| 286 } else { |
| 287 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 289 nullptr); |
| 290 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 291 } |
| 210 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 292 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 211 | 293 |
| 212 uint8 copied_pixels[2][2][4] = {{{0}}}; | 294 uint8 copied_pixels[2][2][4] = {{{0}}}; |
| 213 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 295 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 214 for (int x = 0; x < 2; ++x) { | 296 for (int x = 0; x < 2; ++x) { |
| 215 for (int y = 0; y < 2; ++y) { | 297 for (int y = 0; y < 2; ++y) { |
| 216 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]); | 298 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]); | 299 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]); | 300 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]); | 301 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 220 } | 302 } |
| 221 } | 303 } |
| 222 | 304 |
| 223 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 305 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 224 } | 306 } |
| 225 | 307 |
| 226 // Test that the extension respects the GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM | 308 // Test that the extension respects the GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM |
| 227 // storage setting. | 309 // storage setting. |
| 228 TEST_F(GLCopyTextureCHROMIUMTest, PremultiplyAlpha) { | 310 TEST_P(GLCopyTextureCHROMIUMTest, PremultiplyAlpha) { |
| 311 CopyType copy_type = GetParam(); |
| 229 uint8 pixels[1 * 4] = { 2, 2, 2, 128 }; | 312 uint8 pixels[1 * 4] = { 2, 2, 2, 128 }; |
| 230 | 313 |
| 231 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 314 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 232 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 315 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 233 pixels); | 316 pixels); |
| 234 | 317 |
| 235 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 318 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 236 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 319 if (copy_type == TexImage) { |
| 237 GL_UNSIGNED_BYTE); | 320 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 321 GL_UNSIGNED_BYTE); |
| 322 } else { |
| 323 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 324 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 325 nullptr); |
| 326 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 327 } |
| 238 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 328 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 239 | 329 |
| 240 uint8 copied_pixels[1 * 4] = {0}; | 330 uint8 copied_pixels[1 * 4] = {0}; |
| 241 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 331 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 242 EXPECT_EQ(1u, copied_pixels[0]); | 332 EXPECT_EQ(1u, copied_pixels[0]); |
| 243 EXPECT_EQ(1u, copied_pixels[1]); | 333 EXPECT_EQ(1u, copied_pixels[1]); |
| 244 EXPECT_EQ(1u, copied_pixels[2]); | 334 EXPECT_EQ(1u, copied_pixels[2]); |
| 245 EXPECT_EQ(128u, copied_pixels[3]); | 335 EXPECT_EQ(128u, copied_pixels[3]); |
| 246 | 336 |
| 247 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 337 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 248 } | 338 } |
| 249 | 339 |
| 250 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM | 340 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM |
| 251 // storage setting. | 341 // storage setting. |
| 252 TEST_F(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { | 342 TEST_P(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { |
| 343 CopyType copy_type = GetParam(); |
| 253 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; | 344 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; |
| 254 | 345 |
| 255 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 346 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 256 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 347 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 257 pixels); | 348 pixels); |
| 258 | 349 |
| 259 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 350 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 260 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 351 if (copy_type == TexImage) { |
| 261 GL_UNSIGNED_BYTE); | 352 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 353 GL_UNSIGNED_BYTE); |
| 354 } else { |
| 355 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 356 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 357 nullptr); |
| 358 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 359 } |
| 262 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 360 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 263 | 361 |
| 264 uint8 copied_pixels[1 * 4] = {0}; | 362 uint8 copied_pixels[1 * 4] = {0}; |
| 265 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); |
| 266 EXPECT_EQ(32u, copied_pixels[0]); | 364 EXPECT_EQ(32u, copied_pixels[0]); |
| 267 EXPECT_EQ(32u, copied_pixels[1]); | 365 EXPECT_EQ(32u, copied_pixels[1]); |
| 268 EXPECT_EQ(32u, copied_pixels[2]); | 366 EXPECT_EQ(32u, copied_pixels[2]); |
| 269 EXPECT_EQ(128u, copied_pixels[3]); | 367 EXPECT_EQ(128u, copied_pixels[3]); |
| 270 | 368 |
| 271 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 369 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 272 } | 370 } |
| 273 | 371 |
| 274 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { | 372 TEST_P(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { |
| 373 CopyType copy_type = GetParam(); |
| 275 uint8 pixels[2][2][4]; | 374 uint8 pixels[2][2][4]; |
| 276 for (int x = 0; x < 2; ++x) { | 375 for (int x = 0; x < 2; ++x) { |
| 277 for (int y = 0; y < 2; ++y) { | 376 for (int y = 0; y < 2; ++y) { |
| 278 uint8 color = 16 * x + 16 * y; | 377 uint8 color = 16 * x + 16 * y; |
| 279 pixels[y][x][0] = color; | 378 pixels[y][x][0] = color; |
| 280 pixels[y][x][1] = color; | 379 pixels[y][x][1] = color; |
| 281 pixels[y][x][2] = color; | 380 pixels[y][x][2] = color; |
| 282 pixels[y][x][3] = 128u; | 381 pixels[y][x][3] = 128u; |
| 283 } | 382 } |
| 284 } | 383 } |
| 285 | 384 |
| 286 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 385 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 287 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 386 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 288 pixels); | 387 pixels); |
| 289 | 388 |
| 290 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 389 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 291 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 390 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 292 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 391 if (copy_type == TexImage) { |
| 293 GL_UNSIGNED_BYTE); | 392 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 393 GL_UNSIGNED_BYTE); |
| 394 } else { |
| 395 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 396 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 397 nullptr); |
| 398 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 399 } |
| 294 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 400 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 295 | 401 |
| 296 uint8 copied_pixels[2][2][4] = {{{0}}}; | 402 uint8 copied_pixels[2][2][4] = {{{0}}}; |
| 297 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 403 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 298 for (int x = 0; x < 2; ++x) { | 404 for (int x = 0; x < 2; ++x) { |
| 299 for (int y = 0; y < 2; ++y) { | 405 for (int y = 0; y < 2; ++y) { |
| 300 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); | 406 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]); | 407 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]); | 408 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]); | 409 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 304 } | 410 } |
| 305 } | 411 } |
| 306 | 412 |
| 307 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 413 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 308 } | 414 } |
| 309 | 415 |
| 310 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { | 416 TEST_P(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { |
| 417 CopyType copy_type = GetParam(); |
| 311 uint8 pixels[2][2][4]; | 418 uint8 pixels[2][2][4]; |
| 312 for (int x = 0; x < 2; ++x) { | 419 for (int x = 0; x < 2; ++x) { |
| 313 for (int y = 0; y < 2; ++y) { | 420 for (int y = 0; y < 2; ++y) { |
| 314 uint8 color = 16 * x + 16 * y; | 421 uint8 color = 16 * x + 16 * y; |
| 315 pixels[y][x][0] = color; | 422 pixels[y][x][0] = color; |
| 316 pixels[y][x][1] = color; | 423 pixels[y][x][1] = color; |
| 317 pixels[y][x][2] = color; | 424 pixels[y][x][2] = color; |
| 318 pixels[y][x][3] = 128u; | 425 pixels[y][x][3] = 128u; |
| 319 } | 426 } |
| 320 } | 427 } |
| 321 | 428 |
| 322 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 429 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 323 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 430 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 324 pixels); | 431 pixels); |
| 325 | 432 |
| 326 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | 433 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); |
| 327 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | 434 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); |
| 328 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 435 if (copy_type == TexImage) { |
| 329 GL_UNSIGNED_BYTE); | 436 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 437 GL_UNSIGNED_BYTE); |
| 438 } else { |
| 439 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 440 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 441 nullptr); |
| 442 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 443 } |
| 330 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 444 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 331 | 445 |
| 332 uint8 copied_pixels[2][2][4] = {{{0}}}; | 446 uint8 copied_pixels[2][2][4] = {{{0}}}; |
| 333 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | 447 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); |
| 334 for (int x = 0; x < 2; ++x) { | 448 for (int x = 0; x < 2; ++x) { |
| 335 for (int y = 0; y < 2; ++y) { | 449 for (int y = 0; y < 2; ++y) { |
| 336 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); | 450 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]); | 451 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]); | 452 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]); | 453 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); |
| 340 } | 454 } |
| 341 } | 455 } |
| 342 | 456 |
| 343 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 457 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 344 } | 458 } |
| 345 | 459 |
| 346 namespace { | 460 namespace { |
| 347 | 461 |
| 348 void glEnableDisable(GLint param, GLboolean value) { | 462 void glEnableDisable(GLint param, GLboolean value) { |
| 349 if (value) | 463 if (value) |
| 350 glEnable(param); | 464 glEnable(param); |
| 351 else | 465 else |
| 352 glDisable(param); | 466 glDisable(param); |
| 353 } | 467 } |
| 354 | 468 |
| 355 } // unnamed namespace | 469 } // unnamed namespace |
| 356 | 470 |
| 357 // Validate that some basic GL state is not touched upon execution of | 471 // Validate that some basic GL state is not touched upon execution of |
| 358 // the extension. | 472 // the extension. |
| 359 TEST_F(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { | 473 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { |
| 474 CopyType copy_type = GetParam(); |
| 360 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 475 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 361 | 476 |
| 362 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 477 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 363 | 478 |
| 364 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 479 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 365 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 480 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 366 pixels); | 481 pixels); |
| 367 | 482 |
| 483 if (copy_type == TexSubImage) { |
| 484 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 485 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 486 nullptr); |
| 487 } |
| 488 |
| 368 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; | 489 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; |
| 369 for (int x = 0; x < 2; ++x) { | 490 for (int x = 0; x < 2; ++x) { |
| 370 GLboolean setting = reference_settings[x]; | 491 GLboolean setting = reference_settings[x]; |
| 371 glEnableDisable(GL_DEPTH_TEST, setting); | 492 glEnableDisable(GL_DEPTH_TEST, setting); |
| 372 glEnableDisable(GL_SCISSOR_TEST, setting); | 493 glEnableDisable(GL_SCISSOR_TEST, setting); |
| 373 glEnableDisable(GL_STENCIL_TEST, setting); | 494 glEnableDisable(GL_STENCIL_TEST, setting); |
| 374 glEnableDisable(GL_CULL_FACE, setting); | 495 glEnableDisable(GL_CULL_FACE, setting); |
| 375 glEnableDisable(GL_BLEND, setting); | 496 glEnableDisable(GL_BLEND, setting); |
| 376 glColorMask(setting, setting, setting, setting); | 497 glColorMask(setting, setting, setting, setting); |
| 377 glDepthMask(setting); | 498 glDepthMask(setting); |
| 378 | 499 |
| 379 glActiveTexture(GL_TEXTURE1 + x); | 500 glActiveTexture(GL_TEXTURE1 + x); |
| 380 | 501 |
| 381 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | 502 if (copy_type == TexImage) { |
| 382 GL_RGBA, GL_UNSIGNED_BYTE); | 503 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 504 GL_UNSIGNED_BYTE); |
| 505 } else { |
| 506 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 507 } |
| 383 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 508 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 384 | 509 |
| 385 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); | 510 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); |
| 386 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); | 511 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); |
| 387 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); | 512 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); |
| 388 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); | 513 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); |
| 389 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); | 514 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); |
| 390 | 515 |
| 391 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; | 516 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; |
| 392 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); | 517 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); |
| 393 EXPECT_EQ(setting, bool_array[0]); | 518 EXPECT_EQ(setting, bool_array[0]); |
| 394 | 519 |
| 395 bool_array[0] = GL_FALSE; | 520 bool_array[0] = GL_FALSE; |
| 396 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); | 521 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); |
| 397 EXPECT_EQ(setting, bool_array[0]); | 522 EXPECT_EQ(setting, bool_array[0]); |
| 398 EXPECT_EQ(setting, bool_array[1]); | 523 EXPECT_EQ(setting, bool_array[1]); |
| 399 EXPECT_EQ(setting, bool_array[2]); | 524 EXPECT_EQ(setting, bool_array[2]); |
| 400 EXPECT_EQ(setting, bool_array[3]); | 525 EXPECT_EQ(setting, bool_array[3]); |
| 401 | 526 |
| 402 GLint active_texture = 0; | 527 GLint active_texture = 0; |
| 403 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 528 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
| 404 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); | 529 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); |
| 405 } | 530 } |
| 406 | 531 |
| 407 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 532 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 408 }; | 533 }; |
| 409 | 534 |
| 410 // Verify that invocation of the extension does not modify the bound | 535 // Verify that invocation of the extension does not modify the bound |
| 411 // texture state. | 536 // texture state. |
| 412 TEST_F(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { | 537 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { |
| 538 CopyType copy_type = GetParam(); |
| 413 // Setup the texture used for the extension invocation. | 539 // Setup the texture used for the extension invocation. |
| 414 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 540 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 415 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 541 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 416 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 542 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 417 pixels); | 543 pixels); |
| 418 | 544 |
| 545 if (copy_type == TexSubImage) { |
| 546 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 547 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 548 nullptr); |
| 549 } |
| 550 |
| 419 GLuint texture_ids[2]; | 551 GLuint texture_ids[2]; |
| 420 glGenTextures(2, texture_ids); | 552 glGenTextures(2, texture_ids); |
| 421 | 553 |
| 422 glActiveTexture(GL_TEXTURE0); | 554 glActiveTexture(GL_TEXTURE0); |
| 423 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); | 555 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); |
| 424 | 556 |
| 425 glActiveTexture(GL_TEXTURE1); | 557 glActiveTexture(GL_TEXTURE1); |
| 426 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); | 558 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); |
| 427 | 559 |
| 428 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | 560 if (copy_type == TexImage) { |
| 429 GL_RGBA, GL_UNSIGNED_BYTE); | 561 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 562 GL_UNSIGNED_BYTE); |
| 563 } else { |
| 564 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 565 } |
| 430 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 566 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 431 | 567 |
| 432 GLint active_texture = 0; | 568 GLint active_texture = 0; |
| 433 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 569 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
| 434 EXPECT_EQ(GL_TEXTURE1, active_texture); | 570 EXPECT_EQ(GL_TEXTURE1, active_texture); |
| 435 | 571 |
| 436 GLint bound_texture = 0; | 572 GLint bound_texture = 0; |
| 437 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 573 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 438 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); | 574 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); |
| 439 glBindTexture(GL_TEXTURE_2D, 0); | 575 glBindTexture(GL_TEXTURE_2D, 0); |
| 440 | 576 |
| 441 bound_texture = 0; | 577 bound_texture = 0; |
| 442 glActiveTexture(GL_TEXTURE0); | 578 glActiveTexture(GL_TEXTURE0); |
| 443 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 579 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 444 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); | 580 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); |
| 445 glBindTexture(GL_TEXTURE_2D, 0); | 581 glBindTexture(GL_TEXTURE_2D, 0); |
| 446 | 582 |
| 447 glDeleteTextures(2, texture_ids); | 583 glDeleteTextures(2, texture_ids); |
| 448 | 584 |
| 449 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 585 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 450 } | 586 } |
| 451 | 587 |
| 452 // Verify that invocation of the extension does not perturb the currently | 588 // Verify that invocation of the extension does not perturb the currently |
| 453 // bound FBO state. | 589 // bound FBO state. |
| 454 TEST_F(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { | 590 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { |
| 591 CopyType copy_type = GetParam(); |
| 455 // Setup the texture used for the extension invocation. | 592 // Setup the texture used for the extension invocation. |
| 456 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 593 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 457 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 594 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 458 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 595 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 459 pixels); | 596 pixels); |
| 460 | 597 |
| 598 if (copy_type == TexSubImage) { |
| 599 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 600 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 601 nullptr); |
| 602 } |
| 603 |
| 461 GLuint texture_id; | 604 GLuint texture_id; |
| 462 glGenTextures(1, &texture_id); | 605 glGenTextures(1, &texture_id); |
| 463 glBindTexture(GL_TEXTURE_2D, texture_id); | 606 glBindTexture(GL_TEXTURE_2D, texture_id); |
| 464 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 607 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 465 0); | 608 0); |
| 466 | 609 |
| 467 GLuint renderbuffer_id; | 610 GLuint renderbuffer_id; |
| 468 glGenRenderbuffers(1, &renderbuffer_id); | 611 glGenRenderbuffers(1, &renderbuffer_id); |
| 469 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id); | 612 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id); |
| 470 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 1, 1); | 613 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 1, 1); |
| 471 | 614 |
| 472 GLuint framebuffer_id; | 615 GLuint framebuffer_id; |
| 473 glGenFramebuffers(1, &framebuffer_id); | 616 glGenFramebuffers(1, &framebuffer_id); |
| 474 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); | 617 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); |
| 475 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 618 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 476 texture_id, 0); | 619 texture_id, 0); |
| 477 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, | 620 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
| 478 GL_RENDERBUFFER, renderbuffer_id); | 621 GL_RENDERBUFFER, renderbuffer_id); |
| 479 EXPECT_TRUE( | 622 EXPECT_TRUE( |
| 480 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 623 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 481 | 624 |
| 482 // Test that we can write to the bound framebuffer | 625 // Test that we can write to the bound framebuffer |
| 483 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; | 626 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; |
| 484 glClearColor(1.0, 1.0, 0, 1.0); | 627 glClearColor(1.0, 1.0, 0, 1.0); |
| 485 glClear(GL_COLOR_BUFFER_BIT); | 628 glClear(GL_COLOR_BUFFER_BIT); |
| 486 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); | 629 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); |
| 487 | 630 |
| 488 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, | 631 if (copy_type == TexImage) { |
| 489 GL_RGBA, GL_UNSIGNED_BYTE); | 632 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 633 GL_UNSIGNED_BYTE); |
| 634 } else { |
| 635 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 636 } |
| 490 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 637 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 491 | 638 |
| 492 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); | 639 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); |
| 493 | 640 |
| 494 // Ensure that reading from the framebuffer produces correct pixels. | 641 // Ensure that reading from the framebuffer produces correct pixels. |
| 495 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); | 642 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); |
| 496 | 643 |
| 497 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; | 644 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; |
| 498 glClearColor(1.0, 0, 1.0, 1.0); | 645 glClearColor(1.0, 0, 1.0, 1.0); |
| 499 glClear(GL_COLOR_BUFFER_BIT); | 646 glClear(GL_COLOR_BUFFER_BIT); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 527 &fbo_params); | 674 &fbo_params); |
| 528 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); | 675 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); |
| 529 | 676 |
| 530 glDeleteRenderbuffers(1, &renderbuffer_id); | 677 glDeleteRenderbuffers(1, &renderbuffer_id); |
| 531 glDeleteTextures(1, &texture_id); | 678 glDeleteTextures(1, &texture_id); |
| 532 glDeleteFramebuffers(1, &framebuffer_id); | 679 glDeleteFramebuffers(1, &framebuffer_id); |
| 533 | 680 |
| 534 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 681 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 535 } | 682 } |
| 536 | 683 |
| 537 TEST_F(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { | 684 TEST_P(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { |
| 685 CopyType copy_type = GetParam(); |
| 538 // unbind the one created in setup. | 686 // unbind the one created in setup. |
| 539 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 687 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 540 glBindTexture(GL_TEXTURE_2D, 0); | 688 glBindTexture(GL_TEXTURE_2D, 0); |
| 541 | 689 |
| 542 GLManager gl2; | 690 GLManager gl2; |
| 543 GLManager::Options options; | 691 GLManager::Options options; |
| 544 options.size = gfx::Size(16, 16); | 692 options.size = gfx::Size(16, 16); |
| 545 options.share_group_manager = &gl_; | 693 options.share_group_manager = &gl_; |
| 546 gl2.Initialize(options); | 694 gl2.Initialize(options); |
| 547 gl_.MakeCurrent(); | 695 gl_.MakeCurrent(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 glClear(GL_COLOR_BUFFER_BIT); | 729 glClear(GL_COLOR_BUFFER_BIT); |
| 582 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); | 730 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); |
| 583 glDrawArrays(GL_TRIANGLES, 0, 6); | 731 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 584 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 732 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
| 585 | 733 |
| 586 // Call copyTextureCHROMIUM | 734 // Call copyTextureCHROMIUM |
| 587 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 735 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 588 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 736 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 589 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 737 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 590 pixels); | 738 pixels); |
| 591 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 739 if (copy_type == TexImage) { |
| 592 GL_UNSIGNED_BYTE); | 740 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 741 GL_UNSIGNED_BYTE); |
| 742 } else { |
| 743 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 744 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 745 nullptr); |
| 746 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 747 } |
| 593 | 748 |
| 594 // test using program after | 749 // test using program after |
| 595 glClear(GL_COLOR_BUFFER_BIT); | 750 glClear(GL_COLOR_BUFFER_BIT); |
| 596 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); | 751 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); |
| 597 glDrawArrays(GL_TRIANGLES, 0, 6); | 752 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 598 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 753 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
| 599 | 754 |
| 600 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 755 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 601 | 756 |
| 602 gl2.MakeCurrent(); | 757 gl2.MakeCurrent(); |
| 603 gl2.Destroy(); | 758 gl2.Destroy(); |
| 604 gl_.MakeCurrent(); | 759 gl_.MakeCurrent(); |
| 605 } | 760 } |
| 606 | 761 |
| 607 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. | 762 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. |
| 608 TEST_F(GLCopyTextureCHROMIUMTest, UninitializedSource) { | 763 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { |
| 764 CopyType copy_type = GetParam(); |
| 609 const GLsizei kWidth = 64, kHeight = 64; | 765 const GLsizei kWidth = 64, kHeight = 64; |
| 610 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 766 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 611 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, | 767 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 612 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | 768 GL_UNSIGNED_BYTE, nullptr); |
| 613 | 769 |
| 614 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, | 770 if (copy_type == TexImage) { |
| 615 GL_UNSIGNED_BYTE); | 771 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, |
| 772 GL_UNSIGNED_BYTE); |
| 773 } else { |
| 774 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 775 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 776 GL_UNSIGNED_BYTE, nullptr); |
| 777 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0); |
| 778 } |
| 616 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 779 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 617 | 780 |
| 618 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; | 781 uint8 pixels[kHeight][kWidth][4] = {{{1}}}; |
| 619 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 782 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 620 for (int x = 0; x < kWidth; ++x) { | 783 for (int x = 0; x < kWidth; ++x) { |
| 621 for (int y = 0; y < kHeight; ++y) { | 784 for (int y = 0; y < kHeight; ++y) { |
| 622 EXPECT_EQ(0, pixels[y][x][0]); | 785 EXPECT_EQ(0, pixels[y][x][0]); |
| 623 EXPECT_EQ(0, pixels[y][x][1]); | 786 EXPECT_EQ(0, pixels[y][x][1]); |
| 624 EXPECT_EQ(0, pixels[y][x][2]); | 787 EXPECT_EQ(0, pixels[y][x][2]); |
| 625 EXPECT_EQ(0, pixels[y][x][3]); | 788 EXPECT_EQ(0, pixels[y][x][3]); |
| 626 } | 789 } |
| 627 } | 790 } |
| 628 | 791 |
| 629 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 792 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 630 } | 793 } |
| 631 | 794 |
| 795 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { |
| 796 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 797 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 798 nullptr); |
| 799 |
| 800 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 801 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 802 nullptr); |
| 803 |
| 804 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1); |
| 805 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 806 |
| 807 // xoffset < 0 |
| 808 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], -1, 1); |
| 809 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 810 |
| 811 // xoffset + source_width > dest_width |
| 812 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 2, 2); |
| 813 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 814 } |
| 815 |
| 816 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { |
| 817 uint8 red[1 * 4] = {255u, 0u, 0u, 255u}; |
| 818 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 819 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 820 red); |
| 821 |
| 822 uint8 transparent_pixel[4 * 4] = { |
| 823 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; |
| 824 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 825 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 826 transparent_pixel); |
| 827 |
| 828 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 1, 1); |
| 829 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 830 |
| 831 // Check the FB is still bound. |
| 832 GLint value = 0; |
| 833 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 834 GLuint fb_id = value; |
| 835 EXPECT_EQ(framebuffer_id_, fb_id); |
| 836 |
| 837 // Check that FB is complete. |
| 838 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 839 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 840 |
| 841 uint8 transparent[1 * 4] = {0u, 0u, 0u, 0u}; |
| 842 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); |
| 843 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); |
| 844 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 845 } |
| 846 |
| 632 } // namespace gpu | 847 } // namespace gpu |
| OLD | NEW |