[DevTools] Remove unused moveWindowBy embedder message.
[chromium-blink-merge.git] / cc / test / test_context_provider.h
blob66ae9986b168d895fc6675b805199e43665ccb38
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.
5 #ifndef CC_TEST_TEST_CONTEXT_PROVIDER_H_
6 #define CC_TEST_TEST_CONTEXT_PROVIDER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/synchronization/lock.h"
12 #include "base/threading/thread_checker.h"
13 #include "cc/output/context_provider.h"
14 #include "cc/test/test_context_support.h"
15 #include "gpu/command_buffer/client/gles2_interface_stub.h"
17 namespace cc {
18 class TestWebGraphicsContext3D;
19 class TestGLES2Interface;
21 class TestContextProvider : public ContextProvider {
22 public:
23 typedef base::Callback<scoped_ptr<TestWebGraphicsContext3D>(void)>
24 CreateCallback;
26 static scoped_refptr<TestContextProvider> Create();
27 static scoped_refptr<TestContextProvider> Create(
28 scoped_ptr<TestWebGraphicsContext3D> context);
30 bool BindToCurrentThread() override;
31 Capabilities ContextCapabilities() override;
32 gpu::gles2::GLES2Interface* ContextGL() override;
33 gpu::ContextSupport* ContextSupport() override;
34 class GrContext* GrContext() override;
35 bool IsContextLost() override;
36 void VerifyContexts() override;
37 void DeleteCachedResources() override;
38 bool DestroyedOnMainThread() override;
39 void SetLostContextCallback(const LostContextCallback& cb) override;
40 void SetMemoryPolicyChangedCallback(
41 const MemoryPolicyChangedCallback& cb) override;
43 TestWebGraphicsContext3D* TestContext3d();
45 // This returns the TestWebGraphicsContext3D but is valid to call
46 // before the context is bound to a thread. This is needed to set up
47 // state on the test context before binding. Don't call
48 // InitializeOnCurrentThread on the context returned from this method.
49 TestWebGraphicsContext3D* UnboundTestContext3d();
51 TestContextSupport* support() { return &support_; }
53 void SetMemoryAllocation(const ManagedMemoryPolicy& policy);
55 void SetMaxTransferBufferUsageBytes(size_t max_transfer_buffer_usage_bytes);
57 protected:
58 explicit TestContextProvider(scoped_ptr<TestWebGraphicsContext3D> context);
59 ~TestContextProvider() override;
61 private:
62 void OnLostContext();
64 TestContextSupport support_;
66 scoped_ptr<TestWebGraphicsContext3D> context3d_;
67 scoped_ptr<TestGLES2Interface> context_gl_;
68 bool bound_;
70 base::ThreadChecker main_thread_checker_;
71 base::ThreadChecker context_thread_checker_;
73 base::Lock destroyed_lock_;
74 bool destroyed_;
76 LostContextCallback lost_context_callback_;
77 MemoryPolicyChangedCallback memory_policy_changed_callback_;
79 base::WeakPtrFactory<TestContextProvider> weak_ptr_factory_;
81 DISALLOW_COPY_AND_ASSIGN(TestContextProvider);
84 } // namespace cc
86 #endif // CC_TEST_TEST_CONTEXT_PROVIDER_H_