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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> |
11 | 12 |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
15 #include "cc/blink/context_provider_web_context.h" | 16 #include "cc/blink/context_provider_web_context.h" |
16 #include "cc/output/context_provider.h" | 17 #include "cc/output/context_provider.h" |
17 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
18 #include "content/common/gpu/client/command_buffer_metrics.h" | 19 #include "content/common/gpu/client/command_buffer_metrics.h" |
19 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 20 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
20 #include "gpu/command_buffer/client/shared_memory_limits.h" | 21 #include "gpu/command_buffer/client/shared_memory_limits.h" |
(...skipping 12 matching lines...) Expand all Loading... |
33 namespace content { | 34 namespace content { |
34 | 35 |
35 // Implementation of cc::ContextProvider that provides a | 36 // Implementation of cc::ContextProvider that provides a |
36 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. | 37 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. |
37 class CONTENT_EXPORT ContextProviderCommandBuffer | 38 class CONTENT_EXPORT ContextProviderCommandBuffer |
38 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { | 39 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { |
39 public: | 40 public: |
40 ContextProviderCommandBuffer( | 41 ContextProviderCommandBuffer( |
41 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 42 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
42 const gpu::SharedMemoryLimits& memory_limits, | 43 const gpu::SharedMemoryLimits& memory_limits, |
| 44 ContextProviderCommandBuffer* shared_context_provider, |
43 CommandBufferContextType type); | 45 CommandBufferContextType type); |
44 | 46 |
45 gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); | 47 gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); |
46 | 48 |
47 // cc_blink::ContextProviderWebContext implementation. | 49 // cc_blink::ContextProviderWebContext implementation. |
48 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; | 50 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; |
49 | 51 |
50 // cc::ContextProvider implementation. | 52 // cc::ContextProvider implementation. |
51 bool BindToCurrentThread() override; | 53 bool BindToCurrentThread() override; |
52 void DetachFromThread() override; | 54 void DetachFromThread() override; |
53 gpu::gles2::GLES2Interface* ContextGL() override; | 55 gpu::gles2::GLES2Interface* ContextGL() override; |
54 gpu::ContextSupport* ContextSupport() override; | 56 gpu::ContextSupport* ContextSupport() override; |
55 class GrContext* GrContext() override; | 57 class GrContext* GrContext() override; |
56 void InvalidateGrContext(uint32_t state) override; | 58 void InvalidateGrContext(uint32_t state) override; |
57 void SetupLock() override; | 59 void SetupLock() override; |
58 base::Lock* GetLock() override; | 60 base::Lock* GetLock() override; |
59 gpu::Capabilities ContextCapabilities() override; | 61 gpu::Capabilities ContextCapabilities() override; |
60 void DeleteCachedResources() override; | 62 void DeleteCachedResources() override; |
61 void SetLostContextCallback( | 63 void SetLostContextCallback( |
62 const LostContextCallback& lost_context_callback) override; | 64 const LostContextCallback& lost_context_callback) override; |
63 | 65 |
64 protected: | 66 protected: |
65 ~ContextProviderCommandBuffer() override; | 67 ~ContextProviderCommandBuffer() override; |
66 | 68 |
67 void OnLostContext(); | 69 void OnLostContext(); |
68 | 70 |
69 private: | 71 private: |
| 72 struct SharedProviders : public base::RefCountedThreadSafe<SharedProviders> { |
| 73 base::Lock lock; |
| 74 std::vector<ContextProviderCommandBuffer*> list; |
| 75 |
| 76 SharedProviders(); |
| 77 |
| 78 private: |
| 79 friend class base::RefCountedThreadSafe<SharedProviders>; |
| 80 ~SharedProviders(); |
| 81 }; |
| 82 |
70 base::ThreadChecker main_thread_checker_; | 83 base::ThreadChecker main_thread_checker_; |
71 base::ThreadChecker context_thread_checker_; | 84 base::ThreadChecker context_thread_checker_; |
72 | 85 |
| 86 scoped_refptr<SharedProviders> shared_providers_; |
| 87 |
73 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 88 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
74 std::unique_ptr<gpu::gles2::GLES2TraceImplementation> trace_impl_; | 89 std::unique_ptr<gpu::gles2::GLES2TraceImplementation> trace_impl_; |
75 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; | 90 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; |
76 | 91 |
77 gpu::SharedMemoryLimits memory_limits_; | 92 gpu::SharedMemoryLimits memory_limits_; |
78 CommandBufferContextType context_type_; | 93 CommandBufferContextType context_type_; |
79 std::string debug_name_; | 94 std::string debug_name_; |
80 | 95 |
81 LostContextCallback lost_context_callback_; | 96 LostContextCallback lost_context_callback_; |
82 | 97 |
83 base::Lock context_lock_; | 98 base::Lock context_lock_; |
84 | 99 |
85 class LostContextCallbackProxy; | 100 class LostContextCallbackProxy; |
86 std::unique_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 101 std::unique_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
87 }; | 102 }; |
88 | 103 |
89 } // namespace content | 104 } // namespace content |
90 | 105 |
91 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 106 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
OLD | NEW |