OLD | NEW |
(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 if (!destroyed_ && !context3d_->makeContextCurrent()) |
| 39 destroyed_ = true; |
| 40 return !destroyed_; |
| 41 } |
| 42 |
| 43 WebKit::WebGraphicsContext3D* FakeContextProvider::Context3d() { |
| 44 return context3d_.get(); |
| 45 } |
| 46 class GrContext* FakeContextProvider::GrContext() { |
| 47 // TODO(danakj): Make a fake GrContext. |
| 48 return NULL; |
| 49 } |
| 50 |
| 51 void FakeContextProvider::VerifyContexts() { |
| 52 if (!Context3d() || Context3d()->isContextLost()) |
| 53 destroyed_ = true; |
| 54 } |
| 55 |
| 56 } // namespace cc |
OLD | NEW |