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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
10 #include "gpu/command_buffer/common/id_allocator.h" | 10 #include "gpu/command_buffer/common/id_allocator.h" |
11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" | 11 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h" |
12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" | 12 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h" |
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" | 13 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h" |
14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 14 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
15 #include "gpu/command_buffer/service/context_group.h" | 15 #include "gpu/command_buffer/service/context_group.h" |
16 #include "gpu/command_buffer/service/gl_surface_mock.h" | 16 #include "gpu/command_buffer/service/gl_surface_mock.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
18 #include "gpu/command_buffer/service/image_manager.h" | 18 #include "gpu/command_buffer/service/image_manager.h" |
19 #include "gpu/command_buffer/service/mailbox_manager.h" | 19 #include "gpu/command_buffer/service/mailbox_manager.h" |
20 #include "gpu/command_buffer/service/mocks.h" | 20 #include "gpu/command_buffer/service/mocks.h" |
21 #include "gpu/command_buffer/service/program_manager.h" | 21 #include "gpu/command_buffer/service/program_manager.h" |
22 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" | |
23 #include "gpu/command_buffer/service/stream_texture_mock.h" | |
24 #include "gpu/command_buffer/service/test_helper.h" | |
25 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 #include "ui/gl/gl_image_mock.h" |
26 #include "ui/gl/gl_implementation.h" | 24 #include "ui/gl/gl_implementation.h" |
27 #include "ui/gl/gl_mock.h" | 25 #include "ui/gl/gl_mock.h" |
28 #include "ui/gl/gl_surface_stub.h" | 26 #include "ui/gl/gl_surface_stub.h" |
29 | 27 |
30 | 28 |
31 #if !defined(GL_DEPTH24_STENCIL8) | 29 #if !defined(GL_DEPTH24_STENCIL8) |
32 #define GL_DEPTH24_STENCIL8 0x88F0 | 30 #define GL_DEPTH24_STENCIL8 0x88F0 |
33 #endif | 31 #endif |
34 | 32 |
35 using ::gfx::MockGLInterface; | 33 using ::gfx::MockGLInterface; |
(...skipping 5588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5624 | 5622 |
5625 BindFramebuffer cmd3; | 5623 BindFramebuffer cmd3; |
5626 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); | 5624 cmd3.Init(GL_FRAMEBUFFER, kInvalidClientId); |
5627 EXPECT_NE(error::kNoError, ExecuteCmd(cmd3)); | 5625 EXPECT_NE(error::kNoError, ExecuteCmd(cmd3)); |
5628 | 5626 |
5629 BindRenderbuffer cmd4; | 5627 BindRenderbuffer cmd4; |
5630 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); | 5628 cmd4.Init(GL_RENDERBUFFER, kInvalidClientId); |
5631 EXPECT_NE(error::kNoError, ExecuteCmd(cmd4)); | 5629 EXPECT_NE(error::kNoError, ExecuteCmd(cmd4)); |
5632 } | 5630 } |
5633 | 5631 |
5634 TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUM) { | 5632 class GLES2StreamTextureTest : public GLES2DecoderManualInitTest { |
5635 const GLuint kObjectId = 123; | 5633 public: |
5636 InitDecoder( | 5634 GLES2StreamTextureTest() { } |
5637 "GL_CHROMIUM_stream_texture", // extensions | |
5638 false, // has alpha | |
5639 false, // has depth | |
5640 false, // has stencil | |
5641 false, // request alpha | |
5642 false, // request depth | |
5643 false, // request stencil | |
5644 true); // bind generates resource | |
5645 | 5635 |
5646 EXPECT_CALL(*stream_texture_manager(), CreateStreamTexture( | 5636 virtual void SetUp() { |
5647 kServiceTextureId, client_texture_id_)) | 5637 InitDecoder( |
5648 .WillOnce(Return(kObjectId)) | 5638 "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions |
5649 .RetiresOnSaturation(); | 5639 true, // has alpha |
| 5640 true, // has depth |
| 5641 false, // has stencil |
| 5642 true, // request alpha |
| 5643 true, // request depth |
| 5644 false, // request stencil |
| 5645 true); // bind generates resource |
| 5646 } |
5650 | 5647 |
5651 CreateStreamTextureCHROMIUM cmd; | 5648 protected: |
5652 CreateStreamTextureCHROMIUM::Result* result = | 5649 void CreateAndBindTexImage(GLuint client_texture_id, |
5653 static_cast<CreateStreamTextureCHROMIUM::Result*>(shared_memory_address_); | 5650 GLuint service_texture_id) { |
5654 cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | 5651 TextureRef* texture_ref = GetTexture(client_texture_id); |
5655 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 5652 DoBindTexture( |
5656 EXPECT_EQ(kObjectId, *result); | 5653 GL_TEXTURE_EXTERNAL_OES, client_texture_id, service_texture_id); |
| 5654 scoped_refptr<gfx::GLImage> image = new gfx::GLImageStub; |
| 5655 group().texture_manager()->SetLevelInfo(texture_ref, |
| 5656 GL_TEXTURE_EXTERNAL_OES, |
| 5657 0, |
| 5658 GL_RGBA, |
| 5659 0, |
| 5660 0, |
| 5661 1, |
| 5662 0, |
| 5663 GL_RGBA, |
| 5664 GL_UNSIGNED_BYTE, |
| 5665 true); |
| 5666 group().texture_manager()->SetLevelImage( |
| 5667 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image); |
| 5668 } |
| 5669 |
| 5670 GLuint AddImage(Texture* texture) { |
| 5671 GLuint image_id = GetIdAllocator(id_namespaces::kImages)->AllocateID(); |
| 5672 scoped_refptr<gfx::GLImage> image = |
| 5673 texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0); |
| 5674 EXPECT_TRUE(image != NULL); |
| 5675 group().image_manager()->AddImage(image, image_id); |
| 5676 return image_id; |
| 5677 } |
| 5678 |
| 5679 GLuint DoCreateStreamTexture(GLuint client_texture_id) { |
| 5680 CreateStreamTextureCHROMIUM cmd; |
| 5681 CreateStreamTextureCHROMIUM::Result* result = |
| 5682 static_cast<CreateStreamTextureCHROMIUM::Result*>( |
| 5683 shared_memory_address_); |
| 5684 cmd.Init(client_texture_id, shared_memory_id_, shared_memory_offset_); |
| 5685 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5686 return *result; |
| 5687 } |
| 5688 |
| 5689 scoped_refptr<gfx::GLImage> LookupImage(int32 image_id) { |
| 5690 return group().image_manager()->LookupImage(image_id); |
| 5691 } |
| 5692 }; |
| 5693 |
| 5694 TEST_F(GLES2StreamTextureTest, CreateStreamTextureCHROMIUM) { |
| 5695 GLuint image_id = DoCreateStreamTexture(client_texture_id_); |
5657 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5696 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5697 |
5658 TextureRef* texture_ref = GetTexture(client_texture_id_); | 5698 TextureRef* texture_ref = GetTexture(client_texture_id_); |
5659 EXPECT_TRUE(texture_ref != NULL); | 5699 EXPECT_TRUE(texture_ref != NULL); |
5660 EXPECT_TRUE(texture_ref->texture()->IsStreamTexture()); | 5700 EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), |
5661 EXPECT_CALL(*stream_texture_manager(), | 5701 texture_ref->texture()->target()); |
5662 DestroyStreamTexture(kServiceTextureId)) | 5702 EXPECT_NE(0U, image_id); |
5663 .Times(1) | 5703 |
5664 .RetiresOnSaturation(); | 5704 scoped_refptr<gfx::GLImage> attached_image = |
| 5705 texture_ref->texture()->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0); |
| 5706 scoped_refptr<gfx::GLImage> image = LookupImage(image_id); |
| 5707 EXPECT_TRUE(image.get() != NULL); |
| 5708 EXPECT_EQ(image.get(), attached_image.get()); |
5665 } | 5709 } |
5666 | 5710 |
5667 TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUMBadId) { | 5711 TEST_F(GLES2StreamTextureTest, CreateStreamTextureCHROMIUMBadTextureId) { |
5668 InitDecoder( | 5712 GLuint image_id = DoCreateStreamTexture(kNewClientId); |
5669 "GL_CHROMIUM_stream_texture", // extensions | 5713 EXPECT_EQ(0U, image_id); |
5670 false, // has alpha | |
5671 false, // has depth | |
5672 false, // has stencil | |
5673 false, // request alpha | |
5674 false, // request depth | |
5675 false, // request stencil | |
5676 true); // bind generates resource | |
5677 | |
5678 CreateStreamTextureCHROMIUM cmd; | |
5679 CreateStreamTextureCHROMIUM::Result* result = | |
5680 static_cast<CreateStreamTextureCHROMIUM::Result*>(shared_memory_address_); | |
5681 cmd.Init(kNewClientId, shared_memory_id_, shared_memory_offset_); | |
5682 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
5683 EXPECT_EQ(static_cast<GLuint>(GL_ZERO), *result); | |
5684 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 5714 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
5685 } | 5715 } |
5686 | 5716 |
5687 TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUMAlreadyBound) { | 5717 TEST_F(GLES2StreamTextureTest, CreateStreamTextureCHROMIUMAlreadyBound2D) { |
5688 InitDecoder( | |
5689 "GL_CHROMIUM_stream_texture", // extensions | |
5690 false, // has alpha | |
5691 false, // has depth | |
5692 false, // has stencil | |
5693 false, // request alpha | |
5694 false, // request depth | |
5695 false, // request stencil | |
5696 true); // bind generates resource | |
5697 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 5718 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
5698 | 5719 |
5699 CreateStreamTextureCHROMIUM cmd; | 5720 // Cannot create stream from a texture that's already bound to an incompatible |
5700 CreateStreamTextureCHROMIUM::Result* result = | 5721 // target (not bound to GL_TEXTURE_EXTERNAL_OES). |
5701 static_cast<CreateStreamTextureCHROMIUM::Result*>(shared_memory_address_); | 5722 GLuint image_id = DoCreateStreamTexture(client_texture_id_); |
5702 cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | 5723 EXPECT_EQ(0U, image_id); |
5703 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
5704 EXPECT_EQ(static_cast<GLuint>(GL_ZERO), *result); | |
5705 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 5724 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
5706 } | 5725 } |
5707 | 5726 |
5708 TEST_F(GLES2DecoderManualInitTest, CreateStreamTextureCHROMIUMAlreadySet) { | 5727 TEST_F(GLES2StreamTextureTest, |
5709 InitDecoder( | 5728 CreateStreamTextureCHROMIUMAlreadyBoundExternal) { |
5710 "GL_CHROMIUM_stream_texture", // extensions | 5729 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
5711 false, // has alpha | |
5712 false, // has depth | |
5713 false, // has stencil | |
5714 false, // request alpha | |
5715 false, // request depth | |
5716 false, // request stencil | |
5717 true); // bind generates resource | |
5718 | 5730 |
5719 TextureRef* texture_ref = GetTexture(client_texture_id_); | 5731 GLuint image_id = DoCreateStreamTexture(client_texture_id_); |
5720 group().texture_manager()->SetStreamTexture(texture_ref, true); | 5732 EXPECT_NE(0U, image_id); |
5721 | 5733 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5722 CreateStreamTextureCHROMIUM cmd; | |
5723 cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | |
5724 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
5725 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
5726 | |
5727 EXPECT_CALL(*stream_texture_manager(), | |
5728 DestroyStreamTexture(kServiceTextureId)) | |
5729 .Times(1) | |
5730 .RetiresOnSaturation(); | |
5731 } | 5734 } |
5732 | 5735 |
5733 TEST_F(GLES2DecoderManualInitTest, DrawStreamTextureCHROMIUM) { | |
5734 InitDecoder( | |
5735 "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions | |
5736 true, // has alpha | |
5737 true, // has depth | |
5738 false, // has stencil | |
5739 true, // request alpha | |
5740 true, // request depth | |
5741 false, // request stencil | |
5742 true); // bind generates resource | |
5743 | 5736 |
5744 StrictMock<MockStreamTexture> stream_texture; | 5737 TEST_F(GLES2StreamTextureTest, ReCreateStreamTextureCHROMIUM) { |
| 5738 CreateAndBindTexImage(client_texture_id_, kServiceTextureId); |
| 5739 Texture* texture = GetTexture(client_texture_id_)->texture(); |
| 5740 GLuint image_id = AddImage(texture); |
5745 | 5741 |
| 5742 scoped_refptr<gfx::GLImage> old_image(LookupImage(image_id)); |
| 5743 EXPECT_TRUE(old_image.get() != NULL); |
| 5744 |
| 5745 DestroyStreamTextureCHROMIUM cmd; |
| 5746 cmd.Init(image_id); |
| 5747 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5748 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5749 |
| 5750 image_id = DoCreateStreamTexture(client_texture_id_); |
| 5751 EXPECT_NE(0U, image_id); |
| 5752 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5753 |
| 5754 scoped_refptr<gfx::GLImage> new_image(LookupImage(image_id)); |
| 5755 EXPECT_TRUE(new_image != NULL); |
| 5756 EXPECT_EQ(new_image.get(), |
| 5757 texture->GetLevelImage(GL_TEXTURE_EXTERNAL_OES, 0)); |
| 5758 EXPECT_NE(old_image.get(), new_image.get()); |
| 5759 } |
| 5760 |
| 5761 TEST_F(GLES2StreamTextureTest, DrawStreamTextureCHROMIUM) { |
| 5762 scoped_refptr<gfx::GLImageMock> mock_image(new StrictMock<gfx::GLImageMock>); |
5746 TextureRef* texture_ref = GetTexture(client_texture_id_); | 5763 TextureRef* texture_ref = GetTexture(client_texture_id_); |
5747 group().texture_manager()->SetStreamTexture(texture_ref, true); | |
5748 | |
5749 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | 5764 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); |
5750 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5765 group().texture_manager()->SetLevelInfo(texture_ref, |
| 5766 GL_TEXTURE_EXTERNAL_OES, |
| 5767 0, |
| 5768 GL_RGBA, |
| 5769 0, |
| 5770 0, |
| 5771 1, |
| 5772 0, |
| 5773 GL_RGBA, |
| 5774 GL_UNSIGNED_BYTE, |
| 5775 true); |
| 5776 group().texture_manager()->SetLevelImage( |
| 5777 texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, mock_image); |
5751 | 5778 |
5752 SetupSamplerExternalProgram(); | 5779 SetupSamplerExternalProgram(); |
5753 SetupIndexBuffer(); | 5780 SetupIndexBuffer(); |
5754 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); | 5781 AddExpectationsForSimulatedAttrib0(kMaxValidIndex + 1, 0); |
5755 SetupExpectationsForApplyingDefaultDirtyState(); | 5782 SetupExpectationsForApplyingDefaultDirtyState(); |
5756 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); | 5783 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref)); |
5757 | 5784 |
5758 InSequence s; | 5785 InSequence s; |
5759 EXPECT_CALL(*stream_texture_manager(), LookupStreamTexture(kServiceTextureId)) | 5786 EXPECT_CALL(*mock_image, WillUseTexImage()) |
5760 .WillOnce(Return(&stream_texture)) | |
5761 .RetiresOnSaturation(); | |
5762 EXPECT_CALL(stream_texture, Update()) | |
5763 .Times(1) | 5787 .Times(1) |
5764 .RetiresOnSaturation(); | 5788 .RetiresOnSaturation(); |
5765 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) | 5789 EXPECT_CALL(*gl_, DrawElements(_, _, _, _)) |
5766 .Times(1); | 5790 .Times(1); |
5767 DrawElements cmd; | 5791 DrawElements cmd; |
5768 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, | 5792 cmd.Init(GL_TRIANGLES, kValidIndexRangeCount, GL_UNSIGNED_SHORT, |
5769 kValidIndexRangeStart * 2); | 5793 kValidIndexRangeStart * 2); |
5770 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 5794 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
5771 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5795 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5772 | |
5773 EXPECT_CALL(*stream_texture_manager(), | |
5774 DestroyStreamTexture(kServiceTextureId)) | |
5775 .Times(1) | |
5776 .RetiresOnSaturation(); | |
5777 } | 5796 } |
5778 | 5797 |
5779 TEST_F(GLES2DecoderManualInitTest, BindStreamTextureCHROMIUMInvalid) { | 5798 TEST_F(GLES2StreamTextureTest, DestroyStreamTextureCHROMIUM) { |
5780 InitDecoder( | 5799 CreateAndBindTexImage(client_texture_id_, kServiceTextureId); |
5781 "GL_CHROMIUM_stream_texture", // extensions | 5800 Texture* texture = GetTexture(client_texture_id_)->texture(); |
5782 false, // has alpha | 5801 const GLuint image_id = AddImage(texture); |
5783 false, // has depth | |
5784 false, // has stencil | |
5785 false, // request alpha | |
5786 false, // request depth | |
5787 false, // request stencil | |
5788 true); // bind generates resource | |
5789 | 5802 |
5790 TextureRef* texture_ref = GetTexture(client_texture_id_); | 5803 DestroyStreamTextureCHROMIUM cmd; |
5791 group().texture_manager()->SetStreamTexture(texture_ref, true); | 5804 cmd.Init(image_id); |
5792 | |
5793 BindTexture cmd; | |
5794 cmd.Init(GL_TEXTURE_2D, client_texture_id_); | |
5795 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 5805 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
5796 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 5806 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
5797 | 5807 EXPECT_TRUE(LookupImage(image_id) == NULL); |
5798 BindTexture cmd2; | |
5799 cmd2.Init(GL_TEXTURE_CUBE_MAP, client_texture_id_); | |
5800 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
5801 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | |
5802 | |
5803 EXPECT_CALL(*stream_texture_manager(), | |
5804 DestroyStreamTexture(kServiceTextureId)) | |
5805 .Times(1) | |
5806 .RetiresOnSaturation(); | |
5807 } | 5808 } |
5808 | 5809 |
5809 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUM) { | 5810 TEST_F(GLES2StreamTextureTest, DestroyStreamTextureCHROMIUMUntracked) { |
5810 InitDecoder( | 5811 CreateAndBindTexImage(client_texture_id_, kServiceTextureId); |
5811 "GL_CHROMIUM_stream_texture", // extensions | |
5812 false, // has alpha | |
5813 false, // has depth | |
5814 false, // has stencil | |
5815 false, // request alpha | |
5816 false, // request depth | |
5817 false, // request stencil | |
5818 true); // bind generates resource | |
5819 | 5812 |
5820 TextureRef* texture_ref = GetTexture(client_texture_id_); | 5813 // This should fail because the image is not tracked by the manager. |
5821 group().texture_manager()->SetStreamTexture(texture_ref, true); | |
5822 | |
5823 EXPECT_CALL(*stream_texture_manager(), | |
5824 DestroyStreamTexture(kServiceTextureId)) | |
5825 .Times(1) | |
5826 .RetiresOnSaturation(); | |
5827 | |
5828 DestroyStreamTextureCHROMIUM cmd; | |
5829 cmd.Init(client_texture_id_); | |
5830 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
5831 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
5832 EXPECT_FALSE(texture_ref->texture()->IsStreamTexture()); | |
5833 EXPECT_EQ(0U, texture_ref->texture()->target()); | |
5834 } | |
5835 | |
5836 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMInvalid) { | |
5837 InitDecoder( | |
5838 "GL_CHROMIUM_stream_texture", // extensions | |
5839 false, // has alpha | |
5840 false, // has depth | |
5841 false, // has stencil | |
5842 false, // request alpha | |
5843 false, // request depth | |
5844 false, // request stencil | |
5845 true); // bind generates resource | |
5846 | |
5847 DestroyStreamTextureCHROMIUM cmd; | 5814 DestroyStreamTextureCHROMIUM cmd; |
5848 cmd.Init(client_texture_id_); | 5815 cmd.Init(client_texture_id_); |
5849 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 5816 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
5850 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 5817 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
5851 } | 5818 } |
5852 | 5819 |
5853 TEST_F(GLES2DecoderManualInitTest, DestroyStreamTextureCHROMIUMBadId) { | |
5854 InitDecoder( | |
5855 "GL_CHROMIUM_stream_texture", // extensions | |
5856 false, // has alpha | |
5857 false, // has depth | |
5858 false, // has stencil | |
5859 false, // request alpha | |
5860 false, // request depth | |
5861 false, // request stencil | |
5862 true); // bind generates resource | |
5863 | |
5864 DestroyStreamTextureCHROMIUM cmd; | |
5865 cmd.Init(GL_ZERO); | |
5866 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
5867 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | |
5868 } | |
5869 | |
5870 TEST_F(GLES2DecoderManualInitTest, StreamTextureCHROMIUMNullMgr) { | |
5871 InitDecoder( | |
5872 "", // extensions | |
5873 false, // has alpha | |
5874 false, // has depth | |
5875 false, // has stencil | |
5876 false, // request alpha | |
5877 false, // request depth | |
5878 false, // request stencil | |
5879 true); // bind generates resource | |
5880 | |
5881 CreateStreamTextureCHROMIUM cmd; | |
5882 cmd.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | |
5883 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd)); | |
5884 GetGLError(); // ignore internal error | |
5885 | |
5886 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
5887 group().texture_manager()->SetStreamTexture(texture_ref, true); | |
5888 | |
5889 DestroyStreamTextureCHROMIUM cmd2; | |
5890 cmd2.Init(client_texture_id_); | |
5891 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd2)); | |
5892 GetGLError(); // ignore internal error | |
5893 } | |
5894 | |
5895 TEST_F(GLES2DecoderManualInitTest, ReCreateStreamTextureCHROMIUM) { | |
5896 const GLuint kObjectId = 123; | |
5897 InitDecoder( | |
5898 "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions | |
5899 false, // has alpha | |
5900 false, // has depth | |
5901 false, // has stencil | |
5902 false, // request alpha | |
5903 false, // request depth | |
5904 false, // request stencil | |
5905 true); // bind generates resource | |
5906 | |
5907 EXPECT_CALL(*stream_texture_manager(), | |
5908 DestroyStreamTexture(kServiceTextureId)) | |
5909 .Times(1) | |
5910 .RetiresOnSaturation(); | |
5911 EXPECT_CALL(*stream_texture_manager(), | |
5912 CreateStreamTexture(kServiceTextureId, client_texture_id_)) | |
5913 .WillOnce(Return(kObjectId)) | |
5914 .RetiresOnSaturation(); | |
5915 | |
5916 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
5917 group().texture_manager()->SetStreamTexture(texture_ref, true); | |
5918 | |
5919 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
5920 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
5921 | |
5922 DestroyStreamTextureCHROMIUM cmd; | |
5923 cmd.Init(client_texture_id_); | |
5924 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
5925 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
5926 EXPECT_FALSE(texture_ref->texture()->IsStreamTexture()); | |
5927 | |
5928 CreateStreamTextureCHROMIUM cmd2; | |
5929 cmd2.Init(client_texture_id_, shared_memory_id_, shared_memory_offset_); | |
5930 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | |
5931 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
5932 EXPECT_TRUE(texture_ref->texture()->IsStreamTexture()); | |
5933 | |
5934 EXPECT_CALL(*stream_texture_manager(), | |
5935 DestroyStreamTexture(kServiceTextureId)) | |
5936 .Times(1) | |
5937 .RetiresOnSaturation(); | |
5938 } | |
5939 | |
5940 TEST_F(GLES2DecoderManualInitTest, ProduceAndConsumeStreamTextureCHROMIUM) { | |
5941 InitDecoder( | |
5942 "GL_CHROMIUM_stream_texture GL_OES_EGL_image_external", // extensions | |
5943 false, // has alpha | |
5944 false, // has depth | |
5945 false, // has stencil | |
5946 false, // request alpha | |
5947 false, // request depth | |
5948 false, // request stencil | |
5949 true); // bind generates resource | |
5950 | |
5951 TextureRef* texture_ref = GetTexture(client_texture_id_); | |
5952 group().texture_manager()->SetStreamTexture(texture_ref, true); | |
5953 | |
5954 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId); | |
5955 | |
5956 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | |
5957 group().mailbox_manager()->GenerateMailboxName( | |
5958 reinterpret_cast<MailboxName*>(mailbox)); | |
5959 | |
5960 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); | |
5961 | |
5962 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); | |
5963 | |
5964 ProduceTextureCHROMIUM produce_cmd; | |
5965 produce_cmd.Init( | |
5966 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); | |
5967 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); | |
5968 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
5969 | |
5970 // Create new texture for consume. | |
5971 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
5972 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) | |
5973 .RetiresOnSaturation(); | |
5974 DoBindTexture(GL_TEXTURE_EXTERNAL_OES, kNewClientId, kNewServiceId); | |
5975 | |
5976 // Assigns and binds original service size texture ID. | |
5977 EXPECT_CALL(*gl_, DeleteTextures(1, _)) | |
5978 .Times(1) | |
5979 .RetiresOnSaturation(); | |
5980 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_EXTERNAL_OES, kServiceTextureId)) | |
5981 .Times(1) | |
5982 .RetiresOnSaturation(); | |
5983 | |
5984 // Shared mem got clobbered from GetError() above. | |
5985 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); | |
5986 ConsumeTextureCHROMIUM consume_cmd; | |
5987 consume_cmd.Init( | |
5988 GL_TEXTURE_EXTERNAL_OES, kSharedMemoryId, kSharedMemoryOffset); | |
5989 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); | |
5990 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
5991 | |
5992 // Service ID is restored. | |
5993 EXPECT_EQ(kServiceTextureId, texture_ref->service_id()); | |
5994 | |
5995 EXPECT_CALL(*stream_texture_manager(), | |
5996 DestroyStreamTexture(kServiceTextureId)) | |
5997 .Times(1) | |
5998 .RetiresOnSaturation(); | |
5999 } | |
6000 | |
6001 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { | 5820 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { |
6002 InitDecoder( | 5821 InitDecoder( |
6003 "GL_ARB_texture_rectangle", // extensions | 5822 "GL_ARB_texture_rectangle", // extensions |
6004 false, // has alpha | 5823 false, // has alpha |
6005 false, // has depth | 5824 false, // has depth |
6006 false, // has stencil | 5825 false, // has stencil |
6007 false, // request alpha | 5826 false, // request alpha |
6008 false, // request depth | 5827 false, // request depth |
6009 false, // request stencil | 5828 false, // request stencil |
6010 true); // bind generates resource | 5829 true); // bind generates resource |
(...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8661 // TODO(gman): TexImage2DImmediate | 8480 // TODO(gman): TexImage2DImmediate |
8662 | 8481 |
8663 // TODO(gman): TexSubImage2DImmediate | 8482 // TODO(gman): TexSubImage2DImmediate |
8664 | 8483 |
8665 // TODO(gman): UseProgram | 8484 // TODO(gman): UseProgram |
8666 | 8485 |
8667 // TODO(gman): SwapBuffers | 8486 // TODO(gman): SwapBuffers |
8668 | 8487 |
8669 } // namespace gles2 | 8488 } // namespace gles2 |
8670 } // namespace gpu | 8489 } // namespace gpu |
OLD | NEW |