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