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/gl_mock.h" | 10 #include "gpu/command_buffer/common/gl_mock.h" |
11 #include "gpu/command_buffer/common/id_allocator.h" | 11 #include "gpu/command_buffer/common/id_allocator.h" |
12 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 12 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
13 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 13 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
14 #include "gpu/command_buffer/service/context_group.h" | 14 #include "gpu/command_buffer/service/context_group.h" |
| 15 #include "gpu/command_buffer/service/mailbox_manager.h" |
15 #include "gpu/command_buffer/service/stream_texture_mock.h" | 16 #include "gpu/command_buffer/service/stream_texture_mock.h" |
16 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" | 17 #include "gpu/command_buffer/service/stream_texture_manager_mock.h" |
17 #include "gpu/command_buffer/service/program_manager.h" | 18 #include "gpu/command_buffer/service/program_manager.h" |
18 #include "gpu/command_buffer/service/test_helper.h" | 19 #include "gpu/command_buffer/service/test_helper.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "ui/gfx/gl/gl_implementation.h" | 21 #include "ui/gfx/gl/gl_implementation.h" |
21 #include "ui/gfx/gl/gl_surface_stub.h" | 22 #include "ui/gfx/gl/gl_surface_stub.h" |
22 | 23 |
23 #if !defined(GL_DEPTH24_STENCIL8) | 24 #if !defined(GL_DEPTH24_STENCIL8) |
24 #define GL_DEPTH24_STENCIL8 0x88F0 | 25 #define GL_DEPTH24_STENCIL8 0x88F0 |
(...skipping 6755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6780 EXPECT_FALSE(query->pending()); | 6781 EXPECT_FALSE(query->pending()); |
6781 | 6782 |
6782 // Test end succeeds | 6783 // Test end succeeds |
6783 EndQueryEXT end_cmd; | 6784 EndQueryEXT end_cmd; |
6784 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); | 6785 end_cmd.Init(GL_COMMANDS_ISSUED_CHROMIUM, 1); |
6785 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); | 6786 EXPECT_EQ(error::kNoError, ExecuteCmd(end_cmd)); |
6786 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 6787 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
6787 EXPECT_FALSE(query->pending()); | 6788 EXPECT_FALSE(query->pending()); |
6788 } | 6789 } |
6789 | 6790 |
| 6791 TEST_F(GLES2DecoderTest, GenMailboxCHROMIUM) { |
| 6792 const uint32 kBucketId = 123; |
| 6793 |
| 6794 GenMailboxCHROMIUM gen_mailbox_cmd; |
| 6795 gen_mailbox_cmd.Init(kBucketId); |
| 6796 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_mailbox_cmd)); |
| 6797 |
| 6798 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); |
| 6799 ASSERT_TRUE(bucket != NULL); |
| 6800 ASSERT_EQ(static_cast<uint32>(GL_MAILBOX_SIZE_CHROMIUM), bucket->size()); |
| 6801 |
| 6802 static const GLbyte zero[GL_MAILBOX_SIZE_CHROMIUM] = { |
| 6803 0 |
| 6804 }; |
| 6805 EXPECT_NE(0, memcmp(zero, |
| 6806 bucket->GetData(0, GL_MAILBOX_SIZE_CHROMIUM), |
| 6807 sizeof(zero))); |
| 6808 } |
| 6809 |
| 6810 TEST_F(GLES2DecoderTest, ProduceAndConsumeTextureCHROMIUM) { |
| 6811 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
| 6812 group().mailbox_manager()->GenerateMailboxName( |
| 6813 reinterpret_cast<MailboxName*>(mailbox)); |
| 6814 |
| 6815 memcpy(shared_memory_address_, mailbox, sizeof(mailbox)); |
| 6816 |
| 6817 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 6818 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 6819 0, 0); |
| 6820 DoTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA, 2, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 6821 0, 0); |
| 6822 TextureManager::TextureInfo* info = |
| 6823 group().texture_manager()->GetTextureInfo(client_texture_id_); |
| 6824 EXPECT_EQ(kServiceTextureId, info->service_id()); |
| 6825 |
| 6826 // Assigns and binds new service side texture ID and applies the texture |
| 6827 // objects' state to it. |
| 6828 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 6829 .WillOnce(SetArgumentPointee<1>(kNewServiceId)) |
| 6830 .RetiresOnSaturation(); |
| 6831 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kNewServiceId)) |
| 6832 .Times(1) |
| 6833 .RetiresOnSaturation(); |
| 6834 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6835 GL_TEXTURE_MIN_FILTER, |
| 6836 GL_NEAREST_MIPMAP_LINEAR)); |
| 6837 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6838 GL_TEXTURE_MAG_FILTER, |
| 6839 GL_LINEAR)); |
| 6840 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6841 GL_TEXTURE_WRAP_S, |
| 6842 GL_REPEAT)); |
| 6843 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6844 GL_TEXTURE_WRAP_T, |
| 6845 GL_REPEAT)); |
| 6846 |
| 6847 ProduceTextureCHROMIUM produce_cmd; |
| 6848 produce_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); |
| 6849 EXPECT_EQ(error::kNoError, ExecuteCmd(produce_cmd)); |
| 6850 |
| 6851 // Texture is zero-by-zero. |
| 6852 GLsizei width; |
| 6853 GLsizei height; |
| 6854 GLenum type; |
| 6855 GLenum internal_format; |
| 6856 |
| 6857 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 6858 EXPECT_EQ(0, width); |
| 6859 EXPECT_EQ(0, height); |
| 6860 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 6861 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 6862 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 6863 |
| 6864 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 6865 EXPECT_EQ(0, width); |
| 6866 EXPECT_EQ(0, height); |
| 6867 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
| 6868 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 6869 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 6870 |
| 6871 // Service ID has changed. |
| 6872 EXPECT_EQ(kNewServiceId, info->service_id()); |
| 6873 |
| 6874 // Assigns and binds original service side texture ID and applies the texture |
| 6875 // objects' state to it. |
| 6876 EXPECT_CALL(*gl_, DeleteTextures(1, _)) |
| 6877 .Times(1) |
| 6878 .RetiresOnSaturation(); |
| 6879 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
| 6880 .Times(1) |
| 6881 .RetiresOnSaturation(); |
| 6882 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6883 GL_TEXTURE_MIN_FILTER, |
| 6884 GL_NEAREST_MIPMAP_LINEAR)); |
| 6885 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6886 GL_TEXTURE_MAG_FILTER, |
| 6887 GL_LINEAR)); |
| 6888 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6889 GL_TEXTURE_WRAP_S, |
| 6890 GL_REPEAT)); |
| 6891 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_2D, |
| 6892 GL_TEXTURE_WRAP_T, |
| 6893 GL_REPEAT)); |
| 6894 |
| 6895 ConsumeTextureCHROMIUM consume_cmd; |
| 6896 consume_cmd.Init(GL_TEXTURE_2D, kSharedMemoryId, kSharedMemoryOffset); |
| 6897 EXPECT_EQ(error::kNoError, ExecuteCmd(consume_cmd)); |
| 6898 |
| 6899 // Texture is redefined. |
| 6900 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height)); |
| 6901 EXPECT_EQ(3, width); |
| 6902 EXPECT_EQ(1, height); |
| 6903 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format)); |
| 6904 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 6905 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 6906 |
| 6907 EXPECT_TRUE(info->GetLevelSize(GL_TEXTURE_2D, 1, &width, &height)); |
| 6908 EXPECT_EQ(2, width); |
| 6909 EXPECT_EQ(4, height); |
| 6910 EXPECT_TRUE(info->GetLevelType(GL_TEXTURE_2D, 1, &type, &internal_format)); |
| 6911 EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format); |
| 6912 EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type); |
| 6913 |
| 6914 // Service ID is restored. |
| 6915 EXPECT_EQ(kServiceTextureId, info->service_id()); |
| 6916 } |
6790 | 6917 |
6791 // TODO(gman): Complete this test. | 6918 // TODO(gman): Complete this test. |
6792 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { | 6919 // TEST_F(GLES2DecoderTest, CompressedTexImage2DGLError) { |
6793 // } | 6920 // } |
6794 | 6921 |
6795 // TODO(gman): BufferData | 6922 // TODO(gman): BufferData |
6796 | 6923 |
6797 // TODO(gman): BufferDataImmediate | 6924 // TODO(gman): BufferDataImmediate |
6798 | 6925 |
6799 // TODO(gman): BufferSubData | 6926 // TODO(gman): BufferSubData |
(...skipping 17 matching lines...) Expand all Loading... |
6817 // TODO(gman): TexImage2DImmediate | 6944 // TODO(gman): TexImage2DImmediate |
6818 | 6945 |
6819 // TODO(gman): TexSubImage2DImmediate | 6946 // TODO(gman): TexSubImage2DImmediate |
6820 | 6947 |
6821 // TODO(gman): UseProgram | 6948 // TODO(gman): UseProgram |
6822 | 6949 |
6823 // TODO(gman): SwapBuffers | 6950 // TODO(gman): SwapBuffers |
6824 | 6951 |
6825 } // namespace gles2 | 6952 } // namespace gles2 |
6826 } // namespace gpu | 6953 } // namespace gpu |
OLD | NEW |