cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / cc / debug / test_context_provider.h
blob0be90af7e56591eca5b0512343b53d8c0d4cd79a
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_DEBUG_TEST_CONTEXT_PROVIDER_H_
6 #define CC_DEBUG_TEST_CONTEXT_PROVIDER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h"
11 #include "base/threading/thread_checker.h"
12 #include "cc/base/cc_export.h"
13 #include "cc/output/context_provider.h"
15 namespace WebKit { class WebGraphicsContext3D; }
17 namespace cc {
18 class TestWebGraphicsContext3D;
20 class CC_EXPORT TestContextProvider
21 : public NON_EXPORTED_BASE(cc::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 const CreateCallback& create_callback);
29 static scoped_refptr<TestContextProvider> Create(
30 scoped_ptr<TestWebGraphicsContext3D> context);
32 virtual bool BindToCurrentThread() OVERRIDE;
33 virtual Capabilities ContextCapabilities() OVERRIDE;
34 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
35 virtual class GrContext* GrContext() OVERRIDE;
36 virtual void VerifyContexts() OVERRIDE;
37 virtual bool DestroyedOnMainThread() OVERRIDE;
38 virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE;
39 virtual void SetSwapBuffersCompleteCallback(
40 const SwapBuffersCompleteCallback& cb) OVERRIDE;
41 virtual void SetMemoryPolicyChangedCallback(
42 const MemoryPolicyChangedCallback& cb) OVERRIDE;
44 TestWebGraphicsContext3D* TestContext3d();
46 // This returns the TestWebGraphicsContext3D but is valid to call
47 // before the context is bound to a thread. This is needed to set up
48 // state on the test context before binding. Don't call
49 // makeContextCurrent on the context returned from this method.
50 TestWebGraphicsContext3D* UnboundTestContext3d();
52 void SetMemoryAllocation(const ManagedMemoryPolicy& policy,
53 bool discard_backbuffer_when_not_visible);
55 protected:
56 TestContextProvider();
57 virtual ~TestContextProvider();
59 bool InitializeOnMainThread(const CreateCallback& create_callback);
61 void OnLostContext();
62 void OnSwapBuffersComplete();
64 scoped_ptr<TestWebGraphicsContext3D> context3d_;
65 bool bound_;
67 base::ThreadChecker main_thread_checker_;
68 base::ThreadChecker context_thread_checker_;
70 base::Lock destroyed_lock_;
71 bool destroyed_;
73 LostContextCallback lost_context_callback_;
74 SwapBuffersCompleteCallback swap_buffers_complete_callback_;
75 MemoryPolicyChangedCallback memory_policy_changed_callback_;
77 class LostContextCallbackProxy;
78 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_;
80 class SwapBuffersCompleteCallbackProxy;
81 scoped_ptr<SwapBuffersCompleteCallbackProxy>
82 swap_buffers_complete_callback_proxy_;
85 } // namespace cc
87 #endif // CC_DEBUG_TEST_CONTEXT_PROVIDER_H_