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