| 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 |
| 11 #include <GLES2/gl2ext.h> | 11 #include <GLES2/gl2ext.h> |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <set> | 14 #include <set> |
| 15 | 15 |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/bind_helpers.h" | 17 #include "base/bind_helpers.h" |
| 18 #include "base/callback.h" | 18 #include "base/callback.h" |
| 19 #include "base/command_line.h" | 19 #include "base/command_line.h" |
| 20 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
| 21 #include "base/logging.h" | 21 #include "base/logging.h" |
| 22 #include "base/memory/singleton.h" | 22 #include "base/memory/singleton.h" |
| 23 #include "base/memory/weak_ptr.h" |
| 23 #include "base/message_loop.h" | 24 #include "base/message_loop.h" |
| 24 #include "base/metrics/histogram.h" | 25 #include "base/metrics/histogram.h" |
| 25 #include "base/string_tokenizer.h" | 26 #include "base/string_tokenizer.h" |
| 26 #include "base/synchronization/lock.h" | 27 #include "base/synchronization/lock.h" |
| 27 #include "gpu/command_buffer/client/gles2_implementation.h" | 28 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 28 #include "gpu/command_buffer/client/gles2_lib.h" | 29 #include "gpu/command_buffer/client/gles2_lib.h" |
| 29 #include "gpu/command_buffer/client/transfer_buffer.h" | 30 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 30 #include "gpu/command_buffer/common/constants.h" | 31 #include "gpu/command_buffer/common/constants.h" |
| 31 #include "gpu/command_buffer/service/command_buffer_service.h" | 32 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 32 #include "gpu/command_buffer/service/context_group.h" | 33 #include "gpu/command_buffer/service/context_group.h" |
| 33 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 34 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
| 34 #include "gpu/command_buffer/service/gpu_scheduler.h" | 35 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 36 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 37 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 38 #include "ui/gl/gl_context.h" | 39 #include "ui/gl/gl_context.h" |
| 39 #include "ui/gl/gl_share_group.h" | 40 #include "ui/gl/gl_share_group.h" |
| 40 #include "ui/gl/gl_surface.h" | 41 #include "ui/gl/gl_surface.h" |
| 41 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" | 42 #include "webkit/glue/gl_bindings_skia_cmd_buffer.h" |
| 42 | 43 |
| 44 |
| 45 namespace gpu { |
| 46 class ShaderCache; |
| 47 } |
| 48 |
| 43 using gpu::Buffer; | 49 using gpu::Buffer; |
| 44 using gpu::CommandBuffer; | 50 using gpu::CommandBuffer; |
| 45 using gpu::CommandBufferService; | 51 using gpu::CommandBufferService; |
| 46 using gpu::gles2::GLES2CmdHelper; | 52 using gpu::gles2::GLES2CmdHelper; |
| 47 using gpu::gles2::GLES2Implementation; | 53 using gpu::gles2::GLES2Implementation; |
| 48 using gpu::GpuScheduler; | 54 using gpu::GpuScheduler; |
| 49 using gpu::TransferBuffer; | 55 using gpu::TransferBuffer; |
| 50 using gpu::TransferBufferManager; | 56 using gpu::TransferBufferManager; |
| 51 using gpu::TransferBufferManagerInterface; | 57 using gpu::TransferBufferManagerInterface; |
| 58 using gpu::ShaderCache; |
| 52 | 59 |
| 53 namespace webkit { | 60 namespace webkit { |
| 54 namespace gpu { | 61 namespace gpu { |
| 55 | 62 |
| 56 class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { | 63 class GLInProcessContext : public base::SupportsWeakPtr<GLInProcessContext> { |
| 57 public: | 64 public: |
| 58 // These are the same error codes as used by EGL. | 65 // These are the same error codes as used by EGL. |
| 59 enum Error { | 66 enum Error { |
| 60 SUCCESS = 0x3000, | 67 SUCCESS = 0x3000, |
| 61 NOT_INITIALIZED = 0x3001, | 68 NOT_INITIALIZED = 0x3001, |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 if (!command_buffer_->Initialize()) { | 413 if (!command_buffer_->Initialize()) { |
| 407 LOG(ERROR) << "Could not initialize command buffer."; | 414 LOG(ERROR) << "Could not initialize command buffer."; |
| 408 Destroy(); | 415 Destroy(); |
| 409 return false; | 416 return false; |
| 410 } | 417 } |
| 411 | 418 |
| 412 // TODO(gman): This needs to be true if this is Pepper. | 419 // TODO(gman): This needs to be true if this is Pepper. |
| 413 bool bind_generates_resource = false; | 420 bool bind_generates_resource = false; |
| 414 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ? | 421 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group ? |
| 415 context_group->decoder_->GetContextGroup() : | 422 context_group->decoder_->GetContextGroup() : |
| 416 new ::gpu::gles2::ContextGroup(NULL, bind_generates_resource))); | 423 new ::gpu::gles2::ContextGroup(NULL, |
| 424 bind_generates_resource, |
| 425 base::WeakPtr<ShaderCache>()))); |
| 417 | 426 |
| 418 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), | 427 gpu_scheduler_.reset(new GpuScheduler(command_buffer_.get(), |
| 419 decoder_.get(), | 428 decoder_.get(), |
| 420 decoder_.get())); | 429 decoder_.get())); |
| 421 | 430 |
| 422 decoder_->set_engine(gpu_scheduler_.get()); | 431 decoder_->set_engine(gpu_scheduler_.get()); |
| 423 | 432 |
| 424 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)); | 433 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, gfx::Size(1, 1)); |
| 425 | 434 |
| 426 if (!surface_.get()) { | 435 if (!surface_.get()) { |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { | 1641 void WebGraphicsContext3DInProcessCommandBufferImpl::OnContextLost() { |
| 1633 // TODO(kbr): improve the precision here. | 1642 // TODO(kbr): improve the precision here. |
| 1634 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; | 1643 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; |
| 1635 if (context_lost_callback_) { | 1644 if (context_lost_callback_) { |
| 1636 context_lost_callback_->onContextLost(); | 1645 context_lost_callback_->onContextLost(); |
| 1637 } | 1646 } |
| 1638 } | 1647 } |
| 1639 | 1648 |
| 1640 } // namespace gpu | 1649 } // namespace gpu |
| 1641 } // namespace webkit | 1650 } // namespace webkit |
| OLD | NEW |