Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc

Issue 2639973002: Add target argument to Copy{Sub}TextureCHROMIUM entry point (Closed)
Patch Set: use dest_target instead of target Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } else { 344 } else {
345 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 345 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
346 glTexImage2D(target, 0, dest_format_type.internal_format, 346 glTexImage2D(target, 0, dest_format_type.internal_format,
347 width_ << dest_level, height_ << dest_level, 0, 347 width_ << dest_level, height_ << dest_level, 0,
348 dest_format_type.format, dest_format_type.type, nullptr); 348 dest_format_type.format, dest_format_type.type, nullptr);
349 glGenerateMipmap(target); 349 glGenerateMipmap(target);
350 } 350 }
351 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 351 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
352 352
353 if (copy_type == TexImage) { 353 if (copy_type == TexImage) {
354 glCopyTextureCHROMIUM(textures_[0], source_level, textures_[1], 354 glCopyTextureCHROMIUM(textures_[0], source_level, target, textures_[1],
355 dest_level, dest_format_type.internal_format, 355 dest_level, dest_format_type.internal_format,
356 dest_format_type.type, false, false, false); 356 dest_format_type.type, false, false, false);
357 } else { 357 } else {
358 glBindTexture(target, textures_[1]); 358 glBindTexture(target, textures_[1]);
359 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_, 359 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_,
360 height_, 0, dest_format_type.format, dest_format_type.type, 360 height_, 0, dest_format_type.format, dest_format_type.type,
361 nullptr); 361 nullptr);
362 362
363 glCopySubTextureCHROMIUM(textures_[0], source_level, textures_[1], 363 glCopySubTextureCHROMIUM(textures_[0], source_level, target, textures_[1],
364 dest_level, 0, 0, 0, 0, width_, height_, false, 364 dest_level, 0, 0, 0, 0, width_, height_, false,
365 false, false); 365 false, false);
366 } 366 }
367 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 367 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
368 368
369 // Draw destination texture to a fbo with a texture attachment in RGBA 369 // Draw destination texture to a fbo with a texture attachment in RGBA
370 // format. 370 // format.
371 GLuint texture = CreateDrawingTexture(target, width_, height_); 371 GLuint texture = CreateDrawingTexture(target, width_, height_);
372 GLuint framebuffer = CreateDrawingFBO(target, texture); 372 GLuint framebuffer = CreateDrawingFBO(target, texture);
373 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 373 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { 474 TEST_P(GLCopyTextureCHROMIUMTest, Basic) {
475 CopyType copy_type = GetParam(); 475 CopyType copy_type = GetParam();
476 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; 476 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
477 477
478 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 478 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
479 glBindTexture(GL_TEXTURE_2D, textures_[0]); 479 glBindTexture(GL_TEXTURE_2D, textures_[0]);
480 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,
481 pixels); 481 pixels);
482 482
483 if (copy_type == TexImage) { 483 if (copy_type == TexImage) {
484 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 484 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
485 GL_UNSIGNED_BYTE, false, false, false); 485 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
486 } else { 486 } else {
487 glBindTexture(GL_TEXTURE_2D, textures_[1]); 487 glBindTexture(GL_TEXTURE_2D, textures_[1]);
488 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 488 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
489 nullptr); 489 nullptr);
490 490
491 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, 491 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
492 false, false, false); 492 0, 0, 0, 1, 1, false, false, false);
493 } 493 }
494 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 494 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
495 495
496 // Check the FB is still bound. 496 // Check the FB is still bound.
497 GLint value = 0; 497 GLint value = 0;
498 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 498 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
499 GLuint fb_id = value; 499 GLuint fb_id = value;
500 EXPECT_EQ(framebuffer_id_, fb_id); 500 EXPECT_EQ(framebuffer_id_, fb_id);
501 501
502 // Check that FB is complete. 502 // Check that FB is complete.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE, 614 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE,
615 pixels); 615 pixels);
616 616
617 glBindTexture(GL_TEXTURE_2D, textures_[1]); 617 glBindTexture(GL_TEXTURE_2D, textures_[1]);
618 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1); 618 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1);
619 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 619 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
620 GL_TEXTURE_2D, textures_[1], 0); 620 GL_TEXTURE_2D, textures_[1], 0);
621 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 621 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
622 622
623 if (copy_type == TexImage) { 623 if (copy_type == TexImage) {
624 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 624 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
625 ExtractFormatFrom(dest_internal_format), 625 ExtractFormatFrom(dest_internal_format),
626 GL_UNSIGNED_BYTE, false, false, false); 626 GL_UNSIGNED_BYTE, false, false, false);
627 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); 627 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
628 } else { 628 } else {
629 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 629 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1],
630 1, 1, false, false, false); 630 0, 0, 0, 0, 0, 1, 1, false, false, false);
631 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 631 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
632 632
633 // Check the FB is still bound. 633 // Check the FB is still bound.
634 GLint value = 0; 634 GLint value = 0;
635 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 635 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
636 GLuint fb_id = value; 636 GLuint fb_id = value;
637 EXPECT_EQ(framebuffer_id_, fb_id); 637 EXPECT_EQ(framebuffer_id_, fb_id);
638 638
639 // Check that FB is complete. 639 // Check that FB is complete.
640 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 640 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
(...skipping 17 matching lines...) Expand all
658 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { 658 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) {
659 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); 659 for (size_t dest_index = 0; dest_index < arraysize(dest_formats);
660 dest_index++) { 660 dest_index++) {
661 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 661 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
662 glBindTexture(GL_TEXTURE_2D, textures_[0]); 662 glBindTexture(GL_TEXTURE_2D, textures_[0]);
663 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, 663 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0,
664 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); 664 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr);
665 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 665 EXPECT_TRUE(GL_NO_ERROR == glGetError());
666 666
667 if (copy_type == TexImage) { 667 if (copy_type == TexImage) {
668 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 668 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
669 dest_formats[dest_index], GL_UNSIGNED_BYTE, false, 669 dest_formats[dest_index], GL_UNSIGNED_BYTE, false,
670 false, false); 670 false, false);
671 } else { 671 } else {
672 glBindTexture(GL_TEXTURE_2D, textures_[1]); 672 glBindTexture(GL_TEXTURE_2D, textures_[1]);
673 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, 673 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0,
674 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); 674 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr);
675 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 675 EXPECT_TRUE(GL_NO_ERROR == glGetError());
676 676
677 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 677 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1],
678 1, 1, false, false, false); 678 0, 0, 0, 0, 0, 1, 1, false, false, false);
679 } 679 }
680 680
681 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index 681 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index
682 << " dest_index:" << dest_index; 682 << " dest_index:" << dest_index;
683 glDeleteTextures(2, textures_); 683 glDeleteTextures(2, textures_);
684 glDeleteFramebuffers(1, &framebuffer_id_); 684 glDeleteFramebuffers(1, &framebuffer_id_);
685 } 685 }
686 } 686 }
687 } 687 }
688 688
689 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { 689 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
690 CopyType copy_type = GetParam(); 690 CopyType copy_type = GetParam();
691 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 691 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
692 glBindTexture(GL_TEXTURE_2D, textures_[0]); 692 glBindTexture(GL_TEXTURE_2D, textures_[0]);
693 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 693 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
694 nullptr); 694 nullptr);
695 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 695 EXPECT_TRUE(GL_NO_ERROR == glGetError());
696 696
697 // Check unsupported format reports error. 697 // Check unsupported format reports error.
698 GLint unsupported_dest_formats[] = {GL_RED, GL_RG}; 698 GLint unsupported_dest_formats[] = {GL_RED, GL_RG};
699 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); 699 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats);
700 dest_index++) { 700 dest_index++) {
701 if (copy_type == TexImage) { 701 if (copy_type == TexImage) {
702 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 702 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
703 unsupported_dest_formats[dest_index], 703 unsupported_dest_formats[dest_index],
704 GL_UNSIGNED_BYTE, false, false, false); 704 GL_UNSIGNED_BYTE, false, false, false);
705 } else { 705 } else {
706 glBindTexture(GL_TEXTURE_2D, textures_[1]); 706 glBindTexture(GL_TEXTURE_2D, textures_[1]);
707 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, 707 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1,
708 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, 708 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE,
709 nullptr); 709 nullptr);
710 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 710 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
711 1, false, false, false); 711 0, 0, 0, 0, 1, 1, false, false, false);
712 } 712 }
713 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 713 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
714 << "dest_index:" << dest_index; 714 << "dest_index:" << dest_index;
715 } 715 }
716 glDeleteTextures(2, textures_); 716 glDeleteTextures(2, textures_);
717 glDeleteFramebuffers(1, &framebuffer_id_); 717 glDeleteFramebuffers(1, &framebuffer_id_);
718 } 718 }
719 719
720 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) { 720 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) {
721 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 721 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
722 glBindTexture(GL_TEXTURE_2D, textures_[0]); 722 glBindTexture(GL_TEXTURE_2D, textures_[0]);
723 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 723 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
724 nullptr); 724 nullptr);
725 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 725 EXPECT_TRUE(GL_NO_ERROR == glGetError());
726 726
727 // Check unsupported internal_format/type combination reports error. 727 // Check unsupported internal_format/type combination reports error.
728 struct FormatType { GLenum format, type; }; 728 struct FormatType { GLenum format, type; };
729 FormatType unsupported_format_types[] = { 729 FormatType unsupported_format_types[] = {
730 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, 730 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4},
731 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, 731 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1},
732 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5}, 732 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5},
733 }; 733 };
734 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types); 734 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types);
735 dest_index++) { 735 dest_index++) {
736 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 736 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
737 unsupported_format_types[dest_index].format, 737 unsupported_format_types[dest_index].format,
738 unsupported_format_types[dest_index].type, false, 738 unsupported_format_types[dest_index].type, false,
739 false, false); 739 false, false);
740 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 740 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
741 << "dest_index:" << dest_index; 741 << "dest_index:" << dest_index;
742 } 742 }
743 glDeleteTextures(2, textures_); 743 glDeleteTextures(2, textures_);
744 glDeleteFramebuffers(1, &framebuffer_id_); 744 glDeleteFramebuffers(1, &framebuffer_id_);
745 } 745 }
746 746
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 glTexSubImage2D( 821 glTexSubImage2D(
822 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 822 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
823 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); 823 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError());
824 // GL_INVALID_VALUE due to bad dimensions. 824 // GL_INVALID_VALUE due to bad dimensions.
825 glTexSubImage2D( 825 glTexSubImage2D(
826 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); 826 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
827 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 827 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
828 828
829 // If the dest texture has different properties, glCopyTextureCHROMIUM() 829 // If the dest texture has different properties, glCopyTextureCHROMIUM()
830 // redefines them. 830 // redefines them.
831 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 831 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
832 GL_UNSIGNED_BYTE, false, false, false); 832 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
833 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 833 EXPECT_TRUE(GL_NO_ERROR == glGetError());
834 834
835 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 835 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2
836 // dimension and GL_RGBA format. 836 // dimension and GL_RGBA format.
837 glBindTexture(GL_TEXTURE_2D, textures_[1]); 837 glBindTexture(GL_TEXTURE_2D, textures_[1]);
838 glTexSubImage2D( 838 glTexSubImage2D(
839 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 839 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
840 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 840 EXPECT_TRUE(GL_NO_ERROR == glGetError());
841 841
842 // Check the FB is still bound. 842 // Check the FB is still bound.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 glEnableDisable(GL_SCISSOR_TEST, setting); 894 glEnableDisable(GL_SCISSOR_TEST, setting);
895 glEnableDisable(GL_STENCIL_TEST, setting); 895 glEnableDisable(GL_STENCIL_TEST, setting);
896 glEnableDisable(GL_CULL_FACE, setting); 896 glEnableDisable(GL_CULL_FACE, setting);
897 glEnableDisable(GL_BLEND, setting); 897 glEnableDisable(GL_BLEND, setting);
898 glColorMask(setting, setting, setting, setting); 898 glColorMask(setting, setting, setting, setting);
899 glDepthMask(setting); 899 glDepthMask(setting);
900 900
901 glActiveTexture(GL_TEXTURE1 + x); 901 glActiveTexture(GL_TEXTURE1 + x);
902 902
903 if (copy_type == TexImage) { 903 if (copy_type == TexImage) {
904 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 904 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
905 GL_UNSIGNED_BYTE, false, false, false); 905 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
906 } else { 906 } else {
907 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 907 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
908 1, false, false, false); 908 0, 0, 0, 0, 1, 1, false, false, false);
909 } 909 }
910 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 910 EXPECT_TRUE(GL_NO_ERROR == glGetError());
911 911
912 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); 912 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST));
913 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); 913 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST));
914 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); 914 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST));
915 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); 915 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE));
916 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); 916 EXPECT_EQ(setting, glIsEnabled(GL_BLEND));
917 917
918 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; 918 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 GLuint texture_ids[2]; 957 GLuint texture_ids[2];
958 glGenTextures(2, texture_ids); 958 glGenTextures(2, texture_ids);
959 959
960 glActiveTexture(GL_TEXTURE0); 960 glActiveTexture(GL_TEXTURE0);
961 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); 961 glBindTexture(GL_TEXTURE_2D, texture_ids[0]);
962 962
963 glActiveTexture(GL_TEXTURE1); 963 glActiveTexture(GL_TEXTURE1);
964 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); 964 glBindTexture(GL_TEXTURE_2D, texture_ids[1]);
965 965
966 if (copy_type == TexImage) { 966 if (copy_type == TexImage) {
967 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 967 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
968 GL_UNSIGNED_BYTE, false, false, false); 968 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
969 } else { 969 } else {
970 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, 970 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
971 false, false, false); 971 0, 0, 0, 1, 1, false, false, false);
972 } 972 }
973 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 973 EXPECT_TRUE(GL_NO_ERROR == glGetError());
974 974
975 GLint active_texture = 0; 975 GLint active_texture = 0;
976 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 976 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
977 EXPECT_EQ(GL_TEXTURE1, active_texture); 977 EXPECT_EQ(GL_TEXTURE1, active_texture);
978 978
979 GLint bound_texture = 0; 979 GLint bound_texture = 0;
980 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 980 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
981 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); 981 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 EXPECT_TRUE( 1032 EXPECT_TRUE(
1033 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); 1033 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER));
1034 1034
1035 // Test that we can write to the bound framebuffer 1035 // Test that we can write to the bound framebuffer
1036 uint8_t expected_color[4] = {255u, 255u, 0, 255u}; 1036 uint8_t expected_color[4] = {255u, 255u, 0, 255u};
1037 glClearColor(1.0, 1.0, 0, 1.0); 1037 glClearColor(1.0, 1.0, 0, 1.0);
1038 glClear(GL_COLOR_BUFFER_BIT); 1038 glClear(GL_COLOR_BUFFER_BIT);
1039 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); 1039 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr);
1040 1040
1041 if (copy_type == TexImage) { 1041 if (copy_type == TexImage) {
1042 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 1042 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
1043 GL_UNSIGNED_BYTE, false, false, false); 1043 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
1044 } else { 1044 } else {
1045 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, 1045 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
1046 false, false, false); 1046 0, 0, 0, 1, 1, false, false, false);
1047 } 1047 }
1048 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1048 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1049 1049
1050 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); 1050 EXPECT_TRUE(glIsFramebuffer(framebuffer_id));
1051 1051
1052 // Ensure that reading from the framebuffer produces correct pixels. 1052 // Ensure that reading from the framebuffer produces correct pixels.
1053 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); 1053 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr);
1054 1054
1055 uint8_t expected_color2[4] = {255u, 0, 255u, 255u}; 1055 uint8_t expected_color2[4] = {255u, 0, 255u, 255u};
1056 glClearColor(1.0, 0, 1.0, 1.0); 1056 glClearColor(1.0, 0, 1.0, 1.0);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); 1147 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr));
1148 glDrawArrays(GL_TRIANGLES, 0, 6); 1148 glDrawArrays(GL_TRIANGLES, 0, 6);
1149 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); 1149 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr));
1150 1150
1151 // Call copyTextureCHROMIUM 1151 // Call copyTextureCHROMIUM
1152 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; 1152 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
1153 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1153 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1154 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1154 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1155 pixels); 1155 pixels);
1156 if (copy_type == TexImage) { 1156 if (copy_type == TexImage) {
1157 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 1157 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
1158 GL_UNSIGNED_BYTE, false, false, false); 1158 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
1159 } else { 1159 } else {
1160 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1160 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1161 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1161 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1162 nullptr); 1162 nullptr);
1163 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1, 1163 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
1164 false, false, false); 1164 0, 0, 0, 1, 1, false, false, false);
1165 } 1165 }
1166 1166
1167 // test using program after 1167 // test using program after
1168 glClear(GL_COLOR_BUFFER_BIT); 1168 glClear(GL_COLOR_BUFFER_BIT);
1169 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); 1169 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr));
1170 glDrawArrays(GL_TRIANGLES, 0, 6); 1170 glDrawArrays(GL_TRIANGLES, 0, 6);
1171 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); 1171 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr));
1172 1172
1173 glDeleteTextures(2, textures_); 1173 glDeleteTextures(2, textures_);
1174 glDeleteFramebuffers(1, &framebuffer_id_); 1174 glDeleteFramebuffers(1, &framebuffer_id_);
1175 1175
1176 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1176 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1177 1177
1178 gl2.MakeCurrent(); 1178 gl2.MakeCurrent();
1179 gl2.Destroy(); 1179 gl2.Destroy();
1180 gl_.MakeCurrent(); 1180 gl_.MakeCurrent();
1181 } 1181 }
1182 1182
1183 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. 1183 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures.
1184 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { 1184 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) {
1185 CopyType copy_type = GetParam(); 1185 CopyType copy_type = GetParam();
1186 const GLsizei kWidth = 64, kHeight = 64; 1186 const GLsizei kWidth = 64, kHeight = 64;
1187 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1187 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1188 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1188 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1189 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 1189 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
1190 GL_UNSIGNED_BYTE, nullptr); 1190 GL_UNSIGNED_BYTE, nullptr);
1191 1191
1192 if (copy_type == TexImage) { 1192 if (copy_type == TexImage) {
1193 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 1193 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
1194 GL_UNSIGNED_BYTE, false, false, false); 1194 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
1195 } else { 1195 } else {
1196 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1196 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1197 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 1197 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
1198 GL_UNSIGNED_BYTE, nullptr); 1198 GL_UNSIGNED_BYTE, nullptr);
1199 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1199 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
1200 kWidth, kHeight, false, false, false); 1200 0, 0, 0, kWidth, kHeight, false, false, false);
1201 } 1201 }
1202 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1202 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1203 1203
1204 uint8_t pixels[kHeight][kWidth][4] = {{{1}}}; 1204 uint8_t pixels[kHeight][kWidth][4] = {{{1}}};
1205 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 1205 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
1206 for (int x = 0; x < kWidth; ++x) { 1206 for (int x = 0; x < kWidth; ++x) {
1207 for (int y = 0; y < kHeight; ++y) { 1207 for (int y = 0; y < kHeight; ++y) {
1208 EXPECT_EQ(0, pixels[y][x][0]); 1208 EXPECT_EQ(0, pixels[y][x][0]);
1209 EXPECT_EQ(0, pixels[y][x][1]); 1209 EXPECT_EQ(0, pixels[y][x][1]);
1210 EXPECT_EQ(0, pixels[y][x][2]); 1210 EXPECT_EQ(0, pixels[y][x][2]);
(...skipping 10 matching lines...) Expand all
1221 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { 1221 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) {
1222 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1222 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1223 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1223 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1224 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1224 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1225 nullptr); 1225 nullptr);
1226 1226
1227 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1227 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1228 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1228 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1229 nullptr); 1229 nullptr);
1230 1230
1231 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, 1231 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 1,
1232 false, false, false); 1232 1, 0, 0, 1, 1, false, false, false);
1233 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1233 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1234 1234
1235 // xoffset < 0 1235 // xoffset < 0
1236 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, -1, 1, 0, 0, 1, 1, 1236 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, -1,
1237 false, false, false); 1237 1, 0, 0, 1, 1, false, false, false);
1238 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1238 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1239 1239
1240 // x < 0 1240 // x < 0
1241 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, -1, 0, 1, 1, 1241 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 1,
1242 false, false, false); 1242 1, -1, 0, 1, 1, false, false, false);
1243 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1243 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1244 1244
1245 // xoffset + width > dest_width 1245 // xoffset + width > dest_width
1246 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 2, 2, 0, 0, 2, 2, 1246 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 2,
1247 false, false, false); 1247 2, 0, 0, 2, 2, false, false, false);
1248 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1248 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1249 1249
1250 // x + width > source_width 1250 // x + width > source_width
1251 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 1, 1, 2, 2, 1251 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
1252 false, false, false); 1252 0, 1, 1, 2, 2, false, false, false);
1253 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1253 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1254 1254
1255 glDeleteTextures(2, textures_); 1255 glDeleteTextures(2, textures_);
1256 glDeleteFramebuffers(1, &framebuffer_id_); 1256 glDeleteFramebuffers(1, &framebuffer_id_);
1257 } 1257 }
1258 1258
1259 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) { 1259 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) {
1260 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1260 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1261 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1261 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1262 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1262 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1263 nullptr); 1263 nullptr);
1264 1264
1265 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1265 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1266 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1266 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1267 nullptr); 1267 nullptr);
1268 1268
1269 glCopyTextureCHROMIUM(textures_[0], 0, 99993, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1269 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, 99993, 0, GL_RGBA,
1270 false, false, false); 1270 GL_UNSIGNED_BYTE, false, false, false);
1271 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1271 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1272 1272
1273 glCopyTextureCHROMIUM(99994, 0, textures_[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, 1273 glCopyTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, textures_[1], 0, GL_RGBA,
1274 false, false, false); 1274 GL_UNSIGNED_BYTE, false, false, false);
1275 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1275 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1276 1276
1277 glCopyTextureCHROMIUM(99995, 0, 99996, 0, GL_RGBA, GL_UNSIGNED_BYTE, false, 1277 glCopyTextureCHROMIUM(99995, 0, GL_TEXTURE_2D, 99996, 0, GL_RGBA,
1278 false, false); 1278 GL_UNSIGNED_BYTE, false, false, false);
1279 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1279 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1280 1280
1281 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA, 1281 glCopyTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0,
1282 GL_UNSIGNED_BYTE, false, false, false); 1282 GL_RGBA, GL_UNSIGNED_BYTE, false, false, false);
1283 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1283 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1284 1284
1285 glDeleteTextures(2, textures_); 1285 glDeleteTextures(2, textures_);
1286 glDeleteFramebuffers(1, &framebuffer_id_); 1286 glDeleteFramebuffers(1, &framebuffer_id_);
1287 } 1287 }
1288 1288
1289 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) { 1289 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) {
1290 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1290 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1291 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1291 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1292 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1292 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1293 nullptr); 1293 nullptr);
1294 1294
1295 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1295 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1296 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1296 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1297 nullptr); 1297 nullptr);
1298 1298
1299 glCopySubTextureCHROMIUM(textures_[0], 0, 99993, 0, 1, 1, 0, 0, 1, 1, false, 1299 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, 99993, 0, 1, 1, 0, 0,
1300 false, false); 1300 1, 1, false, false, false);
1301 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1301 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1302 1302
1303 glCopySubTextureCHROMIUM(99994, 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, false, 1303 glCopySubTextureCHROMIUM(99994, 0, GL_TEXTURE_2D, textures_[1], 0, 1, 1, 0, 0,
1304 false, false); 1304 1, 1, false, false, false);
1305 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1305 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1306 1306
1307 glCopySubTextureCHROMIUM(99995, 0, 99996, 0, 1, 1, 0, 0, 1, 1, false, false, 1307 glCopySubTextureCHROMIUM(99995, 0, GL_TEXTURE_2D, 99996, 0, 1, 1, 0, 0, 1, 1,
1308 false); 1308 false, false, false);
1309 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1309 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1310 1310
1311 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, 1311 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 1,
1312 false, false, false); 1312 1, 0, 0, 1, 1, false, false, false);
1313 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1313 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1314 1314
1315 glDeleteTextures(2, textures_); 1315 glDeleteTextures(2, textures_);
1316 glDeleteFramebuffers(1, &framebuffer_id_); 1316 glDeleteFramebuffers(1, &framebuffer_id_);
1317 } 1317 }
1318 1318
1319 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { 1319 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
1320 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u, 1320 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
1321 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u}; 1321 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u};
1322 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1322 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1323 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1323 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1324 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1324 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1325 rgba_pixels); 1325 rgba_pixels);
1326 1326
1327 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1327 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1328 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; 1328 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
1329 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1329 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1330 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1330 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1331 transparent_pixels); 1331 transparent_pixels);
1332 1332
1333 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, 1333 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 1,
1334 false, false, false); 1334 1, 0, 0, 1, 1, false, false, false);
1335 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 1335 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
1336 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 0, 1, 0, 1, 1, 1336 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 1,
1337 false, false, false); 1337 0, 1, 0, 1, 1, false, false, false);
1338 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 1338 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
1339 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 1, 0, 1, 1, 1, 1339 glCopySubTextureCHROMIUM(textures_[0], 0, GL_TEXTURE_2D, textures_[1], 0, 0,
1340 false, false, false); 1340 1, 0, 1, 1, 1, false, false, false);
1341 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 1341 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
1342 1342
1343 // Check the FB is still bound. 1343 // Check the FB is still bound.
1344 GLint value = 0; 1344 GLint value = 0;
1345 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 1345 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
1346 GLuint fb_id = value; 1346 GLuint fb_id = value;
1347 EXPECT_EQ(framebuffer_id_, fb_id); 1347 EXPECT_EQ(framebuffer_id_, fb_id);
1348 1348
1349 // Check that FB is complete. 1349 // Check that FB is complete.
1350 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 1350 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 } 1420 }
1421 } 1421 }
1422 1422
1423 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, 1423 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target,
1424 textures_[1], 0); 1424 textures_[1], 0);
1425 glBindTexture(dest_target, textures_[1]); 1425 glBindTexture(dest_target, textures_[1]);
1426 1426
1427 // Copy the subtexture x=[13,18) y=[6,9) to the destination. 1427 // Copy the subtexture x=[13,18) y=[6,9) to the destination.
1428 glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0); 1428 glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0);
1429 glClear(GL_COLOR_BUFFER_BIT); 1429 glClear(GL_COLOR_BUFFER_BIT);
1430 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, copy_region_x, 1430 glCopySubTextureCHROMIUM(textures_[0], 0, dest_target, textures_[1], 0,
1431 copy_region_y, 13, 6, copy_region_width, 1431 copy_region_x, copy_region_y, 13, 6,
1432 copy_region_height, false, false, false); 1432 copy_region_width, copy_region_height, false,
1433 false, false);
1433 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1434 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1434 1435
1435 for (GLint x = 0; x < dest_width; ++x) { 1436 for (GLint x = 0; x < dest_width; ++x) {
1436 for (GLint y = 0; y < dest_height; ++y) { 1437 for (GLint y = 0; y < dest_height; ++y) {
1437 if (x < copy_region_x || x >= copy_region_x + copy_region_width || 1438 if (x < copy_region_x || x >= copy_region_x + copy_region_width ||
1438 y < copy_region_y || y >= copy_region_y + copy_region_height) { 1439 y < copy_region_y || y >= copy_region_y + copy_region_height) {
1439 GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey, nullptr); 1440 GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey, nullptr);
1440 continue; 1441 continue;
1441 } 1442 }
1442 1443
1443 uint8_t* expected_color; 1444 uint8_t* expected_color;
1444 if (x < copy_region_x + 2) { 1445 if (x < copy_region_x + 2) {
1445 expected_color = y < copy_region_y + 1 ? red : green; 1446 expected_color = y < copy_region_y + 1 ? red : green;
1446 } else { 1447 } else {
1447 expected_color = y < copy_region_y + 1 ? blue : white; 1448 expected_color = y < copy_region_y + 1 ? blue : white;
1448 } 1449 }
1449 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color, nullptr); 1450 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color, nullptr);
1450 } 1451 }
1451 } 1452 }
1452 1453
1453 glDeleteTextures(2, textures_); 1454 glDeleteTextures(2, textures_);
1454 glDeleteFramebuffers(1, &framebuffer_id_); 1455 glDeleteFramebuffers(1, &framebuffer_id_);
1455 } 1456 }
1456 } 1457 }
1457 } 1458 }
1458 1459
1459 } // namespace gpu 1460 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698