Chromium Code Reviews| 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/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 5025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5036 | 5036 |
| 5037 static bool ValueInArray(GLint value, GLint* array, GLint count) { | 5037 static bool ValueInArray(GLint value, GLint* array, GLint count) { |
| 5038 for (GLint ii = 0; ii < count; ++ii) { | 5038 for (GLint ii = 0; ii < count; ++ii) { |
| 5039 if (array[ii] == value) { | 5039 if (array[ii] == value) { |
| 5040 return true; | 5040 return true; |
| 5041 } | 5041 } |
| 5042 } | 5042 } |
| 5043 return false; | 5043 return false; |
| 5044 } | 5044 } |
| 5045 | 5045 |
| 5046 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormats) { | 5046 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormatsS3TC) { |
| 5047 InitState init; | 5047 InitState init; |
| 5048 init.extensions = "GL_EXT_texture_compression_s3tc"; | 5048 init.extensions = "GL_EXT_texture_compression_s3tc"; |
| 5049 init.gl_version = "3.0"; | 5049 init.gl_version = "3.0"; |
| 5050 init.bind_generates_resource = true; | 5050 init.bind_generates_resource = true; |
| 5051 InitDecoder(init); | 5051 InitDecoder(init); |
| 5052 | 5052 |
| 5053 EXPECT_CALL(*gl_, GetError()) | 5053 EXPECT_CALL(*gl_, GetError()) |
| 5054 .WillOnce(Return(GL_NO_ERROR)) | 5054 .WillOnce(Return(GL_NO_ERROR)) |
| 5055 .WillOnce(Return(GL_NO_ERROR)) | 5055 .WillOnce(Return(GL_NO_ERROR)) |
| 5056 .WillOnce(Return(GL_NO_ERROR)) | 5056 .WillOnce(Return(GL_NO_ERROR)) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5089 EXPECT_TRUE(ValueInArray( | 5089 EXPECT_TRUE(ValueInArray( |
| 5090 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, | 5090 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, |
| 5091 result->GetData(), result->GetNumResults())); | 5091 result->GetData(), result->GetNumResults())); |
| 5092 EXPECT_TRUE(ValueInArray( | 5092 EXPECT_TRUE(ValueInArray( |
| 5093 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, | 5093 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, |
| 5094 result->GetData(), result->GetNumResults())); | 5094 result->GetData(), result->GetNumResults())); |
| 5095 | 5095 |
| 5096 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 5096 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 5097 } | 5097 } |
| 5098 | 5098 |
| 5099 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormatsATC) { | |
|
Zhenyao Mo
2014/04/21 21:38:30
You should add a helper test function and combine
| |
| 5100 InitState init; | |
| 5101 init.extensions = "GL_AMD_compressed_ATC_texture"; | |
| 5102 init.gl_version = "3.0"; | |
| 5103 init.bind_generates_resource = true; | |
| 5104 InitDecoder(init); | |
| 5105 | |
| 5106 EXPECT_CALL(*gl_, GetError()) | |
| 5107 .WillOnce(Return(GL_NO_ERROR)) | |
| 5108 .WillOnce(Return(GL_NO_ERROR)) | |
| 5109 .WillOnce(Return(GL_NO_ERROR)) | |
| 5110 .WillOnce(Return(GL_NO_ERROR)) | |
| 5111 .RetiresOnSaturation(); | |
| 5112 | |
| 5113 typedef GetIntegerv::Result Result; | |
| 5114 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 5115 GetIntegerv cmd; | |
| 5116 result->size = 0; | |
| 5117 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 5118 .Times(0) | |
| 5119 .RetiresOnSaturation(); | |
| 5120 cmd.Init( | |
| 5121 GL_NUM_COMPRESSED_TEXTURE_FORMATS, | |
| 5122 shared_memory_id_, shared_memory_offset_); | |
| 5123 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5124 EXPECT_EQ(1, result->GetNumResults()); | |
| 5125 GLint num_formats = result->GetData()[0]; | |
| 5126 EXPECT_EQ(3, num_formats); | |
| 5127 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5128 | |
| 5129 result->size = 0; | |
| 5130 cmd.Init( | |
| 5131 GL_COMPRESSED_TEXTURE_FORMATS, | |
| 5132 shared_memory_id_, shared_memory_offset_); | |
| 5133 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5134 EXPECT_EQ(num_formats, result->GetNumResults()); | |
| 5135 | |
| 5136 EXPECT_TRUE(ValueInArray( | |
| 5137 GL_ATC_RGB_AMD, | |
| 5138 result->GetData(), result->GetNumResults())); | |
| 5139 EXPECT_TRUE(ValueInArray( | |
| 5140 GL_ATC_RGBA_EXPLICIT_ALPHA_AMD, | |
| 5141 result->GetData(), result->GetNumResults())); | |
| 5142 EXPECT_TRUE(ValueInArray( | |
| 5143 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD, | |
| 5144 result->GetData(), result->GetNumResults())); | |
| 5145 | |
| 5146 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5147 } | |
| 5148 | |
| 5149 TEST_F(GLES2DecoderManualInitTest, GetCompressedTextureFormatsPVRTC) { | |
| 5150 InitState init; | |
| 5151 init.extensions = "GL_IMG_texture_compression_pvrtc"; | |
| 5152 init.gl_version = "3.0"; | |
| 5153 init.bind_generates_resource = true; | |
| 5154 InitDecoder(init); | |
| 5155 | |
| 5156 EXPECT_CALL(*gl_, GetError()) | |
| 5157 .WillOnce(Return(GL_NO_ERROR)) | |
| 5158 .WillOnce(Return(GL_NO_ERROR)) | |
| 5159 .WillOnce(Return(GL_NO_ERROR)) | |
| 5160 .WillOnce(Return(GL_NO_ERROR)) | |
| 5161 .RetiresOnSaturation(); | |
| 5162 | |
| 5163 typedef GetIntegerv::Result Result; | |
| 5164 Result* result = static_cast<Result*>(shared_memory_address_); | |
| 5165 GetIntegerv cmd; | |
| 5166 result->size = 0; | |
| 5167 EXPECT_CALL(*gl_, GetIntegerv(_, _)) | |
| 5168 .Times(0) | |
| 5169 .RetiresOnSaturation(); | |
| 5170 cmd.Init( | |
| 5171 GL_NUM_COMPRESSED_TEXTURE_FORMATS, | |
| 5172 shared_memory_id_, shared_memory_offset_); | |
| 5173 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5174 EXPECT_EQ(1, result->GetNumResults()); | |
| 5175 GLint num_formats = result->GetData()[0]; | |
| 5176 EXPECT_EQ(4, num_formats); | |
| 5177 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5178 | |
| 5179 result->size = 0; | |
| 5180 cmd.Init( | |
| 5181 GL_COMPRESSED_TEXTURE_FORMATS, | |
| 5182 shared_memory_id_, shared_memory_offset_); | |
| 5183 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 5184 EXPECT_EQ(num_formats, result->GetNumResults()); | |
| 5185 | |
| 5186 EXPECT_TRUE(ValueInArray( | |
| 5187 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, | |
| 5188 result->GetData(), result->GetNumResults())); | |
| 5189 EXPECT_TRUE(ValueInArray( | |
| 5190 GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, | |
| 5191 result->GetData(), result->GetNumResults())); | |
| 5192 EXPECT_TRUE(ValueInArray( | |
| 5193 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, | |
| 5194 result->GetData(), result->GetNumResults())); | |
| 5195 EXPECT_TRUE(ValueInArray( | |
| 5196 GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, | |
| 5197 result->GetData(), result->GetNumResults())); | |
| 5198 | |
| 5199 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | |
| 5200 } | |
| 5201 | |
| 5099 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) { | 5202 TEST_F(GLES2DecoderManualInitTest, GetNoCompressedTextureFormats) { |
| 5100 InitState init; | 5203 InitState init; |
| 5101 init.gl_version = "3.0"; | 5204 init.gl_version = "3.0"; |
| 5102 init.bind_generates_resource = true; | 5205 init.bind_generates_resource = true; |
| 5103 InitDecoder(init); | 5206 InitDecoder(init); |
| 5104 | 5207 |
| 5105 EXPECT_CALL(*gl_, GetError()) | 5208 EXPECT_CALL(*gl_, GetError()) |
| 5106 .WillOnce(Return(GL_NO_ERROR)) | 5209 .WillOnce(Return(GL_NO_ERROR)) |
| 5107 .WillOnce(Return(GL_NO_ERROR)) | 5210 .WillOnce(Return(GL_NO_ERROR)) |
| 5108 .WillOnce(Return(GL_NO_ERROR)) | 5211 .WillOnce(Return(GL_NO_ERROR)) |
| (...skipping 4433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9542 // TODO(gman): TexImage2DImmediate | 9645 // TODO(gman): TexImage2DImmediate |
| 9543 | 9646 |
| 9544 // TODO(gman): TexSubImage2DImmediate | 9647 // TODO(gman): TexSubImage2DImmediate |
| 9545 | 9648 |
| 9546 // TODO(gman): UseProgram | 9649 // TODO(gman): UseProgram |
| 9547 | 9650 |
| 9548 // TODO(gman): SwapBuffers | 9651 // TODO(gman): SwapBuffers |
| 9549 | 9652 |
| 9550 } // namespace gles2 | 9653 } // namespace gles2 |
| 9551 } // namespace gpu | 9654 } // namespace gpu |
| OLD | NEW |