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

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: Created 5 years, 3 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
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 } 113
114 114
115 GLManager::GLManager() : context_lost_allowed_(false) { 115 GLManager::GLManager() : context_lost_allowed_(false) {
116 SetupBaseContext(); 116 SetupBaseContext();
117 } 117 }
118 118
119 GLManager::~GLManager() { 119 GLManager::~GLManager() {
120 --use_count_; 120 --use_count_;
121 if (!use_count_) { 121 if (!use_count_) {
122 if (base_share_group_) { 122 if (base_share_group_) {
123 delete base_context_; 123 delete base_context_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu); 191 gfx::GpuPreference gpu_preference(gfx::PreferDiscreteGpu);
192 std::vector<int32> attribs; 192 std::vector<int32> attribs;
193 gles2::ContextCreationAttribHelper attrib_helper; 193 gles2::ContextCreationAttribHelper attrib_helper;
194 attrib_helper.red_size = 8; 194 attrib_helper.red_size = 8;
195 attrib_helper.green_size = 8; 195 attrib_helper.green_size = 8;
196 attrib_helper.blue_size = 8; 196 attrib_helper.blue_size = 8;
197 attrib_helper.alpha_size = 8; 197 attrib_helper.alpha_size = 8;
198 attrib_helper.depth_size = 16; 198 attrib_helper.depth_size = 16;
199 attrib_helper.stencil_size = 8; 199 attrib_helper.stencil_size = 8;
200 attrib_helper.webgl_version = options.webgl_version; 200 attrib_helper.context_type = options.context_type;
201
201 attrib_helper.Serialize(&attribs); 202 attrib_helper.Serialize(&attribs);
202 203
203 DCHECK(!command_line || !context_group); 204 DCHECK(!command_line || !context_group);
204 if (!context_group) { 205 if (!context_group) {
205 scoped_refptr<gles2::FeatureInfo> feature_info; 206 scoped_refptr<gles2::FeatureInfo> feature_info;
206 if (command_line) 207 if (command_line)
207 feature_info = new gles2::FeatureInfo(*command_line); 208 feature_info = new gles2::FeatureInfo(*command_line);
208 context_group = new gles2::ContextGroup( 209 context_group = new gles2::ContextGroup(
209 mailbox_manager_.get(), NULL, new gpu::gles2::ShaderTranslatorCache, 210 mailbox_manager_.get(), NULL, new gpu::gles2::ShaderTranslatorCache,
210 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL, 211 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL,
(...skipping 30 matching lines...) Expand all
241 } else { 242 } else {
242 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), 243 context_ = gfx::GLContext::CreateGLContext(share_group_.get(),
243 surface_.get(), 244 surface_.get(),
244 gpu_preference); 245 gpu_preference);
245 } 246 }
246 } 247 }
247 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; 248 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context";
248 249
249 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); 250 ASSERT_TRUE(context_->MakeCurrent(surface_.get()));
250 251
251 ASSERT_TRUE(decoder_->Initialize( 252 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size,
252 surface_.get(), 253 ::gpu::gles2::DisallowedFeatures(), attribs)) {
253 context_.get(), 254 return;
254 true, 255 }
255 options.size,
256 ::gpu::gles2::DisallowedFeatures(),
257 attribs)) << "could not initialize decoder";
258 256
259 command_buffer_->SetPutOffsetChangeCallback( 257 command_buffer_->SetPutOffsetChangeCallback(
260 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); 258 base::Bind(&GLManager::PumpCommands, base::Unretained(this)));
261 command_buffer_->SetGetBufferChangeCallback( 259 command_buffer_->SetGetBufferChangeCallback(
262 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); 260 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this)));
263 261
264 // Create the GLES2 helper, which writes the command buffer protocol. 262 // Create the GLES2 helper, which writes the command buffer protocol.
265 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); 263 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get()));
266 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize)); 264 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize));
267 265
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (gles2_implementation_.get()) { 317 if (gles2_implementation_.get()) {
320 MakeCurrent(); 318 MakeCurrent();
321 EXPECT_TRUE(glGetError() == GL_NONE); 319 EXPECT_TRUE(glGetError() == GL_NONE);
322 gles2_implementation_->Flush(); 320 gles2_implementation_->Flush();
323 gles2_implementation_.reset(); 321 gles2_implementation_.reset();
324 } 322 }
325 transfer_buffer_.reset(); 323 transfer_buffer_.reset();
326 gles2_helper_.reset(); 324 gles2_helper_.reset();
327 command_buffer_.reset(); 325 command_buffer_.reset();
328 if (decoder_.get()) { 326 if (decoder_.get()) {
329 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); 327 bool have_context = decoder_->GetGLContext() &&
328 decoder_->GetGLContext()->MakeCurrent(surface_.get());
330 decoder_->Destroy(have_context); 329 decoder_->Destroy(have_context);
331 decoder_.reset(); 330 decoder_.reset();
332 } 331 }
333 } 332 }
334 333
335 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const { 334 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const {
336 return decoder_->GetContextGroup()->feature_info()->workarounds(); 335 return decoder_->GetContextGroup()->feature_info()->workarounds();
337 } 336 }
338 337
339 void GLManager::PumpCommands() { 338 void GLManager::PumpCommands() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 void GLManager::SetLock(base::Lock*) { 431 void GLManager::SetLock(base::Lock*) {
433 NOTIMPLEMENTED(); 432 NOTIMPLEMENTED();
434 } 433 }
435 434
436 bool GLManager::IsGpuChannelLost() { 435 bool GLManager::IsGpuChannelLost() {
437 NOTIMPLEMENTED(); 436 NOTIMPLEMENTED();
438 return false; 437 return false;
439 } 438 }
440 439
441 } // namespace gpu 440 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698