| 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 "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 5 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
| 9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
| 10 #endif | 10 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/message_loop.h" | 23 #include "base/message_loop.h" |
| 24 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
| 25 #include "base/string_tokenizer.h" | 25 #include "base/string_tokenizer.h" |
| 26 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
| 27 #include "gpu/command_buffer/client/gles2_implementation.h" | 27 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 28 #include "gpu/command_buffer/client/gles2_lib.h" | 28 #include "gpu/command_buffer/client/gles2_lib.h" |
| 29 #include "gpu/command_buffer/client/transfer_buffer.h" | 29 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 30 #include "gpu/command_buffer/common/constants.h" | 30 #include "gpu/command_buffer/common/constants.h" |
| 31 #include "gpu/command_buffer/service/command_buffer_service.h" | 31 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 32 #include "gpu/command_buffer/service/context_group.h" | 32 #include "gpu/command_buffer/service/context_group.h" |
| 33 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 33 #include "gpu/command_buffer/service/gpu_scheduler.h" | 34 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 37 #include "ui/gl/gl_context.h" | 38 #include "ui/gl/gl_context.h" |
| 38 #include "ui/gl/gl_share_group.h" | 39 #include "ui/gl/gl_share_group.h" |
| 39 #include "ui/gl/gl_surface.h" | 40 #include "ui/gl/gl_surface.h" |
| 40 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" | 41 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" |
| 41 | 42 |
| 42 using gpu::Buffer; | 43 using gpu::Buffer; |
| 43 using gpu::CommandBuffer; | 44 using gpu::CommandBuffer; |
| 44 using gpu::CommandBufferService; | 45 using gpu::CommandBufferService; |
| 45 using gpu::gles2::GLES2CmdHelper; | 46 using gpu::gles2::GLES2CmdHelper; |
| 46 using gpu::gles2::GLES2Implementation; | 47 using gpu::gles2::GLES2Implementation; |
| 47 using gpu::GpuScheduler; | 48 using gpu::GpuScheduler; |
| 48 using gpu::TransferBuffer; | 49 using gpu::TransferBuffer; |
| 50 using gpu::TransferBufferManager; |
| 51 using gpu::TransferBufferManagerInterface; |
| 49 | 52 |
| 50 namespace webkit { | 53 namespace webkit { |
| 51 namespace gpu { | 54 namespace gpu { |
| 52 | 55 |
| 53 class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { | 56 class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { |
| 54 public: | 57 public: |
| 55 // These are the same error codes as used by EGL. | 58 // These are the same error codes as used by EGL. |
| 56 enum Error { | 59 enum Error { |
| 57 SUCCESS = 0x3000, | 60 SUCCESS = 0x3000, |
| 58 NOT_INITIALIZED = 0x3001, | 61 NOT_INITIALIZED = 0x3001, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 const char* allowed_extensions, | 154 const char* allowed_extensions, |
| 152 const int32* attrib_list, | 155 const int32* attrib_list, |
| 153 gfx::GpuPreference gpu_preference); | 156 gfx::GpuPreference gpu_preference); |
| 154 void Destroy(); | 157 void Destroy(); |
| 155 | 158 |
| 156 void OnContextLost(); | 159 void OnContextLost(); |
| 157 | 160 |
| 158 base::WeakPtr<GLInProcessContext> parent_; | 161 base::WeakPtr<GLInProcessContext> parent_; |
| 159 base::Closure context_lost_callback_; | 162 base::Closure context_lost_callback_; |
| 160 uint32 parent_texture_id_; | 163 uint32 parent_texture_id_; |
| 164 scoped_ptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
| 161 scoped_ptr<CommandBufferService> command_buffer_; | 165 scoped_ptr<CommandBufferService> command_buffer_; |
| 162 scoped_ptr< ::gpu::GpuScheduler> gpu_scheduler_; | 166 scoped_ptr< ::gpu::GpuScheduler> gpu_scheduler_; |
| 163 scoped_ptr< ::gpu::gles2::GLES2Decoder> decoder_; | 167 scoped_ptr< ::gpu::gles2::GLES2Decoder> decoder_; |
| 164 scoped_refptr<gfx::GLContext> context_; | 168 scoped_refptr<gfx::GLContext> context_; |
| 165 scoped_refptr<gfx::GLSurface> surface_; | 169 scoped_refptr<gfx::GLSurface> surface_; |
| 166 scoped_ptr<GLES2CmdHelper> gles2_helper_; | 170 scoped_ptr<GLES2CmdHelper> gles2_helper_; |
| 167 scoped_ptr<TransferBuffer> transfer_buffer_; | 171 scoped_ptr<TransferBuffer> transfer_buffer_; |
| 168 scoped_ptr<GLES2Implementation> gles2_implementation_; | 172 scoped_ptr<GLES2Implementation> gles2_implementation_; |
| 169 Error last_error_; | 173 Error last_error_; |
| 170 | 174 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 attrib_list = NULL; | 388 attrib_list = NULL; |
| 385 break; | 389 break; |
| 386 default: | 390 default: |
| 387 last_error_ = BAD_ATTRIBUTE; | 391 last_error_ = BAD_ATTRIBUTE; |
| 388 attribs.push_back(NONE); | 392 attribs.push_back(NONE); |
| 389 attrib_list = NULL; | 393 attrib_list = NULL; |
| 390 break; | 394 break; |
| 391 } | 395 } |
| 392 } | 396 } |
| 393 | 397 |
| 394 command_buffer_.reset(new CommandBufferService); | 398 { |
| 399 TransferBufferManager* manager = new TransferBufferManager(); |
| 400 transfer_buffer_manager_.reset(manager); |
| 401 manager->Initialize(); |
| 402 } |
| 403 |
| 404 command_buffer_.reset( |
| 405 new CommandBufferService(transfer_buffer_manager_.get())); |
| 395 if (!command_buffer_->Initialize()) { | 406 if (!command_buffer_->Initialize()) { |
| 396 LOG(ERROR) << "Could not initialize command buffer."; | 407 LOG(ERROR) << "Could not initialize command buffer."; |
| 397 Destroy(); | 408 Destroy(); |
| 398 return false; | 409 return false; |
| 399 } | 410 } |
| 400 | 411 |
| 401 // TODO(gman): This needs to be true if this is Pepper. | 412 // TODO(gman): This needs to be true if this is Pepper. |
| 402 bool bind_generates_resource = false; | 413 bool bind_generates_resource = false; |
| 403 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ? | 414 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ? |
| 404 context_group->decoder_->GetContextGroup() : | 415 context_group->decoder_->GetContextGroup() : |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { | 1632 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { |
| 1622 // TODO(kbr): improve the precision here. | 1633 // TODO(kbr): improve the precision here. |
| 1623 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; | 1634 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; |
| 1624 if (context_lost_callback_) { | 1635 if (context_lost_callback_) { |
| 1625 context_lost_callback_->onContextLost(); | 1636 context_lost_callback_->onContextLost(); |
| 1626 } | 1637 } |
| 1627 } | 1638 } |
| 1628 | 1639 |
| 1629 } // namespace gpu | 1640 } // namespace gpu |
| 1630 } // namespace webkit | 1641 } // namespace webkit |
| OLD | NEW |