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 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "cc/blink/context_provider_web_context.h" | 15 #include "cc/blink/context_provider_web_context.h" |
16 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/common/gpu/client/command_buffer_metrics.h" | 18 #include "content/common/gpu/client/command_buffer_metrics.h" |
19 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 19 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 20 #include "gpu/command_buffer/client/shared_memory_limits.h" |
20 | 21 |
21 namespace skia_bindings { | 22 namespace skia_bindings { |
22 class GrContextForGLES2Interface; | 23 class GrContextForGLES2Interface; |
23 } // namespace skia_bindings | 24 } // namespace skia_bindings |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 // Implementation of cc::ContextProvider that provides a | 28 // Implementation of cc::ContextProvider that provides a |
28 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. | 29 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. |
29 class CONTENT_EXPORT ContextProviderCommandBuffer | 30 class CONTENT_EXPORT ContextProviderCommandBuffer |
30 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { | 31 : NON_EXPORTED_BASE(public cc_blink::ContextProviderWebContext) { |
31 public: | 32 public: |
32 ContextProviderCommandBuffer( | 33 ContextProviderCommandBuffer( |
33 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, | 34 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
| 35 const gpu::SharedMemoryLimits& memory_limits, |
34 CommandBufferContextType type); | 36 CommandBufferContextType type); |
35 | 37 |
36 gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); | 38 gpu::CommandBufferProxyImpl* GetCommandBufferProxy(); |
37 | 39 |
38 // cc_blink::ContextProviderWebContext implementation. | 40 // cc_blink::ContextProviderWebContext implementation. |
39 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; | 41 WebGraphicsContext3DCommandBufferImpl* WebContext3D() override; |
40 | 42 |
41 // cc::ContextProvider implementation. | 43 // cc::ContextProvider implementation. |
42 bool BindToCurrentThread() override; | 44 bool BindToCurrentThread() override; |
43 void DetachFromThread() override; | 45 void DetachFromThread() override; |
44 gpu::gles2::GLES2Interface* ContextGL() override; | 46 gpu::gles2::GLES2Interface* ContextGL() override; |
45 gpu::ContextSupport* ContextSupport() override; | 47 gpu::ContextSupport* ContextSupport() override; |
46 class GrContext* GrContext() override; | 48 class GrContext* GrContext() override; |
47 void InvalidateGrContext(uint32_t state) override; | 49 void InvalidateGrContext(uint32_t state) override; |
48 void SetupLock() override; | 50 void SetupLock() override; |
49 base::Lock* GetLock() override; | 51 base::Lock* GetLock() override; |
50 Capabilities ContextCapabilities() override; | 52 gpu::Capabilities ContextCapabilities() override; |
51 void DeleteCachedResources() override; | 53 void DeleteCachedResources() override; |
52 void SetLostContextCallback( | 54 void SetLostContextCallback( |
53 const LostContextCallback& lost_context_callback) override; | 55 const LostContextCallback& lost_context_callback) override; |
54 | 56 |
55 protected: | 57 protected: |
56 ~ContextProviderCommandBuffer() override; | 58 ~ContextProviderCommandBuffer() override; |
57 | 59 |
58 void OnLostContext(); | 60 void OnLostContext(); |
59 | 61 |
60 private: | 62 private: |
61 void InitializeCapabilities(); | |
62 | |
63 base::ThreadChecker main_thread_checker_; | 63 base::ThreadChecker main_thread_checker_; |
64 base::ThreadChecker context_thread_checker_; | 64 base::ThreadChecker context_thread_checker_; |
65 | 65 |
66 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 66 std::unique_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
67 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; | 67 std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_; |
68 | 68 |
69 cc::ContextProvider::Capabilities capabilities_; | 69 gpu::SharedMemoryLimits memory_limits_; |
70 CommandBufferContextType context_type_; | 70 CommandBufferContextType context_type_; |
71 std::string debug_name_; | 71 std::string debug_name_; |
72 | 72 |
73 LostContextCallback lost_context_callback_; | 73 LostContextCallback lost_context_callback_; |
74 | 74 |
75 base::Lock context_lock_; | 75 base::Lock context_lock_; |
76 | 76 |
77 class LostContextCallbackProxy; | 77 class LostContextCallbackProxy; |
78 std::unique_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 78 std::unique_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
79 }; | 79 }; |
80 | 80 |
81 } // namespace content | 81 } // namespace content |
82 | 82 |
83 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ | 83 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER_H_ |
OLD | NEW |