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