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 "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
| 13 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
13 #include "webkit/common/gpu/webkit_gpu_export.h" | 14 #include "webkit/common/gpu/webkit_gpu_export.h" |
14 | 15 |
15 namespace WebKit { | 16 namespace WebKit { |
16 class WebGraphicsContext3D; | 17 class WebGraphicsContext3D; |
| 18 struct WebGraphicsMemoryAllocation; |
17 } | 19 } |
18 | 20 |
19 namespace webkit { | 21 namespace webkit { |
20 namespace gpu { | 22 namespace gpu { |
21 class GrContextForWebGraphicsContext3D; | 23 class GrContextForWebGraphicsContext3D; |
22 class WebGraphicsContext3DInProcessCommandBufferImpl; | |
23 | 24 |
24 class WEBKIT_GPU_EXPORT ContextProviderInProcess | 25 class WEBKIT_GPU_EXPORT ContextProviderInProcess |
25 : NON_EXPORTED_BASE(public cc::ContextProvider) { | 26 : NON_EXPORTED_BASE(public cc::ContextProvider) { |
26 public: | 27 public: |
27 typedef base::Callback< | 28 typedef base::Callback< |
28 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(void)> | 29 scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl>(void)> |
29 CreateCallback; | 30 CreateCallback; |
30 | 31 |
31 static scoped_refptr<ContextProviderInProcess> Create( | 32 static scoped_refptr<ContextProviderInProcess> Create( |
32 const CreateCallback& create_callback); | 33 const CreateCallback& create_callback); |
33 | 34 |
34 // Calls Create() with a default factory method for creating an offscreen | 35 // Calls Create() with a default factory method for creating an offscreen |
35 // context. | 36 // context. |
36 static scoped_refptr<ContextProviderInProcess> CreateOffscreen(); | 37 static scoped_refptr<ContextProviderInProcess> CreateOffscreen(); |
37 | 38 |
38 virtual bool BindToCurrentThread() OVERRIDE; | 39 virtual bool BindToCurrentThread() OVERRIDE; |
39 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; | 40 virtual webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl* |
| 41 Context3d() OVERRIDE; |
40 virtual class GrContext* GrContext() OVERRIDE; | 42 virtual class GrContext* GrContext() OVERRIDE; |
41 virtual void VerifyContexts() OVERRIDE; | 43 virtual void VerifyContexts() OVERRIDE; |
42 virtual bool DestroyedOnMainThread() OVERRIDE; | 44 virtual bool DestroyedOnMainThread() OVERRIDE; |
43 virtual void SetLostContextCallback( | 45 virtual void SetLostContextCallback( |
44 const LostContextCallback& lost_context_callback) OVERRIDE; | 46 const LostContextCallback& lost_context_callback) OVERRIDE; |
| 47 virtual void SetSwapBuffersCompleteCallback( |
| 48 const SwapBuffersCompleteCallback& swap_buffers_complete_callback) |
| 49 OVERRIDE; |
| 50 virtual void SetMemoryPolicyChangedCallback( |
| 51 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
| 52 OVERRIDE; |
45 | 53 |
46 protected: | 54 protected: |
47 ContextProviderInProcess(); | 55 ContextProviderInProcess(); |
48 virtual ~ContextProviderInProcess(); | 56 virtual ~ContextProviderInProcess(); |
49 | 57 |
50 bool InitializeOnMainThread( | 58 bool InitializeOnMainThread( |
51 const CreateCallback& create_callback); | 59 const CreateCallback& create_callback); |
52 | 60 |
53 void OnLostContext(); | 61 void OnLostContext(); |
54 void OnMemoryAllocationChanged(bool nonzero_allocation); | 62 void OnSwapBuffersComplete(); |
| 63 void OnMemoryAllocationChanged( |
| 64 const WebKit::WebGraphicsMemoryAllocation& allocation); |
55 | 65 |
56 private: | 66 private: |
57 base::ThreadChecker main_thread_checker_; | 67 base::ThreadChecker main_thread_checker_; |
58 base::ThreadChecker context_thread_checker_; | 68 base::ThreadChecker context_thread_checker_; |
59 | 69 |
60 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; | 70 scoped_ptr<webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl> |
| 71 context3d_; |
61 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; | 72 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> gr_context_; |
62 | 73 |
63 LostContextCallback lost_context_callback_; | 74 LostContextCallback lost_context_callback_; |
| 75 SwapBuffersCompleteCallback swap_buffers_complete_callback_; |
| 76 MemoryPolicyChangedCallback memory_policy_changed_callback_; |
64 | 77 |
65 base::Lock destroyed_lock_; | 78 base::Lock destroyed_lock_; |
66 bool destroyed_; | 79 bool destroyed_; |
67 | 80 |
68 class LostContextCallbackProxy; | 81 class LostContextCallbackProxy; |
69 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; | 82 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_; |
70 | 83 |
| 84 class SwapBuffersCompleteCallbackProxy; |
| 85 scoped_ptr<SwapBuffersCompleteCallbackProxy> |
| 86 swap_buffers_complete_callback_proxy_; |
| 87 |
71 class MemoryAllocationCallbackProxy; | 88 class MemoryAllocationCallbackProxy; |
72 scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; | 89 scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; |
73 }; | 90 }; |
74 | 91 |
75 } // namespace gpu | 92 } // namespace gpu |
76 } // namespace webkit | 93 } // namespace webkit |
77 | 94 |
78 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ | 95 #endif // WEBKIT_COMMON_GPU_CONTEXT_PROVIDER_IN_PROCESS_H_ |
OLD | NEW |