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 // Force the command buffer to be torn down as if the context was lost. The |
| 34 // context can still be used just like in lost context situations but it is |
| 35 // no longer bound to a specific thread so it is safe for the previously |
| 36 // bound thread to drop any reference it has. This should only be used if |
| 37 // content provider has been set up for multi-threaded usage by calling |
| 38 // SetupLock(). |
| 39 void Destroy(); |
| 40 |
33 // cc_blink::ContextProviderWebContext implementation. | 41 // cc_blink::ContextProviderWebContext implementation. |
34 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; | 42 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; |
35 | 43 |
36 // cc::ContextProvider implementation. | 44 // cc::ContextProvider implementation. |
37 bool BindToCurrentThread() override; | 45 bool BindToCurrentThread() override; |
38 void DetachFromThread() override; | 46 void DetachFromThread() override; |
39 gpu::gles2::GLES2Interface* ContextGL() override; | 47 gpu::gles2::GLES2Interface* ContextGL() override; |
40 gpu::ContextSupport* ContextSupport() override; | 48 gpu::ContextSupport* ContextSupport() override; |
41 class GrContext* GrContext() override; | 49 class GrContext* GrContext() override; |
42 void InvalidateGrContext(uint32_t state) override; | 50 void InvalidateGrContext(uint32_t state) override; |
(...skipping 13 matching lines...) Expand all Loading... |
56 ContextProviderCommandBuffer( | 64 ContextProviderCommandBuffer( |
57 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 65 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
58 CommandBufferContextType type); | 66 CommandBufferContextType type); |
59 ~ContextProviderCommandBuffer() override; | 67 ~ContextProviderCommandBuffer() override; |
60 | 68 |
61 void OnLostContext(); | 69 void OnLostContext(); |
62 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); | 70 void OnMemoryAllocationChanged(const gpu::MemoryAllocation& allocation); |
63 | 71 |
64 private: | 72 private: |
65 void InitializeCapabilities(); | 73 void InitializeCapabilities(); |
| 74 void DestroyWithMainThreadLockAcquired(); |
66 | 75 |
67 base::ThreadChecker main_thread_checker_; | 76 base::ThreadChecker main_thread_checker_; |
68 base::ThreadChecker context_thread_checker_; | 77 base::ThreadChecker context_thread_checker_; |
69 | 78 |
70 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 79 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
71 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; | 80 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; |
72 | 81 |
73 cc::ContextProvider::Capabilities capabilities_; | 82 cc::ContextProvider::Capabilities capabilities_; |
74 CommandBufferContextType context_type_; | 83 CommandBufferContextType context_type_; |
75 std::string debug_name_; | 84 std::string debug_name_; |
76 | 85 |
77 LostContextCallback lost_context_callback_; | 86 LostContextCallback lost_context_callback_; |
78 MemoryPolicyChangedCallback memory_policy_changed_callback_; | 87 MemoryPolicyChangedCallback memory_policy_changed_callback_; |
79 | 88 |
80 base::Lock main_thread_lock_; | 89 base::Lock main_thread_lock_; |
81 bool destroyed_; | 90 bool destroyed_; |
82 | 91 |
83 base::Lock context_lock_; | 92 base::Lock context_lock_; |
84 | 93 |
85 class LostContextCallbackProxy; | 94 class LostContextCallbackProxy; |
86 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 95 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
87 }; | 96 }; |
88 | 97 |
89 } // namespace content | 98 } // namespace content |
90 | 99 |
91 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 100 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
OLD | NEW |