OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CC_TEST_FAKE_CONTEXT_PROVIDER_H_ | |
6 #define CC_TEST_FAKE_CONTEXT_PROVIDER_H_ | |
7 | |
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/output/context_provider.h" | |
13 | |
14 namespace cc { | |
15 class TestWebGraphicsContext3D; | |
16 | |
17 class FakeContextProvider : public cc::ContextProvider { | |
18 public: | |
19 typedef base::Callback<scoped_ptr<TestWebGraphicsContext3D>(void)> | |
20 CreateCallback; | |
21 | |
22 static scoped_refptr<FakeContextProvider> Create() { | |
23 return Create(CreateCallback()); | |
24 } | |
25 | |
26 static scoped_refptr<FakeContextProvider> Create( | |
27 const CreateCallback& create_callback) { | |
28 scoped_refptr<FakeContextProvider> provider = new FakeContextProvider; | |
29 if (!provider->InitializeOnMainThread(create_callback)) | |
30 return NULL; | |
31 return provider; | |
32 } | |
33 | |
34 virtual bool BindToCurrentThread() OVERRIDE; | |
35 virtual WebKit::WebGraphicsContext3D* Context3d() OVERRIDE; | |
36 virtual class GrContext* GrContext() OVERRIDE; | |
37 virtual void VerifyContexts() OVERRIDE; | |
38 virtual bool DestroyedOnMainThread() OVERRIDE; | |
39 virtual void SetLostContextCallback(const LostContextCallback& cb) OVERRIDE; | |
40 | |
41 protected: | |
42 FakeContextProvider(); | |
43 virtual ~FakeContextProvider(); | |
44 | |
45 bool InitializeOnMainThread(const CreateCallback& create_callback); | |
46 | |
47 scoped_ptr<WebKit::WebGraphicsContext3D> context3d_; | |
48 bool bound_; | |
49 | |
50 base::ThreadChecker main_thread_checker_; | |
51 base::ThreadChecker context_thread_checker_; | |
52 | |
53 base::Lock destroyed_lock_; | |
54 bool destroyed_; | |
55 }; | |
56 | |
57 } // namespace cc | |
58 | |
59 #endif // CC_TEST_FAKE_CONTEXT_PROVIDER_H_ | |
60 | |
OLD | NEW |