Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: cc/test/fake_context_provider.cc

Issue 100373002: cc: Remove old fake_context_provider.cc file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "cc/test/fake_context_provider.h"
6
7 #include "base/bind.h"
8 #include "cc/test/test_web_graphics_context_3d.h"
9
10 namespace cc {
11
12 // static
13 scoped_refptr<FakeContextProvider> FakeContextProvider::
14 CreateForOtherThread() {
15 scoped_refptr<FakeContextProvider> provider = new FakeContextProvider();
16 if (!provider->InitializeOnMainThread())
17 return NULL;
18 return provider;
19 }
20
21 static scoped_ptr<TestWebGraphicsContext3D> ReturnContext(
22 scoped_ptr<TestWebGraphicsContext3D> context3d) {
23 return context3d.Pass();
24 }
25
26 // static
27 scoped_refptr<FakeContextProvider> FakeContextProvider::CreateForOtherThread(
28 scoped_ptr<TestWebGraphicsContext3D> context3d) {
29 CreateCallback create_callback =
30 base::Bind(&ReturnContext, base::Passed(&context3d));
31 scoped_refptr<FakeContextProvider> provider =
32 new FakeContextProvider(create_callback);
33 if (!provider->InitializeOnMainThread())
34 return NULL;
35 return provider;
36 }
37
38 // static
39 scoped_refptr<FakeContextProvider> FakeContextProvider::CreateForOtherThread(
40 const CreateCallback& create_callback) {
41 scoped_refptr<FakeContextProvider> provider =
42 new FakeContextProvider(create_callback);
43 if (!provider->InitializeOnMainThread())
44 return NULL;
45 return provider;
46 }
47
48 FakeContextProvider::FakeContextProvider()
49 : destroyed_(false) {
50 }
51
52 FakeContextProvider::FakeContextProvider(
53 const CreateCallback& create_callback)
54 : create_callback_(create_callback),
55 bound_(false),
56 destroyed_(false) {
57 }
58
59 FakeContextProvider::~FakeContextProvider() {}
60
61 bool FakeContextProvider::InitializeOnMainThread() {
62 DCHECK(!context3d_);
63
64 if (create_callback_.is_null())
65 context3d_ = TestWebGraphicsContext3D::Create().Pass();
66 else
67 context3d_ = create_callback_.Run();
68 return context3d_;
69 }
70
71 bool FakeContextProvider::BindToCurrentThread() {
72 bound_ = true;
73 if (!context3d_->makeContextCurrent()) {
74 base::AutoLock lock(destroyed_lock_);
75 destroyed_ = true;
76 return false;
77 }
78 return true;
79 }
80
81 blink::WebGraphicsContext3D* FakeContextProvider::Context3d() {
82 DCHECK(context3d_);
83 DCHECK(bound_);
84
85 return context3d_.get();
86 }
87 class GrContext* FakeContextProvider::GrContext() {
88 DCHECK(context3d_);
89 DCHECK(bound_);
90
91 // TODO(danakj): Make a fake GrContext.
92 return NULL;
93 }
94
95 void FakeContextProvider::VerifyContexts() {
96 DCHECK(context3d_);
97 DCHECK(bound_);
98
99 if (context3d_->isContextLost()) {
100 base::AutoLock lock(destroyed_lock_);
101 destroyed_ = true;
102 }
103 }
104
105 bool FakeContextProvider::DestroyedOnMainThread() {
106 base::AutoLock lock(destroyed_lock_);
107 return destroyed_;
108 }
109
110 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698