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

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: Created 6 years, 11 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
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
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 bool has_alpha, 108 bool has_alpha,
109 bool has_depth, 109 bool has_depth,
110 bool has_stencil, 110 bool has_stencil,
111 bool request_alpha, 111 bool request_alpha,
112 bool request_depth, 112 bool request_depth,
113 bool request_stencil, 113 bool request_stencil,
114 bool bind_generates_resource, 114 bool bind_generates_resource,
115 const CommandLine* command_line) { 115 const CommandLine* command_line) {
116 Framebuffer::ClearFramebufferCompleteComboMap(); 116 Framebuffer::ClearFramebufferCompleteComboMap();
117 117
118 gfx::ClearGLBindings(); 118 gfx::GLSurface::InitializeOneOffWithMockBindingsForTests();
119 gfx::InitializeStaticGLBindings(gfx::kGLImplementationMockGL);
120 119
121 gl_.reset(new StrictMock<MockGLInterface>()); 120 gl_.reset(new StrictMock<MockGLInterface>());
122 ::gfx::GLInterface::SetGLInterface(gl_.get()); 121 ::gfx::GLInterface::SetGLInterface(gl_.get());
123 122
124 // Only create stream texture manager if extension is requested. 123 // Only create stream texture manager if extension is requested.
125 std::vector<std::string> list; 124 std::vector<std::string> list;
126 base::SplitString(std::string(extensions), ' ', &list); 125 base::SplitString(std::string(extensions), ' ', &list);
127 if (std::find(list.begin(), list.end(), 126 if (std::find(list.begin(), list.end(),
128 "GL_CHROMIUM_stream_texture") != list.end()) 127 "GL_CHROMIUM_stream_texture") != list.end())
129 stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>); 128 stream_texture_manager_.reset(new StrictMock<MockStreamTextureManager>);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 shared_memory_base_ = buffer.ptr; 284 shared_memory_base_ = buffer.ptr;
286 285
287 surface_ = new gfx::GLSurfaceStub; 286 surface_ = new gfx::GLSurfaceStub;
288 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight)); 287 surface_->SetSize(gfx::Size(kBackBufferWidth, kBackBufferHeight));
289 288
290 context_ = new gfx::GLContextStubWithExtensions; 289 context_ = new gfx::GLContextStubWithExtensions;
291 context_->AddExtensionsString(extensions); 290 context_->AddExtensionsString(extensions);
292 context_->SetGLVersionString(gl_version); 291 context_->SetGLVersionString(gl_version);
293 292
294 context_->MakeCurrent(surface_.get()); 293 context_->MakeCurrent(surface_.get());
295 gfx::InitializeDynamicGLBindings(gfx::kGLImplementationMockGL, context_); 294 gfx::GLSurface::InitializeDynamicMockBindingsForTests(context_);
296 295
297 int32 attributes[] = { 296 int32 attributes[] = {
298 EGL_ALPHA_SIZE, request_alpha ? 8 : 0, 297 EGL_ALPHA_SIZE, request_alpha ? 8 : 0,
299 EGL_DEPTH_SIZE, request_depth ? 24 : 0, 298 EGL_DEPTH_SIZE, request_depth ? 24 : 0,
300 EGL_STENCIL_SIZE, request_stencil ? 8 : 0, 299 EGL_STENCIL_SIZE, request_stencil ? 8 : 0,
301 }; 300 };
302 std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); 301 std::vector<int32> attribs(attributes, attributes + arraysize(attributes));
303 302
304 decoder_.reset(GLES2Decoder::Create(group_.get())); 303 decoder_.reset(GLES2Decoder::Create(group_.get()));
305 decoder_->GetLogger()->set_log_synthesized_gl_errors(false); 304 decoder_->GetLogger()->set_log_synthesized_gl_errors(false);
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 SetupDefaultProgram(); 1437 SetupDefaultProgram();
1439 } 1438 }
1440 1439
1441 // Include the auto-generated part of this file. We split this because it means 1440 // Include the auto-generated part of this file. We split this because it means
1442 // we can easily edit the non-auto generated parts right here in this file 1441 // we can easily edit the non-auto generated parts right here in this file
1443 // instead of having to edit some template or the code generator. 1442 // instead of having to edit some template or the code generator.
1444 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h" 1443 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_0_autogen.h"
1445 1444
1446 } // namespace gles2 1445 } // namespace gles2
1447 } // namespace gpu 1446 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698