OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 6 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
8 #include "gpu/command_buffer/service/gl_mock.h" | 8 #include "gpu/command_buffer/service/gl_mock.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
10 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 10 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 CompileShader cmd; | 846 CompileShader cmd; |
847 cmd.Init(kInvalidClientId); | 847 cmd.Init(kInvalidClientId); |
848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
849 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 849 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
850 cmd.Init(client_texture_id_); | 850 cmd.Init(client_texture_id_); |
851 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 851 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
852 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 852 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
853 } | 853 } |
854 | 854 |
855 TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { | 855 TEST_F(GLES2DecoderTest, ShaderSourceAndGetShaderSourceValidArgs) { |
| 856 const uint32 kBucketId = 123; |
856 const char kSource[] = "hello"; | 857 const char kSource[] = "hello"; |
857 const uint32 kSourceSize = sizeof(kSource) - 1; | 858 const uint32 kSourceSize = sizeof(kSource) - 1; |
858 memcpy(shared_memory_address_, kSource, kSourceSize); | 859 memcpy(shared_memory_address_, kSource, kSourceSize); |
859 ShaderSource cmd; | 860 ShaderSource cmd; |
860 cmd.Init(client_shader_id_, | 861 cmd.Init(client_shader_id_, |
861 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); | 862 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); |
862 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 863 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
863 memset(shared_memory_address_, 0, kSourceSize); | 864 memset(shared_memory_address_, 0, kSourceSize); |
864 // TODO(gman): GetShaderSource has to change format so result is always set. | |
865 GetShaderSource get_cmd; | 865 GetShaderSource get_cmd; |
866 get_cmd.Init(client_shader_id_, kSourceSize + 1, | 866 get_cmd.Init(client_shader_id_, kBucketId); |
867 kSharedMemoryId, kSharedMemoryOffset, | |
868 kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize)); | |
869 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); | 867 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); |
870 EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>()); | 868 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); |
871 EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)), | 869 ASSERT_TRUE(bucket != NULL); |
872 kSource, kSourceSize)); | 870 EXPECT_EQ(kSourceSize + 1, bucket->size()); |
| 871 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, |
| 872 bucket->size())); |
873 } | 873 } |
874 | 874 |
875 TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) { | 875 TEST_F(GLES2DecoderTest, ShaderSourceInvalidArgs) { |
876 const char kSource[] = "hello"; | 876 const char kSource[] = "hello"; |
877 const uint32 kSourceSize = sizeof(kSource) - 1; | 877 const uint32 kSourceSize = sizeof(kSource) - 1; |
878 memcpy(shared_memory_address_, kSource, kSourceSize); | 878 memcpy(shared_memory_address_, kSource, kSourceSize); |
879 ShaderSource cmd; | 879 ShaderSource cmd; |
880 cmd.Init(kInvalidClientId, | 880 cmd.Init(kInvalidClientId, |
881 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); | 881 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); |
882 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 882 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
883 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 883 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
884 cmd.Init(client_texture_id_, | 884 cmd.Init(client_texture_id_, |
885 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); | 885 kSharedMemoryId, kSharedMemoryOffset, kSourceSize); |
886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
887 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 887 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
888 cmd.Init(client_shader_id_, | 888 cmd.Init(client_shader_id_, |
889 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize); | 889 kInvalidSharedMemoryId, kSharedMemoryOffset, kSourceSize); |
890 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 890 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
891 cmd.Init(client_shader_id_, | 891 cmd.Init(client_shader_id_, |
892 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize); | 892 kSharedMemoryId, kInvalidSharedMemoryOffset, kSourceSize); |
893 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 893 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
894 cmd.Init(client_shader_id_, | 894 cmd.Init(client_shader_id_, |
895 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); | 895 kSharedMemoryId, kSharedMemoryOffset, kSharedBufferSize); |
896 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 896 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
897 } | 897 } |
898 | 898 |
899 TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) { | 899 TEST_F(GLES2DecoderTest, ShaderSourceImmediateAndGetShaderSourceValidArgs) { |
| 900 const uint32 kBucketId = 123; |
900 const char kSource[] = "hello"; | 901 const char kSource[] = "hello"; |
901 const uint32 kSourceSize = sizeof(kSource) - 1; | 902 const uint32 kSourceSize = sizeof(kSource) - 1; |
902 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); | 903 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); |
903 cmd.Init(client_shader_id_, kSourceSize); | 904 cmd.Init(client_shader_id_, kSourceSize); |
904 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize); | 905 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize); |
905 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize)); | 906 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize)); |
906 memset(shared_memory_address_, 0, kSourceSize); | 907 memset(shared_memory_address_, 0, kSourceSize); |
907 // TODO(gman): GetShaderSource has to change format so result is always set. | 908 // TODO(gman): GetShaderSource has to change format so result is always set. |
908 GetShaderSource get_cmd; | 909 GetShaderSource get_cmd; |
909 get_cmd.Init(client_shader_id_, kSourceSize + 1, | 910 get_cmd.Init(client_shader_id_, kBucketId); |
910 kSharedMemoryId, kSharedMemoryOffset, | |
911 kSharedMemoryId, kSharedMemoryOffset + sizeof(kSourceSize)); | |
912 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); | 911 EXPECT_EQ(error::kNoError, ExecuteCmd(get_cmd)); |
913 EXPECT_EQ(kSourceSize, *GetSharedMemoryAs<uint32*>()); | 912 CommonDecoder::Bucket* bucket = decoder_->GetBucket(kBucketId); |
914 EXPECT_EQ(0, memcmp(GetSharedMemoryAsWithOffset<void*>(sizeof(kSourceSize)), | 913 ASSERT_TRUE(bucket != NULL); |
915 kSource, kSourceSize)); | 914 EXPECT_EQ(kSourceSize + 1, bucket->size()); |
| 915 EXPECT_EQ(0, memcmp(bucket->GetData(0, bucket->size()), kSource, |
| 916 bucket->size())); |
916 } | 917 } |
917 | 918 |
918 TEST_F(GLES2DecoderTest, ShaderSourceImmediateInvalidArgs) { | 919 TEST_F(GLES2DecoderTest, ShaderSourceImmediateInvalidArgs) { |
919 const char kSource[] = "hello"; | 920 const char kSource[] = "hello"; |
920 const uint32 kSourceSize = sizeof(kSource) - 1; | 921 const uint32 kSourceSize = sizeof(kSource) - 1; |
921 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); | 922 ShaderSourceImmediate& cmd = *GetImmediateAs<ShaderSourceImmediate>(); |
922 cmd.Init(kInvalidClientId, kSourceSize); | 923 cmd.Init(kInvalidClientId, kSourceSize); |
923 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize); | 924 memcpy(GetImmediateDataAs<void*>(&cmd), kSource, kSourceSize); |
924 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize)); | 925 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, kSourceSize)); |
925 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); | 926 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 // TODO(gman): UseProgram | 1038 // TODO(gman): UseProgram |
1038 | 1039 |
1039 // TODO(gman): SwapBuffers | 1040 // TODO(gman): SwapBuffers |
1040 | 1041 |
1041 // TODO(gman): VertexAttribPointer | 1042 // TODO(gman): VertexAttribPointer |
1042 | 1043 |
1043 } // namespace gles2 | 1044 } // namespace gles2 |
1044 } // namespace gpu | 1045 } // namespace gpu |
1045 | 1046 |
1046 | 1047 |
OLD | NEW |