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"
14 class TestWebGraphicsContext3D
;
16 class FakeContextProvider
: public cc::ContextProvider
{
18 typedef base::Callback
<scoped_ptr
<TestWebGraphicsContext3D
>(void)>
21 static scoped_refptr
<FakeContextProvider
> Create() {
22 scoped_refptr
<FakeContextProvider
> provider
= new FakeContextProvider();
23 if (!provider
->InitializeOnMainThread())
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())
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
;
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_
;
54 base::Lock destroyed_lock_
;
60 #endif // CC_TEST_FAKE_CONTEXT_PROVIDER_H_