OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 4856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4867 | 4867 |
4868 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); | 4868 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
4869 info->SetStreamTexture(true); | 4869 info->SetStreamTexture(true); |
4870 | 4870 |
4871 DestroyStreamTextureCHROMIUM cmd2; | 4871 DestroyStreamTextureCHROMIUM cmd2; |
4872 cmd2.Init(client_texture_id_); | 4872 cmd2.Init(client_texture_id_); |
4873 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd2)); | 4873 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(cmd2)); |
4874 GetGLError(); // ignore internal error | 4874 GetGLError(); // ignore internal error |
4875 } | 4875 } |
4876 | 4876 |
| 4877 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleBindTexture) { |
| 4878 InitDecoder( |
| 4879 "GL_ARB_texture_rectangle", // extensions |
| 4880 false, // has alpha |
| 4881 false, // has depth |
| 4882 false, // has stencil |
| 4883 false, // request alpha |
| 4884 false, // request depth |
| 4885 false, // request stencil |
| 4886 true); // bind generates resource |
| 4887 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_RECTANGLE_ARB, kNewServiceId)); |
| 4888 EXPECT_CALL(*gl_, GenTextures(1, _)) |
| 4889 .WillOnce(SetArgumentPointee<1>(kNewServiceId)); |
| 4890 BindTexture cmd; |
| 4891 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, kNewClientId); |
| 4892 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4893 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4894 TextureManager::TextureInfo* info = GetTextureInfo(kNewClientId); |
| 4895 EXPECT_TRUE(info != NULL); |
| 4896 EXPECT_TRUE(info->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 4897 } |
| 4898 |
| 4899 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleGetBinding) { |
| 4900 InitDecoder( |
| 4901 "GL_ARB_texture_rectangle", // extensions |
| 4902 false, // has alpha |
| 4903 false, // has depth |
| 4904 false, // has stencil |
| 4905 false, // request alpha |
| 4906 false, // request depth |
| 4907 false, // request stencil |
| 4908 true); // bind generates resource |
| 4909 DoBindTexture( |
| 4910 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 4911 |
| 4912 EXPECT_CALL(*gl_, GetError()) |
| 4913 .WillOnce(Return(GL_NO_ERROR)) |
| 4914 .WillOnce(Return(GL_NO_ERROR)) |
| 4915 .RetiresOnSaturation(); |
| 4916 typedef GetIntegerv::Result Result; |
| 4917 Result* result = static_cast<Result*>(shared_memory_address_); |
| 4918 EXPECT_CALL(*gl_, GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, |
| 4919 result->GetData())) |
| 4920 .Times(0); |
| 4921 result->size = 0; |
| 4922 GetIntegerv cmd; |
| 4923 cmd.Init(GL_TEXTURE_BINDING_RECTANGLE_ARB, |
| 4924 shared_memory_id_, |
| 4925 shared_memory_offset_); |
| 4926 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4927 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned( |
| 4928 GL_TEXTURE_BINDING_RECTANGLE_ARB), result->GetNumResults()); |
| 4929 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4930 EXPECT_EQ(client_texture_id_, (uint32)result->GetData()[0]); |
| 4931 } |
| 4932 |
| 4933 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureDefaults) { |
| 4934 InitDecoder( |
| 4935 "GL_ARB_texture_rectangle", // extensions |
| 4936 false, // has alpha |
| 4937 false, // has depth |
| 4938 false, // has stencil |
| 4939 false, // request alpha |
| 4940 false, // request depth |
| 4941 false, // request stencil |
| 4942 true); // bind generates resource |
| 4943 DoBindTexture( |
| 4944 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 4945 |
| 4946 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
| 4947 EXPECT_TRUE(info != NULL); |
| 4948 EXPECT_TRUE(info->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 4949 EXPECT_TRUE(info->min_filter() == GL_LINEAR); |
| 4950 EXPECT_TRUE(info->wrap_s() == GL_CLAMP_TO_EDGE); |
| 4951 EXPECT_TRUE(info->wrap_t() == GL_CLAMP_TO_EDGE); |
| 4952 } |
| 4953 |
| 4954 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParam) { |
| 4955 InitDecoder( |
| 4956 "GL_ARB_texture_rectangle", // extensions |
| 4957 false, // has alpha |
| 4958 false, // has depth |
| 4959 false, // has stencil |
| 4960 false, // request alpha |
| 4961 false, // request depth |
| 4962 false, // request stencil |
| 4963 true); // bind generates resource |
| 4964 |
| 4965 DoBindTexture( |
| 4966 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 4967 |
| 4968 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, |
| 4969 GL_TEXTURE_MIN_FILTER, |
| 4970 GL_NEAREST)); |
| 4971 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, |
| 4972 GL_TEXTURE_MIN_FILTER, |
| 4973 GL_LINEAR)); |
| 4974 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, |
| 4975 GL_TEXTURE_WRAP_S, |
| 4976 GL_CLAMP_TO_EDGE)); |
| 4977 EXPECT_CALL(*gl_, TexParameteri(GL_TEXTURE_RECTANGLE_ARB, |
| 4978 GL_TEXTURE_WRAP_T, |
| 4979 GL_CLAMP_TO_EDGE)); |
| 4980 TexParameteri cmd; |
| 4981 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 4982 GL_TEXTURE_MIN_FILTER, |
| 4983 GL_NEAREST); |
| 4984 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4985 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4986 |
| 4987 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 4988 GL_TEXTURE_MIN_FILTER, |
| 4989 GL_LINEAR); |
| 4990 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4991 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4992 |
| 4993 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 4994 GL_TEXTURE_WRAP_S, |
| 4995 GL_CLAMP_TO_EDGE); |
| 4996 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4997 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4998 |
| 4999 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 5000 GL_TEXTURE_WRAP_T, |
| 5001 GL_CLAMP_TO_EDGE); |
| 5002 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5003 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5004 |
| 5005 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
| 5006 EXPECT_TRUE(info != NULL); |
| 5007 EXPECT_TRUE(info->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 5008 EXPECT_TRUE(info->min_filter() == GL_LINEAR); |
| 5009 EXPECT_TRUE(info->wrap_s() == GL_CLAMP_TO_EDGE); |
| 5010 EXPECT_TRUE(info->wrap_t() == GL_CLAMP_TO_EDGE); |
| 5011 } |
| 5012 |
| 5013 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTextureParamInvalid) { |
| 5014 InitDecoder( |
| 5015 "GL_ARB_texture_rectangle", // extensions |
| 5016 false, // has alpha |
| 5017 false, // has depth |
| 5018 false, // has stencil |
| 5019 false, // request alpha |
| 5020 false, // request depth |
| 5021 false, // request stencil |
| 5022 true); // bind generates resource |
| 5023 |
| 5024 DoBindTexture( |
| 5025 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 5026 |
| 5027 TexParameteri cmd; |
| 5028 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 5029 GL_TEXTURE_MIN_FILTER, |
| 5030 GL_NEAREST_MIPMAP_NEAREST); |
| 5031 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5032 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 5033 |
| 5034 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 5035 GL_TEXTURE_WRAP_S, |
| 5036 GL_REPEAT); |
| 5037 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5038 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 5039 |
| 5040 cmd.Init(GL_TEXTURE_RECTANGLE_ARB, |
| 5041 GL_TEXTURE_WRAP_T, |
| 5042 GL_REPEAT); |
| 5043 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5044 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 5045 |
| 5046 TextureManager::TextureInfo* info = GetTextureInfo(client_texture_id_); |
| 5047 EXPECT_TRUE(info != NULL); |
| 5048 EXPECT_TRUE(info->target() == GL_TEXTURE_RECTANGLE_ARB); |
| 5049 EXPECT_TRUE(info->min_filter() == GL_LINEAR); |
| 5050 EXPECT_TRUE(info->wrap_s() == GL_CLAMP_TO_EDGE); |
| 5051 EXPECT_TRUE(info->wrap_t() == GL_CLAMP_TO_EDGE); |
| 5052 } |
| 5053 |
| 5054 TEST_F(GLES2DecoderManualInitTest, ARBTextureRectangleTexImage2DError) { |
| 5055 InitDecoder( |
| 5056 "GL_ARB_texture_rectangle", // extensions |
| 5057 false, // has alpha |
| 5058 false, // has depth |
| 5059 false, // has stencil |
| 5060 false, // request alpha |
| 5061 false, // request depth |
| 5062 false, // request stencil |
| 5063 true); // bind generates resource |
| 5064 |
| 5065 GLenum target = GL_TEXTURE_RECTANGLE_ARB; |
| 5066 GLint level = 0; |
| 5067 GLenum internal_format = GL_RGBA; |
| 5068 GLsizei width = 2; |
| 5069 GLsizei height = 4; |
| 5070 GLint border = 0; |
| 5071 GLenum format = GL_RGBA; |
| 5072 GLenum type = GL_UNSIGNED_BYTE; |
| 5073 DoBindTexture( |
| 5074 GL_TEXTURE_RECTANGLE_ARB, client_texture_id_, kServiceTextureId); |
| 5075 ASSERT_TRUE(GetTextureInfo(client_texture_id_) != NULL); |
| 5076 TexImage2D cmd; |
| 5077 cmd.Init(target, level, internal_format, width, height, border, format, |
| 5078 type, kSharedMemoryId, kSharedMemoryOffset); |
| 5079 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 5080 |
| 5081 // TexImage2D is not allowed with GL_TEXTURE_RECTANGLE_ARB targets. |
| 5082 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 5083 } |
| 5084 |
4877 TEST_F(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { | 5085 TEST_F(GLES2DecoderTest, EnableFeatureCHROMIUMBadBucket) { |
4878 const uint32 kBadBucketId = 123; | 5086 const uint32 kBadBucketId = 123; |
4879 EnableFeatureCHROMIUM cmd; | 5087 EnableFeatureCHROMIUM cmd; |
4880 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); | 5088 cmd.Init(kBadBucketId, shared_memory_id_, shared_memory_offset_); |
4881 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); | 5089 EXPECT_NE(error::kNoError, ExecuteCmd(cmd)); |
4882 } | 5090 } |
4883 | 5091 |
4884 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { | 5092 TEST_F(GLES2DecoderTest, RequestExtensionCHROMIUMBadBucket) { |
4885 const uint32 kBadBucketId = 123; | 5093 const uint32 kBadBucketId = 123; |
4886 RequestExtensionCHROMIUM cmd; | 5094 RequestExtensionCHROMIUM cmd; |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5449 // TODO(gman): TexImage2DImmediate | 5657 // TODO(gman): TexImage2DImmediate |
5450 | 5658 |
5451 // TODO(gman): TexSubImage2DImmediate | 5659 // TODO(gman): TexSubImage2DImmediate |
5452 | 5660 |
5453 // TODO(gman): UseProgram | 5661 // TODO(gman): UseProgram |
5454 | 5662 |
5455 // TODO(gman): SwapBuffers | 5663 // TODO(gman): SwapBuffers |
5456 | 5664 |
5457 } // namespace gles2 | 5665 } // namespace gles2 |
5458 } // namespace gpu | 5666 } // namespace gpu |
OLD | NEW |