| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/test/fake_context_provider.h" | 5 #include "cc/test/fake_context_provider.h" |
| 6 | 6 |
| 7 #include "cc/test/test_web_graphics_context_3d.h" | 7 #include "cc/test/test_web_graphics_context_3d.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| 11 FakeContextProvider::FakeContextProvider() | 11 FakeContextProvider::FakeContextProvider() |
| 12 : destroyed_(false) { | 12 : destroyed_(false) { |
| 13 } | 13 } |
| 14 | 14 |
| 15 FakeContextProvider::FakeContextProvider( | 15 FakeContextProvider::FakeContextProvider( |
| 16 const CreateCallback& create_callback) | 16 const CreateCallback& create_callback) |
| 17 : create_callback_(create_callback), | 17 : create_callback_(create_callback), |
| 18 bound_(false), | 18 bound_(false), |
| 19 destroyed_(false) { | 19 destroyed_(false) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 FakeContextProvider::~FakeContextProvider() {} | 22 FakeContextProvider::~FakeContextProvider() {} |
| 23 | 23 |
| 24 bool FakeContextProvider::InitializeOnMainThread() { | 24 bool FakeContextProvider::InitializeOnMainThread() { |
| 25 DCHECK(!context3d_); | 25 DCHECK(!context3d_); |
| 26 | 26 |
| 27 if (create_callback_.is_null()) | 27 if (create_callback_.is_null()) |
| 28 context3d_ = TestWebGraphicsContext3D::Create().Pass(); | 28 context3d_ = TestWebGraphicsContext3D::CreateShared(); |
| 29 else | 29 else |
| 30 context3d_ = create_callback_.Run(); | 30 context3d_ = create_callback_.Run(); |
| 31 return context3d_; | 31 return context3d_; |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool FakeContextProvider::BindToCurrentThread() { | 34 bool FakeContextProvider::BindToCurrentThread() { |
| 35 bound_ = true; | 35 bound_ = true; |
| 36 if (!context3d_->makeContextCurrent()) { | 36 if (!context3d_->makeContextCurrent()) { |
| 37 base::AutoLock lock(destroyed_lock_); | 37 base::AutoLock lock(destroyed_lock_); |
| 38 destroyed_ = true; | 38 destroyed_ = true; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 64 destroyed_ = true; | 64 destroyed_ = true; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool FakeContextProvider::DestroyedOnMainThread() { | 68 bool FakeContextProvider::DestroyedOnMainThread() { |
| 69 base::AutoLock lock(destroyed_lock_); | 69 base::AutoLock lock(destroyed_lock_); |
| 70 return destroyed_; | 70 return destroyed_; |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace cc | 73 } // namespace cc |
| OLD | NEW |