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

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: Fix typo 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 return context3d_->makeContextCurrent();
39 }
40
41 WebKit::WebGraphicsContext3D* FakeContextProvider::Context3d() {
42 return context3d_.get();
43 }
44 class GrContext* FakeContextProvider::GrContext() {
45 // TODO(danakj): Make a fake GrContext.
46 return NULL;
47 }
48
49 void FakeContextProvider::VerifyContexts() {
50 if (!Context3d() || Context3d()->isContextLost()) {
51 base::AutoLock lock(destroyed_lock_);
52 destroyed_ = true;
53 }
54 }
55
56 bool FakeContextProvider::DestroyedOnMainThread() {
57 base::AutoLock lock(destroyed_lock_);
58 return destroyed_;
59 }
60
61 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698