| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "base/threading/thread_checker.h" | 11 #include "base/threading/thread_checker.h" |
| 12 #include "cc/blink/context_provider_web_context.h" | 12 #include "cc/blink/context_provider_web_context.h" |
| 13 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "content/common/gpu/client/command_buffer_metrics.h" |
| 15 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 16 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 16 | 17 |
| 17 namespace webkit { | 18 namespace webkit { |
| 18 namespace gpu { | 19 namespace gpu { |
| 19 class GrContextForWebGraphicsContext3D; | 20 class GrContextForWebGraphicsContext3D; |
| 20 } | 21 } |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 // Implementation of cc::ContextProvider that provides a | 26 // Implementation of cc::ContextProvider that provides a |
| 26 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. | 27 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. |
| 27 class CONTENT_EXPORT ContextProviderCommandBuffer | 28 class CONTENT_EXPORT ContextProviderCommandBuffer |
| 28 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { | 29 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { |
| 29 public: | 30 public: |
| 30 static scoped_refptr<ContextProviderCommandBuffer> Create( | 31 static scoped_refptr<ContextProviderCommandBuffer> Create( |
| 31 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 32 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
| 32 const std::string& debug_name); | 33 CommandBufferContextType type); |
| 33 | 34 |
| 34 CommandBufferProxyImpl* GetCommandBufferProxy(); | 35 CommandBufferProxyImpl* GetCommandBufferProxy(); |
| 35 | 36 |
| 36 // cc_blink::ContextProviderWebContext implementation. | 37 // cc_blink::ContextProviderWebContext implementation. |
| 37 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; | 38 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; |
| 38 | 39 |
| 39 // cc::ContextProvider implementation. | 40 // cc::ContextProvider implementation. |
| 40 bool BindToCurrentThread() override; | 41 bool BindToCurrentThread() override; |
| 41 void DetachFromThread() override; | 42 void DetachFromThread() override; |
| 42 gpu::gles2::GLES2Interface* ContextGL() override; | 43 gpu::gles2::GLES2Interface* ContextGL() override; |
| 43 gpu::ContextSupport* ContextSupport() override; | 44 gpu::ContextSupport* ContextSupport() override; |
| 44 class GrContext* GrContext() override; | 45 class GrContext* GrContext() override; |
| 45 void SetupLock() override; | 46 void SetupLock() override; |
| 46 base::Lock* GetLock() override; | 47 base::Lock* GetLock() override; |
| 47 Capabilities ContextCapabilities() override; | 48 Capabilities ContextCapabilities() override; |
| 48 bool IsContextLost() override; | 49 bool IsContextLost() override; |
| 49 void VerifyContexts() override; | 50 void VerifyContexts() override; |
| 50 void DeleteCachedResources() override; | 51 void DeleteCachedResources() override; |
| 51 bool DestroyedOnMainThread() override; | 52 bool DestroyedOnMainThread() override; |
| 52 void SetLostContextCallback( | 53 void SetLostContextCallback( |
| 53 const LostContextCallback& lost_context_callback) override; | 54 const LostContextCallback& lost_context_callback) override; |
| 54 void SetMemoryPolicyChangedCallback( | 55 void SetMemoryPolicyChangedCallback( |
| 55 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 56 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
| 56 override; | 57 override; |
| 57 | 58 |
| 58 protected: | 59 protected: |
| 59 ContextProviderCommandBuffer( | 60 ContextProviderCommandBuffer( |
| 60 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 61 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
| 61 const std::string& debug_name); | 62 CommandBufferContextType type); |
| 62 ~ContextProviderCommandBuffer() override; | 63 ~ContextProviderCommandBuffer() override; |
| 63 | 64 |
| 64 void OnLostContext(); | 65 void OnLostContext(); |
| 65 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); | 66 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); |
| 66 | 67 |
| 67 private: | 68 private: |
| 68 void InitializeCapabilities(); | 69 void InitializeCapabilities(); |
| 69 | 70 |
| 70 base::ThreadChecker main_thread_checker_; | 71 base::ThreadChecker main_thread_checker_; |
| 71 base::ThreadChecker context_thread_checker_; | 72 base::ThreadChecker context_thread_checker_; |
| 72 | 73 |
| 73 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 74 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
| 74 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; | 75 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; |
| 75 | 76 |
| 76 cc::ContextProvider::Capabilities capabilities_; | 77 cc::ContextProvider::Capabilities capabilities_; |
| 78 CommandBufferContextType context_type_; |
| 77 std::string debug_name_; | 79 std::string debug_name_; |
| 78 | 80 |
| 79 LostContextCallback lost_context_callback_; | 81 LostContextCallback lost_context_callback_; |
| 80 MemoryPolicyChangedCallback memory_policy_changed_callback_; | 82 MemoryPolicyChangedCallback memory_policy_changed_callback_; |
| 81 | 83 |
| 82 base::Lock main_thread_lock_; | 84 base::Lock main_thread_lock_; |
| 83 bool destroyed_; | 85 bool destroyed_; |
| 84 | 86 |
| 85 base::Lock context_lock_; | 87 base::Lock context_lock_; |
| 86 | 88 |
| 87 class LostContextCallbackProxy; | 89 class LostContextCallbackProxy; |
| 88 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 90 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace content | 93 } // namespace content |
| 92 | 94 |
| 93 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 95 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
| OLD | NEW |