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 12 matching lines...) Expand all Loading... |
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 | 32 |
| 33 // Destroy WebGraphicsContext3DCommandBufferImpl context and GrContext. This |
| 34 // should only be used if content provider has been set up for multi-threaded |
| 35 // usage by calling SetupLock(). |
| 36 void Destroy(); |
| 37 |
33 // cc_blink::ContextProviderWebContext implementation. | 38 // cc_blink::ContextProviderWebContext implementation. |
34 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; | 39 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; |
35 | 40 |
36 // cc::ContextProvider implementation. | 41 // cc::ContextProvider implementation. |
37 bool BindToCurrentThread() override; | 42 bool BindToCurrentThread() override; |
38 void DetachFromThread() override; | 43 void DetachFromThread() override; |
39 gpu::gles2::GLES2Interface* ContextGL() override; | 44 gpu::gles2::GLES2Interface* ContextGL() override; |
40 gpu::ContextSupport* ContextSupport() override; | 45 gpu::ContextSupport* ContextSupport() override; |
41 class GrContext* GrContext() override; | 46 class GrContext* GrContext() override; |
42 void InvalidateGrContext(uint32_t state) override; | 47 void InvalidateGrContext(uint32_t state) override; |
43 void SetupLock() override; | 48 void SetupLock() override; |
44 base::Lock* GetLock() override; | 49 base::Lock* GetLock() override; |
45 Capabilities ContextCapabilities() override; | 50 Capabilities ContextCapabilities() override; |
46 void VerifyContexts() override; | 51 void VerifyContexts() override; |
47 void DeleteCachedResources() override; | 52 void DeleteCachedResources() override; |
48 bool DestroyedOnMainThread() override; | 53 bool HasBeenLostOnMainThread() override; |
49 void SetLostContextCallback( | 54 void SetLostContextCallback( |
50 const LostContextCallback& lost_context_callback) override; | 55 const LostContextCallback& lost_context_callback) override; |
51 void SetMemoryPolicyChangedCallback( | 56 void SetMemoryPolicyChangedCallback( |
52 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 57 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
53 override; | 58 override; |
| 59 bool HasBeenDestroyed() override; |
54 | 60 |
55 protected: | 61 protected: |
56 ContextProviderCommandBuffer( | 62 ContextProviderCommandBuffer( |
57 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 63 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
58 CommandBufferContextType type); | 64 CommandBufferContextType type); |
59 ~ContextProviderCommandBuffer() override; | 65 ~ContextProviderCommandBuffer() override; |
60 | 66 |
61 void OnLostContext(); | 67 void OnLostContext(); |
62 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); | 68 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); |
63 | 69 |
64 private: | 70 private: |
65 void InitializeCapabilities(); | 71 void InitializeCapabilities(); |
| 72 void DestroyWithLockAcquired(); |
66 | 73 |
67 base::ThreadChecker main_thread_checker_; | 74 base::ThreadChecker main_thread_checker_; |
68 base::ThreadChecker context_thread_checker_; | 75 base::ThreadChecker context_thread_checker_; |
69 | 76 |
70 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 77 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
71 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; | 78 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; |
72 | 79 |
73 cc::ContextProvider::Capabilities capabilities_; | 80 cc::ContextProvider::Capabilities capabilities_; |
74 CommandBufferContextType context_type_; | 81 CommandBufferContextType context_type_; |
75 std::string debug_name_; | 82 std::string debug_name_; |
76 | 83 |
77 LostContextCallback lost_context_callback_; | 84 LostContextCallback lost_context_callback_; |
78 MemoryPolicyChangedCallback memory_policy_changed_callback_; | 85 MemoryPolicyChangedCallback memory_policy_changed_callback_; |
79 | 86 |
80 base::Lock main_thread_lock_; | 87 base::Lock main_thread_lock_; |
81 bool destroyed_; | 88 bool lost_; |
82 | 89 |
83 base::Lock context_lock_; | 90 base::Lock context_lock_; |
| 91 bool destroyed_; |
84 | 92 |
85 class LostContextCallbackProxy; | 93 class LostContextCallbackProxy; |
86 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 94 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
87 }; | 95 }; |
88 | 96 |
89 } // namespace content | 97 } // namespace content |
90 | 98 |
91 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 99 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
OLD | NEW |