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
),
22 FakeContextProvider::~FakeContextProvider() {}
24 bool FakeContextProvider::InitializeOnMainThread() {
27 if (create_callback_
.is_null())
28 context3d_
= TestWebGraphicsContext3D::Create().Pass();
30 context3d_
= create_callback_
.Run();
34 bool FakeContextProvider::BindToCurrentThread() {
36 if (!context3d_
->makeContextCurrent()) {
37 base::AutoLock
lock(destroyed_lock_
);
44 WebKit::WebGraphicsContext3D
* FakeContextProvider::Context3d() {
48 return context3d_
.get();
50 class GrContext
* FakeContextProvider::GrContext() {
54 // TODO(danakj): Make a fake GrContext.
58 void FakeContextProvider::VerifyContexts() {
62 if (context3d_
->isContextLost()) {
63 base::AutoLock
lock(destroyed_lock_
);
68 bool FakeContextProvider::DestroyedOnMainThread() {
69 base::AutoLock
lock(destroyed_lock_
);