Dismiss autofill popup on screen orientation change.
[chromium-blink-merge.git] / cc / debug / test_context_provider.h
blob3e677049e6f9fb2dd1697b56f49861207b7b8a9e
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 WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
34 virtual class GrContext* GrContext() OVERRIDE;
35 virtual void VerifyContexts() OVERRIDE;
36 virtual bool DestroyedOnMainThread() OVERRIDE;
37 virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE;
38 virtual void SetSwapBuffersCompleteCallback(
39 const SwapBuffersCompleteCallback& cb) OVERRIDE;
40 virtual void SetMemoryPolicyChangedCallback(
41 const MemoryPolicyChangedCallback& cb) OVERRIDE;
43 TestWebGraphicsContext3D* TestContext3d() { return context3d_.get(); }
45 void SetMemoryAllocation(const ManagedMemoryPolicy& policy,
46 bool discard_backbuffer_when_not_visible);
48 protected:
49 TestContextProvider();
50 virtual ~TestContextProvider();
52 bool InitializeOnMainThread(const CreateCallback& create_callback);
54 void OnLostContext();
55 void OnSwapBuffersComplete();
57 scoped_ptr<TestWebGraphicsContext3D> context3d_;
58 bool bound_;
60 base::ThreadChecker main_thread_checker_;
61 base::ThreadChecker context_thread_checker_;
63 base::Lock destroyed_lock_;
64 bool destroyed_;
66 LostContextCallback lost_context_callback_;
67 SwapBuffersCompleteCallback swap_buffers_complete_callback_;
68 MemoryPolicyChangedCallback memory_policy_changed_callback_;
70 class LostContextCallbackProxy;
71 scoped_ptr<LostContextCallbackProxy> lost_context_callback_proxy_;
73 class SwapBuffersCompleteCallbackProxy;
74 scoped_ptr<SwapBuffersCompleteCallbackProxy>
75 swap_buffers_complete_callback_proxy_;
78 } // namespace cc
80 #endif // CC_DEBUG_TEST_CONTEXT_PROVIDER_H_