James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_ |
| 6 | #define CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_ |
| 7 | |
Etienne Membrives | 386015a | 2015-02-19 17:27:12 +0100 | [diff] [blame] | 8 | #include "base/synchronization/lock.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 9 | #include "cc/output/context_provider.h" |
James Robinson | 7f48021 | 2014-10-31 10:28:08 -0700 | [diff] [blame] | 10 | #include "cc/test/test_gpu_memory_buffer_manager.h" |
| 11 | #include "cc/test/test_image_factory.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 12 | #include "skia/ext/refptr.h" |
| 13 | |
| 14 | class GrContext; |
| 15 | |
| 16 | namespace gpu { |
| 17 | class GLInProcessContext; |
| 18 | } |
| 19 | |
| 20 | namespace cc { |
| 21 | |
| 22 | scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext(); |
James Robinson | 7f48021 | 2014-10-31 10:28:08 -0700 | [diff] [blame] | 23 | scoped_ptr<gpu::GLInProcessContext> CreateTestInProcessContext( |
| 24 | TestGpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 25 | TestImageFactory* image_factory); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 26 | |
| 27 | class TestInProcessContextProvider : public ContextProvider { |
| 28 | public: |
| 29 | TestInProcessContextProvider(); |
| 30 | |
James Robinson | e1b30cf | 2014-10-21 12:25:40 -0700 | [diff] [blame] | 31 | bool BindToCurrentThread() override; |
| 32 | gpu::gles2::GLES2Interface* ContextGL() override; |
| 33 | gpu::ContextSupport* ContextSupport() override; |
| 34 | class GrContext* GrContext() override; |
Etienne Membrives | 386015a | 2015-02-19 17:27:12 +0100 | [diff] [blame] | 35 | void SetupLock() override; |
| 36 | base::Lock* GetLock() override; |
James Robinson | e1b30cf | 2014-10-21 12:25:40 -0700 | [diff] [blame] | 37 | Capabilities ContextCapabilities() override; |
| 38 | bool IsContextLost() override; |
| 39 | void VerifyContexts() override; |
| 40 | void DeleteCachedResources() override; |
| 41 | bool DestroyedOnMainThread() override; |
| 42 | void SetLostContextCallback( |
James Robinson | baf71d3 | 2014-10-08 13:00:20 -0700 | [diff] [blame] | 43 | const LostContextCallback& lost_context_callback) override; |
James Robinson | e1b30cf | 2014-10-21 12:25:40 -0700 | [diff] [blame] | 44 | void SetMemoryPolicyChangedCallback( |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 45 | const MemoryPolicyChangedCallback& memory_policy_changed_callback) |
James Robinson | baf71d3 | 2014-10-08 13:00:20 -0700 | [diff] [blame] | 46 | override; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 47 | |
| 48 | protected: |
| 49 | friend class base::RefCountedThreadSafe<TestInProcessContextProvider>; |
James Robinson | e1b30cf | 2014-10-21 12:25:40 -0700 | [diff] [blame] | 50 | ~TestInProcessContextProvider() override; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 51 | |
| 52 | private: |
James Robinson | 7f48021 | 2014-10-31 10:28:08 -0700 | [diff] [blame] | 53 | TestGpuMemoryBufferManager gpu_memory_buffer_manager_; |
| 54 | TestImageFactory image_factory_; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 55 | scoped_ptr<gpu::GLInProcessContext> context_; |
| 56 | skia::RefPtr<class GrContext> gr_context_; |
Etienne Membrives | 386015a | 2015-02-19 17:27:12 +0100 | [diff] [blame] | 57 | base::Lock context_lock_; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | } // namespace cc |
| 61 | |
| 62 | #endif // CC_TEST_TEST_IN_PROCESS_CONTEXT_PROVIDER_H_ |