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

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

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cc::ContextProvider Created 7 years, 10 months 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
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 "cc/test/test_web_graphics_context_3d.h"
8
9 namespace cc {
10
11 FakeContextProvider::FakeContextProvider()
12 : destroyed_(false) {
13 }
14
15 FakeContextProvider::FakeContextProvider(
16 const CreateCallback& create_callback)
17 : create_callback_(create_callback),
18 destroyed_(false) {
19 }
20
21 FakeContextProvider::~FakeContextProvider() {}
22
23 bool FakeContextProvider::InitializeOnMainThread() {
24 if (destroyed_)
25 return false;
26 if (context3d_)
27 return true;
28
29 if (create_callback_.is_null())
30 context3d_ = TestWebGraphicsContext3D::Create().Pass();
31 else
32 context3d_ = create_callback_.Run();
33 destroyed_ = !context3d_;
34 return !!context3d_;
35 }
36
37 bool FakeContextProvider::BindToCurrentThread() {
38 if (!context3d_->makeContextCurrent()) {
39 base::AutoLock lock(destroyed_lock_);
40 destroyed_ = true;
41 }
42 return !destroyed_;
43 }
44
45 WebKit::WebGraphicsContext3D* FakeContextProvider::Context3d() {
46 return context3d_.get();
47 }
48 class GrContext* FakeContextProvider::GrContext() {
49 // TODO(danakj): Make a fake GrContext.
50 return NULL;
51 }
52
53 void FakeContextProvider::VerifyContexts() {
54 if (!Context3d() || Context3d()->isContextLost()) {
55 base::AutoLock lock(destroyed_lock_);
56 destroyed_ = true;
57 }
58 }
59
60 bool FakeContextProvider::DestroyedOnMainThread() {
61 base::AutoLock lock(destroyed_lock_);
62 return destroyed_;
63 }
64
65 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698