OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) | 5 #if defined(ENABLE_GPU) |
6 | 6 |
7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #ifndef GL_GLEXT_PROTOTYPES | 10 #ifndef GL_GLEXT_PROTOTYPES |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // functions are invoked. | 79 // functions are invoked. |
80 static bool Initialize(); | 80 static bool Initialize(); |
81 | 81 |
82 // Terminate the library. This must be called after any other functions | 82 // Terminate the library. This must be called after any other functions |
83 // have completed. | 83 // have completed. |
84 static bool Terminate(); | 84 static bool Terminate(); |
85 | 85 |
86 ~GLInProcessContext(); | 86 ~GLInProcessContext(); |
87 | 87 |
88 void PumpCommands(); | 88 void PumpCommands(); |
89 bool GetBufferChanged(int32 transfer_buffer_id); | |
90 | 89 |
91 // Create a GLInProcessContext that renders directly to a view. The view and | 90 // Create a GLInProcessContext that renders directly to a view. The view and |
92 // the associated window must not be destroyed until the returned | 91 // the associated window must not be destroyed until the returned |
93 // GLInProcessContext has been destroyed, otherwise the GPU process might | 92 // GLInProcessContext has been destroyed, otherwise the GPU process might |
94 // attempt to render to an invalid window handle. | 93 // attempt to render to an invalid window handle. |
95 // | 94 // |
96 // NOTE: on Mac OS X, this entry point is only used to set up the | 95 // NOTE: on Mac OS X, this entry point is only used to set up the |
97 // accelerated compositor's output. On this platform, we actually pass | 96 // accelerated compositor's output. On this platform, we actually pass |
98 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, | 97 // a gfx::PluginWindowHandle in place of the gfx::NativeViewId, |
99 // because the facility to allocate a fake PluginWindowHandle is | 98 // because the facility to allocate a fake PluginWindowHandle is |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 LAZY_INSTANCE_INITIALIZER; | 304 LAZY_INSTANCE_INITIALIZER; |
306 | 305 |
307 void GLInProcessContext::PumpCommands() { | 306 void GLInProcessContext::PumpCommands() { |
308 base::AutoLock lock(g_decoder_lock.Get()); | 307 base::AutoLock lock(g_decoder_lock.Get()); |
309 decoder_->MakeCurrent(); | 308 decoder_->MakeCurrent(); |
310 gpu_scheduler_->PutChanged(); | 309 gpu_scheduler_->PutChanged(); |
311 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); | 310 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); |
312 CHECK(state.error == ::gpu::error::kNoError); | 311 CHECK(state.error == ::gpu::error::kNoError); |
313 } | 312 } |
314 | 313 |
315 bool GLInProcessContext::GetBufferChanged(int32 transfer_buffer_id) { | |
316 return gpu_scheduler_->SetGetBuffer(transfer_buffer_id); | |
317 } | |
318 | |
319 uint32 GLInProcessContext::GetParentTextureId() { | 314 uint32 GLInProcessContext::GetParentTextureId() { |
320 return parent_texture_id_; | 315 return parent_texture_id_; |
321 } | 316 } |
322 | 317 |
323 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { | 318 uint32 GLInProcessContext::CreateParentTexture(const gfx::Size& size) { |
324 uint32 texture = 0; | 319 uint32 texture = 0; |
325 gles2_implementation_->GenTextures(1, &texture); | 320 gles2_implementation_->GenTextures(1, &texture); |
326 gles2_implementation_->Flush(); | 321 gles2_implementation_->Flush(); |
327 return texture; | 322 return texture; |
328 } | 323 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 break; | 450 break; |
456 default: | 451 default: |
457 last_error_ = BAD_ATTRIBUTE; | 452 last_error_ = BAD_ATTRIBUTE; |
458 attribs.push_back(NONE); | 453 attribs.push_back(NONE); |
459 attrib_list = NULL; | 454 attrib_list = NULL; |
460 break; | 455 break; |
461 } | 456 } |
462 } | 457 } |
463 | 458 |
464 command_buffer_.reset(new CommandBufferService); | 459 command_buffer_.reset(new CommandBufferService); |
465 if (!command_buffer_->Initialize()) { | 460 if (!command_buffer_->Initialize(kCommandBufferSize)) { |
466 LOG(ERROR) << "Could not initialize command buffer."; | 461 LOG(ERROR) << "Could not initialize command buffer."; |
467 Destroy(); | 462 Destroy(); |
468 return false; | 463 return false; |
469 } | 464 } |
470 | 465 |
471 // TODO(gman): This needs to be true if this is Pepper. | 466 // TODO(gman): This needs to be true if this is Pepper. |
472 bool bind_generates_resource = false; | 467 bool bind_generates_resource = false; |
473 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ? | 468 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ? |
474 context_group->decoder_->GetContextGroup() : | 469 context_group->decoder_->GetContextGroup() : |
475 new ::gpu::gles2::ContextGroup(bind_generates_resource))); | 470 new ::gpu::gles2::ContextGroup(bind_generates_resource))); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (!decoder_->SetParent( | 516 if (!decoder_->SetParent( |
522 parent_.get() ? parent_->decoder_.get() : NULL, | 517 parent_.get() ? parent_->decoder_.get() : NULL, |
523 parent_texture_id_)) { | 518 parent_texture_id_)) { |
524 LOG(ERROR) << "Could not set parent."; | 519 LOG(ERROR) << "Could not set parent."; |
525 Destroy(); | 520 Destroy(); |
526 return false; | 521 return false; |
527 } | 522 } |
528 | 523 |
529 command_buffer_->SetPutOffsetChangeCallback( | 524 command_buffer_->SetPutOffsetChangeCallback( |
530 base::Bind(&GLInProcessContext::PumpCommands, base::Unretained(this))); | 525 base::Bind(&GLInProcessContext::PumpCommands, base::Unretained(this))); |
531 command_buffer_->SetGetBufferChangeCallback( | |
532 base::Bind( | |
533 &GLInProcessContext::GetBufferChanged, base::Unretained(this))); | |
534 | 526 |
535 // Create the GLES2 helper, which writes the command buffer protocol. | 527 // Create the GLES2 helper, which writes the command buffer protocol. |
536 gles2_helper_.reset(new GLES2CmdHelper(command_buffer_.get())); | 528 gles2_helper_.reset(new GLES2CmdHelper(command_buffer_.get())); |
537 if (!gles2_helper_->Initialize(kCommandBufferSize)) { | 529 if (!gles2_helper_->Initialize(kCommandBufferSize)) { |
538 Destroy(); | 530 Destroy(); |
539 return false; | 531 return false; |
540 } | 532 } |
541 | 533 |
542 // Create a transfer buffer. | 534 // Create a transfer buffer. |
543 transfer_buffer_id_ = | 535 transfer_buffer_id_ = |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; | 1681 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; |
1690 if (context_lost_callback_) { | 1682 if (context_lost_callback_) { |
1691 context_lost_callback_->onContextLost(); | 1683 context_lost_callback_->onContextLost(); |
1692 } | 1684 } |
1693 } | 1685 } |
1694 | 1686 |
1695 } // namespace gpu | 1687 } // namespace gpu |
1696 } // namespace webkit | 1688 } // namespace webkit |
1697 | 1689 |
1698 #endif // defined(ENABLE_GPU) | 1690 #endif // defined(ENABLE_GPU) |
OLD | NEW |