| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 client_query_id_(123), | 55 client_query_id_(123), |
| 56 client_vertexarray_id_(124) { | 56 client_vertexarray_id_(124) { |
| 57 memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_)); | 57 memset(immediate_buffer_, 0xEE, sizeof(immediate_buffer_)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 GLES2DecoderTestBase::~GLES2DecoderTestBase() {} | 60 GLES2DecoderTestBase::~GLES2DecoderTestBase() {} |
| 61 | 61 |
| 62 void GLES2DecoderTestBase::SetUp() { | 62 void GLES2DecoderTestBase::SetUp() { |
| 63 InitDecoder( | 63 InitDecoder( |
| 64 "", // extensions | 64 "", // extensions |
| 65 "3.0", // gl version |
| 65 true, // has alpha | 66 true, // has alpha |
| 66 true, // has depth | 67 true, // has depth |
| 67 false, // has stencil | 68 false, // has stencil |
| 68 true, // request alpha | 69 true, // request alpha |
| 69 true, // request depth | 70 true, // request depth |
| 70 false, // request stencil | 71 false, // request stencil |
| 71 true); // bind generates resource | 72 true); // bind generates resource |
| 72 } | 73 } |
| 73 | 74 |
| 74 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { | 75 void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { |
| 75 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) { | 76 for (GLint ii = 0; ii < kNumVertexAttribs; ++ii) { |
| 76 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) | 77 EXPECT_CALL(*gl_, VertexAttrib4f(ii, 0.0f, 0.0f, 0.0f, 1.0f)) |
| 77 .Times(1) | 78 .Times(1) |
| 78 .RetiresOnSaturation(); | 79 .RetiresOnSaturation(); |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 | 82 |
| 82 void GLES2DecoderTestBase::InitDecoder( | 83 void GLES2DecoderTestBase::InitDecoder( |
| 83 const char* extensions, | 84 const char* extensions, |
| 85 const char* gl_version, |
| 84 bool has_alpha, | 86 bool has_alpha, |
| 85 bool has_depth, | 87 bool has_depth, |
| 86 bool has_stencil, | 88 bool has_stencil, |
| 87 bool request_alpha, | 89 bool request_alpha, |
| 88 bool request_depth, | 90 bool request_depth, |
| 89 bool request_stencil, | 91 bool request_stencil, |
| 90 bool bind_generates_resource) { | 92 bool bind_generates_resource) { |
| 91 InitDecoderWithCommandLine(extensions, | 93 InitDecoderWithCommandLine(extensions, |
| 94 gl_version, |
| 92 has_alpha, | 95 has_alpha, |
| 93 has_depth, | 96 has_depth, |
| 94 has_stencil, | 97 has_stencil, |
| 95 request_alpha, | 98 request_alpha, |
| 96 request_depth, | 99 request_depth, |
| 97 request_stencil, | 100 request_stencil, |
| 98 bind_generates_resource, | 101 bind_generates_resource, |
| 99 NULL); | 102 NULL); |
| 100 } | 103 } |
| 101 | 104 |
| 102 void GLES2DecoderTestBase::InitDecoderWithCommandLine( | 105 void GLES2DecoderTestBase::InitDecoderWithCommandLine( |
| 103 const char* extensions, | 106 const char* extensions, |
| 107 const char* gl_version, |
| 104 bool has_alpha, | 108 bool has_alpha, |
| 105 bool has_depth, | 109 bool has_depth, |
| 106 bool has_stencil, | 110 bool has_stencil, |
| 107 bool request_alpha, | 111 bool request_alpha, |
| 108 bool request_depth, | 112 bool request_depth, |
| 109 bool request_stencil, | 113 bool request_stencil, |
| 110 bool bind_generates_resource, | 114 bool bind_generates_resource, |
| 111 const CommandLine* command_line) { | 115 const CommandLine* command_line) { |
| 112 Framebuffer::ClearFramebufferCompleteComboMap(); | 116 Framebuffer::ClearFramebufferCompleteComboMap(); |
| 117 |
| 118 gfx::ClearGLBindings(); |
| 119 gfx::InitializeStaticGLBindings(gfx::kGLImplementationMockGL); |
| 120 |
| 113 gl_.reset(new StrictMock<MockGLInterface>()); | 121 gl_.reset(new StrictMock<MockGLInterface>()); |
| 114 ::gfx::GLInterface::SetGLInterface(gl_.get()); | 122 ::gfx::GLInterface::SetGLInterface(gl_.get()); |
| 115 | 123 |
| 116 // Only create stream texture manager if extension is requested. | 124 // Only create stream texture manager if extension is requested. |
| 117 std::vector<std::string> list; | 125 std::vector<std::string> list; |
| 118 base::SplitString(std::string(extensions), ' ', &list); | 126 base::SplitString(std::string(extensions), ' ', &list); |
| 119 if (std::find(list.begin(), list.end(), | 127 if (std::find(list.begin(), list.end(), |
| 120 "GL_CHROMIUM_stream_texture") != list.end()) | 128 "GL_CHROMIUM_stream_texture") != list.end()) |
| 121 stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>); | 129 stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>); |
| 122 scoped_refptr<FeatureInfo> feature_info; | 130 scoped_refptr<FeatureInfo> feature_info; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 gpu::Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); | 280 gpu::Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); |
| 273 shared_memory_offset_ = kSharedMemoryOffset; | 281 shared_memory_offset_ = kSharedMemoryOffset; |
| 274 shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + | 282 shared_memory_address_ = reinterpret_cast<int8*>(buffer.ptr) + |
| 275 shared_memory_offset_; | 283 shared_memory_offset_; |
| 276 shared_memory_id_ = kSharedMemoryId; | 284 shared_memory_id_ = kSharedMemoryId; |
| 277 shared_memory_base_ = buffer.ptr; | 285 shared_memory_base_ = buffer.ptr; |
| 278 | 286 |
| 279 surface_ = new gfx::GLSurfaceStub; | 287 surface_ = new gfx::GLSurfaceStub; |
| 280 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); | 288 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); |
| 281 | 289 |
| 282 context_ = new gfx::GLContextStub; | 290 context_ = new gfx::GLContextStubWithExtensions; |
| 291 context_->AddExtensionsString(extensions); |
| 292 context_->SetGLVersionString(gl_version); |
| 283 | 293 |
| 284 context_->MakeCurrent(surface_.get()); | 294 context_->MakeCurrent(surface_.get()); |
| 295 gfx::InitializeDynamicGLBindings(gfx::kGLImplementationMockGL, context_); |
| 285 | 296 |
| 286 int32 attributes[] = { | 297 int32 attributes[] = { |
| 287 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, | 298 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, |
| 288 EGL_DEPTH_SIZE, request_depth ? 24 : 0, | 299 EGL_DEPTH_SIZE, request_depth ? 24 : 0, |
| 289 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, | 300 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, |
| 290 }; | 301 }; |
| 291 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); | 302 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); |
| 292 | 303 |
| 293 decoder_.reset(GLES2Decoder::Create(group_.get())); | 304 decoder_.reset(GLES2Decoder::Create(group_.get())); |
| 294 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); | 305 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 SetupDefaultProgram(); | 1436 SetupDefaultProgram(); |
| 1426 } | 1437 } |
| 1427 | 1438 |
| 1428 // Include the auto-generated part of this file. We split this because it means | 1439 // Include the auto-generated part of this file. We split this because it means |
| 1429 // we can easily edit the non-auto generated parts right here in this file | 1440 // we can easily edit the non-auto generated parts right here in this file |
| 1430 // instead of having to edit some template or the code generator. | 1441 // instead of having to edit some template or the code generator. |
| 1431 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1442 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
| 1432 | 1443 |
| 1433 } // namespace gles2 | 1444 } // namespace gles2 |
| 1434 } // namespace gpu | 1445 } // namespace gpu |
| OLD | NEW |