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/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 Loading... |
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(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 Loading... |
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 switch (options.context_type) { |
| 200 case CONTEXT_TYPE_WEBGL1: |
| 201 attrib_helper.context_type = |
| 202 gles2::ContextCreationAttribHelper::CONTEXT_TYPE_WEBGL1; |
| 203 break; |
| 204 case CONTEXT_TYPE_WEBGL2: |
| 205 attrib_helper.context_type = |
| 206 gles2::ContextCreationAttribHelper::CONTEXT_TYPE_WEBGL2; |
| 207 break; |
| 208 case CONTEXT_TYPE_OPENGLES2: |
| 209 attrib_helper.context_type = |
| 210 gles2::ContextCreationAttribHelper::CONTEXT_TYPE_OPENGLES2; |
| 211 break; |
| 212 case CONTEXT_TYPE_OPENGLES3: |
| 213 attrib_helper.context_type = |
| 214 gles2::ContextCreationAttribHelper::CONTEXT_TYPE_OPENGLES3; |
| 215 break; |
| 216 } |
| 217 |
201 attrib_helper.Serialize(&attribs); | 218 attrib_helper.Serialize(&attribs); |
202 | 219 |
203 DCHECK(!command_line || !context_group); | 220 DCHECK(!command_line || !context_group); |
204 if (!context_group) { | 221 if (!context_group) { |
205 scoped_refptr<gles2::FeatureInfo> feature_info; | 222 scoped_refptr<gles2::FeatureInfo> feature_info; |
206 if (command_line) | 223 if (command_line) |
207 feature_info = new gles2::FeatureInfo(*command_line); | 224 feature_info = new gles2::FeatureInfo(*command_line); |
208 context_group = new gles2::ContextGroup( | 225 context_group = new gles2::ContextGroup( |
209 mailbox_manager_.get(), NULL, new gpu::gles2::ShaderTranslatorCache, | 226 mailbox_manager_.get(), NULL, new gpu::gles2::ShaderTranslatorCache, |
210 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL, | 227 new gpu::gles2::FramebufferCompletenessCache, feature_info, NULL, NULL, |
(...skipping 30 matching lines...) Expand all Loading... |
241 } else { | 258 } else { |
242 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), | 259 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), |
243 surface_.get(), | 260 surface_.get(), |
244 gpu_preference); | 261 gpu_preference); |
245 } | 262 } |
246 } | 263 } |
247 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; | 264 ASSERT_TRUE(context_.get() != NULL) << "could not create GL context"; |
248 | 265 |
249 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); | 266 ASSERT_TRUE(context_->MakeCurrent(surface_.get())); |
250 | 267 |
251 ASSERT_TRUE(decoder_->Initialize( | 268 if (!decoder_->Initialize(surface_.get(), context_.get(), true, options.size, |
252 surface_.get(), | 269 ::gpu::gles2::DisallowedFeatures(), attribs)) { |
253 context_.get(), | 270 return; |
254 true, | 271 } |
255 options.size, | |
256 ::gpu::gles2::DisallowedFeatures(), | |
257 attribs)) << "could not initialize decoder"; | |
258 | 272 |
259 command_buffer_->SetPutOffsetChangeCallback( | 273 command_buffer_->SetPutOffsetChangeCallback( |
260 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); | 274 base::Bind(&GLManager::PumpCommands, base::Unretained(this))); |
261 command_buffer_->SetGetBufferChangeCallback( | 275 command_buffer_->SetGetBufferChangeCallback( |
262 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); | 276 base::Bind(&GLManager::GetBufferChanged, base::Unretained(this))); |
263 | 277 |
264 // Create the GLES2 helper, which writes the command buffer protocol. | 278 // Create the GLES2 helper, which writes the command buffer protocol. |
265 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); | 279 gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); |
266 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize)); | 280 ASSERT_TRUE(gles2_helper_->Initialize(kCommandBufferSize)); |
267 | 281 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (gles2_implementation_.get()) { | 333 if (gles2_implementation_.get()) { |
320 MakeCurrent(); | 334 MakeCurrent(); |
321 EXPECT_TRUE(glGetError() == GL_NONE); | 335 EXPECT_TRUE(glGetError() == GL_NONE); |
322 gles2_implementation_->Flush(); | 336 gles2_implementation_->Flush(); |
323 gles2_implementation_.reset(); | 337 gles2_implementation_.reset(); |
324 } | 338 } |
325 transfer_buffer_.reset(); | 339 transfer_buffer_.reset(); |
326 gles2_helper_.reset(); | 340 gles2_helper_.reset(); |
327 command_buffer_.reset(); | 341 command_buffer_.reset(); |
328 if (decoder_.get()) { | 342 if (decoder_.get()) { |
329 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); | 343 bool have_context = decoder_->GetGLContext() && |
| 344 decoder_->GetGLContext()->MakeCurrent(surface_.get()); |
330 decoder_->Destroy(have_context); | 345 decoder_->Destroy(have_context); |
331 decoder_.reset(); | 346 decoder_.reset(); |
332 } | 347 } |
333 } | 348 } |
334 | 349 |
335 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const { | 350 const gpu::gles2::FeatureInfo::Workarounds& GLManager::workarounds() const { |
336 return decoder_->GetContextGroup()->feature_info()->workarounds(); | 351 return decoder_->GetContextGroup()->feature_info()->workarounds(); |
337 } | 352 } |
338 | 353 |
339 void GLManager::PumpCommands() { | 354 void GLManager::PumpCommands() { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 void GLManager::SetLock(base::Lock*) { | 447 void GLManager::SetLock(base::Lock*) { |
433 NOTIMPLEMENTED(); | 448 NOTIMPLEMENTED(); |
434 } | 449 } |
435 | 450 |
436 bool GLManager::IsGpuChannelLost() { | 451 bool GLManager::IsGpuChannelLost() { |
437 NOTIMPLEMENTED(); | 452 NOTIMPLEMENTED(); |
438 return false; | 453 return false; |
439 } | 454 } |
440 | 455 |
441 } // namespace gpu | 456 } // namespace gpu |
OLD | NEW |