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 3 // found in the LICENSE file. 4 5 #ifndef GL_GLEXT_PROTOTYPES 6 #define GL_GLEXT_PROTOTYPES 7 #endif 8 9 #include <GLES2/gl2.h> 10 #include <GLES2/gl2ext.h> 11 #include <GLES2/gl2extchromium.h> 12 13 #include "gpu/command_buffer/tests/gl_manager.h" 14 #include "gpu/command_buffer/tests/gl_test_utils.h" 15 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gtest/include/gtest/gtest.h" 17 18 namespace gpu { 19 20 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. 21 class GLCopyTextureCHROMIUMTest : public testing::Test { 22 protected: 23 virtual void SetUp() { 24 gl_.Initialize(GLManager::Options()); 25 26 glGenTextures(2, textures_); 27 glBindTexture(GL_TEXTURE_2D, textures_[1]); 28 29 // Some drivers (NVidia/SGX) require texture settings to be a certain way or 30 // they won't report FRAMEBUFFER_COMPLETE. 31 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 32 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 33 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 34 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 35 36 glGenFramebuffers(1, &framebuffer_id_); 37 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); 38 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 39 textures_[1], 0); 40 } 41 42 virtual void TearDown() { 43 glDeleteTextures(2, textures_); 44 glDeleteFramebuffers(1, &framebuffer_id_); 45 gl_.Destroy(); 46 } 47 48 GLManager gl_; 49 GLuint textures_[2]; 50 GLuint framebuffer_id_; 51 }; 52 53 // Test to ensure that the basic functionality of the extension works. 54 TEST_F(GLCopyTextureCHROMIUMTest, Basic) { 55 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 56 57 glBindTexture(GL_TEXTURE_2D, textures_[0]); 58 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 59 pixels); 60 61 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 62 GL_UNSIGNED_BYTE); 63 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 64 65 // Check the FB is still bound. 66 GLint value = 0; 67 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 68 GLuint fb_id = value; 69 EXPECT_EQ(framebuffer_id_, fb_id); 70 71 // Check that FB is complete. 72 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 73 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 74 75 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); 76 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 77 } 78 79 // Test that the extension respects the flip-y pixel storage setting. 80 TEST_F(GLCopyTextureCHROMIUMTest, FlipY) { 81 uint8 pixels[2][2][4]; 82 for (int x = 0; x < 2; ++x) { 83 for (int y = 0; y < 2; ++y) { 84 pixels[y][x][0] = x + y; 85 pixels[y][x][1] = x + y; 86 pixels[y][x][2] = x + y; 87 pixels[y][x][3] = 255u; 88 } 89 } 90 91 glBindTexture(GL_TEXTURE_2D, textures_[0]); 92 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 93 pixels); 94 95 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); 96 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 97 GL_UNSIGNED_BYTE); 98 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 99 100 uint8 copied_pixels[2][2][4] = {{{0}}}; 101 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 102 for (int x = 0; x < 2; ++x) { 103 for (int y = 0; y < 2; ++y) 104 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]); 105 } 106 107 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 108 } 109 110 // Test that the extension respects the GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM 111 // storage setting. 112 TEST_F(GLCopyTextureCHROMIUMTest, PremultiplyAlpha) { 113 uint8 pixels[1 * 4] = { 2, 2, 2, 128 }; 114 115 glBindTexture(GL_TEXTURE_2D, textures_[0]); 116 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 117 pixels); 118 119 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 120 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 121 GL_UNSIGNED_BYTE); 122 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 123 124 uint8 copied_pixels[1 * 4] = {0}; 125 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 126 EXPECT_EQ(1u, copied_pixels[0]); 127 EXPECT_EQ(1u, copied_pixels[1]); 128 EXPECT_EQ(1u, copied_pixels[2]); 129 EXPECT_EQ(128u, copied_pixels[3]); 130 131 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 132 } 133 134 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM 135 // storage setting. 136 TEST_F(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { 137 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; 138 139 glBindTexture(GL_TEXTURE_2D, textures_[0]); 140 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 141 pixels); 142 143 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 144 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 145 GL_UNSIGNED_BYTE); 146 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 147 148 uint8 copied_pixels[1 * 4] = {0}; 149 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 150 EXPECT_EQ(32u, copied_pixels[0]); 151 EXPECT_EQ(32u, copied_pixels[1]); 152 EXPECT_EQ(32u, copied_pixels[2]); 153 EXPECT_EQ(128u, copied_pixels[3]); 154 155 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 156 } 157 158 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { 159 uint8 pixels[2][2][4]; 160 for (int x = 0; x < 2; ++x) { 161 for (int y = 0; y < 2; ++y) { 162 uint8 color = 16 * x + 16 * y; 163 pixels[y][x][0] = color; 164 pixels[y][x][1] = color; 165 pixels[y][x][2] = color; 166 pixels[y][x][3] = 128u; 167 } 168 } 169 170 glBindTexture(GL_TEXTURE_2D, textures_[0]); 171 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 172 pixels); 173 174 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); 175 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 176 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 177 GL_UNSIGNED_BYTE); 178 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 179 180 uint8 copied_pixels[2][2][4] = {{{0}}}; 181 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 182 for (int x = 0; x < 2; ++x) { 183 for (int y = 0; y < 2; ++y) { 184 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); 185 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); 186 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); 187 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); 188 } 189 } 190 191 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 192 } 193 194 TEST_F(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { 195 uint8 pixels[2][2][4]; 196 for (int x = 0; x < 2; ++x) { 197 for (int y = 0; y < 2; ++y) { 198 uint8 color = 16 * x + 16 * y; 199 pixels[y][x][0] = color; 200 pixels[y][x][1] = color; 201 pixels[y][x][2] = color; 202 pixels[y][x][3] = 128u; 203 } 204 } 205 206 glBindTexture(GL_TEXTURE_2D, textures_[0]); 207 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 208 pixels); 209 210 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); 211 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); 212 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 213 GL_UNSIGNED_BYTE); 214 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 215 216 uint8 copied_pixels[2][2][4] = {{{0}}}; 217 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); 218 for (int x = 0; x < 2; ++x) { 219 for (int y = 0; y < 2; ++y) { 220 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); 221 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]); 222 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]); 223 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); 224 } 225 } 226 227 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 228 } 229 230 namespace { 231 232 void glEnableDisable(GLint param, GLboolean value) { 233 if (value) 234 glEnable(param); 235 else 236 glDisable(param); 237 } 238 239 } // unnamed namespace 240 241 // Validate that some basic GL state is not touched upon execution of 242 // the extension. 243 TEST_F(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { 244 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 245 246 glBindFramebuffer(GL_FRAMEBUFFER, 0); 247 248 glBindTexture(GL_TEXTURE_2D, textures_[0]); 249 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 250 pixels); 251 252 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; 253 for (int x = 0; x < 2; ++x) { 254 GLboolean setting = reference_settings[x]; 255 glEnableDisable(GL_DEPTH_TEST, setting); 256 glEnableDisable(GL_SCISSOR_TEST, setting); 257 glEnableDisable(GL_STENCIL_TEST, setting); 258 glEnableDisable(GL_CULL_FACE, setting); 259 glEnableDisable(GL_BLEND, setting); 260 glColorMask(setting, setting, setting, setting); 261 glDepthMask(setting); 262 263 glActiveTexture(GL_TEXTURE1 + x); 264 265 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 266 GL_RGBA, GL_UNSIGNED_BYTE); 267 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 268 269 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); 270 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); 271 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); 272 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); 273 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); 274 275 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; 276 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); 277 EXPECT_EQ(setting, bool_array[0]); 278 279 bool_array[0] = GL_FALSE; 280 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); 281 EXPECT_EQ(setting, bool_array[0]); 282 EXPECT_EQ(setting, bool_array[1]); 283 EXPECT_EQ(setting, bool_array[2]); 284 EXPECT_EQ(setting, bool_array[3]); 285 286 GLint active_texture = 0; 287 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 288 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); 289 } 290 291 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 292 }; 293 294 // Verify that invocation of the extension does not modify the bound 295 // texture state. 296 TEST_F(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { 297 // Setup the texture used for the extension invocation. 298 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 299 glBindTexture(GL_TEXTURE_2D, textures_[0]); 300 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 301 pixels); 302 303 GLuint texture_ids[2]; 304 glGenTextures(2, texture_ids); 305 306 glActiveTexture(GL_TEXTURE0); 307 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); 308 309 glActiveTexture(GL_TEXTURE1); 310 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); 311 312 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 313 GL_RGBA, GL_UNSIGNED_BYTE); 314 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 315 316 GLint active_texture = 0; 317 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 318 EXPECT_EQ(GL_TEXTURE1, active_texture); 319 320 GLint bound_texture = 0; 321 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 322 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); 323 glBindTexture(GL_TEXTURE_2D, 0); 324 325 bound_texture = 0; 326 glActiveTexture(GL_TEXTURE0); 327 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 328 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); 329 glBindTexture(GL_TEXTURE_2D, 0); 330 331 glDeleteTextures(2, texture_ids); 332 333 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 334 } 335 336 // Verify that invocation of the extension does not perturb the currently 337 // bound FBO state. 338 TEST_F(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { 339 // Setup the texture used for the extension invocation. 340 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 341 glBindTexture(GL_TEXTURE_2D, textures_[0]); 342 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 343 pixels); 344 345 GLuint texture_id; 346 glGenTextures(1, &texture_id); 347 glBindTexture(GL_TEXTURE_2D, texture_id); 348 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 349 0); 350 351 GLuint renderbuffer_id; 352 glGenRenderbuffers(1, &renderbuffer_id); 353 glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer_id); 354 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 1, 1); 355 356 GLuint framebuffer_id; 357 glGenFramebuffers(1, &framebuffer_id); 358 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id); 359 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 360 texture_id, 0); 361 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 362 GL_RENDERBUFFER, renderbuffer_id); 363 EXPECT_TRUE( 364 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); 365 366 // Test that we can write to the bound framebuffer 367 uint8 expected_color[4] = { 255u, 255u, 0, 255u }; 368 glClearColor(1.0, 1.0, 0, 1.0); 369 glClear(GL_COLOR_BUFFER_BIT); 370 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 371 372 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 373 GL_RGBA, GL_UNSIGNED_BYTE); 374 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 375 376 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); 377 378 // Ensure that reading from the framebuffer produces correct pixels. 379 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color); 380 381 uint8 expected_color2[4] = { 255u, 0, 255u, 255u }; 382 glClearColor(1.0, 0, 1.0, 1.0); 383 glClear(GL_COLOR_BUFFER_BIT); 384 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color2); 385 386 GLint bound_fbo = 0; 387 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &bound_fbo); 388 EXPECT_EQ(framebuffer_id, static_cast<GLuint>(bound_fbo)); 389 390 GLint fbo_params = 0; 391 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 392 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, 393 &fbo_params); 394 EXPECT_EQ(GL_TEXTURE, fbo_params); 395 396 fbo_params = 0; 397 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 398 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 399 &fbo_params); 400 EXPECT_EQ(texture_id, static_cast<GLuint>(fbo_params)); 401 402 fbo_params = 0; 403 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 404 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, 405 &fbo_params); 406 EXPECT_EQ(GL_RENDERBUFFER, fbo_params); 407 408 fbo_params = 0; 409 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 410 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 411 &fbo_params); 412 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); 413 414 glDeleteRenderbuffers(1, &renderbuffer_id); 415 glDeleteTextures(1, &texture_id); 416 glDeleteFramebuffers(1, &framebuffer_id); 417 418 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 419 } 420 421 TEST_F(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { 422 // unbind the one created in setup. 423 glBindFramebuffer(GL_FRAMEBUFFER, 0); 424 glBindTexture(GL_TEXTURE_2D, 0); 425 426 GLManager gl2; 427 GLManager::Options options; 428 options.size = gfx::Size(16, 16); 429 options.share_group_manager = &gl_; 430 gl2.Initialize(options); 431 gl_.MakeCurrent(); 432 433 static const char* v_shader_str = 434 "attribute vec4 g_Position;\n" 435 "void main()\n" 436 "{\n" 437 " gl_Position = g_Position;\n" 438 "}\n"; 439 static const char* f_shader_str = 440 "precision mediump float;\n" 441 "void main()\n" 442 "{\n" 443 " gl_FragColor = vec4(0,1,0,1);\n" 444 "}\n"; 445 446 GLuint program = GLTestHelper::LoadProgram(v_shader_str, f_shader_str); 447 glUseProgram(program); 448 GLuint position_loc = glGetAttribLocation(program, "g_Position"); 449 glFlush(); 450 451 // Delete program from other context. 452 gl2.MakeCurrent(); 453 glDeleteProgram(program); 454 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 455 glFlush(); 456 457 // Program should still be usable on this context. 458 gl_.MakeCurrent(); 459 460 GLTestHelper::SetupUnitQuad(position_loc); 461 462 // test using program before 463 uint8 expected[] = { 0, 255, 0, 255, }; 464 uint8 zero[] = { 0, 0, 0, 0, }; 465 glClear(GL_COLOR_BUFFER_BIT); 466 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 467 glDrawArrays(GL_TRIANGLES, 0, 6); 468 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 469 470 // Call copyTextureCHROMIUM 471 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; 472 glBindTexture(GL_TEXTURE_2D, textures_[0]); 473 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 474 pixels); 475 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, GL_RGBA, 476 GL_UNSIGNED_BYTE); 477 478 // test using program after 479 glClear(GL_COLOR_BUFFER_BIT); 480 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); 481 glDrawArrays(GL_TRIANGLES, 0, 6); 482 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); 483 484 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 485 486 gl2.MakeCurrent(); 487 gl2.Destroy(); 488 gl_.MakeCurrent(); 489 } 490 491 } // namespace gpu 492