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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 203 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
204 | 204 |
205 glGenFramebuffers(1, &framebuffer_id_); | 205 glGenFramebuffers(1, &framebuffer_id_); |
206 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); | 206 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_); |
207 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, | 207 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, |
208 textures_[1], 0); | 208 textures_[1], 0); |
209 } | 209 } |
210 | 210 |
211 void SetUp() override { | 211 void SetUp() override { |
212 gl_.Initialize(GLManager::Options()); | 212 gl_.Initialize(GLManager::Options()); |
213 | |
214 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | |
215 } | 213 } |
216 | 214 |
217 void TearDown() override { | 215 void TearDown() override { gl_.Destroy(); } |
218 glDeleteTextures(2, textures_); | |
219 glDeleteFramebuffers(1, &framebuffer_id_); | |
220 gl_.Destroy(); | |
221 } | |
222 | 216 |
223 void CreateBackingForTexture(GLenum target, GLsizei width, GLsizei height) { | 217 void CreateBackingForTexture(GLenum target, GLsizei width, GLsizei height) { |
224 if (target == GL_TEXTURE_RECTANGLE_ARB) { | 218 if (target == GL_TEXTURE_RECTANGLE_ARB) { |
225 GLuint image_id = glCreateGpuMemoryBufferImageCHROMIUM( | 219 GLuint image_id = glCreateGpuMemoryBufferImageCHROMIUM( |
226 width, height, GL_RGBA, GL_READ_WRITE_CHROMIUM); | 220 width, height, GL_RGBA, GL_READ_WRITE_CHROMIUM); |
227 glBindTexImage2DCHROMIUM(target, image_id); | 221 glBindTexImage2DCHROMIUM(target, image_id); |
228 } else { | 222 } else { |
229 glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_RGBA, | 223 glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_RGBA, |
230 GL_UNSIGNED_BYTE, nullptr); | 224 GL_UNSIGNED_BYTE, nullptr); |
231 } | 225 } |
(...skipping 20 matching lines...) Expand all Loading... |
252 | 246 |
253 class GLCopyTextureCHROMIUMES3Test : public GLCopyTextureCHROMIUMTest { | 247 class GLCopyTextureCHROMIUMES3Test : public GLCopyTextureCHROMIUMTest { |
254 protected: | 248 protected: |
255 void SetUp() override { | 249 void SetUp() override { |
256 GLManager::Options options; | 250 GLManager::Options options; |
257 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3; | 251 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3; |
258 options.size = gfx::Size(64, 64); | 252 options.size = gfx::Size(64, 64); |
259 gl_.Initialize(options); | 253 gl_.Initialize(options); |
260 } | 254 } |
261 | 255 |
262 void TearDown() override { gl_.Destroy(); } | |
263 | |
264 // If a driver isn't capable of supporting ES3 context, creating | 256 // If a driver isn't capable of supporting ES3 context, creating |
265 // ContextGroup will fail. Just skip the test. | 257 // ContextGroup will fail. Just skip the test. |
266 bool ShouldSkipTest() const { | 258 bool ShouldSkipTest() const { |
267 return (!gl_.decoder() || !gl_.decoder()->GetContextGroup()); | 259 return (!gl_.decoder() || !gl_.decoder()->GetContextGroup()); |
268 } | 260 } |
269 | 261 |
270 // RGB9_E5 isn't accepted by glCopyTexImage2D if underlying context is ES. | 262 // RGB9_E5 isn't accepted by glCopyTexImage2D if underlying context is ES. |
271 // TODO(qiankun.miao@intel.com): we should support RGB9_E5 in ES context. | 263 // TODO(qiankun.miao@intel.com): we should support RGB9_E5 in ES context. |
272 // Maybe, we can add a readback path for RGB9_E5 format in ES context. | 264 // Maybe, we can add a readback path for RGB9_E5 format in ES context. |
273 bool ShouldSkipRGB9_E5() const { | 265 bool ShouldSkipRGB9_E5() const { |
(...skipping 29 matching lines...) Expand all Loading... |
303 | 295 |
304 INSTANTIATE_TEST_CASE_P(CopyType, | 296 INSTANTIATE_TEST_CASE_P(CopyType, |
305 GLCopyTextureCHROMIUMES3Test, | 297 GLCopyTextureCHROMIUMES3Test, |
306 ::testing::ValuesIn(kCopyTypes)); | 298 ::testing::ValuesIn(kCopyTypes)); |
307 | 299 |
308 // Test to ensure that the basic functionality of the extension works. | 300 // Test to ensure that the basic functionality of the extension works. |
309 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { | 301 TEST_P(GLCopyTextureCHROMIUMTest, Basic) { |
310 CopyType copy_type = GetParam(); | 302 CopyType copy_type = GetParam(); |
311 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; | 303 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
312 | 304 |
| 305 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
313 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 306 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
314 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 307 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
315 pixels); | 308 pixels); |
316 | 309 |
317 if (copy_type == TexImage) { | 310 if (copy_type == TexImage) { |
318 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 311 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, |
319 GL_UNSIGNED_BYTE, false, false, false); | 312 GL_UNSIGNED_BYTE, false, false, false); |
320 } else { | 313 } else { |
321 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 314 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
322 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 315 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 return; | 541 return; |
549 } | 542 } |
550 CopyType copy_type = GetParam(); | 543 CopyType copy_type = GetParam(); |
551 GLenum src_internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; | 544 GLenum src_internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; |
552 GLenum dest_internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; | 545 GLenum dest_internal_formats[] = {GL_RGB8_OES, GL_RGBA8_OES, GL_BGRA8_EXT}; |
553 | 546 |
554 uint8_t pixels[1 * 4] = {255u, 0u, 255u, 255u}; | 547 uint8_t pixels[1 * 4] = {255u, 0u, 255u, 255u}; |
555 | 548 |
556 for (auto src_internal_format : src_internal_formats) { | 549 for (auto src_internal_format : src_internal_formats) { |
557 for (auto dest_internal_format : dest_internal_formats) { | 550 for (auto dest_internal_format : dest_internal_formats) { |
558 glDeleteTextures(2, textures_); | |
559 glDeleteFramebuffers(1, &framebuffer_id_); | |
560 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); | 551 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
561 | |
562 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 552 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
563 glTexStorage2DEXT(GL_TEXTURE_2D, 1, src_internal_format, 1, 1); | 553 glTexStorage2DEXT(GL_TEXTURE_2D, 1, src_internal_format, 1, 1); |
564 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, | 554 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, |
565 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE, | 555 ExtractFormatFrom(src_internal_format), GL_UNSIGNED_BYTE, |
566 pixels); | 556 pixels); |
567 | 557 |
568 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 558 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
569 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1); | 559 glTexStorage2DEXT(GL_TEXTURE_2D, 1, dest_internal_format, 1, 1); |
570 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 560 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
571 GL_TEXTURE_2D, textures_[1], 0); | 561 GL_TEXTURE_2D, textures_[1], 0); |
(...skipping 15 matching lines...) Expand all Loading... |
587 GLuint fb_id = value; | 577 GLuint fb_id = value; |
588 EXPECT_EQ(framebuffer_id_, fb_id); | 578 EXPECT_EQ(framebuffer_id_, fb_id); |
589 | 579 |
590 // Check that FB is complete. | 580 // Check that FB is complete. |
591 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 581 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
592 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 582 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
593 | 583 |
594 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); | 584 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, pixels); |
595 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 585 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
596 } | 586 } |
| 587 glDeleteTextures(2, textures_); |
| 588 glDeleteFramebuffers(1, &framebuffer_id_); |
597 } | 589 } |
598 } | 590 } |
599 } | 591 } |
600 | 592 |
601 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) { | 593 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) { |
602 CopyType copy_type = GetParam(); | 594 CopyType copy_type = GetParam(); |
603 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, | 595 GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA, |
604 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; | 596 GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT}; |
605 GLint dest_formats[] = {GL_RGB, GL_RGBA, GL_BGRA_EXT}; | 597 GLint dest_formats[] = {GL_RGB, GL_RGBA, GL_BGRA_EXT}; |
606 | 598 |
607 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { | 599 for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) { |
608 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); | 600 for (size_t dest_index = 0; dest_index < arraysize(dest_formats); |
609 dest_index++) { | 601 dest_index++) { |
| 602 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
610 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 603 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
611 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, | 604 glTexImage2D(GL_TEXTURE_2D, 0, src_formats[src_index], 1, 1, 0, |
612 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); | 605 src_formats[src_index], GL_UNSIGNED_BYTE, nullptr); |
613 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 606 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
614 | 607 |
615 if (copy_type == TexImage) { | 608 if (copy_type == TexImage) { |
616 glCopyTextureCHROMIUM(textures_[0], textures_[1], | 609 glCopyTextureCHROMIUM(textures_[0], textures_[1], |
617 dest_formats[dest_index], GL_UNSIGNED_BYTE, | 610 dest_formats[dest_index], GL_UNSIGNED_BYTE, |
618 false, false, false); | 611 false, false, false); |
619 } else { | 612 } else { |
620 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 613 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
621 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, | 614 glTexImage2D(GL_TEXTURE_2D, 0, dest_formats[dest_index], 1, 1, 0, |
622 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); | 615 dest_formats[dest_index], GL_UNSIGNED_BYTE, nullptr); |
623 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 616 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
624 | 617 |
625 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, | 618 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, |
626 0, 0, 0, 1, 1, false, false, false); | 619 0, 0, 0, 1, 1, false, false, false); |
627 } | 620 } |
628 | 621 |
629 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index | 622 EXPECT_TRUE(GL_NO_ERROR == glGetError()) << "src_index:" << src_index |
630 << " dest_index:" << dest_index; | 623 << " dest_index:" << dest_index; |
| 624 glDeleteTextures(2, textures_); |
| 625 glDeleteFramebuffers(1, &framebuffer_id_); |
631 } | 626 } |
632 } | 627 } |
633 } | 628 } |
634 | 629 |
635 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { | 630 TEST_P(GLCopyTextureCHROMIUMTest, InternalFormatNotSupported) { |
636 CopyType copy_type = GetParam(); | 631 CopyType copy_type = GetParam(); |
| 632 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
637 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 633 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
638 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 634 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
639 nullptr); | 635 nullptr); |
640 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 636 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
641 | 637 |
642 // Check unsupported format reports error. | 638 // Check unsupported format reports error. |
643 GLint unsupported_dest_formats[] = {GL_RED, GL_RG}; | 639 GLint unsupported_dest_formats[] = {GL_RED, GL_RG}; |
644 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); | 640 for (size_t dest_index = 0; dest_index < arraysize(unsupported_dest_formats); |
645 dest_index++) { | 641 dest_index++) { |
646 if (copy_type == TexImage) { | 642 if (copy_type == TexImage) { |
647 glCopyTextureCHROMIUM(textures_[0], textures_[1], | 643 glCopyTextureCHROMIUM(textures_[0], textures_[1], |
648 unsupported_dest_formats[dest_index], | 644 unsupported_dest_formats[dest_index], |
649 GL_UNSIGNED_BYTE, false, false, false); | 645 GL_UNSIGNED_BYTE, false, false, false); |
650 } else { | 646 } else { |
651 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 647 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
652 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, | 648 glTexImage2D(GL_TEXTURE_2D, 0, unsupported_dest_formats[dest_index], 1, 1, |
653 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, | 649 0, unsupported_dest_formats[dest_index], GL_UNSIGNED_BYTE, |
654 nullptr); | 650 nullptr); |
655 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, | 651 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, |
656 0, 0, 1, 1, false, false, false); | 652 0, 0, 1, 1, false, false, false); |
657 } | 653 } |
658 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) | 654 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) |
659 << "dest_index:" << dest_index; | 655 << "dest_index:" << dest_index; |
660 } | 656 } |
| 657 glDeleteTextures(2, textures_); |
| 658 glDeleteFramebuffers(1, &framebuffer_id_); |
661 } | 659 } |
662 | 660 |
663 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) { | 661 TEST_F(GLCopyTextureCHROMIUMTest, InternalFormatTypeCombinationNotSupported) { |
| 662 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
664 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 663 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
665 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 664 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
666 nullptr); | 665 nullptr); |
667 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 666 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
668 | 667 |
669 // Check unsupported internal_format/type combination reports error. | 668 // Check unsupported internal_format/type combination reports error. |
670 struct FormatType { GLenum format, type; }; | 669 struct FormatType { GLenum format, type; }; |
671 FormatType unsupported_format_types[] = { | 670 FormatType unsupported_format_types[] = { |
672 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, | 671 {GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4}, |
673 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, | 672 {GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1}, |
674 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5}, | 673 {GL_RGBA, GL_UNSIGNED_SHORT_5_6_5}, |
675 }; | 674 }; |
676 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types); | 675 for (size_t dest_index = 0; dest_index < arraysize(unsupported_format_types); |
677 dest_index++) { | 676 dest_index++) { |
678 glCopyTextureCHROMIUM( | 677 glCopyTextureCHROMIUM( |
679 textures_[0], textures_[1], unsupported_format_types[dest_index].format, | 678 textures_[0], textures_[1], unsupported_format_types[dest_index].format, |
680 unsupported_format_types[dest_index].type, false, false, false); | 679 unsupported_format_types[dest_index].type, false, false, false); |
681 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) | 680 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()) |
682 << "dest_index:" << dest_index; | 681 << "dest_index:" << dest_index; |
683 } | 682 } |
| 683 glDeleteTextures(2, textures_); |
| 684 glDeleteFramebuffers(1, &framebuffer_id_); |
684 } | 685 } |
685 | 686 |
686 // Test to ensure that the destination texture is redefined if the properties | 687 // Test to ensure that the destination texture is redefined if the properties |
687 // are different. | 688 // are different. |
688 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { | 689 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { |
689 uint8_t pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, | 690 uint8_t pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, |
690 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; | 691 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; |
691 | 692 |
| 693 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
692 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 694 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
693 glTexImage2D( | 695 glTexImage2D( |
694 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 696 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
695 | 697 |
696 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 698 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
697 glTexImage2D(GL_TEXTURE_2D, | 699 glTexImage2D(GL_TEXTURE_2D, |
698 0, | 700 0, |
699 GL_BGRA_EXT, | 701 GL_BGRA_EXT, |
700 1, | 702 1, |
701 1, | 703 1, |
(...skipping 29 matching lines...) Expand all Loading... |
731 GLint value = 0; | 733 GLint value = 0; |
732 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); | 734 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &value); |
733 GLuint fb_id = value; | 735 GLuint fb_id = value; |
734 EXPECT_EQ(framebuffer_id_, fb_id); | 736 EXPECT_EQ(framebuffer_id_, fb_id); |
735 | 737 |
736 // Check that FB is complete. | 738 // Check that FB is complete. |
737 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 739 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
738 glCheckFramebufferStatus(GL_FRAMEBUFFER)); | 740 glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
739 | 741 |
740 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); | 742 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, &pixels[12]); |
| 743 |
| 744 glDeleteTextures(2, textures_); |
| 745 glDeleteFramebuffers(1, &framebuffer_id_); |
| 746 |
741 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 747 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
742 } | 748 } |
743 | 749 |
744 namespace { | 750 namespace { |
745 | 751 |
746 void glEnableDisable(GLint param, GLboolean value) { | 752 void glEnableDisable(GLint param, GLboolean value) { |
747 if (value) | 753 if (value) |
748 glEnable(param); | 754 glEnable(param); |
749 else | 755 else |
750 glDisable(param); | 756 glDisable(param); |
751 } | 757 } |
752 | 758 |
753 } // unnamed namespace | 759 } // unnamed namespace |
754 | 760 |
755 // Validate that some basic GL state is not touched upon execution of | 761 // Validate that some basic GL state is not touched upon execution of |
756 // the extension. | 762 // the extension. |
757 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { | 763 TEST_P(GLCopyTextureCHROMIUMTest, BasicStatePreservation) { |
758 CopyType copy_type = GetParam(); | 764 CopyType copy_type = GetParam(); |
759 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; | 765 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
760 | 766 |
| 767 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
761 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 768 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
762 | 769 |
763 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 770 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
764 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 771 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
765 pixels); | 772 pixels); |
766 | 773 |
767 if (copy_type == TexSubImage) { | 774 if (copy_type == TexSubImage) { |
768 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 775 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
769 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 776 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
770 nullptr); | 777 nullptr); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
807 EXPECT_EQ(setting, bool_array[0]); | 814 EXPECT_EQ(setting, bool_array[0]); |
808 EXPECT_EQ(setting, bool_array[1]); | 815 EXPECT_EQ(setting, bool_array[1]); |
809 EXPECT_EQ(setting, bool_array[2]); | 816 EXPECT_EQ(setting, bool_array[2]); |
810 EXPECT_EQ(setting, bool_array[3]); | 817 EXPECT_EQ(setting, bool_array[3]); |
811 | 818 |
812 GLint active_texture = 0; | 819 GLint active_texture = 0; |
813 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 820 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
814 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); | 821 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); |
815 } | 822 } |
816 | 823 |
| 824 glDeleteTextures(2, textures_); |
| 825 glDeleteFramebuffers(1, &framebuffer_id_); |
| 826 |
817 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 827 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
818 }; | 828 }; |
819 | 829 |
820 // Verify that invocation of the extension does not modify the bound | 830 // Verify that invocation of the extension does not modify the bound |
821 // texture state. | 831 // texture state. |
822 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { | 832 TEST_P(GLCopyTextureCHROMIUMTest, TextureStatePreserved) { |
823 CopyType copy_type = GetParam(); | 833 CopyType copy_type = GetParam(); |
824 // Setup the texture used for the extension invocation. | 834 // Setup the texture used for the extension invocation. |
825 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; | 835 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
| 836 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
826 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 837 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
827 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 838 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
828 pixels); | 839 pixels); |
829 | 840 |
830 if (copy_type == TexSubImage) { | 841 if (copy_type == TexSubImage) { |
831 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 842 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
832 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 843 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
833 nullptr); | 844 nullptr); |
834 } | 845 } |
835 | 846 |
(...skipping 24 matching lines...) Expand all Loading... |
860 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); | 871 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); |
861 glBindTexture(GL_TEXTURE_2D, 0); | 872 glBindTexture(GL_TEXTURE_2D, 0); |
862 | 873 |
863 bound_texture = 0; | 874 bound_texture = 0; |
864 glActiveTexture(GL_TEXTURE0); | 875 glActiveTexture(GL_TEXTURE0); |
865 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 876 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
866 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); | 877 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); |
867 glBindTexture(GL_TEXTURE_2D, 0); | 878 glBindTexture(GL_TEXTURE_2D, 0); |
868 | 879 |
869 glDeleteTextures(2, texture_ids); | 880 glDeleteTextures(2, texture_ids); |
| 881 glDeleteTextures(2, textures_); |
| 882 glDeleteFramebuffers(1, &framebuffer_id_); |
870 | 883 |
871 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 884 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
872 } | 885 } |
873 | 886 |
874 // Verify that invocation of the extension does not perturb the currently | 887 // Verify that invocation of the extension does not perturb the currently |
875 // bound FBO state. | 888 // bound FBO state. |
876 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { | 889 TEST_P(GLCopyTextureCHROMIUMTest, FBOStatePreserved) { |
877 CopyType copy_type = GetParam(); | 890 CopyType copy_type = GetParam(); |
878 // Setup the texture used for the extension invocation. | 891 // Setup the texture used for the extension invocation. |
879 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; | 892 uint8_t pixels[1 * 4] = {255u, 0u, 0u, 255u}; |
| 893 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
880 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 894 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
881 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 895 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
882 pixels); | 896 pixels); |
883 | 897 |
884 if (copy_type == TexSubImage) { | 898 if (copy_type == TexSubImage) { |
885 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 899 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
886 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 900 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
887 nullptr); | 901 nullptr); |
888 } | 902 } |
889 | 903 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 | 971 |
958 fbo_params = 0; | 972 fbo_params = 0; |
959 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, | 973 glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, |
960 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, | 974 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, |
961 &fbo_params); | 975 &fbo_params); |
962 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); | 976 EXPECT_EQ(renderbuffer_id, static_cast<GLuint>(fbo_params)); |
963 | 977 |
964 glDeleteRenderbuffers(1, &renderbuffer_id); | 978 glDeleteRenderbuffers(1, &renderbuffer_id); |
965 glDeleteTextures(1, &texture_id); | 979 glDeleteTextures(1, &texture_id); |
966 glDeleteFramebuffers(1, &framebuffer_id); | 980 glDeleteFramebuffers(1, &framebuffer_id); |
| 981 glDeleteTextures(2, textures_); |
| 982 glDeleteFramebuffers(1, &framebuffer_id_); |
967 | 983 |
968 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 984 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
969 } | 985 } |
970 | 986 |
971 TEST_P(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { | 987 TEST_P(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) { |
972 CopyType copy_type = GetParam(); | 988 CopyType copy_type = GetParam(); |
973 // unbind the one created in setup. | 989 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
974 glBindFramebuffer(GL_FRAMEBUFFER, 0); | 990 glBindFramebuffer(GL_FRAMEBUFFER, 0); |
975 glBindTexture(GL_TEXTURE_2D, 0); | 991 glBindTexture(GL_TEXTURE_2D, 0); |
976 | 992 |
977 GLManager gl2; | 993 GLManager gl2; |
978 GLManager::Options options; | 994 GLManager::Options options; |
979 options.size = gfx::Size(16, 16); | 995 options.size = gfx::Size(16, 16); |
980 options.share_group_manager = &gl_; | 996 options.share_group_manager = &gl_; |
981 gl2.Initialize(options); | 997 gl2.Initialize(options); |
982 gl_.MakeCurrent(); | 998 gl_.MakeCurrent(); |
983 | 999 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 1053 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, |
1038 0, 1, 1, false, false, false); | 1054 0, 1, 1, false, false, false); |
1039 } | 1055 } |
1040 | 1056 |
1041 // test using program after | 1057 // test using program after |
1042 glClear(GL_COLOR_BUFFER_BIT); | 1058 glClear(GL_COLOR_BUFFER_BIT); |
1043 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); | 1059 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, zero)); |
1044 glDrawArrays(GL_TRIANGLES, 0, 6); | 1060 glDrawArrays(GL_TRIANGLES, 0, 6); |
1045 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); | 1061 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected)); |
1046 | 1062 |
| 1063 glDeleteTextures(2, textures_); |
| 1064 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1065 |
1047 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1066 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
1048 | 1067 |
1049 gl2.MakeCurrent(); | 1068 gl2.MakeCurrent(); |
1050 gl2.Destroy(); | 1069 gl2.Destroy(); |
1051 gl_.MakeCurrent(); | 1070 gl_.MakeCurrent(); |
1052 } | 1071 } |
1053 | 1072 |
1054 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. | 1073 // Test that glCopyTextureCHROMIUM doesn't leak uninitialized textures. |
1055 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { | 1074 TEST_P(GLCopyTextureCHROMIUMTest, UninitializedSource) { |
1056 CopyType copy_type = GetParam(); | 1075 CopyType copy_type = GetParam(); |
1057 const GLsizei kWidth = 64, kHeight = 64; | 1076 const GLsizei kWidth = 64, kHeight = 64; |
| 1077 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
1058 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1078 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
1059 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | 1079 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
1060 GL_UNSIGNED_BYTE, nullptr); | 1080 GL_UNSIGNED_BYTE, nullptr); |
1061 | 1081 |
1062 if (copy_type == TexImage) { | 1082 if (copy_type == TexImage) { |
1063 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 1083 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, |
1064 GL_UNSIGNED_BYTE, false, false, false); | 1084 GL_UNSIGNED_BYTE, false, false, false); |
1065 } else { | 1085 } else { |
1066 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1086 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
1067 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, | 1087 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kWidth, kHeight, 0, GL_RGBA, |
1068 GL_UNSIGNED_BYTE, nullptr); | 1088 GL_UNSIGNED_BYTE, nullptr); |
1069 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, | 1089 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 0, |
1070 0, kWidth, kHeight, false, false, false); | 1090 0, kWidth, kHeight, false, false, false); |
1071 } | 1091 } |
1072 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1092 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
1073 | 1093 |
1074 uint8_t pixels[kHeight][kWidth][4] = {{{1}}}; | 1094 uint8_t pixels[kHeight][kWidth][4] = {{{1}}}; |
1075 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); | 1095 glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
1076 for (int x = 0; x < kWidth; ++x) { | 1096 for (int x = 0; x < kWidth; ++x) { |
1077 for (int y = 0; y < kHeight; ++y) { | 1097 for (int y = 0; y < kHeight; ++y) { |
1078 EXPECT_EQ(0, pixels[y][x][0]); | 1098 EXPECT_EQ(0, pixels[y][x][0]); |
1079 EXPECT_EQ(0, pixels[y][x][1]); | 1099 EXPECT_EQ(0, pixels[y][x][1]); |
1080 EXPECT_EQ(0, pixels[y][x][2]); | 1100 EXPECT_EQ(0, pixels[y][x][2]); |
1081 EXPECT_EQ(0, pixels[y][x][3]); | 1101 EXPECT_EQ(0, pixels[y][x][3]); |
1082 } | 1102 } |
1083 } | 1103 } |
1084 | 1104 |
| 1105 glDeleteTextures(2, textures_); |
| 1106 glDeleteFramebuffers(1, &framebuffer_id_); |
| 1107 |
1085 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1108 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
1086 } | 1109 } |
1087 | 1110 |
1088 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { | 1111 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureDimension) { |
| 1112 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
1089 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1113 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
1090 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1114 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1091 nullptr); | 1115 nullptr); |
1092 | 1116 |
1093 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1117 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
1094 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1118 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1095 nullptr); | 1119 nullptr); |
1096 | 1120 |
1097 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, | 1121 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, |
1098 0, 1, 1, false, false, false); | 1122 0, 1, 1, false, false, false); |
(...skipping 11 matching lines...) Expand all Loading... |
1110 | 1134 |
1111 // xoffset + width > dest_width | 1135 // xoffset + width > dest_width |
1112 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 2, 2, 0, | 1136 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 2, 2, 0, |
1113 0, 2, 2, false, false, false); | 1137 0, 2, 2, false, false, false); |
1114 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | 1138 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
1115 | 1139 |
1116 // x + width > source_width | 1140 // x + width > source_width |
1117 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 1, | 1141 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 0, 0, 1, |
1118 1, 2, 2, false, false, false); | 1142 1, 2, 2, false, false, false); |
1119 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); | 1143 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 1144 |
| 1145 glDeleteTextures(2, textures_); |
| 1146 glDeleteFramebuffers(1, &framebuffer_id_); |
1120 } | 1147 } |
1121 | 1148 |
1122 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) { | 1149 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureInvalidTextureIds) { |
| 1150 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
1123 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1151 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
1124 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1152 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1125 nullptr); | 1153 nullptr); |
1126 | 1154 |
1127 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1155 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
1128 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1156 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1129 nullptr); | 1157 nullptr); |
1130 | 1158 |
1131 glCopyTextureCHROMIUM(textures_[0], 99993, GL_RGBA, | 1159 glCopyTextureCHROMIUM(textures_[0], 99993, GL_RGBA, |
1132 GL_UNSIGNED_BYTE, false, false, false); | 1160 GL_UNSIGNED_BYTE, false, false, false); |
1133 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1161 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
1134 | 1162 |
1135 glCopyTextureCHROMIUM(99994, textures_[1], GL_RGBA, | 1163 glCopyTextureCHROMIUM(99994, textures_[1], GL_RGBA, |
1136 GL_UNSIGNED_BYTE, false, false, false); | 1164 GL_UNSIGNED_BYTE, false, false, false); |
1137 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1165 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
1138 | 1166 |
1139 glCopyTextureCHROMIUM(99995, 99996, GL_RGBA, GL_UNSIGNED_BYTE, | 1167 glCopyTextureCHROMIUM(99995, 99996, GL_RGBA, GL_UNSIGNED_BYTE, |
1140 false, false, false); | 1168 false, false, false); |
1141 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1169 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
1142 | 1170 |
1143 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, | 1171 glCopyTextureCHROMIUM(textures_[0], textures_[1], GL_RGBA, |
1144 GL_UNSIGNED_BYTE, false, false, false); | 1172 GL_UNSIGNED_BYTE, false, false, false); |
1145 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1173 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1174 |
| 1175 glDeleteTextures(2, textures_); |
| 1176 glDeleteFramebuffers(1, &framebuffer_id_); |
1146 } | 1177 } |
1147 | 1178 |
1148 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) { | 1179 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureInvalidTextureIds) { |
| 1180 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
1149 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1181 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
1150 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1182 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1151 nullptr); | 1183 nullptr); |
1152 | 1184 |
1153 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1185 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
1154 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1186 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 3, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1155 nullptr); | 1187 nullptr); |
1156 | 1188 |
1157 glCopySubTextureCHROMIUM(textures_[0], 99993, 1, 1, 0, 0, 1, 1, | 1189 glCopySubTextureCHROMIUM(textures_[0], 99993, 1, 1, 0, 0, 1, 1, |
1158 false, false, false); | 1190 false, false, false); |
1159 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1191 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
1160 | 1192 |
1161 glCopySubTextureCHROMIUM(99994, textures_[1], 1, 1, 0, 0, 1, 1, | 1193 glCopySubTextureCHROMIUM(99994, textures_[1], 1, 1, 0, 0, 1, 1, |
1162 false, false, false); | 1194 false, false, false); |
1163 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1195 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
1164 | 1196 |
1165 glCopySubTextureCHROMIUM(99995, 99996, 1, 1, 0, 0, 1, 1, false, | 1197 glCopySubTextureCHROMIUM(99995, 99996, 1, 1, 0, 0, 1, 1, false, |
1166 false, false); | 1198 false, false); |
1167 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); | 1199 EXPECT_TRUE(GL_INVALID_VALUE == glGetError()); |
1168 | 1200 |
1169 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, | 1201 glCopySubTextureCHROMIUM(textures_[0], textures_[1], 1, 1, 0, |
1170 0, 1, 1, false, false, false); | 1202 0, 1, 1, false, false, false); |
1171 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1203 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1204 |
| 1205 glDeleteTextures(2, textures_); |
| 1206 glDeleteFramebuffers(1, &framebuffer_id_); |
1172 } | 1207 } |
1173 | 1208 |
1174 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { | 1209 TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) { |
1175 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u, | 1210 uint8_t rgba_pixels[4 * 4] = {255u, 0u, 0u, 255u, 0u, 255u, 0u, 255u, |
1176 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u}; | 1211 0u, 0u, 255u, 255u, 0u, 0u, 0u, 255u}; |
| 1212 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); |
1177 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 1213 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
1178 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1214 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1179 rgba_pixels); | 1215 rgba_pixels); |
1180 | 1216 |
1181 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, | 1217 uint8_t transparent_pixels[4 * 4] = {0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, |
1182 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; | 1218 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u}; |
1183 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 1219 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
1184 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 1220 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
1185 transparent_pixels); | 1221 transparent_pixels); |
1186 | 1222 |
(...skipping 19 matching lines...) Expand all Loading... |
1206 | 1242 |
1207 uint8_t transparent[1 * 4] = {0u, 0u, 0u, 0u}; | 1243 uint8_t transparent[1 * 4] = {0u, 0u, 0u, 0u}; |
1208 uint8_t red[1 * 4] = {255u, 0u, 0u, 255u}; | 1244 uint8_t red[1 * 4] = {255u, 0u, 0u, 255u}; |
1209 uint8_t green[1 * 4] = {0u, 255u, 0u, 255u}; | 1245 uint8_t green[1 * 4] = {0u, 255u, 0u, 255u}; |
1210 uint8_t blue[1 * 4] = {0u, 0u, 255u, 255u}; | 1246 uint8_t blue[1 * 4] = {0u, 0u, 255u, 255u}; |
1211 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); | 1247 GLTestHelper::CheckPixels(0, 0, 1, 1, 0, transparent); |
1212 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); | 1248 GLTestHelper::CheckPixels(1, 1, 1, 1, 0, red); |
1213 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); | 1249 GLTestHelper::CheckPixels(1, 0, 1, 1, 0, green); |
1214 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); | 1250 GLTestHelper::CheckPixels(0, 1, 1, 1, 0, blue); |
1215 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 1251 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 1252 |
| 1253 glDeleteTextures(2, textures_); |
| 1254 glDeleteFramebuffers(1, &framebuffer_id_); |
1216 } | 1255 } |
1217 | 1256 |
1218 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureBetweenTexture2DAndRectangleArb) { | 1257 TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureBetweenTexture2DAndRectangleArb) { |
1219 if (!GLTestHelper::HasExtension("GL_ARB_texture_rectangle")) { | 1258 if (!GLTestHelper::HasExtension("GL_ARB_texture_rectangle")) { |
1220 LOG(INFO) << | 1259 LOG(INFO) << |
1221 "GL_ARB_texture_rectangle not supported. Skipping test..."; | 1260 "GL_ARB_texture_rectangle not supported. Skipping test..."; |
1222 return; | 1261 return; |
1223 } | 1262 } |
1224 | 1263 |
1225 GLenum src_targets[] = {GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_2D}; | 1264 GLenum src_targets[] = {GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_2D}; |
(...skipping 11 matching lines...) Expand all Loading... |
1237 uint8_t green[1 * 4] = {0u, 255u, 0, 255u}; | 1276 uint8_t green[1 * 4] = {0u, 255u, 0, 255u}; |
1238 uint8_t white[1 * 4] = {255u, 255u, 255u, 255u}; | 1277 uint8_t white[1 * 4] = {255u, 255u, 255u, 255u}; |
1239 uint8_t grey[1 * 4] = {199u, 199u, 199u, 255u}; | 1278 uint8_t grey[1 * 4] = {199u, 199u, 199u, 255u}; |
1240 | 1279 |
1241 for (size_t src_index = 0; src_index < arraysize(src_targets); src_index++) { | 1280 for (size_t src_index = 0; src_index < arraysize(src_targets); src_index++) { |
1242 GLenum src_target = src_targets[src_index]; | 1281 GLenum src_target = src_targets[src_index]; |
1243 for (size_t dest_index = 0; dest_index < arraysize(dest_targets); | 1282 for (size_t dest_index = 0; dest_index < arraysize(dest_targets); |
1244 dest_index++) { | 1283 dest_index++) { |
1245 GLenum dest_target = dest_targets[dest_index]; | 1284 GLenum dest_target = dest_targets[dest_index]; |
1246 | 1285 |
1247 // SetUp() sets up textures with the wrong parameters for this test, and | |
1248 // TearDown() expects to successfully delete textures/framebuffers, so | |
1249 // this is the right place for the delete/create calls. | |
1250 glDeleteTextures(2, textures_); | |
1251 glDeleteFramebuffers(1, &framebuffer_id_); | |
1252 CreateAndBindDestinationTextureAndFBO(dest_target); | 1286 CreateAndBindDestinationTextureAndFBO(dest_target); |
1253 | 1287 |
1254 // Allocate source and destination textures. | 1288 // Allocate source and destination textures. |
1255 glBindTexture(src_target, textures_[0]); | 1289 glBindTexture(src_target, textures_[0]); |
1256 CreateBackingForTexture(src_target, src_width, src_height); | 1290 CreateBackingForTexture(src_target, src_width, src_height); |
1257 | 1291 |
1258 glBindTexture(dest_target, textures_[1]); | 1292 glBindTexture(dest_target, textures_[1]); |
1259 CreateBackingForTexture(dest_target, dest_width, dest_height); | 1293 CreateBackingForTexture(dest_target, dest_width, dest_height); |
1260 | 1294 |
1261 // The bottom left is red, bottom right is blue, top left is green, top | 1295 // The bottom left is red, bottom right is blue, top left is green, top |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 | 1332 |
1299 uint8_t* expected_color; | 1333 uint8_t* expected_color; |
1300 if (x < copy_region_x + 2) { | 1334 if (x < copy_region_x + 2) { |
1301 expected_color = y < copy_region_y + 1 ? red : green; | 1335 expected_color = y < copy_region_y + 1 ? red : green; |
1302 } else { | 1336 } else { |
1303 expected_color = y < copy_region_y + 1 ? blue : white; | 1337 expected_color = y < copy_region_y + 1 ? blue : white; |
1304 } | 1338 } |
1305 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color); | 1339 GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color); |
1306 } | 1340 } |
1307 } | 1341 } |
| 1342 |
| 1343 glDeleteTextures(2, textures_); |
| 1344 glDeleteFramebuffers(1, &framebuffer_id_); |
1308 } | 1345 } |
1309 } | 1346 } |
1310 } | 1347 } |
1311 | 1348 |
1312 } // namespace gpu | 1349 } // namespace gpu |
OLD | NEW |