| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 : extensions("GL_EXT_framebuffer_object"), | 150 : extensions("GL_EXT_framebuffer_object"), |
| 151 gl_version("2.1"), | 151 gl_version("2.1"), |
| 152 has_alpha(false), | 152 has_alpha(false), |
| 153 has_depth(false), | 153 has_depth(false), |
| 154 has_stencil(false), | 154 has_stencil(false), |
| 155 request_alpha(false), | 155 request_alpha(false), |
| 156 request_depth(false), | 156 request_depth(false), |
| 157 request_stencil(false), | 157 request_stencil(false), |
| 158 bind_generates_resource(false), | 158 bind_generates_resource(false), |
| 159 lose_context_when_out_of_memory(false), | 159 lose_context_when_out_of_memory(false), |
| 160 use_native_vao(true) { | 160 use_native_vao(true), |
| 161 webgl_version(0) { |
| 161 } | 162 } |
| 162 | 163 |
| 163 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { | 164 void GLES2DecoderTestBase::InitDecoder(const InitState& init) { |
| 164 InitDecoderWithCommandLine(init, NULL); | 165 InitDecoderWithCommandLine(init, NULL); |
| 165 } | 166 } |
| 166 | 167 |
| 167 void GLES2DecoderTestBase::InitDecoderWithCommandLine( | 168 void GLES2DecoderTestBase::InitDecoderWithCommandLine( |
| 168 const InitState& init, | 169 const InitState& init, |
| 169 const base::CommandLine* command_line) { | 170 const base::CommandLine* command_line) { |
| 170 InitState normalized_init = init; | 171 InitState normalized_init = init; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // We initialize the ContextGroup with a MockGLES2Decoder so that | 221 // We initialize the ContextGroup with a MockGLES2Decoder so that |
| 221 // we can use the ContextGroup to figure out how the real GLES2Decoder | 222 // we can use the ContextGroup to figure out how the real GLES2Decoder |
| 222 // will initialize itself. | 223 // will initialize itself. |
| 223 mock_decoder_.reset(new MockGLES2Decoder()); | 224 mock_decoder_.reset(new MockGLES2Decoder()); |
| 224 | 225 |
| 225 // Install FakeDoCommands handler so we can use individual DoCommand() | 226 // Install FakeDoCommands handler so we can use individual DoCommand() |
| 226 // expectations. | 227 // expectations. |
| 227 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly( | 228 EXPECT_CALL(*mock_decoder_, DoCommands(_, _, _, _)).WillRepeatedly( |
| 228 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands)); | 229 Invoke(mock_decoder_.get(), &MockGLES2Decoder::FakeDoCommands)); |
| 229 | 230 |
| 230 EXPECT_TRUE( | |
| 231 group_->Initialize(mock_decoder_.get(), DisallowedFeatures())); | |
| 232 | 231 |
| 233 if (group_->feature_info()->IsES3Capable()) { | 232 EXPECT_TRUE(group_->Initialize( |
| 233 mock_decoder_.get(), |
| 234 ContextGroup::GetContextType(init.webgl_version), |
| 235 DisallowedFeatures())); |
| 236 |
| 237 if (init.webgl_version == 2) { |
| 234 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _)) | 238 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_COLOR_ATTACHMENTS, _)) |
| 235 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments)) | 239 .WillOnce(SetArgumentPointee<1>(kMaxColorAttachments)) |
| 236 .RetiresOnSaturation(); | 240 .RetiresOnSaturation(); |
| 237 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _)) | 241 EXPECT_CALL(*gl_, GetIntegerv(GL_MAX_DRAW_BUFFERS, _)) |
| 238 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers)) | 242 .WillOnce(SetArgumentPointee<1>(kMaxDrawBuffers)) |
| 239 .RetiresOnSaturation(); | 243 .RetiresOnSaturation(); |
| 240 } | 244 } |
| 241 | 245 |
| 242 if (group_->feature_info()->feature_flags().native_vertex_array_object) { | 246 if (group_->feature_info()->feature_flags().native_vertex_array_object) { |
| 243 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _)) | 247 EXPECT_CALL(*gl_, GenVertexArraysOES(1, _)) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 engine_.reset(new StrictMock<MockCommandBufferEngine>()); | 397 engine_.reset(new StrictMock<MockCommandBufferEngine>()); |
| 394 scoped_refptr<gpu::Buffer> buffer = | 398 scoped_refptr<gpu::Buffer> buffer = |
| 395 engine_->GetSharedMemoryBuffer(kSharedMemoryId); | 399 engine_->GetSharedMemoryBuffer(kSharedMemoryId); |
| 396 shared_memory_offset_ = kSharedMemoryOffset; | 400 shared_memory_offset_ = kSharedMemoryOffset; |
| 397 shared_memory_address_ = | 401 shared_memory_address_ = |
| 398 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; | 402 reinterpret_cast<int8*>(buffer->memory()) + shared_memory_offset_; |
| 399 shared_memory_id_ = kSharedMemoryId; | 403 shared_memory_id_ = kSharedMemoryId; |
| 400 shared_memory_base_ = buffer->memory(); | 404 shared_memory_base_ = buffer->memory(); |
| 401 | 405 |
| 402 static const int32 kLoseContextWhenOutOfMemory = 0x10002; | 406 static const int32 kLoseContextWhenOutOfMemory = 0x10002; |
| 403 static const int32 kES3ContextRequired = 0x10003; | 407 static const int32 kWebGLVersion = 0x10003; |
| 404 | |
| 405 bool es3_context_required = group_->feature_info()->IsES3Capable(); | |
| 406 | 408 |
| 407 int32 attributes[] = { | 409 int32 attributes[] = { |
| 408 EGL_ALPHA_SIZE, | 410 EGL_ALPHA_SIZE, |
| 409 normalized_init.request_alpha ? 8 : 0, | 411 normalized_init.request_alpha ? 8 : 0, |
| 410 EGL_DEPTH_SIZE, | 412 EGL_DEPTH_SIZE, |
| 411 normalized_init.request_depth ? 24 : 0, | 413 normalized_init.request_depth ? 24 : 0, |
| 412 EGL_STENCIL_SIZE, | 414 EGL_STENCIL_SIZE, |
| 413 normalized_init.request_stencil ? 8 : 0, | 415 normalized_init.request_stencil ? 8 : 0, |
| 414 kLoseContextWhenOutOfMemory, | 416 kLoseContextWhenOutOfMemory, |
| 415 normalized_init.lose_context_when_out_of_memory ? 1 : 0, | 417 normalized_init.lose_context_when_out_of_memory ? 1 : 0, |
| 416 kES3ContextRequired, | 418 kWebGLVersion, |
| 417 es3_context_required ? 1 : 0 | 419 init.webgl_version |
| 418 }; | 420 }; |
| 419 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); | 421 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); |
| 420 | 422 |
| 421 decoder_.reset(GLES2Decoder::Create(group_.get())); | 423 decoder_.reset(GLES2Decoder::Create(group_.get())); |
| 422 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); | 424 decoder_->SetIgnoreCachedStateForTest(ignore_cached_state_for_test_); |
| 423 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); | 425 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); |
| 424 decoder_->Initialize(surface_, | 426 decoder_->Initialize(surface_, |
| 425 context_, | 427 context_, |
| 426 false, | 428 false, |
| 427 surface_->GetSize(), | 429 surface_->GetSize(), |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 SetupDefaultProgram(); | 1818 SetupDefaultProgram(); |
| 1817 } | 1819 } |
| 1818 | 1820 |
| 1819 // Include the auto-generated part of this file. We split this because it means | 1821 // Include the auto-generated part of this file. We split this because it means |
| 1820 // we can easily edit the non-auto generated parts right here in this file | 1822 // we can easily edit the non-auto generated parts right here in this file |
| 1821 // instead of having to edit some template or the code generator. | 1823 // instead of having to edit some template or the code generator. |
| 1822 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1824 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
| 1823 | 1825 |
| 1824 } // namespace gles2 | 1826 } // namespace gles2 |
| 1825 } // namespace gpu | 1827 } // namespace gpu |
| OLD | NEW |