| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 command_buffer_->SetGetBuffer(transfer_buffer_id); | 292 command_buffer_->SetGetBuffer(transfer_buffer_id); |
| 293 return true; | 293 return true; |
| 294 } | 294 } |
| 295 | 295 |
| 296 bool InProcessCommandBuffer::Initialize( | 296 bool InProcessCommandBuffer::Initialize( |
| 297 scoped_refptr<gfx::GLSurface> surface, | 297 scoped_refptr<gfx::GLSurface> surface, |
| 298 bool is_offscreen, | 298 bool is_offscreen, |
| 299 bool share_resources, | 299 bool share_resources, |
| 300 gfx::AcceleratedWidget window, | 300 gfx::AcceleratedWidget window, |
| 301 const gfx::Size& size, | 301 const gfx::Size& size, |
| 302 const char* allowed_extensions, | |
| 303 const std::vector<int32>& attribs, | 302 const std::vector<int32>& attribs, |
| 304 gfx::GpuPreference gpu_preference, | 303 gfx::GpuPreference gpu_preference, |
| 305 const base::Closure& context_lost_callback, | 304 const base::Closure& context_lost_callback, |
| 306 unsigned int share_group_id) { | 305 unsigned int share_group_id) { |
| 307 | 306 |
| 308 share_resources_ = share_resources; | 307 share_resources_ = share_resources; |
| 309 context_lost_callback_ = WrapCallback(context_lost_callback); | 308 context_lost_callback_ = WrapCallback(context_lost_callback); |
| 310 share_group_id_ = share_group_id; | 309 share_group_id_ = share_group_id; |
| 311 | 310 |
| 312 if (surface) { | 311 if (surface) { |
| 313 // GPU thread must be the same as client thread due to GLSurface not being | 312 // GPU thread must be the same as client thread due to GLSurface not being |
| 314 // thread safe. | 313 // thread safe. |
| 315 sequence_checker_.reset(new base::SequenceChecker); | 314 sequence_checker_.reset(new base::SequenceChecker); |
| 316 surface_ = surface; | 315 surface_ = surface; |
| 317 } | 316 } |
| 318 | 317 |
| 319 base::Callback<bool(void)> init_task = | 318 base::Callback<bool(void)> init_task = |
| 320 base::Bind(&InProcessCommandBuffer::InitializeOnGpuThread, | 319 base::Bind(&InProcessCommandBuffer::InitializeOnGpuThread, |
| 321 base::Unretained(this), | 320 base::Unretained(this), |
| 322 is_offscreen, | 321 is_offscreen, |
| 323 window, | 322 window, |
| 324 size, | 323 size, |
| 325 allowed_extensions, | |
| 326 attribs, | 324 attribs, |
| 327 gpu_preference); | 325 gpu_preference); |
| 328 | 326 |
| 329 base::WaitableEvent completion(true, false); | 327 base::WaitableEvent completion(true, false); |
| 330 bool result = false; | 328 bool result = false; |
| 331 QueueTask( | 329 QueueTask( |
| 332 base::Bind(&RunTaskWithResult<bool>, init_task, &result, &completion)); | 330 base::Bind(&RunTaskWithResult<bool>, init_task, &result, &completion)); |
| 333 completion.Wait(); | 331 completion.Wait(); |
| 334 return result; | 332 return result; |
| 335 } | 333 } |
| 336 | 334 |
| 337 bool InProcessCommandBuffer::InitializeOnGpuThread( | 335 bool InProcessCommandBuffer::InitializeOnGpuThread( |
| 338 bool is_offscreen, | 336 bool is_offscreen, |
| 339 gfx::AcceleratedWidget window, | 337 gfx::AcceleratedWidget window, |
| 340 const gfx::Size& size, | 338 const gfx::Size& size, |
| 341 const char* allowed_extensions, | |
| 342 const std::vector<int32>& attribs, | 339 const std::vector<int32>& attribs, |
| 343 gfx::GpuPreference gpu_preference) { | 340 gfx::GpuPreference gpu_preference) { |
| 344 CheckSequencedThread(); | 341 CheckSequencedThread(); |
| 345 // Use one share group for all contexts. | 342 // Use one share group for all contexts. |
| 346 CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group, | 343 CR_DEFINE_STATIC_LOCAL(scoped_refptr<gfx::GLShareGroup>, share_group, |
| 347 (new gfx::GLShareGroup)); | 344 (new gfx::GLShareGroup)); |
| 348 | 345 |
| 349 DCHECK(size.width() >= 0 && size.height() >= 0); | 346 DCHECK(size.width() >= 0 && size.height() >= 0); |
| 350 | 347 |
| 351 TransferBufferManager* manager = new TransferBufferManager(); | 348 TransferBufferManager* manager = new TransferBufferManager(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 455 } |
| 459 | 456 |
| 460 gles2::DisallowedFeatures disallowed_features; | 457 gles2::DisallowedFeatures disallowed_features; |
| 461 disallowed_features.swap_buffer_complete_callback = true; | 458 disallowed_features.swap_buffer_complete_callback = true; |
| 462 disallowed_features.gpu_memory_manager = true; | 459 disallowed_features.gpu_memory_manager = true; |
| 463 if (!decoder_->Initialize(surface_, | 460 if (!decoder_->Initialize(surface_, |
| 464 context_, | 461 context_, |
| 465 is_offscreen, | 462 is_offscreen, |
| 466 size, | 463 size, |
| 467 disallowed_features, | 464 disallowed_features, |
| 468 allowed_extensions, | |
| 469 attribs)) { | 465 attribs)) { |
| 470 LOG(ERROR) << "Could not initialize decoder."; | 466 LOG(ERROR) << "Could not initialize decoder."; |
| 471 DestroyOnGpuThread(); | 467 DestroyOnGpuThread(); |
| 472 return false; | 468 return false; |
| 473 } | 469 } |
| 474 | 470 |
| 475 if (!is_offscreen) { | 471 if (!is_offscreen) { |
| 476 decoder_->SetResizeCallback(base::Bind( | 472 decoder_->SetResizeCallback(base::Bind( |
| 477 &InProcessCommandBuffer::OnResizeView, base::Unretained(this))); | 473 &InProcessCommandBuffer::OnResizeView, base::Unretained(this))); |
| 478 } | 474 } |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 g_gpu_queue.Get().RunTasks(); | 750 g_gpu_queue.Get().RunTasks(); |
| 755 } | 751 } |
| 756 | 752 |
| 757 // static | 753 // static |
| 758 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( | 754 void InProcessCommandBuffer::SetGpuMemoryBufferFactory( |
| 759 GpuMemoryBufferFactory* factory) { | 755 GpuMemoryBufferFactory* factory) { |
| 760 g_gpu_memory_buffer_factory = factory; | 756 g_gpu_memory_buffer_factory = factory; |
| 761 } | 757 } |
| 762 | 758 |
| 763 } // namespace gpu | 759 } // namespace gpu |
| OLD | NEW |