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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc

Issue 1401423003: Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit tests and avoid unnecessary teximage2d call in decoder Created 5 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" 9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
(...skipping 2609 matching lines...) Expand 10 before | Expand all | Expand 10 after
2620 GLenum type; 2620 GLenum type;
2621 GLenum internal_format; 2621 GLenum internal_format;
2622 2622
2623 EXPECT_TRUE( 2623 EXPECT_TRUE(
2624 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 2624 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
2625 EXPECT_EQ(3, width); 2625 EXPECT_EQ(3, width);
2626 EXPECT_EQ(1, height); 2626 EXPECT_EQ(1, height);
2627 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); 2627 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
2628 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 2628 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
2629 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 2629 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
2630 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2630 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2631 2631
2632 // Bind image to texture. 2632 // Bind image to texture.
2633 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2633 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2634 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 2634 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
2635 EXPECT_TRUE( 2635 EXPECT_TRUE(
2636 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 2636 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
2637 // Image should now be set. 2637 // Image should now be set.
2638 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2638 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2639 2639
2640 // Define new texture image. 2640 // Define new texture image.
2641 DoTexImage2D( 2641 DoTexImage2D(
2642 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 2642 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
2643 EXPECT_TRUE( 2643 EXPECT_TRUE(
2644 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 2644 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
2645 // Image should no longer be set. 2645 // Image should no longer be set.
2646 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2646 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2647 } 2647 }
2648 2648
2649 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) { 2649 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) {
2650 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); 2650 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
2651 GetImageManager()->AddImage(image.get(), 1); 2651 GetImageManager()->AddImage(image.get(), 1);
2652 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId); 2652 DoBindTexture(GL_TEXTURE_CUBE_MAP, client_texture_id_, kServiceTextureId);
2653 2653
2654 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd; 2654 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd;
2655 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1); 2655 bind_tex_image_2d_cmd.Init(GL_TEXTURE_CUBE_MAP, 1);
2656 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd)); 2656 EXPECT_EQ(error::kNoError, ExecuteCmd(bind_tex_image_2d_cmd));
2657 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); 2657 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
2658 } 2658 }
2659 2659
2660 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) { 2660 TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) {
2661 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); 2661 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
2662 GetImageManager()->AddImage(image.get(), 1); 2662 GetImageManager()->AddImage(image.get(), 1);
2663 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 2663 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2664 2664
2665 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 2665 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
2666 2666
2667 TextureRef* texture_ref = 2667 TextureRef* texture_ref =
2668 group().texture_manager()->GetTexture(client_texture_id_); 2668 group().texture_manager()->GetTexture(client_texture_id_);
2669 ASSERT_TRUE(texture_ref != NULL); 2669 ASSERT_TRUE(texture_ref != NULL);
2670 Texture* texture = texture_ref->texture(); 2670 Texture* texture = texture_ref->texture();
2671 2671
2672 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 2672 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
2673 DoTexImage2D( 2673 DoTexImage2D(
2674 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 2674 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
2675 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2675 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2676 } 2676 }
2677 2677
2678 TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) { 2678 TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) {
2679 // Specifically tests that TexSubImage2D is not optimized to TexImage2D 2679 // Specifically tests that TexSubImage2D is not optimized to TexImage2D
2680 // in the presence of image attachments. 2680 // in the presence of image attachments.
2681 ASSERT_FALSE( 2681 ASSERT_FALSE(
2682 feature_info()->workarounds().texsubimage_faster_than_teximage); 2682 feature_info()->workarounds().texsubimage_faster_than_teximage);
2683 2683
2684 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); 2684 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
2685 GetImageManager()->AddImage(image.get(), 1); 2685 GetImageManager()->AddImage(image.get(), 1);
(...skipping 17 matching lines...) Expand all
2703 pixels_shm_id, pixels_shm_offset); 2703 pixels_shm_id, pixels_shm_offset);
2704 2704
2705 // Bind texture to GLImage. 2705 // Bind texture to GLImage.
2706 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 2706 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
2707 2707
2708 // Check binding. 2708 // Check binding.
2709 TextureRef* texture_ref = 2709 TextureRef* texture_ref =
2710 group().texture_manager()->GetTexture(client_texture_id_); 2710 group().texture_manager()->GetTexture(client_texture_id_);
2711 ASSERT_TRUE(texture_ref != NULL); 2711 ASSERT_TRUE(texture_ref != NULL);
2712 Texture* texture = texture_ref->texture(); 2712 Texture* texture = texture_ref->texture();
2713 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 2713 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
2714 2714
2715 // TexSubImage2D should not unbind GLImage. 2715 // TexSubImage2D should not unbind GLImage.
2716 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, 2716 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width,
2717 height, format, type, _)) 2717 height, format, type, _))
2718 .Times(1) 2718 .Times(1)
2719 .RetiresOnSaturation(); 2719 .RetiresOnSaturation();
2720 cmds::TexSubImage2D tex_sub_image_2d_cmd; 2720 cmds::TexSubImage2D tex_sub_image_2d_cmd;
2721 tex_sub_image_2d_cmd.Init(target, level, xoffset, yoffset, width, height, 2721 tex_sub_image_2d_cmd.Init(target, level, xoffset, yoffset, width, height,
2722 format, type, pixels_shm_id, pixels_shm_offset, 2722 format, type, pixels_shm_id, pixels_shm_offset,
2723 internal); 2723 internal);
2724 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd)); 2724 EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd));
2725 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 2725 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
2726 } 2726 }
2727 2727
2728 TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) { 2728 TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) {
2729 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); 2729 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
2730 GetImageManager()->AddImage(image.get(), 1); 2730 GetImageManager()->AddImage(image.get(), 1);
2731 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 2731 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2732 2732
2733 GLenum target = GL_TEXTURE_2D; 2733 GLenum target = GL_TEXTURE_2D;
2734 GLint level = 0; 2734 GLint level = 0;
2735 GLint xoffset = 0; 2735 GLint xoffset = 0;
(...skipping 11 matching lines...) Expand all
2747 pixels_shm_id, pixels_shm_offset); 2747 pixels_shm_id, pixels_shm_offset);
2748 2748
2749 // Bind texture to GLImage. 2749 // Bind texture to GLImage.
2750 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 2750 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
2751 2751
2752 // Check binding. 2752 // Check binding.
2753 TextureRef* texture_ref = 2753 TextureRef* texture_ref =
2754 group().texture_manager()->GetTexture(client_texture_id_); 2754 group().texture_manager()->GetTexture(client_texture_id_);
2755 ASSERT_TRUE(texture_ref != NULL); 2755 ASSERT_TRUE(texture_ref != NULL);
2756 Texture* texture = texture_ref->texture(); 2756 Texture* texture = texture_ref->texture();
2757 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 2757 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
2758 2758
2759 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage. 2759 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage.
2760 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) 2760 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
2761 .Times(2) 2761 .Times(2)
2762 .RetiresOnSaturation(); 2762 .RetiresOnSaturation();
2763 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width, 2763 EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width,
2764 height, format, type, _)) 2764 height, format, type, _))
2765 .Times(1) 2765 .Times(1)
2766 .RetiresOnSaturation(); 2766 .RetiresOnSaturation();
2767 GetDecoder()->ClearLevel(texture, target, level, format, type, 0, 0, width, 2767 GetDecoder()->ClearLevel(texture, target, level, format, type, 0, 0, width,
2768 height); 2768 height);
2769 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get()); 2769 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
2770 } 2770 }
2771 2771
2772 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) { 2772 TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
2773 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 2773 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2774 DoTexImage2D( 2774 DoTexImage2D(
2775 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); 2775 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
2776 TextureRef* texture_ref = 2776 TextureRef* texture_ref =
2777 group().texture_manager()->GetTexture(client_texture_id_); 2777 group().texture_manager()->GetTexture(client_texture_id_);
2778 ASSERT_TRUE(texture_ref != NULL); 2778 ASSERT_TRUE(texture_ref != NULL);
2779 Texture* texture = texture_ref->texture(); 2779 Texture* texture = texture_ref->texture();
2780 EXPECT_EQ(kServiceTextureId, texture->service_id()); 2780 EXPECT_EQ(kServiceTextureId, texture->service_id());
2781 2781
2782 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); 2782 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub);
2783 GetImageManager()->AddImage(image.get(), 1); 2783 GetImageManager()->AddImage(image.get(), 1);
2784 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL); 2784 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL);
2785 2785
2786 GLsizei width; 2786 GLsizei width;
2787 GLsizei height; 2787 GLsizei height;
2788 GLenum type; 2788 GLenum type;
2789 GLenum internal_format; 2789 GLenum internal_format;
2790 2790
2791 EXPECT_TRUE( 2791 EXPECT_TRUE(
2792 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 2792 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
2793 EXPECT_EQ(3, width); 2793 EXPECT_EQ(3, width);
2794 EXPECT_EQ(1, height); 2794 EXPECT_EQ(1, height);
2795 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); 2795 EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
2796 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); 2796 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
2797 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); 2797 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
2798 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2798 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2799 2799
2800 // Bind image to texture. 2800 // Bind image to texture.
2801 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2801 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2802 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1); 2802 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, 1);
2803 EXPECT_TRUE( 2803 EXPECT_TRUE(
2804 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 2804 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
2805 // Image should now be set. 2805 // Image should now be set.
2806 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2806 EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2807 2807
2808 // Release image from texture. 2808 // Release image from texture.
2809 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2809 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2810 EXPECT_CALL(*gl_, GetError()) 2810 EXPECT_CALL(*gl_, GetError())
2811 .WillOnce(Return(GL_NO_ERROR)) 2811 .WillOnce(Return(GL_NO_ERROR))
2812 .WillOnce(Return(GL_NO_ERROR)) 2812 .WillOnce(Return(GL_NO_ERROR))
2813 .RetiresOnSaturation(); 2813 .RetiresOnSaturation();
2814 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; 2814 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd;
2815 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1); 2815 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, 1);
2816 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); 2816 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd));
2817 EXPECT_TRUE( 2817 EXPECT_TRUE(
2818 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr)); 2818 texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
2819 // Image should no longer be set. 2819 // Image should no longer be set.
2820 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL); 2820 EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
2821 } 2821 }
2822 2822
2823 class MockGLImage : public gfx::GLImage { 2823 class MockGLImage : public gfx::GLImage {
2824 public: 2824 public:
2825 MockGLImage() {} 2825 MockGLImage() {}
2826 2826
2827 // Overridden from gfx::GLImage: 2827 // Overridden from gfx::GLImage:
2828 MOCK_METHOD0(GetSize, gfx::Size()); 2828 MOCK_METHOD0(GetSize, gfx::Size());
2829 MOCK_METHOD0(GetInternalFormat, unsigned()); 2829 MOCK_METHOD0(GetInternalFormat, unsigned());
2830 MOCK_METHOD1(Destroy, void(bool)); 2830 MOCK_METHOD1(Destroy, void(bool));
2831 MOCK_METHOD1(BindTexImage, bool(unsigned)); 2831 MOCK_METHOD1(BindTexImage, bool(unsigned));
2832 MOCK_METHOD1(ReleaseTexImage, void(unsigned)); 2832 MOCK_METHOD1(ReleaseTexImage, void(unsigned));
2833 MOCK_METHOD1(CopyTexImage, bool(unsigned));
2833 MOCK_METHOD3(CopyTexSubImage, 2834 MOCK_METHOD3(CopyTexSubImage,
2834 bool(unsigned, const gfx::Point&, const gfx::Rect&)); 2835 bool(unsigned, const gfx::Point&, const gfx::Rect&));
2835 MOCK_METHOD0(WillUseTexImage, void());
2836 MOCK_METHOD0(DidUseTexImage, void());
2837 MOCK_METHOD0(WillModifyTexImage, void());
2838 MOCK_METHOD0(DidModifyTexImage, void());
2839 MOCK_METHOD5(ScheduleOverlayPlane, bool(gfx::AcceleratedWidget, 2836 MOCK_METHOD5(ScheduleOverlayPlane, bool(gfx::AcceleratedWidget,
2840 int, 2837 int,
2841 gfx::OverlayTransform, 2838 gfx::OverlayTransform,
2842 const gfx::Rect&, 2839 const gfx::Rect&,
2843 const gfx::RectF&)); 2840 const gfx::RectF&));
2844 MOCK_METHOD3(OnMemoryDump, 2841 MOCK_METHOD3(OnMemoryDump,
2845 void(base::trace_event::ProcessMemoryDump*, 2842 void(base::trace_event::ProcessMemoryDump*,
2846 uint64_t, 2843 uint64_t,
2847 const std::string&)); 2844 const std::string&));
2848 2845
2849 protected: 2846 protected:
2850 virtual ~MockGLImage() {} 2847 virtual ~MockGLImage() {}
2851 }; 2848 };
2852 2849
2853 TEST_P(GLES2DecoderWithShaderTest, UseTexImage) { 2850 TEST_P(GLES2DecoderWithShaderTest, CopyTexImage) {
2854 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); 2851 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2855 DoTexImage2D(GL_TEXTURE_2D, 2852 DoTexImage2D(GL_TEXTURE_2D,
2856 0, 2853 0,
2857 GL_RGBA, 2854 GL_RGBA,
2858 1, 2855 1,
2859 1, 2856 1,
2860 0, 2857 0,
2861 GL_RGBA, 2858 GL_RGBA,
2862 GL_UNSIGNED_BYTE, 2859 GL_UNSIGNED_BYTE,
2863 kSharedMemoryId, 2860 kSharedMemoryId,
2864 kSharedMemoryOffset); 2861 kSharedMemoryOffset);
2865 2862
2866 TextureRef* texture_ref = 2863 TextureRef* texture_ref =
2867 group().texture_manager()->GetTexture(client_texture_id_); 2864 group().texture_manager()->GetTexture(client_texture_id_);
2868 ASSERT_TRUE(texture_ref != NULL); 2865 ASSERT_TRUE(texture_ref != NULL);
2869 Texture* texture = texture_ref->texture(); 2866 Texture* texture = texture_ref->texture();
2870 EXPECT_EQ(kServiceTextureId, texture->service_id()); 2867 EXPECT_EQ(kServiceTextureId, texture->service_id());
2871 2868
2872 const int32 kImageId = 1; 2869 const int32 kImageId = 1;
2873 scoped_refptr<MockGLImage> image(new MockGLImage); 2870 scoped_refptr<MockGLImage> image(new MockGLImage);
2874 GetImageManager()->AddImage(image.get(), kImageId); 2871 GetImageManager()->AddImage(image.get(), kImageId);
2875 2872
2876 // Bind image to texture. 2873 // Bind image to texture.
2877 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) 2874 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D))
2878 .Times(1) 2875 .Times(1)
2879 .WillOnce(Return(true)) 2876 .WillOnce(Return(false))
2880 .RetiresOnSaturation(); 2877 .RetiresOnSaturation();
2881 EXPECT_CALL(*image.get(), GetSize()) 2878 EXPECT_CALL(*image.get(), GetSize())
2882 .Times(1) 2879 .Times(1)
2883 .WillOnce(Return(gfx::Size(1, 1))) 2880 .WillOnce(Return(gfx::Size(1, 1)))
2884 .RetiresOnSaturation(); 2881 .RetiresOnSaturation();
2882 EXPECT_CALL(*image.get(), GetInternalFormat())
2883 .Times(1)
2884 .WillOnce(Return(GL_RGBA))
2885 .RetiresOnSaturation();
2885 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2886 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2886 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId); 2887 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId);
2887 2888
2888 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); 2889 AddExpectationsForSimulatedAttrib0(kNumVertices, 0);
2889 SetupExpectationsForApplyingDefaultDirtyState(); 2890 SetupExpectationsForApplyingDefaultDirtyState();
2890 2891
2891 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2892 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2892 EXPECT_CALL(*gl_, GetError()) 2893 EXPECT_CALL(*gl_, GetError())
2893 .WillOnce(Return(GL_NO_ERROR)) 2894 .WillOnce(Return(GL_NO_ERROR))
2894 .WillOnce(Return(GL_NO_ERROR)) 2895 .WillOnce(Return(GL_NO_ERROR))
2895 .WillOnce(Return(GL_NO_ERROR))
2896 .WillOnce(Return(GL_NO_ERROR))
2897 .RetiresOnSaturation(); 2896 .RetiresOnSaturation();
2898 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(3).RetiresOnSaturation(); 2897 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(2).RetiresOnSaturation();
2899 EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation(); 2898 EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D))
2900 EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation(); 2899 .Times(1)
2900 .WillOnce(Return(true))
2901 .RetiresOnSaturation();
2901 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 2902 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
2902 .Times(1) 2903 .Times(1)
2903 .RetiresOnSaturation(); 2904 .RetiresOnSaturation();
2904 DrawArrays cmd; 2905 DrawArrays cmd;
2905 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 2906 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
2906 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2907 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2908 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2908 2909
2910 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
2911 // Re-bind image to texture.
2912 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd;
2913 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId);
2914 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd));
2915 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D))
2916 .Times(1)
2917 .WillOnce(Return(false))
2918 .RetiresOnSaturation();
2919 EXPECT_CALL(*image.get(), GetSize())
2920 .Times(1)
2921 .WillOnce(Return(gfx::Size(1, 1)))
2922 .RetiresOnSaturation();
2923 EXPECT_CALL(*image.get(), GetInternalFormat())
2924 .Times(1)
2925 .WillOnce(Return(GL_RGBA))
2926 .RetiresOnSaturation();
2927 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId);
2928
2909 DoBindFramebuffer( 2929 DoBindFramebuffer(
2910 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); 2930 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
2911 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2931 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2912 EXPECT_CALL(*gl_, GetError()) 2932 EXPECT_CALL(*gl_, GetError())
2913 .WillOnce(Return(GL_NO_ERROR)) 2933 .WillOnce(Return(GL_NO_ERROR))
2914 .WillOnce(Return(GL_NO_ERROR)) 2934 .WillOnce(Return(GL_NO_ERROR))
2915 .RetiresOnSaturation(); 2935 .RetiresOnSaturation();
2916 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); 2936 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
2917 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) 2937 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
2918 .Times(2) 2938 .Times(2)
2919 .RetiresOnSaturation(); 2939 .RetiresOnSaturation();
2920 // Image will be 'in use' as long as bound to a framebuffer. 2940 EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D))
2921 EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation(); 2941 .Times(1)
2942 .WillOnce(Return(true))
2943 .RetiresOnSaturation();
2922 EXPECT_CALL(*gl_, 2944 EXPECT_CALL(*gl_,
2923 FramebufferTexture2DEXT(GL_FRAMEBUFFER, 2945 FramebufferTexture2DEXT(GL_FRAMEBUFFER,
2924 GL_COLOR_ATTACHMENT0, 2946 GL_COLOR_ATTACHMENT0,
2925 GL_TEXTURE_2D, 2947 GL_TEXTURE_2D,
2926 kServiceTextureId, 2948 kServiceTextureId,
2927 0)) 2949 0))
2928 .Times(1) 2950 .Times(1)
2929 .RetiresOnSaturation(); 2951 .RetiresOnSaturation();
2930 EXPECT_CALL(*gl_, GetError()) 2952 EXPECT_CALL(*gl_, GetError())
2931 .WillOnce(Return(GL_NO_ERROR)) 2953 .WillOnce(Return(GL_NO_ERROR))
2932 .WillOnce(Return(GL_NO_ERROR)) 2954 .WillOnce(Return(GL_NO_ERROR))
2933 .RetiresOnSaturation(); 2955 .RetiresOnSaturation();
2934 FramebufferTexture2D fbtex_cmd; 2956 FramebufferTexture2D fbtex_cmd;
2935 fbtex_cmd.Init(GL_FRAMEBUFFER, 2957 fbtex_cmd.Init(GL_FRAMEBUFFER,
2936 GL_COLOR_ATTACHMENT0, 2958 GL_COLOR_ATTACHMENT0,
2937 GL_TEXTURE_2D, 2959 GL_TEXTURE_2D,
2938 client_texture_id_); 2960 client_texture_id_);
2939 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd)); 2961 EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd));
2940 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2962 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2941 2963
2942 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. 2964 EXPECT_CALL(*image.get(), Destroy(true)).Times(1).RetiresOnSaturation();
2943 EXPECT_CALL(*gl_, GetError()) 2965 image = nullptr;
2944 .WillOnce(Return(GL_NO_ERROR))
2945 .WillOnce(Return(GL_NO_ERROR))
2946 .RetiresOnSaturation();
2947 EXPECT_CALL(*gl_,
2948 FramebufferRenderbufferEXT(GL_FRAMEBUFFER,
2949 GL_COLOR_ATTACHMENT0,
2950 GL_RENDERBUFFER,
2951 kServiceRenderbufferId))
2952 .Times(1)
2953 .RetiresOnSaturation();
2954 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
2955 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
2956 .Times(2)
2957 .RetiresOnSaturation();
2958 // Image should no longer be 'in use' after being unbound from framebuffer.
2959 EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
2960 EXPECT_CALL(*gl_, GetError())
2961 .WillOnce(Return(GL_NO_ERROR))
2962 .WillOnce(Return(GL_NO_ERROR))
2963 .RetiresOnSaturation();
2964 FramebufferRenderbuffer fbrb_cmd;
2965 fbrb_cmd.Init(GL_FRAMEBUFFER,
2966 GL_COLOR_ATTACHMENT0,
2967 GL_RENDERBUFFER,
2968 client_renderbuffer_id_);
2969 EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd));
2970 } 2966 }
2971 2967
2972 TEST_P(GLES2DecoderManualInitTest, DrawWithGLImageExternal) { 2968 TEST_P(GLES2DecoderManualInitTest, DrawWithGLImageExternal) {
2973 InitState init; 2969 InitState init;
2974 init.extensions = "GL_OES_EGL_image_external"; 2970 init.extensions = "GL_OES_EGL_image_external";
2975 init.gl_version = "opengl es 2.0"; 2971 init.gl_version = "opengl es 2.0";
2976 init.has_alpha = true; 2972 init.has_alpha = true;
2977 init.has_depth = true; 2973 init.has_depth = true;
2978 init.request_alpha = true; 2974 init.request_alpha = true;
2979 init.request_depth = true; 2975 init.request_depth = true;
2980 init.bind_generates_resource = true; 2976 init.bind_generates_resource = true;
2981 InitDecoder(init); 2977 InitDecoder(init);
2982 2978
2983 TextureRef* texture_ref = GetTexture(client_texture_id_); 2979 TextureRef* texture_ref = GetTexture(client_texture_id_);
2984 scoped_refptr<MockGLImage> image(new MockGLImage); 2980 scoped_refptr<MockGLImage> image(new MockGLImage);
2985 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES); 2981 group().texture_manager()->SetTarget(texture_ref, GL_TEXTURE_EXTERNAL_OES);
2986 group().texture_manager()->SetLevelInfo(texture_ref, GL_TEXTURE_EXTERNAL_OES, 2982 group().texture_manager()->SetLevelInfo(texture_ref, GL_TEXTURE_EXTERNAL_OES,
2987 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA, 2983 0, GL_RGBA, 0, 0, 1, 0, GL_RGBA,
2988 GL_UNSIGNED_BYTE, gfx::Rect()); 2984 GL_UNSIGNED_BYTE, gfx::Rect());
2989 group().texture_manager()->SetLevelImage( 2985 group().texture_manager()->SetLevelImage(texture_ref, GL_TEXTURE_EXTERNAL_OES,
2990 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image.get()); 2986 0, image.get(), Texture::BOUND);
2991 2987
2992 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); 2988 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
2993 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2989 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2994 2990
2995 SetupSamplerExternalProgram(); 2991 SetupSamplerExternalProgram();
2996 SetupIndexBuffer(); 2992 SetupIndexBuffer();
2997 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); 2993 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0);
2998 SetupExpectationsForApplyingDefaultDirtyState(); 2994 SetupExpectationsForApplyingDefaultDirtyState();
2999 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); 2995 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref));
3000 2996
3001 InSequence s; 2997 InSequence s;
3002 EXPECT_CALL(*gl_, GetError())
3003 .WillOnce(Return(GL_NO_ERROR))
3004 .RetiresOnSaturation();
3005 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
3006 EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
3007 EXPECT_CALL(*gl_, GetError())
3008 .WillOnce(Return(GL_NO_ERROR))
3009 .RetiresOnSaturation();
3010 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(1); 2998 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(1);
3011 EXPECT_CALL(*gl_, GetError())
3012 .WillOnce(Return(GL_NO_ERROR))
3013 .RetiresOnSaturation();
3014 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
3015 EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
3016 EXPECT_CALL(*gl_, GetError())
3017 .WillOnce(Return(GL_NO_ERROR))
3018 .RetiresOnSaturation();
3019 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
3020 DrawElements cmd; 2999 DrawElements cmd;
3021 cmd.Init(GL_TRIANGLES, 3000 cmd.Init(GL_TRIANGLES,
3022 kValidIndexRangeCount, 3001 kValidIndexRangeCount,
3023 GL_UNSIGNED_SHORT, 3002 GL_UNSIGNED_SHORT,
3024 kValidIndexRangeStart * 2); 3003 kValidIndexRangeStart * 2);
3025 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 3004 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
3026 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 3005 EXPECT_EQ(GL_NO_ERROR, GetGLError());
3027 } 3006 }
3028 3007
3029 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES2) { 3008 TEST_P(GLES2DecoderManualInitTest, TexImage2DFloatOnGLES2) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 // TODO(gman): CompressedTexSubImage2DImmediate 3363 // TODO(gman): CompressedTexSubImage2DImmediate
3385 3364
3386 // TODO(gman): TexImage2D 3365 // TODO(gman): TexImage2D
3387 3366
3388 // TODO(gman): TexImage2DImmediate 3367 // TODO(gman): TexImage2DImmediate
3389 3368
3390 // TODO(gman): TexSubImage2DImmediate 3369 // TODO(gman): TexSubImage2DImmediate
3391 3370
3392 } // namespace gles2 3371 } // namespace gles2
3393 } // namespace gpu 3372 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698