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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // Implementation of cc::ContextProvider that provides a | 22 // Implementation of cc::ContextProvider that provides a |
23 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. | 23 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. |
24 class CONTENT_EXPORT ContextProviderCommandBuffer | 24 class CONTENT_EXPORT ContextProviderCommandBuffer |
25 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { | 25 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { |
26 public: | 26 public: |
27 static scoped_refptr<ContextProviderCommandBuffer> Create( | 27 static scoped_refptr<ContextProviderCommandBuffer> Create( |
28 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 28 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
29 CommandBufferContextType type); | 29 CommandBufferContextType type); |
30 | 30 |
31 CommandBufferProxyImpl* GetCommandBufferProxy(); | 31 CommandBufferProxyImpl* GetCommandBufferProxy(); |
| 32 void Destroy(); |
32 | 33 |
33 // cc_blink::ContextProviderWebContext implementation. | 34 // cc_blink::ContextProviderWebContext implementation. |
34 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; | 35 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; |
35 | 36 |
36 // cc::ContextProvider implementation. | 37 // cc::ContextProvider implementation. |
37 bool BindToCurrentThread() override; | 38 bool BindToCurrentThread() override; |
38 void DetachFromThread() override; | 39 void DetachFromThread() override; |
39 gpu::gles2::GLES2Interface* ContextGL() override; | 40 gpu::gles2::GLES2Interface* ContextGL() override; |
40 gpu::ContextSupport* ContextSupport() override; | 41 gpu::ContextSupport* ContextSupport() override; |
41 class GrContext* GrContext() override; | 42 class GrContext* GrContext() override; |
42 void InvalidateGrContext(uint32_t state) override; | 43 void InvalidateGrContext(uint32_t state) override; |
43 void SetupLock() override; | 44 void SetupLock() override; |
44 base::Lock* GetLock() override; | 45 base::Lock* GetLock() override; |
45 Capabilities ContextCapabilities() override; | 46 Capabilities ContextCapabilities() override; |
46 void VerifyContexts() override; | 47 void VerifyContexts() override; |
47 void DeleteCachedResources() override; | 48 void DeleteCachedResources() override; |
48 bool DestroyedOnMainThread() override; | 49 bool DestroyedOnMainThread() override; |
49 void SetLostContextCallback( | 50 void SetLostContextCallback( |
50 const LostContextCallback& lost_context_callback) override; | 51 const LostContextCallback& lost_context_callback) override; |
51 void SetMemoryPolicyChangedCallback( | 52 void SetMemoryPolicyChangedCallback( |
52 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 53 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
53 override; | 54 override; |
| 55 bool HasBeenDestroyed() override; |
54 | 56 |
55 protected: | 57 protected: |
56 ContextProviderCommandBuffer( | 58 ContextProviderCommandBuffer( |
57 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 59 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
58 CommandBufferContextType type); | 60 CommandBufferContextType type); |
59 ~ContextProviderCommandBuffer() override; | 61 ~ContextProviderCommandBuffer() override; |
60 | 62 |
61 void OnLostContext(); | 63 void OnLostContext(); |
62 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); | 64 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); |
63 | 65 |
64 private: | 66 private: |
65 void InitializeCapabilities(); | 67 void InitializeCapabilities(); |
| 68 void DestroyWithMainThreadLockAcquired(); |
66 | 69 |
67 base::ThreadChecker main_thread_checker_; | 70 base::ThreadChecker main_thread_checker_; |
68 base::ThreadChecker context_thread_checker_; | 71 base::ThreadChecker context_thread_checker_; |
69 | 72 |
70 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 73 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
71 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; | 74 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; |
72 | 75 |
73 cc::ContextProvider::Capabilities capabilities_; | 76 cc::ContextProvider::Capabilities capabilities_; |
74 CommandBufferContextType context_type_; | 77 CommandBufferContextType context_type_; |
75 std::string debug_name_; | 78 std::string debug_name_; |
76 | 79 |
77 LostContextCallback lost_context_callback_; | 80 LostContextCallback lost_context_callback_; |
78 MemoryPolicyChangedCallback memory_policy_changed_callback_; | 81 MemoryPolicyChangedCallback memory_policy_changed_callback_; |
79 | 82 |
80 base::Lock main_thread_lock_; | 83 base::Lock main_thread_lock_; |
81 bool destroyed_; | 84 bool destroyed_; |
82 | 85 |
83 base::Lock context_lock_; | 86 base::Lock context_lock_; |
84 | 87 |
85 class LostContextCallbackProxy; | 88 class LostContextCallbackProxy; |
86 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 89 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
87 }; | 90 }; |
88 | 91 |
89 } // namespace content | 92 } // namespace content |
90 | 93 |
91 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 94 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
OLD | NEW |