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"
11 FakeContextProvider::FakeContextProvider()
15 FakeContextProvider::FakeContextProvider(
16 const CreateCallback
& create_callback
)
17 : create_callback_(create_callback
),
21 FakeContextProvider::~FakeContextProvider() {}
23 bool FakeContextProvider::InitializeOnMainThread() {
29 if (create_callback_
.is_null())
30 context3d_
= TestWebGraphicsContext3D::Create().Pass();
32 context3d_
= create_callback_
.Run();
33 destroyed_
= !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.
49 void FakeContextProvider::VerifyContexts() {
50 if (!Context3d() || Context3d()->isContextLost()) {
51 base::AutoLock
lock(destroyed_lock_
);
56 bool FakeContextProvider::DestroyedOnMainThread() {
57 base::AutoLock
lock(destroyed_lock_
);