| 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 | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER |
| 6 #define CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER | 6 #define CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
| 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 12 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 13 | 13 |
| 14 namespace webkit { | 14 namespace webkit { |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 class GrContextForWebGraphicsContext3D; | 16 class GrContextForWebGraphicsContext3D; |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 // Implementation of cc::ContextProvider that provides a | 22 // Implementation of cc::ContextProvider that provides a |
| 23 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. | 23 // WebGraphicsContext3DCommandBufferImpl context and a GrContext. |
| 24 class ContextProviderCommandBuffer : public cc::ContextProvider { | 24 class ContextProviderCommandBuffer : public cc::ContextProvider { |
| 25 public: | 25 public: |
| 26 typedef base::Callback< | |
| 27 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(void)> CreateCallback; | |
| 28 static scoped_refptr<ContextProviderCommandBuffer> Create( | 26 static scoped_refptr<ContextProviderCommandBuffer> Create( |
| 29 const CreateCallback& create_callback); | 27 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d); |
| 30 | 28 |
| 31 virtual bool BindToCurrentThread() OVERRIDE; | 29 virtual bool BindToCurrentThread() OVERRIDE; |
| 32 virtual WebGraphicsContext3DCommandBufferImpl* Context3d() OVERRIDE; | 30 virtual WebGraphicsContext3DCommandBufferImpl* Context3d() OVERRIDE; |
| 33 virtual class GrContext* GrContext() OVERRIDE; | 31 virtual class GrContext* GrContext() OVERRIDE; |
| 34 virtual void VerifyContexts() OVERRIDE; | 32 virtual void VerifyContexts() OVERRIDE; |
| 35 virtual bool DestroyedOnMainThread() OVERRIDE; | 33 virtual bool DestroyedOnMainThread() OVERRIDE; |
| 36 virtual void SetLostContextCallback( | 34 virtual void SetLostContextCallback( |
| 37 const LostContextCallback& lost_context_callback) OVERRIDE; | 35 const LostContextCallback& lost_context_callback) OVERRIDE; |
| 38 virtual void SetSwapBuffersCompleteCallback( | 36 virtual void SetSwapBuffersCompleteCallback( |
| 39 const SwapBuffersCompleteCallback& swap_buffers_complete_callback) | 37 const SwapBuffersCompleteCallback& swap_buffers_complete_callback) |
| 40 OVERRIDE; | 38 OVERRIDE; |
| 41 virtual void SetMemoryPolicyChangedCallback( | 39 virtual void SetMemoryPolicyChangedCallback( |
| 42 const MemoryPolicyChangedCallback& memory_policy_changed_callback) | 40 const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
| 43 OVERRIDE; | 41 OVERRIDE; |
| 44 | 42 |
| 45 void set_leak_on_destroy() { | 43 void set_leak_on_destroy() { |
| 46 base::AutoLock lock(main_thread_lock_); | 44 base::AutoLock lock(main_thread_lock_); |
| 47 leak_on_destroy_ = true; | 45 leak_on_destroy_ = true; |
| 48 } | 46 } |
| 49 | 47 |
| 50 protected: | 48 protected: |
| 51 ContextProviderCommandBuffer(); | 49 ContextProviderCommandBuffer( |
| 50 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d); |
| 52 virtual ~ContextProviderCommandBuffer(); | 51 virtual ~ContextProviderCommandBuffer(); |
| 53 | 52 |
| 54 // This must be called immedately after creating this object, and it should | |
| 55 // be thrown away if this returns false. | |
| 56 bool InitializeOnMainThread(const CreateCallback& create_callback); | |
| 57 | |
| 58 void OnLostContext(); | 53 void OnLostContext(); |
| 59 void OnSwapBuffersComplete(); | 54 void OnSwapBuffersComplete(); |
| 60 void OnMemoryAllocationChanged( | 55 void OnMemoryAllocationChanged( |
| 61 const WebKit::WebGraphicsMemoryAllocation& allocation); | 56 const WebKit::WebGraphicsMemoryAllocation& allocation); |
| 62 | 57 |
| 63 private: | 58 private: |
| 64 base::ThreadChecker main_thread_checker_; | 59 base::ThreadChecker main_thread_checker_; |
| 65 base::ThreadChecker context_thread_checker_; | 60 base::ThreadChecker context_thread_checker_; |
| 66 | 61 |
| 67 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; | 62 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 82 scoped_ptr<SwapBuffersCompleteCallbackProxy> | 77 scoped_ptr<SwapBuffersCompleteCallbackProxy> |
| 83 swap_buffers_complete_callback_proxy_; | 78 swap_buffers_complete_callback_proxy_; |
| 84 | 79 |
| 85 class MemoryAllocationCallbackProxy; | 80 class MemoryAllocationCallbackProxy; |
| 86 scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; | 81 scoped_ptr<MemoryAllocationCallbackProxy> memory_allocation_callback_proxy_; |
| 87 }; | 82 }; |
| 88 | 83 |
| 89 } // namespace content | 84 } // namespace content |
| 90 | 85 |
| 91 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER | 86 #endif // CONTENT_COMMON_GPU_CLIENT_CONTEXT_PROVIDER_COMMAND_BUFFER |
| OLD | NEW |