Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc

Issue 135213003: Ensure GL initialization only happens once, and provide common init path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initgl: compile3 Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/common/unittest_main.cc ('k') | gpu/config/gpu_info_collector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 scoped_refptr<FeatureInfo> feature_info; 128 scoped_refptr<FeatureInfo> feature_info;
129 if (command_line) 129 if (command_line)
130 feature_info = new FeatureInfo(*command_line); 130 feature_info = new FeatureInfo(*command_line);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 shared_memory_base_ = buffer.ptr; 282 shared_memory_base_ = buffer.ptr;
283 283
284 surface_ = new gfx::GLSurfaceStub; 284 surface_ = new gfx::GLSurfaceStub;
285 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); 285 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight));
286 286
287 context_ = new gfx::GLContextStubWithExtensions; 287 context_ = new gfx::GLContextStubWithExtensions;
288 context_->AddExtensionsString(extensions); 288 context_->AddExtensionsString(extensions);
289 context_->SetGLVersionString(gl_version); 289 context_->SetGLVersionString(gl_version);
290 290
291 context_->MakeCurrent(surface_.get()); 291 context_->MakeCurrent(surface_.get());
292 gfx::InitializeDynamicGLBindings(gfx::kGLImplementationMockGL, context_); 292 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_);
293 293
294 int32 attributes[] = { 294 int32 attributes[] = {
295 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, 295 EGL_ALPHA_SIZE, request_alpha ? 8 : 0,
296 EGL_DEPTH_SIZE, request_depth ? 24 : 0, 296 EGL_DEPTH_SIZE, request_depth ? 24 : 0,
297 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, 297 EGL_STENCIL_SIZE, request_stencil ? 8 : 0,
298 }; 298 };
299 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); 299 std::vector<int32> attribs(attributes, attributes + arraysize(attributes));
300 300
301 decoder_.reset(GLES2Decoder::Create(group_.get())); 301 decoder_.reset(GLES2Decoder::Create(group_.get()));
302 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); 302 decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1435 SetupDefaultProgram(); 1435 SetupDefaultProgram();
1436 } 1436 }
1437 1437
1438 // Include the auto-generated part of this file. We split this because it means 1438 // 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 1439 // 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. 1440 // instead of having to edit some template or the code generator.
1441 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" 1441 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h"
1442 1442
1443 } // namespace gles2 1443 } // namespace gles2
1444 } // namespace gpu 1444 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/unittest_main.cc ('k') | gpu/config/gpu_info_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698