| 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_base.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 gl_version("2.1"), | 152 gl_version("2.1"), |
| 153 has_alpha(false), | 153 has_alpha(false), |
| 154 has_depth(false), | 154 has_depth(false), |
| 155 has_stencil(false), | 155 has_stencil(false), |
| 156 request_alpha(false), | 156 request_alpha(false), |
| 157 request_depth(false), | 157 request_depth(false), |
| 158 request_stencil(false), | 158 request_stencil(false), |
| 159 bind_generates_resource(false), | 159 bind_generates_resource(false), |
| 160 lose_context_when_out_of_memory(false), | 160 lose_context_when_out_of_memory(false), |
| 161 use_native_vao(true), | 161 use_native_vao(true), |
| 162 webgl_version(0) { | 162 context_type(CONTEXT_TYPE_OPENGLES2) {} |
| 163 } | |
| 164 | 163 |
| 165 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { | 164 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { |
| 166 InitDecoderWithCommandLine(init, NULL); | 165 InitDecoderWithCommandLine(init, NULL); |
| 167 } | 166 } |
| 168 | 167 |
| 169 void GLES2DecoderTestBase::InitDecoderWithCommandLine( | 168 void GLES2DecoderTestBase::InitDecoderWithCommandLine( |
| 170 const InitState& init, | 169 const InitState& init, |
| 171 const base::CommandLine* command_line) { | 170 const base::CommandLine* command_line) { |
| 172 InitState normalized_init = init; | 171 InitState normalized_init = init; |
| 173 NormalizeInitState(&normalized_init); | 172 NormalizeInitState(&normalized_init); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // We initialize the ContextGroup with a MockGLES2Decoder so that | 216 // We initialize the ContextGroup with a MockGLES2Decoder so that |
| 218 // we can use the ContextGroup to figure out how the real GLES2Decoder | 217 // we can use the ContextGroup to figure out how the real GLES2Decoder |
| 219 // will initialize itself. | 218 // will initialize itself. |
| 220 mock_decoder_.reset(new MockGLES2Decoder()); | 219 mock_decoder_.reset(new MockGLES2Decoder()); |
| 221 | 220 |
| 222 // Install FakeDoCommands handler so we can use individual DoCommand() | 221 // Install FakeDoCommands handler so we can use individual DoCommand() |
| 223 // expectations. | 222 // expectations. |
| 224 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly( | 223 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly( |
| 225 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands)); | 224 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands)); |
| 226 | 225 |
| 226 EXPECT_TRUE(group_->Initialize(mock_decoder_.get(), init.context_type, |
| 227 DisallowedFeatures())); |
| 227 | 228 |
| 228 EXPECT_TRUE(group_->Initialize( | 229 if (init.context_type == CONTEXT_TYPE_WEBGL2 || |
| 229 mock_decoder_.get(), | 230 init.context_type == CONTEXT_TYPE_OPENGLES3) { |
| 230 ContextGroup::GetContextType(init.webgl_version), | |
| 231 DisallowedFeatures())); | |
| 232 | |
| 233 if (init.webgl_version == 2) { | |
| 234 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _)) | 231 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _)) |
| 235 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments)) | 232 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments)) |
| 236 .RetiresOnSaturation(); | 233 .RetiresOnSaturation(); |
| 237 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _)) | 234 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _)) |
| 238 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers)) | 235 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers)) |
| 239 .RetiresOnSaturation(); | 236 .RetiresOnSaturation(); |
| 240 } | 237 } |
| 241 | 238 |
| 242 if (group_->feature_info()->feature_flags().native_vertex_array_object) { | 239 if (group_->feature_info()->feature_flags().native_vertex_array_object) { |
| 243 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _)) | 240 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _)) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 engine_->GetSharedMemoryBuffer(kSharedMemoryId); | 392 engine_->GetSharedMemoryBuffer(kSharedMemoryId); |
| 396 shared_memory_offset_ = kSharedMemoryOffset; | 393 shared_memory_offset_ = kSharedMemoryOffset; |
| 397 shared_memory_address_ = | 394 shared_memory_address_ = |
| 398 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; | 395 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; |
| 399 shared_memory_id_ = kSharedMemoryId; | 396 shared_memory_id_ = kSharedMemoryId; |
| 400 shared_memory_base_ = buffer->memory(); | 397 shared_memory_base_ = buffer->memory(); |
| 401 | 398 |
| 402 static const int32 kLoseContextWhenOutOfMemory = 0x10002; | 399 static const int32 kLoseContextWhenOutOfMemory = 0x10002; |
| 403 static const int32 kWebGLVersion = 0x10003; | 400 static const int32 kWebGLVersion = 0x10003; |
| 404 | 401 |
| 405 int32 attributes[] = { | 402 int32 attributes[] = {EGL_ALPHA_SIZE, |
| 406 EGL_ALPHA_SIZE, | 403 normalized_init.request_alpha ? 8 : 0, |
| 407 normalized_init.request_alpha ? 8 : 0, | 404 EGL_DEPTH_SIZE, |
| 408 EGL_DEPTH_SIZE, | 405 normalized_init.request_depth ? 24 : 0, |
| 409 normalized_init.request_depth ? 24 : 0, | 406 EGL_STENCIL_SIZE, |
| 410 EGL_STENCIL_SIZE, | 407 normalized_init.request_stencil ? 8 : 0, |
| 411 normalized_init.request_stencil ? 8 : 0, | 408 kLoseContextWhenOutOfMemory, |
| 412 kLoseContextWhenOutOfMemory, | 409 normalized_init.lose_context_when_out_of_memory ? 1 : 0, |
| 413 normalized_init.lose_context_when_out_of_memory ? 1 : 0, | 410 kWebGLVersion, |
| 414 kWebGLVersion, | 411 init.context_type}; |
| 415 init.webgl_version | |
| 416 }; | |
| 417 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); | 412 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); |
| 418 | 413 |
| 419 decoder_.reset(GLES2Decoder::Create(group_.get())); | 414 decoder_.reset(GLES2Decoder::Create(group_.get())); |
| 420 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); | 415 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); |
| 421 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); | 416 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); |
| 422 decoder_->Initialize(surface_, | 417 ASSERT_TRUE(decoder_->Initialize(surface_, context_, false, |
| 423 context_, | 418 surface_->GetSize(), DisallowedFeatures(), |
| 424 false, | 419 attribs)); |
| 425 surface_->GetSize(), | 420 |
| 426 DisallowedFeatures(), | |
| 427 attribs); | |
| 428 EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true)); | 421 EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(true)); |
| 429 if (context_->WasAllocatedUsingRobustnessExtension()) { | 422 if (context_->WasAllocatedUsingRobustnessExtension()) { |
| 430 EXPECT_CALL(*gl_, GetGraphicsResetStatusARB()) | 423 EXPECT_CALL(*gl_, GetGraphicsResetStatusARB()) |
| 431 .WillOnce(Return(GL_NO_ERROR)); | 424 .WillOnce(Return(GL_NO_ERROR)); |
| 432 } | 425 } |
| 433 decoder_->MakeCurrent(); | 426 decoder_->MakeCurrent(); |
| 434 decoder_->set_engine(engine_.get()); | 427 decoder_->set_engine(engine_.get()); |
| 435 decoder_->BeginDecoding(); | 428 decoder_->BeginDecoding(); |
| 436 | 429 |
| 437 EXPECT_CALL(*gl_, GenBuffersARB(_, _)) | 430 EXPECT_CALL(*gl_, GenBuffersARB(_, _)) |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 SetupDefaultProgram(); | 1825 SetupDefaultProgram(); |
| 1833 } | 1826 } |
| 1834 | 1827 |
| 1835 // Include the auto-generated part of this file. We split this because it means | 1828 // Include the auto-generated part of this file. We split this because it means |
| 1836 // we can easily edit the non-auto generated parts right here in this file | 1829 // we can easily edit the non-auto generated parts right here in this file |
| 1837 // instead of having to edit some template or the code generator. | 1830 // instead of having to edit some template or the code generator. |
| 1838 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1831 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
| 1839 | 1832 |
| 1840 } // namespace gles2 | 1833 } // namespace gles2 |
| 1841 } // namespace gpu | 1834 } // namespace gpu |
| OLD | NEW |