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_unittest.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.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 17 matching lines...) Expand all Loading... |
28 #include "ui/gl/gl_mock.h" | 28 #include "ui/gl/gl_mock.h" |
29 #include "ui/gl/gl_surface_stub.h" | 29 #include "ui/gl/gl_surface_stub.h" |
30 | 30 |
31 | 31 |
32 #if !defined(GL_DEPTH24_STENCIL8) | 32 #if !defined(GL_DEPTH24_STENCIL8) |
33 #define GL_DEPTH24_STENCIL8 0x88F0 | 33 #define GL_DEPTH24_STENCIL8 0x88F0 |
34 #endif | 34 #endif |
35 | 35 |
36 using ::gfx::MockGLInterface; | 36 using ::gfx::MockGLInterface; |
37 using ::testing::_; | 37 using ::testing::_; |
| 38 using ::testing::AtLeast; |
38 using ::testing::DoAll; | 39 using ::testing::DoAll; |
39 using ::testing::InSequence; | 40 using ::testing::InSequence; |
40 using ::testing::Invoke; | 41 using ::testing::Invoke; |
41 using ::testing::MatcherCast; | 42 using ::testing::MatcherCast; |
42 using ::testing::Mock; | 43 using ::testing::Mock; |
43 using ::testing::Pointee; | 44 using ::testing::Pointee; |
44 using ::testing::Return; | 45 using ::testing::Return; |
45 using ::testing::SaveArg; | 46 using ::testing::SaveArg; |
46 using ::testing::SetArrayArgument; | 47 using ::testing::SetArrayArgument; |
47 using ::testing::SetArgumentPointee; | 48 using ::testing::SetArgumentPointee; |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 // Check we get out of memory and no call to glBufferData if Ensure | 1204 // Check we get out of memory and no call to glBufferData if Ensure |
1204 // fails. | 1205 // fails. |
1205 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) | 1206 EXPECT_CALL(*memory_tracker.get(), EnsureGPUMemoryAvailable(128)) |
1206 .WillOnce(Return(false)) | 1207 .WillOnce(Return(false)) |
1207 .RetiresOnSaturation(); | 1208 .RetiresOnSaturation(); |
1208 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 1209 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
1209 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 1210 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
1210 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); | 1211 EXPECT_EQ(128u, memory_tracker->GetPoolSize(MemoryTracker::kManaged)); |
1211 } | 1212 } |
1212 | 1213 |
| 1214 TEST_P(GLES2DecoderManualInitTest, ImmutableCopyTexImage2D) { |
| 1215 const GLenum kTarget = GL_TEXTURE_2D; |
| 1216 const GLint kLevel = 0; |
| 1217 const GLenum kInternalFormat = GL_RGBA; |
| 1218 const GLenum kSizedInternalFormat = GL_RGBA8; |
| 1219 const GLsizei kWidth = 4; |
| 1220 const GLsizei kHeight = 8; |
| 1221 const GLint kBorder = 0; |
| 1222 InitState init; |
| 1223 init.extensions = "GL_EXT_texture_storage"; |
| 1224 init.gl_version = "3.0"; |
| 1225 init.has_alpha = true; |
| 1226 init.request_alpha = true; |
| 1227 init.bind_generates_resource = true; |
| 1228 InitDecoder(init); |
| 1229 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 1230 |
| 1231 // CopyTexImage2D will call arbitrary amount of GetErrors. |
| 1232 EXPECT_CALL(*gl_, GetError()) |
| 1233 .Times(AtLeast(1)); |
| 1234 |
| 1235 EXPECT_CALL(*gl_, |
| 1236 CopyTexImage2D( |
| 1237 kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight, |
| 1238 kBorder)) |
| 1239 .Times(1); |
| 1240 |
| 1241 EXPECT_CALL(*gl_, |
| 1242 TexStorage2DEXT( |
| 1243 kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight)) |
| 1244 .Times(1); |
| 1245 CopyTexImage2D copy_cmd; |
| 1246 copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight, |
| 1247 kBorder); |
| 1248 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); |
| 1249 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1250 |
| 1251 TexStorage2DEXT storage_cmd; |
| 1252 storage_cmd.Init(kTarget, kLevel, kSizedInternalFormat, kWidth, kHeight); |
| 1253 EXPECT_EQ(error::kNoError, ExecuteCmd(storage_cmd)); |
| 1254 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1255 |
| 1256 // This should not invoke CopyTexImage2D. |
| 1257 copy_cmd.Init(kTarget, kLevel, kInternalFormat, 0, 0, kWidth, kHeight, |
| 1258 kBorder); |
| 1259 EXPECT_EQ(error::kNoError, ExecuteCmd(copy_cmd)); |
| 1260 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 1261 } |
| 1262 |
1213 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); | 1263 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderTest, ::testing::Bool()); |
1214 | 1264 |
1215 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); | 1265 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderWithShaderTest, ::testing::Bool()); |
1216 | 1266 |
1217 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); | 1267 INSTANTIATE_TEST_CASE_P(Service, GLES2DecoderManualInitTest, ::testing::Bool()); |
1218 | 1268 |
1219 INSTANTIATE_TEST_CASE_P(Service, | 1269 INSTANTIATE_TEST_CASE_P(Service, |
1220 GLES2DecoderRGBBackbufferTest, | 1270 GLES2DecoderRGBBackbufferTest, |
1221 ::testing::Bool()); | 1271 ::testing::Bool()); |
1222 | 1272 |
1223 } // namespace gles2 | 1273 } // namespace gles2 |
1224 } // namespace gpu | 1274 } // namespace gpu |
OLD | NEW |