add a use_alsa gyp setting
[chromium-blink-merge.git] / cc / test / fake_context_provider.cc
blobed777fc0af8a172c2885b4654977e8876c2fce6d
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 destroyed_(false) {
21 FakeContextProvider::~FakeContextProvider() {}
23 bool FakeContextProvider::InitializeOnMainThread() {
24 if (destroyed_)
25 return false;
26 if (context3d_)
27 return true;
29 if (create_callback_.is_null())
30 context3d_ = TestWebGraphicsContext3D::Create().Pass();
31 else
32 context3d_ = create_callback_.Run();
33 destroyed_ = !context3d_;
34 return !!context3d_;
37 bool FakeContextProvider::BindToCurrentThread() {
38 return context3d_->makeContextCurrent();
41 WebKit::WebGraphicsContext3D* FakeContextProvider::Context3d() {
42 return context3d_.get();
44 class GrContext* FakeContextProvider::GrContext() {
45 // TODO(danakj): Make a fake GrContext.
46 return NULL;
49 void FakeContextProvider::VerifyContexts() {
50 if (!Context3d() || Context3d()->isContextLost()) {
51 base::AutoLock lock(destroyed_lock_);
52 destroyed_ = true;
56 bool FakeContextProvider::DestroyedOnMainThread() {
57 base::AutoLock lock(destroyed_lock_);
58 return destroyed_;
61 } // namespace cc