Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / cc / test / fake_context_provider.h
blob9ab1abd3d383619cf35b3c157db36a3cffc88112
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_FAKE_CONTEXT_PROVIDER_H_
6 #define CC_TEST_FAKE_CONTEXT_PROVIDER_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/synchronization/lock.h"
11 #include "cc/output/context_provider.h"
13 namespace cc {
14 class TestWebGraphicsContext3D;
16 class FakeContextProvider : public cc::ContextProvider {
17 public:
18 typedef base::Callback<scoped_ptr<TestWebGraphicsContext3D>(void)>
19 CreateCallback;
21 static scoped_refptr<FakeContextProvider> Create() {
22 scoped_refptr<FakeContextProvider> provider = new FakeContextProvider();
23 if (!provider->InitializeOnMainThread())
24 return NULL;
25 return provider;
28 static scoped_refptr<FakeContextProvider> Create(
29 const CreateCallback& create_callback) {
30 scoped_refptr<FakeContextProvider> provider =
31 new FakeContextProvider(create_callback);
32 if (!provider->InitializeOnMainThread())
33 return NULL;
34 return provider;
37 virtual bool BindToCurrentThread() OVERRIDE;
38 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE;
39 virtual class GrContext* GrContext() OVERRIDE;
40 virtual void VerifyContexts() OVERRIDE;
41 virtual bool DestroyedOnMainThread() OVERRIDE;
43 protected:
44 FakeContextProvider();
45 explicit FakeContextProvider(const CreateCallback& create_callback);
46 virtual ~FakeContextProvider();
48 bool InitializeOnMainThread();
50 CreateCallback create_callback_;
51 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_;
52 bool bound_;
54 base::Lock destroyed_lock_;
55 bool destroyed_;
58 } // namespace cc
60 #endif // CC_TEST_FAKE_CONTEXT_PROVIDER_H_