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 |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 13 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
14 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 14 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 15 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
16 #include "gpu/command_buffer/service/context_group.h" | 16 #include "gpu/command_buffer/service/context_group.h" |
17 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
18 #include "gpu/command_buffer/service/logger.h" | 18 #include "gpu/command_buffer/service/logger.h" |
19 #include "gpu/command_buffer/service/program_manager.h" | 19 #include "gpu/command_buffer/service/program_manager.h" |
20 #include "gpu/command_buffer/service/test_helper.h" | 20 #include "gpu/command_buffer/service/test_helper.h" |
21 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 21 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/gl/gl_implementation.h" | 23 #include "ui/gl/gl_implementation.h" |
24 #include "ui/gl/gl_mock.h" | 24 #include "ui/gl/gl_mock.h" |
| 25 #include "ui/gl/gl_surface.h" |
25 | 26 |
26 using ::gfx::MockGLInterface; | 27 using ::gfx::MockGLInterface; |
27 using ::testing::_; | 28 using ::testing::_; |
28 using ::testing::DoAll; | 29 using ::testing::DoAll; |
29 using ::testing::InSequence; | 30 using ::testing::InSequence; |
30 using ::testing::MatcherCast; | 31 using ::testing::MatcherCast; |
31 using ::testing::Pointee; | 32 using ::testing::Pointee; |
32 using ::testing::Return; | 33 using ::testing::Return; |
33 using ::testing::SetArrayArgument; | 34 using ::testing::SetArrayArgument; |
34 using ::testing::SetArgPointee; | 35 using ::testing::SetArgPointee; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bool has_alpha, | 109 bool has_alpha, |
109 bool has_depth, | 110 bool has_depth, |
110 bool has_stencil, | 111 bool has_stencil, |
111 bool request_alpha, | 112 bool request_alpha, |
112 bool request_depth, | 113 bool request_depth, |
113 bool request_stencil, | 114 bool request_stencil, |
114 bool bind_generates_resource, | 115 bool bind_generates_resource, |
115 const CommandLine* command_line) { | 116 const CommandLine* command_line) { |
116 Framebuffer::ClearFramebufferCompleteComboMap(); | 117 Framebuffer::ClearFramebufferCompleteComboMap(); |
117 | 118 |
118 gfx::ClearGLBindings(); | |
119 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); | 119 gfx::SetGLGetProcAddressProc(gfx::MockGLInterface::GetGLProcAddress); |
120 gfx::InitializeStaticGLBindings(gfx::kGLImplementationMockGL); | 120 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests(); |
121 | 121 |
122 gl_.reset(new StrictMock<MockGLInterface>()); | 122 gl_.reset(new StrictMock<MockGLInterface>()); |
123 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); | 123 ::gfx::MockGLInterface::SetGLInterface(gl_.get()); |
124 | 124 |
125 // Only create stream texture manager if extension is requested. | 125 // Only create stream texture manager if extension is requested. |
126 std::vector<std::string> list; | 126 std::vector<std::string> list; |
127 base::SplitString(std::string(extensions), ' ', &list); | 127 base::SplitString(std::string(extensions), ' ', &list); |
128 if (std::find(list.begin(), list.end(), | 128 if (std::find(list.begin(), list.end(), |
129 "GL_CHROMIUM_stream_texture") != list.end()) | 129 "GL_CHROMIUM_stream_texture") != list.end()) |
130 stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>); | 130 stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 shared_memory_base_ = buffer.ptr; | 286 shared_memory_base_ = buffer.ptr; |
287 | 287 |
288 surface_ = new gfx::GLSurfaceStub; | 288 surface_ = new gfx::GLSurfaceStub; |
289 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); | 289 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); |
290 | 290 |
291 context_ = new gfx::GLContextStubWithExtensions; | 291 context_ = new gfx::GLContextStubWithExtensions; |
292 context_->AddExtensionsString(extensions); | 292 context_->AddExtensionsString(extensions); |
293 context_->SetGLVersionString(gl_version); | 293 context_->SetGLVersionString(gl_version); |
294 | 294 |
295 context_->MakeCurrent(surface_.get()); | 295 context_->MakeCurrent(surface_.get()); |
296 gfx::InitializeDynamicGLBindings(gfx::kGLImplementationMockGL, context_); | 296 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_); |
297 | 297 |
298 int32 attributes[] = { | 298 int32 attributes[] = { |
299 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, | 299 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, |
300 EGL_DEPTH_SIZE, request_depth ? 24 : 0, | 300 EGL_DEPTH_SIZE, request_depth ? 24 : 0, |
301 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, | 301 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, |
302 }; | 302 }; |
303 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); | 303 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); |
304 | 304 |
305 decoder_.reset(GLES2Decoder::Create(group_.get())); | 305 decoder_.reset(GLES2Decoder::Create(group_.get())); |
306 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); | 306 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); |
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1439 SetupDefaultProgram(); | 1439 SetupDefaultProgram(); |
1440 } | 1440 } |
1441 | 1441 |
1442 // Include the auto-generated part of this file. We split this because it means | 1442 // Include the auto-generated part of this file. We split this because it means |
1443 // we can easily edit the non-auto generated parts right here in this file | 1443 // we can easily edit the non-auto generated parts right here in this file |
1444 // instead of having to edit some template or the code generator. | 1444 // instead of having to edit some template or the code generator. |
1445 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" | 1445 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" |
1446 | 1446 |
1447 } // namespace gles2 | 1447 } // namespace gles2 |
1448 } // namespace gpu | 1448 } // namespace gpu |
OLD | NEW |