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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 1325433003: command_buffer: Add support for creating non-WebGL ES 3 contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing hunk Created 5 years, 2 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
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_program_unittest.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/tests/gl_manager.h" 5 #include "gpu/command_buffer/tests/gl_manager.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 scoped_refptr<gfx::GLContext>* GLManager::base_context_; 102 scoped_refptr<gfx::GLContext>* GLManager::base_context_;
103 103
104 GLManager::Options::Options() 104 GLManager::Options::Options()
105 : size(4, 4), 105 : size(4, 4),
106 share_group_manager(NULL), 106 share_group_manager(NULL),
107 share_mailbox_manager(NULL), 107 share_mailbox_manager(NULL),
108 virtual_manager(NULL), 108 virtual_manager(NULL),
109 bind_generates_resource(false), 109 bind_generates_resource(false),
110 lose_context_when_out_of_memory(false), 110 lose_context_when_out_of_memory(false),
111 context_lost_allowed(false), 111 context_lost_allowed(false),
112 webgl_version(0) { 112 context_type(gles2::CONTEXT_TYPE_OPENGLES2) {}
113 }
114 113
115 GLManager::GLManager() : context_lost_allowed_(false) { 114 GLManager::GLManager() : context_lost_allowed_(false) {
116 SetupBaseContext(); 115 SetupBaseContext();
117 } 116 }
118 117
119 GLManager::~GLManager() { 118 GLManager::~GLManager() {
120 --use_count_; 119 --use_count_;
121 if (!use_count_) { 120 if (!use_count_) {
122 if (base_share_group_) { 121 if (base_share_group_) {
123 delete base_context_; 122 delete base_context_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 189
191 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); 190 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu);
192 std::vector<int32> attribs; 191 std::vector<int32> attribs;
193 gles2::ContextCreationAttribHelper attrib_helper; 192 gles2::ContextCreationAttribHelper attrib_helper;
194 attrib_helper.red_size = 8; 193 attrib_helper.red_size = 8;
195 attrib_helper.green_size = 8; 194 attrib_helper.green_size = 8;
196 attrib_helper.blue_size = 8; 195 attrib_helper.blue_size = 8;
197 attrib_helper.alpha_size = 8; 196 attrib_helper.alpha_size = 8;
198 attrib_helper.depth_size = 16; 197 attrib_helper.depth_size = 16;
199 attrib_helper.stencil_size = 8; 198 attrib_helper.stencil_size = 8;
200 attrib_helper.webgl_version = options.webgl_version; 199 attrib_helper.context_type = options.context_type;
200
201 attrib_helper.Serialize(&attribs); 201 attrib_helper.Serialize(&attribs);
202 202
203 DCHECK(!command_line || !context_group); 203 DCHECK(!command_line || !context_group);
204 if (!context_group) { 204 if (!context_group) {
205 scoped_refptr<gles2::FeatureInfo> feature_info; 205 scoped_refptr<gles2::FeatureInfo> feature_info;
206 if (command_line) 206 if (command_line)
207 feature_info = new gles2::FeatureInfo(*command_line); 207 feature_info = new gles2::FeatureInfo(*command_line);
208 context_group = new gles2::ContextGroup( 208 context_group = new gles2::ContextGroup(
209 mailbox_manager_.get(), NULL, new gpu::gles2::ShaderTranslatorCache, 209 mailbox_manager_.get(), NULL, new gpu::gles2::ShaderTranslatorCache,
210 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL, 210 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL,
(...skipping 30 matching lines...) Expand all
241 } else { 241 } else {
242 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), 242 context_ = gfx::GLContext::CreateGLContext(share_group_.get(),
243 surface_.get(), 243 surface_.get(),
244 gpu_preference); 244 gpu_preference);
245 } 245 }
246 } 246 }
247 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; 247 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context";
248 248
249 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); 249 ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
250 250
251 ASSERT_TRUE(decoder_->Initialize( 251 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size,
252 surface_.get(), 252 ::gpu::gles2::DisallowedFeatures(), attribs)) {
253 context_.get(), 253 return;
254 true, 254 }
255 options.size,
256 ::gpu::gles2::DisallowedFeatures(),
257 attribs)) << "could not initialize decoder";
258 255
259 command_buffer_->SetPutOffsetChangeCallback( 256 command_buffer_->SetPutOffsetChangeCallback(
260 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); 257 base::Bind(&GLManager::PumpCommands, base::Unretained(this)));
261 command_buffer_->SetGetBufferChangeCallback( 258 command_buffer_->SetGetBufferChangeCallback(
262 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); 259 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this)));
263 260
264 // Create the GLES2 helper, which writes the command buffer protocol. 261 // Create the GLES2 helper, which writes the command buffer protocol.
265 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); 262 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get()));
266 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize)); 263 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize));
267 264
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (gles2_implementation_.get()) { 316 if (gles2_implementation_.get()) {
320 MakeCurrent(); 317 MakeCurrent();
321 EXPECT_TRUE(glGetError() == GL_NONE); 318 EXPECT_TRUE(glGetError() == GL_NONE);
322 gles2_implementation_->Flush(); 319 gles2_implementation_->Flush();
323 gles2_implementation_.reset(); 320 gles2_implementation_.reset();
324 } 321 }
325 transfer_buffer_.reset(); 322 transfer_buffer_.reset();
326 gles2_helper_.reset(); 323 gles2_helper_.reset();
327 command_buffer_.reset(); 324 command_buffer_.reset();
328 if (decoder_.get()) { 325 if (decoder_.get()) {
329 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); 326 bool have_context = decoder_->GetGLContext() &&
327 decoder_->GetGLContext()->MakeCurrent(surface_.get());
330 decoder_->Destroy(have_context); 328 decoder_->Destroy(have_context);
331 decoder_.reset(); 329 decoder_.reset();
332 } 330 }
333 } 331 }
334 332
335 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const { 333 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const {
336 return decoder_->GetContextGroup()->feature_info()->workarounds(); 334 return decoder_->GetContextGroup()->feature_info()->workarounds();
337 } 335 }
338 336
339 void GLManager::PumpCommands() { 337 void GLManager::PumpCommands() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 438
441 gpu::CommandBufferNamespace GLManager::GetNamespaceID() const { 439 gpu::CommandBufferNamespace GLManager::GetNamespaceID() const {
442 return gpu::CommandBufferNamespace::IN_PROCESS; 440 return gpu::CommandBufferNamespace::IN_PROCESS;
443 } 441 }
444 442
445 uint64_t GLManager::GetCommandBufferID() const { 443 uint64_t GLManager::GetCommandBufferID() const {
446 return 0; 444 return 0;
447 } 445 }
448 446
449 } // namespace gpu 447 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_program_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698