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

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

Issue 2610853005: Modify Copy{Sub}TextureCHROMIUM entry point to add level argument (Closed)
Patch Set: fix chromeos 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 glBindTexture(target, textures_[1]); 321 glBindTexture(target, textures_[1]);
322 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 322 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
323 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 323 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
324 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 324 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
325 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 325 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
326 326
327 // TODO(qiankun.miao@intel.com): Upgrade glCopyTextureCHROMIUM and 327 // TODO(qiankun.miao@intel.com): Upgrade glCopyTextureCHROMIUM and
328 // glCopySubTextureCHROMIUM to support copying from level > 0 of source 328 // glCopySubTextureCHROMIUM to support copying from level > 0 of source
329 // texture to level > 0 of dest texture. 329 // texture to level > 0 of dest texture.
330 if (copy_type == TexImage) { 330 if (copy_type == TexImage) {
331 glCopyTextureCHROMIUM(textures_[0], textures_[1], 331 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0,
332 dest_format_type.internal_format, 332 dest_format_type.internal_format,
333 dest_format_type.type, false, false, false); 333 dest_format_type.type, false, false, false);
334 } else { 334 } else {
335 glBindTexture(target, textures_[1]); 335 glBindTexture(target, textures_[1]);
336 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_, 336 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_,
337 height_, 0, dest_format_type.format, dest_format_type.type, 337 height_, 0, dest_format_type.format, dest_format_type.type,
338 nullptr); 338 nullptr);
339 339
340 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 0, width_, 340 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0,
341 height_, false, false, false); 341 width_, height_, false, false, false);
342 } 342 }
343 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 343 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
344 344
345 // Draw destination texture to a fbo with a texture attachment in RGBA 345 // Draw destination texture to a fbo with a texture attachment in RGBA
346 // format. 346 // format.
347 GLuint texture = CreateDrawingTexture(target, width_, height_); 347 GLuint texture = CreateDrawingTexture(target, width_, height_);
348 GLuint framebuffer = CreateDrawingFBO(target, texture); 348 GLuint framebuffer = CreateDrawingFBO(target, texture);
349 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 349 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
350 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 350 glCheckFramebufferStatus(GL_FRAMEBUFFER));
351 glViewport(0, 0, width_, height_); 351 glViewport(0, 0, width_, height_);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { 448 TEST_P(GLCopyTextureCHROMIUMTest, Basic) {
449 CopyType copy_type = GetParam(); 449 CopyType copy_type = GetParam();
450 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; 450 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
451 451
452 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 452 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
453 glBindTexture(GL_TEXTURE_2D, textures_[0]); 453 glBindTexture(GL_TEXTURE_2D, textures_[0]);
454 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 454 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
455 pixels); 455 pixels);
456 456
457 if (copy_type == TexImage) { 457 if (copy_type == TexImage) {
458 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 458 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
459 GL_UNSIGNED_BYTE, false, false, false); 459 GL_UNSIGNED_BYTE, false, false, false);
460 } else { 460 } else {
461 glBindTexture(GL_TEXTURE_2D, textures_[1]); 461 glBindTexture(GL_TEXTURE_2D, textures_[1]);
462 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 462 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
463 nullptr); 463 nullptr);
464 464
465 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 465 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1,
466 0, 1, 1, false, false, false); 466 false, false, false);
467 } 467 }
468 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 468 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
469 469
470 // Check the FB is still bound. 470 // Check the FB is still bound.
471 GLint value = 0; 471 GLint value = 0;
472 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 472 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
473 GLuint fb_id = value; 473 GLuint fb_id = value;
474 EXPECT_EQ(framebuffer_id_, fb_id); 474 EXPECT_EQ(framebuffer_id_, fb_id);
475 475
476 // Check that FB is complete. 476 // Check that FB is complete.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE, 588 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE,
589 pixels); 589 pixels);
590 590
591 glBindTexture(GL_TEXTURE_2D, textures_[1]); 591 glBindTexture(GL_TEXTURE_2D, textures_[1]);
592 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1); 592 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1);
593 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 593 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
594 GL_TEXTURE_2D, textures_[1], 0); 594 GL_TEXTURE_2D, textures_[1], 0);
595 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 595 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
596 596
597 if (copy_type == TexImage) { 597 if (copy_type == TexImage) {
598 glCopyTextureCHROMIUM(textures_[0], textures_[1], 598 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0,
599 ExtractFormatFrom(dest_internal_format), 599 ExtractFormatFrom(dest_internal_format),
600 GL_UNSIGNED_BYTE, false, false, false); 600 GL_UNSIGNED_BYTE, false, false, false);
601 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION); 601 EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
602 } else { 602 } else {
603 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 0, 1, 1, 603 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0,
604 false, false, false); 604 1, 1, false, false, false);
605 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 605 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
606 606
607 // Check the FB is still bound. 607 // Check the FB is still bound.
608 GLint value = 0; 608 GLint value = 0;
609 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 609 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
610 GLuint fb_id = value; 610 GLuint fb_id = value;
611 EXPECT_EQ(framebuffer_id_, fb_id); 611 EXPECT_EQ(framebuffer_id_, fb_id);
612 612
613 // Check that FB is complete. 613 // Check that FB is complete.
614 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 614 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
(...skipping 17 matching lines...) Expand all
632 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { 632 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) {
633 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); 633 for (size_t dest_index = 0; dest_index < arraysize(dest_formats);
634 dest_index++) { 634 dest_index++) {
635 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 635 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
636 glBindTexture(GL_TEXTURE_2D, textures_[0]); 636 glBindTexture(GL_TEXTURE_2D, textures_[0]);
637 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, 637 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0,
638 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); 638 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr);
639 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 639 EXPECT_TRUE(GL_NO_ERROR == glGetError());
640 640
641 if (copy_type == TexImage) { 641 if (copy_type == TexImage) {
642 glCopyTextureCHROMIUM(textures_[0], textures_[1], 642 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0,
643 dest_formats[dest_index], GL_UNSIGNED_BYTE, 643 dest_formats[dest_index], GL_UNSIGNED_BYTE, false,
644 false, false, false); 644 false, false);
645 } else { 645 } else {
646 glBindTexture(GL_TEXTURE_2D, textures_[1]); 646 glBindTexture(GL_TEXTURE_2D, textures_[1]);
647 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, 647 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0,
648 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); 648 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr);
649 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 649 EXPECT_TRUE(GL_NO_ERROR == glGetError());
650 650
651 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 651 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0,
652 0, 0, 0, 1, 1, false, false, false); 652 1, 1, false, false, false);
653 } 653 }
654 654
655 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index 655 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index
656 << " dest_index:" << dest_index; 656 << " dest_index:" << dest_index;
657 glDeleteTextures(2, textures_); 657 glDeleteTextures(2, textures_);
658 glDeleteFramebuffers(1, &framebuffer_id_); 658 glDeleteFramebuffers(1, &framebuffer_id_);
659 } 659 }
660 } 660 }
661 } 661 }
662 662
663 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { 663 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
664 CopyType copy_type = GetParam(); 664 CopyType copy_type = GetParam();
665 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 665 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
666 glBindTexture(GL_TEXTURE_2D, textures_[0]); 666 glBindTexture(GL_TEXTURE_2D, textures_[0]);
667 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 667 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
668 nullptr); 668 nullptr);
669 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 669 EXPECT_TRUE(GL_NO_ERROR == glGetError());
670 670
671 // Check unsupported format reports error. 671 // Check unsupported format reports error.
672 GLint unsupported_dest_formats[] = {GL_RED, GL_RG}; 672 GLint unsupported_dest_formats[] = {GL_RED, GL_RG};
673 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); 673 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats);
674 dest_index++) { 674 dest_index++) {
675 if (copy_type == TexImage) { 675 if (copy_type == TexImage) {
676 glCopyTextureCHROMIUM(textures_[0], textures_[1], 676 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0,
677 unsupported_dest_formats[dest_index], 677 unsupported_dest_formats[dest_index],
678 GL_UNSIGNED_BYTE, false, false, false); 678 GL_UNSIGNED_BYTE, false, false, false);
679 } else { 679 } else {
680 glBindTexture(GL_TEXTURE_2D, textures_[1]); 680 glBindTexture(GL_TEXTURE_2D, textures_[1]);
681 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, 681 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1,
682 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, 682 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE,
683 nullptr); 683 nullptr);
684 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 684 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1,
685 0, 0, 1, 1, false, false, false); 685 1, false, false, false);
686 } 686 }
687 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 687 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
688 << "dest_index:" << dest_index; 688 << "dest_index:" << dest_index;
689 } 689 }
690 glDeleteTextures(2, textures_); 690 glDeleteTextures(2, textures_);
691 glDeleteFramebuffers(1, &framebuffer_id_); 691 glDeleteFramebuffers(1, &framebuffer_id_);
692 } 692 }
693 693
694 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) { 694 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) {
695 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 695 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
696 glBindTexture(GL_TEXTURE_2D, textures_[0]); 696 glBindTexture(GL_TEXTURE_2D, textures_[0]);
697 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 697 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
698 nullptr); 698 nullptr);
699 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 699 EXPECT_TRUE(GL_NO_ERROR == glGetError());
700 700
701 // Check unsupported internal_format/type combination reports error. 701 // Check unsupported internal_format/type combination reports error.
702 struct FormatType { GLenum format, type; }; 702 struct FormatType { GLenum format, type; };
703 FormatType unsupported_format_types[] = { 703 FormatType unsupported_format_types[] = {
704 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, 704 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4},
705 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, 705 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1},
706 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5}, 706 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5},
707 }; 707 };
708 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types); 708 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types);
709 dest_index++) { 709 dest_index++) {
710 glCopyTextureCHROMIUM( 710 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0,
711 textures_[0], textures_[1], unsupported_format_types[dest_index].format, 711 unsupported_format_types[dest_index].format,
712 unsupported_format_types[dest_index].type, false, false, false); 712 unsupported_format_types[dest_index].type, false,
713 false, false);
713 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) 714 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError())
714 << "dest_index:" << dest_index; 715 << "dest_index:" << dest_index;
715 } 716 }
716 glDeleteTextures(2, textures_); 717 glDeleteTextures(2, textures_);
717 glDeleteFramebuffers(1, &framebuffer_id_); 718 glDeleteFramebuffers(1, &framebuffer_id_);
718 } 719 }
719 720
720 TEST_P(GLCopyTextureCHROMIUMTest, CopyTextureLevel) { 721 TEST_P(GLCopyTextureCHROMIUMTest, CopyTextureLevel) {
721 CopyType copy_type = GetParam(); 722 CopyType copy_type = GetParam();
722 723
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 glTexSubImage2D( 790 glTexSubImage2D(
790 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 791 GL_TEXTURE_2D, 0, 0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
791 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); 792 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError());
792 // GL_INVALID_VALUE due to bad dimensions. 793 // GL_INVALID_VALUE due to bad dimensions.
793 glTexSubImage2D( 794 glTexSubImage2D(
794 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels); 795 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
795 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 796 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
796 797
797 // If the dest texture has different properties, glCopyTextureCHROMIUM() 798 // If the dest texture has different properties, glCopyTextureCHROMIUM()
798 // redefines them. 799 // redefines them.
799 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 800 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
800 GL_UNSIGNED_BYTE, false, false, false); 801 GL_UNSIGNED_BYTE, false, false, false);
801 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 802 EXPECT_TRUE(GL_NO_ERROR == glGetError());
802 803
803 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2 804 // glTexSubImage2D() succeeds because textures_[1] is redefined into 2x2
804 // dimension and GL_RGBA format. 805 // dimension and GL_RGBA format.
805 glBindTexture(GL_TEXTURE_2D, textures_[1]); 806 glBindTexture(GL_TEXTURE_2D, textures_[1]);
806 glTexSubImage2D( 807 glTexSubImage2D(
807 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 808 GL_TEXTURE_2D, 0, 1, 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
808 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 809 EXPECT_TRUE(GL_NO_ERROR == glGetError());
809 810
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 glEnableDisable(GL_SCISSOR_TEST, setting); 863 glEnableDisable(GL_SCISSOR_TEST, setting);
863 glEnableDisable(GL_STENCIL_TEST, setting); 864 glEnableDisable(GL_STENCIL_TEST, setting);
864 glEnableDisable(GL_CULL_FACE, setting); 865 glEnableDisable(GL_CULL_FACE, setting);
865 glEnableDisable(GL_BLEND, setting); 866 glEnableDisable(GL_BLEND, setting);
866 glColorMask(setting, setting, setting, setting); 867 glColorMask(setting, setting, setting, setting);
867 glDepthMask(setting); 868 glDepthMask(setting);
868 869
869 glActiveTexture(GL_TEXTURE1 + x); 870 glActiveTexture(GL_TEXTURE1 + x);
870 871
871 if (copy_type == TexImage) { 872 if (copy_type == TexImage) {
872 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 873 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
873 GL_UNSIGNED_BYTE, false, false, false); 874 GL_UNSIGNED_BYTE, false, false, false);
874 } else { 875 } else {
875 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 876 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1,
876 0, 0, 1, 1, false, false, false); 877 1, false, false, false);
877 } 878 }
878 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 879 EXPECT_TRUE(GL_NO_ERROR == glGetError());
879 880
880 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); 881 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST));
881 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); 882 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST));
882 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); 883 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST));
883 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); 884 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE));
884 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); 885 EXPECT_EQ(setting, glIsEnabled(GL_BLEND));
885 886
886 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; 887 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 GLuint texture_ids[2]; 926 GLuint texture_ids[2];
926 glGenTextures(2, texture_ids); 927 glGenTextures(2, texture_ids);
927 928
928 glActiveTexture(GL_TEXTURE0); 929 glActiveTexture(GL_TEXTURE0);
929 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); 930 glBindTexture(GL_TEXTURE_2D, texture_ids[0]);
930 931
931 glActiveTexture(GL_TEXTURE1); 932 glActiveTexture(GL_TEXTURE1);
932 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); 933 glBindTexture(GL_TEXTURE_2D, texture_ids[1]);
933 934
934 if (copy_type == TexImage) { 935 if (copy_type == TexImage) {
935 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 936 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
936 GL_UNSIGNED_BYTE, false, false, false); 937 GL_UNSIGNED_BYTE, false, false, false);
937 } else { 938 } else {
938 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 939 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1,
939 0, 1, 1, false, false, false); 940 false, false, false);
940 } 941 }
941 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 942 EXPECT_TRUE(GL_NO_ERROR == glGetError());
942 943
943 GLint active_texture = 0; 944 GLint active_texture = 0;
944 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); 945 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
945 EXPECT_EQ(GL_TEXTURE1, active_texture); 946 EXPECT_EQ(GL_TEXTURE1, active_texture);
946 947
947 GLint bound_texture = 0; 948 GLint bound_texture = 0;
948 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); 949 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture);
949 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); 950 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 EXPECT_TRUE( 1001 EXPECT_TRUE(
1001 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)); 1002 GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER));
1002 1003
1003 // Test that we can write to the bound framebuffer 1004 // Test that we can write to the bound framebuffer
1004 uint8_t expected_color[4] = {255u, 255u, 0, 255u}; 1005 uint8_t expected_color[4] = {255u, 255u, 0, 255u};
1005 glClearColor(1.0, 1.0, 0, 1.0); 1006 glClearColor(1.0, 1.0, 0, 1.0);
1006 glClear(GL_COLOR_BUFFER_BIT); 1007 glClear(GL_COLOR_BUFFER_BIT);
1007 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); 1008 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr);
1008 1009
1009 if (copy_type == TexImage) { 1010 if (copy_type == TexImage) {
1010 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 1011 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
1011 GL_UNSIGNED_BYTE, false, false, false); 1012 GL_UNSIGNED_BYTE, false, false, false);
1012 } else { 1013 } else {
1013 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 1014 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1,
1014 0, 1, 1, false, false, false); 1015 false, false, false);
1015 } 1016 }
1016 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1017 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1017 1018
1018 EXPECT_TRUE(glIsFramebuffer(framebuffer_id)); 1019 EXPECT_TRUE(glIsFramebuffer(framebuffer_id));
1019 1020
1020 // Ensure that reading from the framebuffer produces correct pixels. 1021 // Ensure that reading from the framebuffer produces correct pixels.
1021 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr); 1022 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_color, nullptr);
1022 1023
1023 uint8_t expected_color2[4] = {255u, 0, 255u, 255u}; 1024 uint8_t expected_color2[4] = {255u, 0, 255u, 255u};
1024 glClearColor(1.0, 0, 1.0, 1.0); 1025 glClearColor(1.0, 0, 1.0, 1.0);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); 1116 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr));
1116 glDrawArrays(GL_TRIANGLES, 0, 6); 1117 glDrawArrays(GL_TRIANGLES, 0, 6);
1117 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); 1118 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr));
1118 1119
1119 // Call copyTextureCHROMIUM 1120 // Call copyTextureCHROMIUM
1120 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; 1121 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u};
1121 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1122 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1122 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1123 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1123 pixels); 1124 pixels);
1124 if (copy_type == TexImage) { 1125 if (copy_type == TexImage) {
1125 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 1126 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
1126 GL_UNSIGNED_BYTE, false, false, false); 1127 GL_UNSIGNED_BYTE, false, false, false);
1127 } else { 1128 } else {
1128 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1129 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1129 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1130 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1130 nullptr); 1131 nullptr);
1131 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 1132 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0, 1, 1,
1132 0, 1, 1, false, false, false); 1133 false, false, false);
1133 } 1134 }
1134 1135
1135 // test using program after 1136 // test using program after
1136 glClear(GL_COLOR_BUFFER_BIT); 1137 glClear(GL_COLOR_BUFFER_BIT);
1137 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr)); 1138 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero, nullptr));
1138 glDrawArrays(GL_TRIANGLES, 0, 6); 1139 glDrawArrays(GL_TRIANGLES, 0, 6);
1139 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr)); 1140 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected, nullptr));
1140 1141
1141 glDeleteTextures(2, textures_); 1142 glDeleteTextures(2, textures_);
1142 glDeleteFramebuffers(1, &framebuffer_id_); 1143 glDeleteFramebuffers(1, &framebuffer_id_);
1143 1144
1144 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1145 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1145 1146
1146 gl2.MakeCurrent(); 1147 gl2.MakeCurrent();
1147 gl2.Destroy(); 1148 gl2.Destroy();
1148 gl_.MakeCurrent(); 1149 gl_.MakeCurrent();
1149 } 1150 }
1150 1151
1151 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. 1152 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures.
1152 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { 1153 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) {
1153 CopyType copy_type = GetParam(); 1154 CopyType copy_type = GetParam();
1154 const GLsizei kWidth = 64, kHeight = 64; 1155 const GLsizei kWidth = 64, kHeight = 64;
1155 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1156 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1156 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1157 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1157 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 1158 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
1158 GL_UNSIGNED_BYTE, nullptr); 1159 GL_UNSIGNED_BYTE, nullptr);
1159 1160
1160 if (copy_type == TexImage) { 1161 if (copy_type == TexImage) {
1161 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 1162 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
1162 GL_UNSIGNED_BYTE, false, false, false); 1163 GL_UNSIGNED_BYTE, false, false, false);
1163 } else { 1164 } else {
1164 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1165 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1165 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, 1166 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA,
1166 GL_UNSIGNED_BYTE, nullptr); 1167 GL_UNSIGNED_BYTE, nullptr);
1167 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, 1168 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 0, 0,
1168 0, kWidth, kHeight, false, false, false); 1169 kWidth, kHeight, false, false, false);
1169 } 1170 }
1170 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1171 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1171 1172
1172 uint8_t pixels[kHeight][kWidth][4] = {{{1}}}; 1173 uint8_t pixels[kHeight][kWidth][4] = {{{1}}};
1173 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 1174 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
1174 for (int x = 0; x < kWidth; ++x) { 1175 for (int x = 0; x < kWidth; ++x) {
1175 for (int y = 0; y < kHeight; ++y) { 1176 for (int y = 0; y < kHeight; ++y) {
1176 EXPECT_EQ(0, pixels[y][x][0]); 1177 EXPECT_EQ(0, pixels[y][x][0]);
1177 EXPECT_EQ(0, pixels[y][x][1]); 1178 EXPECT_EQ(0, pixels[y][x][1]);
1178 EXPECT_EQ(0, pixels[y][x][2]); 1179 EXPECT_EQ(0, pixels[y][x][2]);
(...skipping 10 matching lines...) Expand all
1189 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { 1190 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) {
1190 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1191 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1191 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1192 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1192 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1193 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1193 nullptr); 1194 nullptr);
1194 1195
1195 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1196 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1196 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1197 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1197 nullptr); 1198 nullptr);
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(GL_NO_ERROR == glGetError()); 1202 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1202 1203
1203 // xoffset < 0 1204 // xoffset < 0
1204 glCopySubTextureCHROMIUM(textures_[0], textures_[1], -1, 1, 0, 1205 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, -1, 1, 0, 0, 1, 1,
1205 0, 1, 1, false, false, false); 1206 false, false, false);
1206 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1207 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1207 1208
1208 // x < 0 1209 // x < 0
1209 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, -1, 1210 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, -1, 0, 1, 1,
1210 0, 1, 1, false, false, false); 1211 false, false, false);
1211 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1212 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1212 1213
1213 // xoffset + width > dest_width 1214 // xoffset + width > dest_width
1214 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 2, 2, 0, 1215 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 2, 2, 0, 0, 2, 2,
1215 0, 2, 2, false, false, false); 1216 false, false, false);
1216 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1217 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1217 1218
1218 // x + width > source_width 1219 // x + width > source_width
1219 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 1, 1220 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 0, 1, 1, 2, 2,
1220 1, 2, 2, false, false, false); 1221 false, false, false);
1221 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); 1222 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
1222 1223
1223 glDeleteTextures(2, textures_); 1224 glDeleteTextures(2, textures_);
1224 glDeleteFramebuffers(1, &framebuffer_id_); 1225 glDeleteFramebuffers(1, &framebuffer_id_);
1225 } 1226 }
1226 1227
1227 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) { 1228 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) {
1228 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1229 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1229 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1230 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1230 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1231 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1231 nullptr); 1232 nullptr);
1232 1233
1233 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1234 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1234 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1235 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1235 nullptr); 1236 nullptr);
1236 1237
1237 glCopyTextureCHROMIUM(textures_[0], 99993, GL_RGBA, 1238 glCopyTextureCHROMIUM(textures_[0], 0, 99993, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1238 GL_UNSIGNED_BYTE, false, false, false);
1239 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1240
1241 glCopyTextureCHROMIUM(99994, textures_[1], GL_RGBA,
1242 GL_UNSIGNED_BYTE, false, false, false);
1243 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1244
1245 glCopyTextureCHROMIUM(99995, 99996, GL_RGBA, GL_UNSIGNED_BYTE,
1246 false, false, false); 1239 false, false, false);
1247 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1240 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1248 1241
1249 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, 1242 glCopyTextureCHROMIUM(99994, 0, textures_[1], 0, GL_RGBA, GL_UNSIGNED_BYTE,
1243 false, false, false);
1244 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1245
1246 glCopyTextureCHROMIUM(99995, 0, 99996, 0, GL_RGBA, GL_UNSIGNED_BYTE, false,
1247 false, false);
1248 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1249
1250 glCopyTextureCHROMIUM(textures_[0], 0, textures_[1], 0, GL_RGBA,
1250 GL_UNSIGNED_BYTE, false, false, false); 1251 GL_UNSIGNED_BYTE, false, false, false);
1251 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1252 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1252 1253
1253 glDeleteTextures(2, textures_); 1254 glDeleteTextures(2, textures_);
1254 glDeleteFramebuffers(1, &framebuffer_id_); 1255 glDeleteFramebuffers(1, &framebuffer_id_);
1255 } 1256 }
1256 1257
1257 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) { 1258 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) {
1258 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1259 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1259 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1260 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1260 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1261 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1261 nullptr); 1262 nullptr);
1262 1263
1263 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1264 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1264 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1265 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1265 nullptr); 1266 nullptr);
1266 1267
1267 glCopySubTextureCHROMIUM(textures_[0], 99993, 1, 1, 0, 0, 1, 1, 1268 glCopySubTextureCHROMIUM(textures_[0], 0, 99993, 0, 1, 1, 0, 0, 1, 1, false,
1268 false, false, false);
1269 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1270
1271 glCopySubTextureCHROMIUM(99994, textures_[1], 1, 1, 0, 0, 1, 1,
1272 false, false, false);
1273 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1274
1275 glCopySubTextureCHROMIUM(99995, 99996, 1, 1, 0, 0, 1, 1, false,
1276 false, false); 1269 false, false);
1277 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); 1270 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1278 1271
1279 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, 1272 glCopySubTextureCHROMIUM(99994, 0, textures_[1], 0, 1, 1, 0, 0, 1, 1, false,
1280 0, 1, 1, false, false, false); 1273 false, false);
1274 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1275
1276 glCopySubTextureCHROMIUM(99995, 0, 99996, 0, 1, 1, 0, 0, 1, 1, false, false,
1277 false);
1278 EXPECT_TRUE(GL_INVALID_VALUE == glGetError());
1279
1280 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1,
1281 false, false, false);
1281 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1282 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1282 1283
1283 glDeleteTextures(2, textures_); 1284 glDeleteTextures(2, textures_);
1284 glDeleteFramebuffers(1, &framebuffer_id_); 1285 glDeleteFramebuffers(1, &framebuffer_id_);
1285 } 1286 }
1286 1287
1287 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { 1288 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
1288 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u, 1289 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u,
1289 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u}; 1290 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u};
1290 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 1291 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
1291 glBindTexture(GL_TEXTURE_2D, textures_[0]); 1292 glBindTexture(GL_TEXTURE_2D, textures_[0]);
1292 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1293 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1293 rgba_pixels); 1294 rgba_pixels);
1294 1295
1295 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1296 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u,
1296 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; 1297 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
1297 glBindTexture(GL_TEXTURE_2D, textures_[1]); 1298 glBindTexture(GL_TEXTURE_2D, textures_[1]);
1298 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 1299 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE,
1299 transparent_pixels); 1300 transparent_pixels);
1300 1301
1301 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, 1302 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 1, 0, 0, 1, 1,
1302 0, 1, 1, false, false, false); 1303 false, false, false);
1303 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 1304 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
1304 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 0, 1, 1305 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 1, 0, 1, 0, 1, 1,
1305 0, 1, 1, false, false, false); 1306 false, false, false);
1306 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 1307 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
1307 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 1, 0, 1308 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, 0, 1, 0, 1, 1, 1,
1308 1, 1, 1, false, false, false); 1309 false, false, false);
1309 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 1310 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
1310 1311
1311 // Check the FB is still bound. 1312 // Check the FB is still bound.
1312 GLint value = 0; 1313 GLint value = 0;
1313 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); 1314 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value);
1314 GLuint fb_id = value; 1315 GLuint fb_id = value;
1315 EXPECT_EQ(framebuffer_id_, fb_id); 1316 EXPECT_EQ(framebuffer_id_, fb_id);
1316 1317
1317 // Check that FB is complete. 1318 // Check that FB is complete.
1318 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 1319 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 } 1389 }
1389 } 1390 }
1390 1391
1391 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target, 1392 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target,
1392 textures_[1], 0); 1393 textures_[1], 0);
1393 glBindTexture(dest_target, textures_[1]); 1394 glBindTexture(dest_target, textures_[1]);
1394 1395
1395 // Copy the subtexture x=[13,18) y=[6,9) to the destination. 1396 // Copy the subtexture x=[13,18) y=[6,9) to the destination.
1396 glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0); 1397 glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0);
1397 glClear(GL_COLOR_BUFFER_BIT); 1398 glClear(GL_COLOR_BUFFER_BIT);
1398 glCopySubTextureCHROMIUM(textures_[0], textures_[1], copy_region_x, 1399 glCopySubTextureCHROMIUM(textures_[0], 0, textures_[1], 0, copy_region_x,
1399 copy_region_y, 13, 6, copy_region_width, 1400 copy_region_y, 13, 6, copy_region_width,
1400 copy_region_height, false, false, false); 1401 copy_region_height, false, false, false);
1401 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 1402 EXPECT_TRUE(GL_NO_ERROR == glGetError());
1402 1403
1403 for (GLint x = 0; x < dest_width; ++x) { 1404 for (GLint x = 0; x < dest_width; ++x) {
1404 for (GLint y = 0; y < dest_height; ++y) { 1405 for (GLint y = 0; y < dest_height; ++y) {
1405 if (x < copy_region_x || x >= copy_region_x + copy_region_width || 1406 if (x < copy_region_x || x >= copy_region_x + copy_region_width ||
1406 y < copy_region_y || y >= copy_region_y + copy_region_height) { 1407 y < copy_region_y || y >= copy_region_y + copy_region_height) {
1407 GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey, nullptr); 1408 GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey, nullptr);
1408 continue; 1409 continue;
1409 } 1410 }
1410 1411
1411 uint8_t* expected_color; 1412 uint8_t* expected_color;
1412 if (x < copy_region_x + 2) { 1413 if (x < copy_region_x + 2) {
1413 expected_color = y < copy_region_y + 1 ? red : green; 1414 expected_color = y < copy_region_y + 1 ? red : green;
1414 } else { 1415 } else {
1415 expected_color = y < copy_region_y + 1 ? blue : white; 1416 expected_color = y < copy_region_y + 1 ? blue : white;
1416 } 1417 }
1417 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color, nullptr); 1418 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color, nullptr);
1418 } 1419 }
1419 } 1420 }
1420 1421
1421 glDeleteTextures(2, textures_); 1422 glDeleteTextures(2, textures_);
1422 glDeleteFramebuffers(1, &framebuffer_id_); 1423 glDeleteFramebuffers(1, &framebuffer_id_);
1423 } 1424 }
1424 } 1425 }
1425 } 1426 }
1426 1427
1427 } // namespace gpu 1428 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698