Add signalSyncPoint to the WebGraphicsContext3D command buffer impls.
[chromium-blink-merge.git] / cc / test / fake_context_provider.cc
blobe12f78317421c916746a90bc7b4a817cf7fe59d5
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 #include "cc/test/fake_context_provider.h"
7 #include "cc/test/test_web_graphics_context_3d.h"
9 namespace cc {
11 FakeContextProvider::FakeContextProvider()
12 : destroyed_(false) {
15 FakeContextProvider::FakeContextProvider(
16 const CreateCallback& create_callback)
17 : create_callback_(create_callback),
18 bound_(false),
19 destroyed_(false) {
22 FakeContextProvider::~FakeContextProvider() {}
24 bool FakeContextProvider::InitializeOnMainThread() {
25 DCHECK(!context3d_);
27 if (create_callback_.is_null())
28 context3d_ = TestWebGraphicsContext3D::Create().Pass();
29 else
30 context3d_ = create_callback_.Run();
31 return context3d_;
34 bool FakeContextProvider::BindToCurrentThread() {
35 bound_ = true;
36 if (!context3d_->makeContextCurrent()) {
37 base::AutoLock lock(destroyed_lock_);
38 destroyed_ = true;
39 return false;
41 return true;
44 WebKit::WebGraphicsContext3D* FakeContextProvider::Context3d() {
45 DCHECK(context3d_);
46 DCHECK(bound_);
48 return context3d_.get();
50 class GrContext* FakeContextProvider::GrContext() {
51 DCHECK(context3d_);
52 DCHECK(bound_);
54 // TODO(danakj): Make a fake GrContext.
55 return NULL;
58 void FakeContextProvider::VerifyContexts() {
59 DCHECK(context3d_);
60 DCHECK(bound_);
62 if (context3d_->isContextLost()) {
63 base::AutoLock lock(destroyed_lock_);
64 destroyed_ = true;
68 bool FakeContextProvider::DestroyedOnMainThread() {
69 base::AutoLock lock(destroyed_lock_);
70 return destroyed_;
73 } // namespace cc