| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 memory_tracker_, | 134 memory_tracker_, |
| 135 feature_info.get(), | 135 feature_info.get(), |
| 136 bind_generates_resource)); | 136 bind_generates_resource)); |
| 137 // These two workarounds are always turned on. | 137 // These two workarounds are always turned on. |
| 138 group_->feature_info( | 138 group_->feature_info( |
| 139 )->workarounds_.set_texture_filter_before_generating_mipmap = true; | 139 )->workarounds_.set_texture_filter_before_generating_mipmap = true; |
| 140 group_->feature_info()->workarounds_.clear_alpha_in_readpixels = true; | 140 group_->feature_info()->workarounds_.clear_alpha_in_readpixels = true; |
| 141 | 141 |
| 142 InSequence sequence; | 142 InSequence sequence; |
| 143 | 143 |
| 144 surface_ = new gfx::GLSurfaceStub; |
| 145 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); |
| 146 |
| 147 // Context needs to be created before initializing ContextGroup, which will |
| 148 // in turn initialize FeatureInfo, which needs a context to determine |
| 149 // extension support. |
| 150 context_ = new gfx::GLContextStubWithExtensions; |
| 151 context_->AddExtensionsString(extensions); |
| 152 context_->SetGLVersionString(gl_version); |
| 153 |
| 154 context_->MakeCurrent(surface_.get()); |
| 155 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); |
| 156 |
| 144 TestHelper::SetupContextGroupInitExpectations(gl_.get(), | 157 TestHelper::SetupContextGroupInitExpectations(gl_.get(), |
| 145 DisallowedFeatures(), extensions); | 158 DisallowedFeatures(), extensions, gl_version); |
| 146 | 159 |
| 147 // We initialize the ContextGroup with a MockGLES2Decoder so that | 160 // We initialize the ContextGroup with a MockGLES2Decoder so that |
| 148 // we can use the ContextGroup to figure out how the real GLES2Decoder | 161 // we can use the ContextGroup to figure out how the real GLES2Decoder |
| 149 // will initialize itself. | 162 // will initialize itself. |
| 150 mock_decoder_.reset(new MockGLES2Decoder()); | 163 mock_decoder_.reset(new MockGLES2Decoder()); |
| 151 EXPECT_TRUE( | 164 EXPECT_TRUE( |
| 152 group_->Initialize(mock_decoder_.get(), DisallowedFeatures())); | 165 group_->Initialize(mock_decoder_.get(), DisallowedFeatures())); |
| 153 | 166 |
| 154 AddExpectationsForVertexAttribManager(); | 167 AddExpectationsForVertexAttribManager(); |
| 155 | 168 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 #endif | 287 #endif |
| 275 | 288 |
| 276 engine_.reset(new StrictMock<MockCommandBufferEngine>()); | 289 engine_.reset(new StrictMock<MockCommandBufferEngine>()); |
| 277 gpu::Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); | 290 gpu::Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); |
| 278 shared_memory_offset_ = kSharedMemoryOffset; | 291 shared_memory_offset_ = kSharedMemoryOffset; |
| 279 shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + | 292 shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + |
| 280 shared_memory_offset_; | 293 shared_memory_offset_; |
| 281 shared_memory_id_ = kSharedMemoryId; | 294 shared_memory_id_ = kSharedMemoryId; |
| 282 shared_memory_base_ = buffer.ptr; | 295 shared_memory_base_ = buffer.ptr; |
| 283 | 296 |
| 284 surface_ = new gfx::GLSurfaceStub; | |
| 285 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); | |
| 286 | |
| 287 context_ = new gfx::GLContextStubWithExtensions; | |
| 288 context_->AddExtensionsString(extensions); | |
| 289 context_->SetGLVersionString(gl_version); | |
| 290 | |
| 291 context_->MakeCurrent(surface_.get()); | |
| 292 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); | |
| 293 | |
| 294 int32 attributes[] = { | 297 int32 attributes[] = { |
| 295 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, | 298 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, |
| 296 EGL_DEPTH_SIZE, request_depth ? 24 : 0, | 299 EGL_DEPTH_SIZE, request_depth ? 24 : 0, |
| 297 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, | 300 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, |
| 298 }; | 301 }; |
| 299 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); | 302 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); |
| 300 | 303 |
| 301 decoder_.reset(GLES2Decoder::Create(group_.get())); | 304 decoder_.reset(GLES2Decoder::Create(group_.get())); |
| 302 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); | 305 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); |
| 303 decoder_->Initialize(surface_, | 306 decoder_->Initialize(surface_, |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 .RetiresOnSaturation(); | 830 .RetiresOnSaturation(); |
| 828 EXPECT_CALL(*gl_, GetError()) | 831 EXPECT_CALL(*gl_, GetError()) |
| 829 .WillOnce(Return(GL_NO_ERROR)) | 832 .WillOnce(Return(GL_NO_ERROR)) |
| 830 .RetiresOnSaturation(); | 833 .RetiresOnSaturation(); |
| 831 cmds::TexImage2D cmd; | 834 cmds::TexImage2D cmd; |
| 832 cmd.Init(target, level, internal_format, width, height, border, format, | 835 cmd.Init(target, level, internal_format, width, height, border, format, |
| 833 type, shared_memory_id, shared_memory_offset); | 836 type, shared_memory_id, shared_memory_offset); |
| 834 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 837 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 835 } | 838 } |
| 836 | 839 |
| 840 void GLES2DecoderTestBase::DoTexImage2DConvertInternalFormat( |
| 841 GLenum target, GLint level, GLenum call_internal_format, |
| 842 GLsizei width, GLsizei height, GLint border, |
| 843 GLenum format, GLenum type, |
| 844 uint32 shared_memory_id, uint32 shared_memory_offset, |
| 845 GLenum expected_internal_format) { |
| 846 EXPECT_CALL(*gl_, GetError()) |
| 847 .WillOnce(Return(GL_NO_ERROR)) |
| 848 .RetiresOnSaturation(); |
| 849 EXPECT_CALL(*gl_, TexImage2D(target, level, expected_internal_format, |
| 850 width, height, border, format, type, _)) |
| 851 .Times(1) |
| 852 .RetiresOnSaturation(); |
| 853 EXPECT_CALL(*gl_, GetError()) |
| 854 .WillOnce(Return(GL_NO_ERROR)) |
| 855 .RetiresOnSaturation(); |
| 856 cmds::TexImage2D cmd; |
| 857 cmd.Init(target, level, call_internal_format, width, height, border, format, |
| 858 type, shared_memory_id, shared_memory_offset); |
| 859 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 860 } |
| 861 |
| 837 void GLES2DecoderTestBase::DoCompressedTexImage2D( | 862 void GLES2DecoderTestBase::DoCompressedTexImage2D( |
| 838 GLenum target, GLint level, GLenum format, | 863 GLenum target, GLint level, GLenum format, |
| 839 GLsizei width, GLsizei height, GLint border, | 864 GLsizei width, GLsizei height, GLint border, |
| 840 GLsizei size, uint32 bucket_id) { | 865 GLsizei size, uint32 bucket_id) { |
| 841 EXPECT_CALL(*gl_, GetError()) | 866 EXPECT_CALL(*gl_, GetError()) |
| 842 .WillOnce(Return(GL_NO_ERROR)) | 867 .WillOnce(Return(GL_NO_ERROR)) |
| 843 .RetiresOnSaturation(); | 868 .RetiresOnSaturation(); |
| 844 EXPECT_CALL(*gl_, CompressedTexImage2D( | 869 EXPECT_CALL(*gl_, CompressedTexImage2D( |
| 845 target, level, format, width, height, border, size, _)) | 870 target, level, format, width, height, border, size, _)) |
| 846 .Times(1) | 871 .Times(1) |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 SetupDefaultProgram(); | 1460 SetupDefaultProgram(); |
| 1436 } | 1461 } |
| 1437 | 1462 |
| 1438 // Include the auto-generated part of this file. We split this because it means | 1463 // Include the auto-generated part of this file. We split this because it means |
| 1439 // we can easily edit the non-auto generated parts right here in this file | 1464 // we can easily edit the non-auto generated parts right here in this file |
| 1440 // instead of having to edit some template or the code generator. | 1465 // instead of having to edit some template or the code generator. |
| 1441 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1466 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
| 1442 | 1467 |
| 1443 } // namespace gles2 | 1468 } // namespace gles2 |
| 1444 } // namespace gpu | 1469 } // namespace gpu |
| OLD | NEW |