OLD | NEW |
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 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2604 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUM) { | 2604 TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUM) { |
2605 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2605 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2606 DoTexImage2D( | 2606 DoTexImage2D( |
2607 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 2607 GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
2608 TextureRef* texture_ref = | 2608 TextureRef* texture_ref = |
2609 group().texture_manager()->GetTexture(client_texture_id_); | 2609 group().texture_manager()->GetTexture(client_texture_id_); |
2610 ASSERT_TRUE(texture_ref != NULL); | 2610 ASSERT_TRUE(texture_ref != NULL); |
2611 Texture* texture = texture_ref->texture(); | 2611 Texture* texture = texture_ref->texture(); |
2612 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 2612 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
2613 | 2613 |
2614 scoped_refptr<gfx::GLImage> image(new gfx::GLImageStub); | 2614 scoped_refptr<gl::GLImage> image(new gl::GLImageStub); |
2615 GetImageManager()->AddImage(image.get(), 1); | 2615 GetImageManager()->AddImage(image.get(), 1); |
2616 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL); | 2616 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL); |
2617 | 2617 |
2618 GLsizei width; | 2618 GLsizei width; |
2619 GLsizei height; | 2619 GLsizei height; |
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)); |
(...skipping 15 matching lines...) Expand all Loading... |
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) == NULL); |
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<gl::GLImage> image(new gl::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<gl::GLImage> image(new gl::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) == 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) == NULL); |
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<gl::GLImage> image(new gl::GLImageStub); |
2685 GetImageManager()->AddImage(image.get(), 1); | 2685 GetImageManager()->AddImage(image.get(), 1); |
2686 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 2686 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
2687 | 2687 |
2688 GLenum target = GL_TEXTURE_2D; | 2688 GLenum target = GL_TEXTURE_2D; |
2689 GLint level = 0; | 2689 GLint level = 0; |
2690 GLint xoffset = 0; | 2690 GLint xoffset = 0; |
2691 GLint yoffset = 0; | 2691 GLint yoffset = 0; |
2692 GLsizei width = 1; | 2692 GLsizei width = 1; |
2693 GLsizei height = 1; | 2693 GLsizei height = 1; |
2694 GLint border = 0; | 2694 GLint border = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
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) == 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<gl::GLImage> image(new gl::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; |
2736 GLint yoffset = 0; | 2736 GLint yoffset = 0; |
2737 GLsizei width = 1; | 2737 GLsizei width = 1; |
2738 GLsizei height = 1; | 2738 GLsizei height = 1; |
2739 GLint border = 0; | 2739 GLint border = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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<gl::GLImage> image(new gl::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)); |
(...skipping 20 matching lines...) Expand all Loading... |
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) == NULL); |
2821 } | 2821 } |
2822 | 2822 |
2823 class MockGLImage : public gfx::GLImage { | 2823 class MockGLImage : public gl::GLImage { |
2824 public: | 2824 public: |
2825 MockGLImage() {} | 2825 MockGLImage() {} |
2826 | 2826 |
2827 // Overridden from gfx::GLImage: | 2827 // Overridden from gl::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_METHOD1(CopyTexImage, bool(unsigned)); |
2834 MOCK_METHOD3(CopyTexSubImage, | 2834 MOCK_METHOD3(CopyTexSubImage, |
2835 bool(unsigned, const gfx::Point&, const gfx::Rect&)); | 2835 bool(unsigned, const gfx::Point&, const gfx::Rect&)); |
2836 MOCK_METHOD5(ScheduleOverlayPlane, bool(gfx::AcceleratedWidget, | 2836 MOCK_METHOD5(ScheduleOverlayPlane, bool(gfx::AcceleratedWidget, |
2837 int, | 2837 int, |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3363 // TODO(gman): CompressedTexSubImage2DImmediate | 3363 // TODO(gman): CompressedTexSubImage2DImmediate |
3364 | 3364 |
3365 // TODO(gman): TexImage2D | 3365 // TODO(gman): TexImage2D |
3366 | 3366 |
3367 // TODO(gman): TexImage2DImmediate | 3367 // TODO(gman): TexImage2DImmediate |
3368 | 3368 |
3369 // TODO(gman): TexSubImage2DImmediate | 3369 // TODO(gman): TexSubImage2DImmediate |
3370 | 3370 |
3371 } // namespace gles2 | 3371 } // namespace gles2 |
3372 } // namespace gpu | 3372 } // namespace gpu |
OLD | NEW |