| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { | 307 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { |
| 308 CopyType copy_type = GetParam(); | 308 CopyType copy_type = GetParam(); |
| 309 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; | 309 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
| 310 | 310 |
| 311 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 311 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 312 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 312 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 313 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 313 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 314 pixels); | 314 pixels); |
| 315 | 315 |
| 316 if (copy_type == TexImage) { | 316 if (copy_type == TexImage) { |
| 317 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 317 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 318 GL_UNSIGNED_BYTE, false, false, false); | 318 GL_UNSIGNED_BYTE, false, false, false); |
| 319 } else { | 319 } else { |
| 320 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 320 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 321 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 321 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 322 nullptr); | 322 nullptr); |
| 323 | 323 |
| 324 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 324 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, |
| 325 0, 1, 1, false, false, false); | 325 false, false, false); |
| 326 } | 326 } |
| 327 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 327 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 328 | 328 |
| 329 // Check the FB is still bound. | 329 // Check the FB is still bound. |
| 330 GLint value = 0; | 330 GLint value = 0; |
| 331 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 331 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 332 GLuint fb_id = value; | 332 GLuint fb_id = value; |
| 333 EXPECT_EQ(framebuffer_id_, fb_id); | 333 EXPECT_EQ(framebuffer_id_, fb_id); |
| 334 | 334 |
| 335 // Check that FB is complete. | 335 // Check that FB is complete. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 445 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 446 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 446 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 447 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 447 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 448 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 448 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 449 glTexImage2D(GL_TEXTURE_2D, 0, src_format_type.internal_format, kWidth, | 449 glTexImage2D(GL_TEXTURE_2D, 0, src_format_type.internal_format, kWidth, |
| 450 kHeight, 0, src_format_type.format, src_format_type.type, | 450 kHeight, 0, src_format_type.format, src_format_type.type, |
| 451 pixels); | 451 pixels); |
| 452 | 452 |
| 453 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 453 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 454 if (copy_type == TexImage) { | 454 if (copy_type == TexImage) { |
| 455 glCopyTextureCHROMIUM(textures_[0], textures_[1], | 455 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, |
| 456 dest_format_type.internal_format, | 456 dest_format_type.internal_format, |
| 457 dest_format_type.type, false, false, false); | 457 dest_format_type.type, false, false, false); |
| 458 } else { | 458 } else { |
| 459 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 459 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 460 glTexImage2D(GL_TEXTURE_2D, 0, dest_format_type.internal_format, kWidth, | 460 glTexImage2D(GL_TEXTURE_2D, 0, dest_format_type.internal_format, kWidth, |
| 461 kHeight, 0, dest_format_type.format, dest_format_type.type, | 461 kHeight, 0, dest_format_type.format, dest_format_type.type, |
| 462 nullptr); | 462 nullptr); |
| 463 | 463 |
| 464 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 0, kWidth, | 464 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, |
| 465 kHeight, false, false, false); | 465 kWidth, kHeight, false, false, false); |
| 466 } | 466 } |
| 467 EXPECT_TRUE(glGetError() == GL_NO_ERROR) | 467 EXPECT_TRUE(glGetError() == GL_NO_ERROR) |
| 468 << " src_internal_format: " | 468 << " src_internal_format: " |
| 469 << gles2::GLES2Util::GetStringEnum(src_format_type.internal_format) | 469 << gles2::GLES2Util::GetStringEnum(src_format_type.internal_format) |
| 470 << " dest_internal_format: " | 470 << " dest_internal_format: " |
| 471 << gles2::GLES2Util::GetStringEnum(dest_format_type.internal_format); | 471 << gles2::GLES2Util::GetStringEnum(dest_format_type.internal_format); |
| 472 | 472 |
| 473 // Draw destination texture to a fbo with attachment in RGBA format. | 473 // Draw destination texture to a fbo with attachment in RGBA format. |
| 474 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 474 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 475 GLuint framebuffer = 0; | 475 GLuint framebuffer = 0; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE, | 531 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE, |
| 532 pixels); | 532 pixels); |
| 533 | 533 |
| 534 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 534 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 535 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1); | 535 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1); |
| 536 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 536 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 537 GL_TEXTURE_2D, textures_[1], 0); | 537 GL_TEXTURE_2D, textures_[1], 0); |
| 538 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 538 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 539 | 539 |
| 540 if (copy_type == TexImage) { | 540 if (copy_type == TexImage) { |
| 541 glCopyTextureCHROMIUM(textures_[0], textures_[1], | 541 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, |
| 542 ExtractFormatFrom(dest_internal_format), | 542 ExtractFormatFrom(dest_internal_format), |
| 543 GL_UNSIGNED_BYTE, false, false, false); | 543 GL_UNSIGNED_BYTE, false, false, false); |
| 544 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); | 544 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); |
| 545 } else { | 545 } else { |
| 546 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 0, 1, 1, | 546 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, |
| 547 false, false, false); | 547 1, 1, false, false, false); |
| 548 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 548 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 549 | 549 |
| 550 // Check the FB is still bound. | 550 // Check the FB is still bound. |
| 551 GLint value = 0; | 551 GLint value = 0; |
| 552 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 552 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 553 GLuint fb_id = value; | 553 GLuint fb_id = value; |
| 554 EXPECT_EQ(framebuffer_id_, fb_id); | 554 EXPECT_EQ(framebuffer_id_, fb_id); |
| 555 | 555 |
| 556 // Check that FB is complete. | 556 // Check that FB is complete. |
| 557 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 557 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 575 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { | 575 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { |
| 576 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); | 576 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); |
| 577 dest_index++) { | 577 dest_index++) { |
| 578 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 578 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 579 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 579 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 580 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, | 580 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, |
| 581 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); | 581 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); |
| 582 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 582 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 583 | 583 |
| 584 if (copy_type == TexImage) { | 584 if (copy_type == TexImage) { |
| 585 glCopyTextureCHROMIUM(textures_[0], textures_[1], | 585 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, |
| 586 dest_formats[dest_index], GL_UNSIGNED_BYTE, | 586 dest_formats[dest_index], GL_UNSIGNED_BYTE, false, |
| 587 false, false, false); | 587 false, false); |
| 588 } else { | 588 } else { |
| 589 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 589 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 590 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, | 590 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, |
| 591 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); | 591 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); |
| 592 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 592 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 593 | 593 |
| 594 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, | 594 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, |
| 595 0, 0, 0, 1, 1, false, false, false); | 595 1, 1, false, false, false); |
| 596 } | 596 } |
| 597 | 597 |
| 598 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index | 598 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index |
| 599 << " dest_index:" << dest_index; | 599 << " dest_index:" << dest_index; |
| 600 glDeleteTextures(2, textures_); | 600 glDeleteTextures(2, textures_); |
| 601 glDeleteFramebuffers(1, &framebuffer_id_); | 601 glDeleteFramebuffers(1, &framebuffer_id_); |
| 602 } | 602 } |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 | 605 |
| 606 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { | 606 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { |
| 607 CopyType copy_type = GetParam(); | 607 CopyType copy_type = GetParam(); |
| 608 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 608 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 609 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 609 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 610 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 610 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 611 nullptr); | 611 nullptr); |
| 612 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 612 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 613 | 613 |
| 614 // Check unsupported format reports error. | 614 // Check unsupported format reports error. |
| 615 GLint unsupported_dest_formats[] = {GL_RED, GL_RG}; | 615 GLint unsupported_dest_formats[] = {GL_RED, GL_RG}; |
| 616 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); | 616 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); |
| 617 dest_index++) { | 617 dest_index++) { |
| 618 if (copy_type == TexImage) { | 618 if (copy_type == TexImage) { |
| 619 glCopyTextureCHROMIUM(textures_[0], textures_[1], | 619 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, |
| 620 unsupported_dest_formats[dest_index], | 620 unsupported_dest_formats[dest_index], |
| 621 GL_UNSIGNED_BYTE, false, false, false); | 621 GL_UNSIGNED_BYTE, false, false, false); |
| 622 } else { | 622 } else { |
| 623 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 623 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 624 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, | 624 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, |
| 625 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, | 625 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, |
| 626 nullptr); | 626 nullptr); |
| 627 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, | 627 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, |
| 628 0, 0, 1, 1, false, false, false); | 628 1, false, false, false); |
| 629 } | 629 } |
| 630 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) | 630 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) |
| 631 << "dest_index:" << dest_index; | 631 << "dest_index:" << dest_index; |
| 632 } | 632 } |
| 633 glDeleteTextures(2, textures_); | 633 glDeleteTextures(2, textures_); |
| 634 glDeleteFramebuffers(1, &framebuffer_id_); | 634 glDeleteFramebuffers(1, &framebuffer_id_); |
| 635 } | 635 } |
| 636 | 636 |
| 637 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) { | 637 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) { |
| 638 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 638 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 639 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 639 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 640 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 640 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 641 nullptr); | 641 nullptr); |
| 642 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 642 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 643 | 643 |
| 644 // Check unsupported internal_format/type combination reports error. | 644 // Check unsupported internal_format/type combination reports error. |
| 645 struct FormatType { GLenum format, type; }; | 645 struct FormatType { GLenum format, type; }; |
| 646 FormatType unsupported_format_types[] = { | 646 FormatType unsupported_format_types[] = { |
| 647 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, | 647 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, |
| 648 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, | 648 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, |
| 649 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5}, | 649 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5}, |
| 650 }; | 650 }; |
| 651 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types); | 651 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types); |
| 652 dest_index++) { | 652 dest_index++) { |
| 653 glCopyTextureCHROMIUM( | 653 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, |
| 654 textures_[0], textures_[1], unsupported_format_types[dest_index].format, | 654 unsupported_format_types[dest_index].format, |
| 655 unsupported_format_types[dest_index].type, false, false, false); | 655 unsupported_format_types[dest_index].type, false, |
| 656 false, false); |
| 656 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) | 657 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) |
| 657 << "dest_index:" << dest_index; | 658 << "dest_index:" << dest_index; |
| 658 } | 659 } |
| 659 glDeleteTextures(2, textures_); | 660 glDeleteTextures(2, textures_); |
| 660 glDeleteFramebuffers(1, &framebuffer_id_); | 661 glDeleteFramebuffers(1, &framebuffer_id_); |
| 661 } | 662 } |
| 662 | 663 |
| 663 // Test to ensure that the destination texture is redefined if the properties | 664 // Test to ensure that the destination texture is redefined if the properties |
| 664 // are different. | 665 // are different. |
| 665 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { | 666 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 687 glTexSubImage2D( | 688 glTexSubImage2D( |
| 688 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 689 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 689 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); | 690 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); |
| 690 // GL_INVALID_VALUE due to bad dimensions. | 691 // GL_INVALID_VALUE due to bad dimensions. |
| 691 glTexSubImage2D( | 692 glTexSubImage2D( |
| 692 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); | 693 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); |
| 693 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 694 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 694 | 695 |
| 695 // If the dest texture has different properties, glCopyTextureCHROMIUM() | 696 // If the dest texture has different properties, glCopyTextureCHROMIUM() |
| 696 // redefines them. | 697 // redefines them. |
| 697 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 698 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 698 GL_UNSIGNED_BYTE, false, false, false); | 699 GL_UNSIGNED_BYTE, false, false, false); |
| 699 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 700 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 700 | 701 |
| 701 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 | 702 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 |
| 702 // dimension and GL_RGBA format. | 703 // dimension and GL_RGBA format. |
| 703 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 704 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 704 glTexSubImage2D( | 705 glTexSubImage2D( |
| 705 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 706 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 706 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 707 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 707 | 708 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 glEnableDisable(GL_SCISSOR_TEST, setting); | 761 glEnableDisable(GL_SCISSOR_TEST, setting); |
| 761 glEnableDisable(GL_STENCIL_TEST, setting); | 762 glEnableDisable(GL_STENCIL_TEST, setting); |
| 762 glEnableDisable(GL_CULL_FACE, setting); | 763 glEnableDisable(GL_CULL_FACE, setting); |
| 763 glEnableDisable(GL_BLEND, setting); | 764 glEnableDisable(GL_BLEND, setting); |
| 764 glColorMask(setting, setting, setting, setting); | 765 glColorMask(setting, setting, setting, setting); |
| 765 glDepthMask(setting); | 766 glDepthMask(setting); |
| 766 | 767 |
| 767 glActiveTexture(GL_TEXTURE1 + x); | 768 glActiveTexture(GL_TEXTURE1 + x); |
| 768 | 769 |
| 769 if (copy_type == TexImage) { | 770 if (copy_type == TexImage) { |
| 770 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 771 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 771 GL_UNSIGNED_BYTE, false, false, false); | 772 GL_UNSIGNED_BYTE, false, false, false); |
| 772 } else { | 773 } else { |
| 773 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, | 774 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, |
| 774 0, 0, 1, 1, false, false, false); | 775 1, false, false, false); |
| 775 } | 776 } |
| 776 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 777 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 777 | 778 |
| 778 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); | 779 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); |
| 779 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); | 780 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); |
| 780 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); | 781 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); |
| 781 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); | 782 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); |
| 782 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); | 783 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); |
| 783 | 784 |
| 784 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; | 785 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 GLuint texture_ids[2]; | 824 GLuint texture_ids[2]; |
| 824 glGenTextures(2, texture_ids); | 825 glGenTextures(2, texture_ids); |
| 825 | 826 |
| 826 glActiveTexture(GL_TEXTURE0); | 827 glActiveTexture(GL_TEXTURE0); |
| 827 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); | 828 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); |
| 828 | 829 |
| 829 glActiveTexture(GL_TEXTURE1); | 830 glActiveTexture(GL_TEXTURE1); |
| 830 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); | 831 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); |
| 831 | 832 |
| 832 if (copy_type == TexImage) { | 833 if (copy_type == TexImage) { |
| 833 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 834 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 834 GL_UNSIGNED_BYTE, false, false, false); | 835 GL_UNSIGNED_BYTE, false, false, false); |
| 835 } else { | 836 } else { |
| 836 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 837 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, |
| 837 0, 1, 1, false, false, false); | 838 false, false, false); |
| 838 } | 839 } |
| 839 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 840 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 840 | 841 |
| 841 GLint active_texture = 0; | 842 GLint active_texture = 0; |
| 842 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 843 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
| 843 EXPECT_EQ(GL_TEXTURE1, active_texture); | 844 EXPECT_EQ(GL_TEXTURE1, active_texture); |
| 844 | 845 |
| 845 GLint bound_texture = 0; | 846 GLint bound_texture = 0; |
| 846 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 847 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
| 847 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); | 848 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 EXPECT_TRUE( | 899 EXPECT_TRUE( |
| 899 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 900 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 900 | 901 |
| 901 // Test that we can write to the bound framebuffer | 902 // Test that we can write to the bound framebuffer |
| 902 uint8_t expected_color[4] = {255u, 255u, 0, 255u}; | 903 uint8_t expected_color[4] = {255u, 255u, 0, 255u}; |
| 903 glClearColor(1.0, 1.0, 0, 1.0); | 904 glClearColor(1.0, 1.0, 0, 1.0); |
| 904 glClear(GL_COLOR_BUFFER_BIT); | 905 glClear(GL_COLOR_BUFFER_BIT); |
| 905 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); | 906 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); |
| 906 | 907 |
| 907 if (copy_type == TexImage) { | 908 if (copy_type == TexImage) { |
| 908 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 909 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 909 GL_UNSIGNED_BYTE, false, false, false); | 910 GL_UNSIGNED_BYTE, false, false, false); |
| 910 } else { | 911 } else { |
| 911 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 912 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, |
| 912 0, 1, 1, false, false, false); | 913 false, false, false); |
| 913 } | 914 } |
| 914 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 915 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 915 | 916 |
| 916 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); | 917 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); |
| 917 | 918 |
| 918 // Ensure that reading from the framebuffer produces correct pixels. | 919 // Ensure that reading from the framebuffer produces correct pixels. |
| 919 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); | 920 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); |
| 920 | 921 |
| 921 uint8_t expected_color2[4] = {255u, 0, 255u, 255u}; | 922 uint8_t expected_color2[4] = {255u, 0, 255u, 255u}; |
| 922 glClearColor(1.0, 0, 1.0, 1.0); | 923 glClearColor(1.0, 0, 1.0, 1.0); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); | 1014 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); |
| 1014 glDrawArrays(GL_TRIANGLES, 0, 6); | 1015 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 1015 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); | 1016 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); |
| 1016 | 1017 |
| 1017 // Call copyTextureCHROMIUM | 1018 // Call copyTextureCHROMIUM |
| 1018 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; | 1019 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
| 1019 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1020 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 1020 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1021 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1021 pixels); | 1022 pixels); |
| 1022 if (copy_type == TexImage) { | 1023 if (copy_type == TexImage) { |
| 1023 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 1024 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 1024 GL_UNSIGNED_BYTE, false, false, false); | 1025 GL_UNSIGNED_BYTE, false, false, false); |
| 1025 } else { | 1026 } else { |
| 1026 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1027 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 1027 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1028 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1028 nullptr); | 1029 nullptr); |
| 1029 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 1030 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, |
| 1030 0, 1, 1, false, false, false); | 1031 false, false, false); |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 // test using program after | 1034 // test using program after |
| 1034 glClear(GL_COLOR_BUFFER_BIT); | 1035 glClear(GL_COLOR_BUFFER_BIT); |
| 1035 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); | 1036 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); |
| 1036 glDrawArrays(GL_TRIANGLES, 0, 6); | 1037 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 1037 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); | 1038 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); |
| 1038 | 1039 |
| 1039 glDeleteTextures(2, textures_); | 1040 glDeleteTextures(2, textures_); |
| 1040 glDeleteFramebuffers(1, &framebuffer_id_); | 1041 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1041 | 1042 |
| 1042 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1043 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1043 | 1044 |
| 1044 gl2.MakeCurrent(); | 1045 gl2.MakeCurrent(); |
| 1045 gl2.Destroy(); | 1046 gl2.Destroy(); |
| 1046 gl_.MakeCurrent(); | 1047 gl_.MakeCurrent(); |
| 1047 } | 1048 } |
| 1048 | 1049 |
| 1049 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. | 1050 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. |
| 1050 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { | 1051 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { |
| 1051 CopyType copy_type = GetParam(); | 1052 CopyType copy_type = GetParam(); |
| 1052 const GLsizei kWidth = 64, kHeight = 64; | 1053 const GLsizei kWidth = 64, kHeight = 64; |
| 1053 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 1054 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 1054 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1055 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 1055 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | 1056 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 1056 GL_UNSIGNED_BYTE, nullptr); | 1057 GL_UNSIGNED_BYTE, nullptr); |
| 1057 | 1058 |
| 1058 if (copy_type == TexImage) { | 1059 if (copy_type == TexImage) { |
| 1059 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 1060 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 1060 GL_UNSIGNED_BYTE, false, false, false); | 1061 GL_UNSIGNED_BYTE, false, false, false); |
| 1061 } else { | 1062 } else { |
| 1062 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1063 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 1063 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | 1064 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
| 1064 GL_UNSIGNED_BYTE, nullptr); | 1065 GL_UNSIGNED_BYTE, nullptr); |
| 1065 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 1066 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, |
| 1066 0, kWidth, kHeight, false, false, false); | 1067 kWidth, kHeight, false, false, false); |
| 1067 } | 1068 } |
| 1068 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1069 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1069 | 1070 |
| 1070 uint8_t pixels[kHeight][kWidth][4] = {{{1}}}; | 1071 uint8_t pixels[kHeight][kWidth][4] = {{{1}}}; |
| 1071 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 1072 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 1072 for (int x = 0; x < kWidth; ++x) { | 1073 for (int x = 0; x < kWidth; ++x) { |
| 1073 for (int y = 0; y < kHeight; ++y) { | 1074 for (int y = 0; y < kHeight; ++y) { |
| 1074 EXPECT_EQ(0, pixels[y][x][0]); | 1075 EXPECT_EQ(0, pixels[y][x][0]); |
| 1075 EXPECT_EQ(0, pixels[y][x][1]); | 1076 EXPECT_EQ(0, pixels[y][x][1]); |
| 1076 EXPECT_EQ(0, pixels[y][x][2]); | 1077 EXPECT_EQ(0, pixels[y][x][2]); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1087 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { | 1088 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { |
| 1088 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 1089 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 1089 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1090 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 1090 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1091 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1091 nullptr); | 1092 nullptr); |
| 1092 | 1093 |
| 1093 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1094 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 1094 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1095 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1095 nullptr); | 1096 nullptr); |
| 1096 | 1097 |
| 1097 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, | 1098 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, |
| 1098 0, 1, 1, false, false, false); | 1099 false, false, false); |
| 1099 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1100 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1100 | 1101 |
| 1101 // xoffset < 0 | 1102 // xoffset < 0 |
| 1102 glCopySubTextureCHROMIUM(textures_[0], textures_[1], -1, 1, 0, | 1103 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, -1, 1, 0, 0, 1, 1, |
| 1103 0, 1, 1, false, false, false); | 1104 false, false, false); |
| 1104 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | 1105 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 1105 | 1106 |
| 1106 // x < 0 | 1107 // x < 0 |
| 1107 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, -1, | 1108 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, -1, 0, 1, 1, |
| 1108 0, 1, 1, false, false, false); | 1109 false, false, false); |
| 1109 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | 1110 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 1110 | 1111 |
| 1111 // xoffset + width > dest_width | 1112 // xoffset + width > dest_width |
| 1112 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 2, 2, 0, | 1113 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 2, 2, 0, 0, 2, 2, |
| 1113 0, 2, 2, false, false, false); | 1114 false, false, false); |
| 1114 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | 1115 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 1115 | 1116 |
| 1116 // x + width > source_width | 1117 // x + width > source_width |
| 1117 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 1, | 1118 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 1, 1, 2, 2, |
| 1118 1, 2, 2, false, false, false); | 1119 false, false, false); |
| 1119 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | 1120 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 1120 | 1121 |
| 1121 glDeleteTextures(2, textures_); | 1122 glDeleteTextures(2, textures_); |
| 1122 glDeleteFramebuffers(1, &framebuffer_id_); | 1123 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1123 } | 1124 } |
| 1124 | 1125 |
| 1125 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) { | 1126 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) { |
| 1126 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 1127 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 1127 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1128 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 1128 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1129 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1129 nullptr); | 1130 nullptr); |
| 1130 | 1131 |
| 1131 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1132 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 1132 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1133 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1133 nullptr); | 1134 nullptr); |
| 1134 | 1135 |
| 1135 glCopyTextureCHROMIUM(textures_[0], 99993, GL_RGBA, | 1136 glCopyTextureCHROMIUM(textures_[0], 0, 99993, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1136 GL_UNSIGNED_BYTE, false, false, false); | |
| 1137 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | |
| 1138 | |
| 1139 glCopyTextureCHROMIUM(99994, textures_[1], GL_RGBA, | |
| 1140 GL_UNSIGNED_BYTE, false, false, false); | |
| 1141 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | |
| 1142 | |
| 1143 glCopyTextureCHROMIUM(99995, 99996, GL_RGBA, GL_UNSIGNED_BYTE, | |
| 1144 false, false, false); | 1137 false, false, false); |
| 1145 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1138 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 1146 | 1139 |
| 1147 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 1140 glCopyTextureCHROMIUM(99994, 0, textures_[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1141 false, false, false); |
| 1142 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 1143 |
| 1144 glCopyTextureCHROMIUM(99995, 0, 99996, 0, GL_RGBA, GL_UNSIGNED_BYTE, false, |
| 1145 false, false); |
| 1146 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 1147 |
| 1148 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, |
| 1148 GL_UNSIGNED_BYTE, false, false, false); | 1149 GL_UNSIGNED_BYTE, false, false, false); |
| 1149 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1150 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1150 | 1151 |
| 1151 glDeleteTextures(2, textures_); | 1152 glDeleteTextures(2, textures_); |
| 1152 glDeleteFramebuffers(1, &framebuffer_id_); | 1153 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1153 } | 1154 } |
| 1154 | 1155 |
| 1155 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) { | 1156 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) { |
| 1156 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 1157 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 1157 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1158 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 1158 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1159 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1159 nullptr); | 1160 nullptr); |
| 1160 | 1161 |
| 1161 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1162 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 1162 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1163 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1163 nullptr); | 1164 nullptr); |
| 1164 | 1165 |
| 1165 glCopySubTextureCHROMIUM(textures_[0], 99993, 1, 1, 0, 0, 1, 1, | 1166 glCopySubTextureCHROMIUM(textures_[0], 0, 99993, 0, 1, 1, 0, 0, 1, 1, false, |
| 1166 false, false, false); | |
| 1167 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | |
| 1168 | |
| 1169 glCopySubTextureCHROMIUM(99994, textures_[1], 1, 1, 0, 0, 1, 1, | |
| 1170 false, false, false); | |
| 1171 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | |
| 1172 | |
| 1173 glCopySubTextureCHROMIUM(99995, 99996, 1, 1, 0, 0, 1, 1, false, | |
| 1174 false, false); | 1167 false, false); |
| 1175 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1168 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 1176 | 1169 |
| 1177 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, | 1170 glCopySubTextureCHROMIUM(99994, 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, false, |
| 1178 0, 1, 1, false, false, false); | 1171 false, false); |
| 1172 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 1173 |
| 1174 glCopySubTextureCHROMIUM(99995, 0, 99996, 0, 1, 1, 0, 0, 1, 1, false, false, |
| 1175 false); |
| 1176 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
| 1177 |
| 1178 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, |
| 1179 false, false, false); |
| 1179 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1180 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1180 | 1181 |
| 1181 glDeleteTextures(2, textures_); | 1182 glDeleteTextures(2, textures_); |
| 1182 glDeleteFramebuffers(1, &framebuffer_id_); | 1183 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1183 } | 1184 } |
| 1184 | 1185 |
| 1185 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { | 1186 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { |
| 1186 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u, | 1187 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u, |
| 1187 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u}; | 1188 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u}; |
| 1188 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 1189 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
| 1189 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1190 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 1190 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1191 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1191 rgba_pixels); | 1192 rgba_pixels); |
| 1192 | 1193 |
| 1193 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, | 1194 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, |
| 1194 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; | 1195 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; |
| 1195 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1196 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 1196 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1197 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1197 transparent_pixels); | 1198 transparent_pixels); |
| 1198 | 1199 |
| 1199 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, | 1200 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, |
| 1200 0, 1, 1, false, false, false); | 1201 false, false, false); |
| 1201 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 1202 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 1202 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 0, 1, | 1203 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 0, 1, 0, 1, 1, |
| 1203 0, 1, 1, false, false, false); | 1204 false, false, false); |
| 1204 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 1205 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 1205 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 1, 0, | 1206 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 1, 0, 1, 1, 1, |
| 1206 1, 1, 1, false, false, false); | 1207 false, false, false); |
| 1207 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 1208 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 1208 | 1209 |
| 1209 // Check the FB is still bound. | 1210 // Check the FB is still bound. |
| 1210 GLint value = 0; | 1211 GLint value = 0; |
| 1211 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 1212 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
| 1212 GLuint fb_id = value; | 1213 GLuint fb_id = value; |
| 1213 EXPECT_EQ(framebuffer_id_, fb_id); | 1214 EXPECT_EQ(framebuffer_id_, fb_id); |
| 1214 | 1215 |
| 1215 // Check that FB is complete. | 1216 // Check that FB is complete. |
| 1216 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 1217 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 } | 1287 } |
| 1287 } | 1288 } |
| 1288 | 1289 |
| 1289 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, | 1290 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, |
| 1290 textures_[1], 0); | 1291 textures_[1], 0); |
| 1291 glBindTexture(dest_target, textures_[1]); | 1292 glBindTexture(dest_target, textures_[1]); |
| 1292 | 1293 |
| 1293 // Copy the subtexture x=[13,18) y=[6,9) to the destination. | 1294 // Copy the subtexture x=[13,18) y=[6,9) to the destination. |
| 1294 glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0); | 1295 glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0); |
| 1295 glClear(GL_COLOR_BUFFER_BIT); | 1296 glClear(GL_COLOR_BUFFER_BIT); |
| 1296 glCopySubTextureCHROMIUM(textures_[0], textures_[1], copy_region_x, | 1297 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, copy_region_x, |
| 1297 copy_region_y, 13, 6, copy_region_width, | 1298 copy_region_y, 13, 6, copy_region_width, |
| 1298 copy_region_height, false, false, false); | 1299 copy_region_height, false, false, false); |
| 1299 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1300 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1300 | 1301 |
| 1301 for (GLint x = 0; x < dest_width; ++x) { | 1302 for (GLint x = 0; x < dest_width; ++x) { |
| 1302 for (GLint y = 0; y < dest_height; ++y) { | 1303 for (GLint y = 0; y < dest_height; ++y) { |
| 1303 if (x < copy_region_x || x >= copy_region_x + copy_region_width || | 1304 if (x < copy_region_x || x >= copy_region_x + copy_region_width || |
| 1304 y < copy_region_y || y >= copy_region_y + copy_region_height) { | 1305 y < copy_region_y || y >= copy_region_y + copy_region_height) { |
| 1305 GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey, nullptr); | 1306 GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey, nullptr); |
| 1306 continue; | 1307 continue; |
| 1307 } | 1308 } |
| 1308 | 1309 |
| 1309 uint8_t* expected_color; | 1310 uint8_t* expected_color; |
| 1310 if (x < copy_region_x + 2) { | 1311 if (x < copy_region_x + 2) { |
| 1311 expected_color = y < copy_region_y + 1 ? red : green; | 1312 expected_color = y < copy_region_y + 1 ? red : green; |
| 1312 } else { | 1313 } else { |
| 1313 expected_color = y < copy_region_y + 1 ? blue : white; | 1314 expected_color = y < copy_region_y + 1 ? blue : white; |
| 1314 } | 1315 } |
| 1315 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color, nullptr); | 1316 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color, nullptr); |
| 1316 } | 1317 } |
| 1317 } | 1318 } |
| 1318 | 1319 |
| 1319 glDeleteTextures(2, textures_); | 1320 glDeleteTextures(2, textures_); |
| 1320 glDeleteFramebuffers(1, &framebuffer_id_); | 1321 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1321 } | 1322 } |
| 1322 } | 1323 } |
| 1323 } | 1324 } |
| 1324 | 1325 |
| 1325 } // namespace gpu | 1326 } // namespace gpu |
| OLD | NEW |