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 WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 5 #ifndef WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 6 #define WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
11 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
12 #include "gpu/blink/webgraphicscontext3d_in_process_command_buffer_impl.h" | |
13 #include "webkit/common/gpu/context_provider_web_context.h" | 14 #include "webkit/common/gpu/context_provider_web_context.h" |
14 #include "webkit/common/gpu/webkit_gpu_export.h" | 15 #include "webkit/common/gpu/webkit_gpu_export.h" |
15 | 16 |
16 namespace blink { class WebGraphicsContext3D; } | 17 namespace blink { class WebGraphicsContext3D; } |
17 | 18 |
| 19 namespace gpu_blink { |
| 20 class WebGraphicsContext3DInProcessCommandBufferImpl; |
| 21 } |
| 22 |
18 namespace webkit { | 23 namespace webkit { |
19 namespace gpu { | 24 namespace gpu { |
20 class GrContextForWebGraphicsContext3D; | 25 class GrContextForWebGraphicsContext3D; |
21 | 26 |
22 class WEBKIT_GPU_EXPORT ContextProviderInProcess | 27 class WEBKIT_GPU_EXPORT ContextProviderInProcess |
23 : NON_EXPORTED_BASE(public ContextProviderWebContext) { | 28 : NON_EXPORTED_BASE(public ContextProviderWebContext) { |
24 public: | 29 public: |
25 static scoped_refptr<ContextProviderInProcess> Create( | 30 static scoped_refptr<ContextProviderInProcess> Create( |
26 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | 31 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> |
27 context3d, | 32 context3d, |
28 const std::string& debug_name); | 33 const std::string& debug_name); |
29 | 34 |
30 // Uses default attributes for creating an offscreen context. | 35 // Uses default attributes for creating an offscreen context. |
31 static scoped_refptr<ContextProviderInProcess> CreateOffscreen( | 36 static scoped_refptr<ContextProviderInProcess> CreateOffscreen( |
32 bool lose_context_when_out_of_memory); | 37 bool lose_context_when_out_of_memory); |
33 | 38 |
| 39 private: |
| 40 ContextProviderInProcess( |
| 41 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> |
| 42 context3d, |
| 43 const std::string& debug_name); |
| 44 ~ContextProviderInProcess() override; |
| 45 |
| 46 // ContextProviderWebContext: |
34 blink::WebGraphicsContext3D* WebContext3D() override; | 47 blink::WebGraphicsContext3D* WebContext3D() override; |
35 | 48 |
| 49 // cc::ContextProvider: |
36 bool BindToCurrentThread() override; | 50 bool BindToCurrentThread() override; |
37 Capabilities ContextCapabilities() override; | 51 Capabilities ContextCapabilities() override; |
38 ::gpu::gles2::GLES2Interface* ContextGL() override; | 52 ::gpu::gles2::GLES2Interface* ContextGL() override; |
39 ::gpu::ContextSupport* ContextSupport() override; | 53 ::gpu::ContextSupport* ContextSupport() override; |
40 class GrContext* GrContext() override; | 54 class GrContext* GrContext() override; |
41 bool IsContextLost() override; | 55 bool IsContextLost() override; |
42 void VerifyContexts() override; | 56 void VerifyContexts() override; |
43 void DeleteCachedResources() override; | 57 void DeleteCachedResources() override; |
44 bool DestroyedOnMainThread() override; | 58 bool DestroyedOnMainThread() override; |
45 void SetLostContextCallback( | 59 void SetLostContextCallback( |
46 const LostContextCallback& lost_context_callback) override; | 60 const LostContextCallback& lost_context_callback) override; |
47 void SetMemoryPolicyChangedCallback( | 61 void SetMemoryPolicyChangedCallback( |
48 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 62 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
49 override; | 63 override; |
50 | 64 |
51 protected: | |
52 ContextProviderInProcess( | |
53 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | |
54 context3d, | |
55 const std::string& debug_name); | |
56 ~ContextProviderInProcess() override; | |
57 | |
58 void OnLostContext(); | 65 void OnLostContext(); |
59 | |
60 private: | |
61 void InitializeCapabilities(); | 66 void InitializeCapabilities(); |
62 | 67 |
63 base::ThreadChecker main_thread_checker_; | 68 base::ThreadChecker main_thread_checker_; |
64 base::ThreadChecker context_thread_checker_; | 69 base::ThreadChecker context_thread_checker_; |
65 | 70 |
66 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> | 71 scoped_ptr<gpu_blink::WebGraphicsContext3DInProcessCommandBufferImpl> |
67 context3d_; | 72 context3d_; |
68 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; | 73 scoped_ptr<GrContextForWebGraphicsContext3D> gr_context_; |
69 | 74 |
70 LostContextCallback lost_context_callback_; | 75 LostContextCallback lost_context_callback_; |
71 | 76 |
72 base::Lock destroyed_lock_; | 77 base::Lock destroyed_lock_; |
73 bool destroyed_; | 78 bool destroyed_; |
74 | 79 |
75 std::string debug_name_; | 80 std::string debug_name_; |
76 class LostContextCallbackProxy; | 81 class LostContextCallbackProxy; |
77 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 82 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
78 | 83 |
79 cc::ContextProvider::Capabilities capabilities_; | 84 cc::ContextProvider::Capabilities capabilities_; |
80 | 85 |
81 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); | 86 DISALLOW_COPY_AND_ASSIGN(ContextProviderInProcess); |
82 }; | 87 }; |
83 | 88 |
84 } // namespace gpu | 89 } // namespace gpu |
85 } // namespace webkit | 90 } // namespace webkit |
86 | 91 |
87 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 92 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
OLD | NEW |