| 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> |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 EXPECT_EQ(framebuffer_id_, fb_id); | 258 EXPECT_EQ(framebuffer_id_, fb_id); |
| 259 | 259 |
| 260 // Check that FB is complete. | 260 // Check that FB is complete. |
| 261 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 261 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 262 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 262 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 263 | 263 |
| 264 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); | 264 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); |
| 265 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 265 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 266 } | 266 } |
| 267 | 267 |
| 268 // Test that the extension respects the flip-y pixel storage setting. | |
| 269 TEST_P(GLCopyTextureCHROMIUMTest, FlipY) { | |
| 270 CopyType copy_type = GetParam(); | |
| 271 uint8 pixels[2][2][4]; | |
| 272 for (int x = 0; x < 2; ++x) { | |
| 273 for (int y = 0; y < 2; ++y) { | |
| 274 pixels[y][x][0] = x + y; | |
| 275 pixels[y][x][1] = x + y; | |
| 276 pixels[y][x][2] = x + y; | |
| 277 pixels[y][x][3] = 255u; | |
| 278 } | |
| 279 } | |
| 280 | |
| 281 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 282 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 283 pixels); | |
| 284 | |
| 285 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | |
| 286 | |
| 287 if (copy_type == TexImage) { | |
| 288 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, | |
| 289 GL_UNSIGNED_BYTE, true, false, false); | |
| 290 } else { | |
| 291 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 292 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 293 nullptr); | |
| 294 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, | |
| 295 0, 2, 2, true, false, false); | |
| 296 } | |
| 297 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 298 | |
| 299 uint8 copied_pixels[2][2][4] = {{{0}}}; | |
| 300 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | |
| 301 for (int x = 0; x < 2; ++x) { | |
| 302 for (int y = 0; y < 2; ++y) { | |
| 303 EXPECT_EQ(pixels[1-y][x][0], copied_pixels[y][x][0]); | |
| 304 EXPECT_EQ(pixels[1-y][x][1], copied_pixels[y][x][1]); | |
| 305 EXPECT_EQ(pixels[1-y][x][2], copied_pixels[y][x][2]); | |
| 306 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | |
| 307 } | |
| 308 } | |
| 309 | |
| 310 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 311 } | |
| 312 | |
| 313 // Test that the extension respects the GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM | |
| 314 // storage setting. | |
| 315 TEST_P(GLCopyTextureCHROMIUMTest, PremultiplyAlpha) { | |
| 316 CopyType copy_type = GetParam(); | |
| 317 uint8 pixels[1 * 4] = { 2, 2, 2, 128 }; | |
| 318 | |
| 319 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 320 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 321 pixels); | |
| 322 | |
| 323 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | |
| 324 if (copy_type == TexImage) { | |
| 325 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, | |
| 326 GL_UNSIGNED_BYTE, false, true, false); | |
| 327 } else { | |
| 328 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 329 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 330 nullptr); | |
| 331 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, | |
| 332 0, 1, 1, false, true, false); | |
| 333 } | |
| 334 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 335 | |
| 336 uint8 copied_pixels[1 * 4] = {0}; | |
| 337 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | |
| 338 EXPECT_EQ(1u, copied_pixels[0]); | |
| 339 EXPECT_EQ(1u, copied_pixels[1]); | |
| 340 EXPECT_EQ(1u, copied_pixels[2]); | |
| 341 EXPECT_EQ(128u, copied_pixels[3]); | |
| 342 | |
| 343 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 344 } | |
| 345 | |
| 346 // Test that the extension respects the GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM | |
| 347 // storage setting. | |
| 348 TEST_P(GLCopyTextureCHROMIUMTest, UnpremultiplyAlpha) { | |
| 349 CopyType copy_type = GetParam(); | |
| 350 uint8 pixels[1 * 4] = { 16, 16, 16, 128 }; | |
| 351 | |
| 352 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 353 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 354 pixels); | |
| 355 | |
| 356 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | |
| 357 if (copy_type == TexImage) { | |
| 358 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, | |
| 359 GL_UNSIGNED_BYTE, false, false, true); | |
| 360 } else { | |
| 361 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 362 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 363 nullptr); | |
| 364 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, | |
| 365 0, 1, 1, false, false, true); | |
| 366 } | |
| 367 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 368 | |
| 369 uint8 copied_pixels[1 * 4] = {0}; | |
| 370 glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | |
| 371 EXPECT_EQ(32u, copied_pixels[0]); | |
| 372 EXPECT_EQ(32u, copied_pixels[1]); | |
| 373 EXPECT_EQ(32u, copied_pixels[2]); | |
| 374 EXPECT_EQ(128u, copied_pixels[3]); | |
| 375 | |
| 376 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 377 } | |
| 378 | |
| 379 TEST_P(GLCopyTextureCHROMIUMTest, FlipYAndPremultiplyAlpha) { | |
| 380 CopyType copy_type = GetParam(); | |
| 381 uint8 pixels[2][2][4]; | |
| 382 for (int x = 0; x < 2; ++x) { | |
| 383 for (int y = 0; y < 2; ++y) { | |
| 384 uint8 color = 16 * x + 16 * y; | |
| 385 pixels[y][x][0] = color; | |
| 386 pixels[y][x][1] = color; | |
| 387 pixels[y][x][2] = color; | |
| 388 pixels[y][x][3] = 128u; | |
| 389 } | |
| 390 } | |
| 391 | |
| 392 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 393 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 394 pixels); | |
| 395 | |
| 396 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | |
| 397 glPixelStorei(GL_UNPACK_PREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | |
| 398 if (copy_type == TexImage) { | |
| 399 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, | |
| 400 GL_UNSIGNED_BYTE, true, true, false); | |
| 401 } else { | |
| 402 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 403 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 404 nullptr); | |
| 405 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, | |
| 406 0, 2, 2, true, true, false); | |
| 407 } | |
| 408 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 409 | |
| 410 uint8 copied_pixels[2][2][4] = {{{0}}}; | |
| 411 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | |
| 412 for (int x = 0; x < 2; ++x) { | |
| 413 for (int y = 0; y < 2; ++y) { | |
| 414 EXPECT_EQ(pixels[1-y][x][0] / 2, copied_pixels[y][x][0]); | |
| 415 EXPECT_EQ(pixels[1-y][x][1] / 2, copied_pixels[y][x][1]); | |
| 416 EXPECT_EQ(pixels[1-y][x][2] / 2, copied_pixels[y][x][2]); | |
| 417 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | |
| 418 } | |
| 419 } | |
| 420 | |
| 421 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 422 } | |
| 423 | |
| 424 TEST_P(GLCopyTextureCHROMIUMTest, FlipYAndUnpremultiplyAlpha) { | |
| 425 CopyType copy_type = GetParam(); | |
| 426 uint8 pixels[2][2][4]; | |
| 427 for (int x = 0; x < 2; ++x) { | |
| 428 for (int y = 0; y < 2; ++y) { | |
| 429 uint8 color = 16 * x + 16 * y; | |
| 430 pixels[y][x][0] = color; | |
| 431 pixels[y][x][1] = color; | |
| 432 pixels[y][x][2] = color; | |
| 433 pixels[y][x][3] = 128u; | |
| 434 } | |
| 435 } | |
| 436 | |
| 437 glBindTexture(GL_TEXTURE_2D, textures_[0]); | |
| 438 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 439 pixels); | |
| 440 | |
| 441 glPixelStorei(GL_UNPACK_FLIP_Y_CHROMIUM, GL_TRUE); | |
| 442 glPixelStorei(GL_UNPACK_UNPREMULTIPLY_ALPHA_CHROMIUM, GL_TRUE); | |
| 443 if (copy_type == TexImage) { | |
| 444 glCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], GL_RGBA, | |
| 445 GL_UNSIGNED_BYTE, true, false, true); | |
| 446 } else { | |
| 447 glBindTexture(GL_TEXTURE_2D, textures_[1]); | |
| 448 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 449 nullptr); | |
| 450 glCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], 0, 0, 0, | |
| 451 0, 2, 2, true, false, true); | |
| 452 } | |
| 453 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 454 | |
| 455 uint8 copied_pixels[2][2][4] = {{{0}}}; | |
| 456 glReadPixels(0, 0, 2, 2, GL_RGBA, GL_UNSIGNED_BYTE, copied_pixels); | |
| 457 for (int x = 0; x < 2; ++x) { | |
| 458 for (int y = 0; y < 2; ++y) { | |
| 459 EXPECT_EQ(pixels[1-y][x][0] * 2, copied_pixels[y][x][0]); | |
| 460 EXPECT_EQ(pixels[1-y][x][1] * 2, copied_pixels[y][x][1]); | |
| 461 EXPECT_EQ(pixels[1-y][x][2] * 2, copied_pixels[y][x][2]); | |
| 462 EXPECT_EQ(pixels[1-y][x][3], copied_pixels[y][x][3]); | |
| 463 } | |
| 464 } | |
| 465 | |
| 466 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | |
| 467 } | |
| 468 | |
| 469 namespace { | 268 namespace { |
| 470 | 269 |
| 471 void glEnableDisable(GLint param, GLboolean value) { | 270 void glEnableDisable(GLint param, GLboolean value) { |
| 472 if (value) | 271 if (value) |
| 473 glEnable(param); | 272 glEnable(param); |
| 474 else | 273 else |
| 475 glDisable(param); | 274 glDisable(param); |
| 476 } | 275 } |
| 477 | 276 |
| 478 } // unnamed namespace | 277 } // unnamed namespace |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 uint8 green[1 * 4] = {0u, 255u, 0u, 255u}; | 691 uint8 green[1 * 4] = {0u, 255u, 0u, 255u}; |
| 893 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u}; | 692 uint8 blue[1 * 4] = {0u, 0u, 255u, 255u}; |
| 894 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); | 693 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); |
| 895 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); | 694 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); |
| 896 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); | 695 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); |
| 897 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); | 696 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); |
| 898 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 697 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 899 } | 698 } |
| 900 | 699 |
| 901 } // namespace gpu | 700 } // namespace gpu |
| OLD | NEW |