| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "webkit/common/gpu/test_context_provider_factory.h" | 5 #include "webkit/common/gpu/test_context_provider_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "cc/output/context_provider.h" | 8 #include "cc/output/context_provider.h" |
| 9 #include "webkit/common/gpu/context_provider_in_process.h" | 9 #include "webkit/common/gpu/context_provider_in_process.h" |
| 10 | 10 |
| 11 namespace webkit { | 11 namespace webkit { |
| 12 namespace gpu { | 12 namespace gpu { |
| 13 | 13 |
| 14 static TestContextProviderFactory* context_provider_instance = NULL; | 14 static TestContextProviderFactory* context_provider_instance = NULL; |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 TestContextProviderFactory* TestContextProviderFactory::GetInstance() { | 17 TestContextProviderFactory* TestContextProviderFactory::GetInstance() { |
| 18 if (!context_provider_instance) | 18 if (!context_provider_instance) |
| 19 context_provider_instance = new TestContextProviderFactory(); | 19 context_provider_instance = new TestContextProviderFactory(); |
| 20 return context_provider_instance; | 20 return context_provider_instance; |
| 21 } | 21 } |
| 22 | 22 |
| 23 TestContextProviderFactory::TestContextProviderFactory() {} | 23 TestContextProviderFactory::TestContextProviderFactory() {} |
| 24 | 24 |
| 25 TestContextProviderFactory::~TestContextProviderFactory() {} | 25 TestContextProviderFactory::~TestContextProviderFactory() {} |
| 26 | 26 |
| 27 scoped_refptr<cc::ContextProvider> TestContextProviderFactory:: | 27 scoped_refptr<cc::ContextProvider> TestContextProviderFactory:: |
| 28 OffscreenContextProviderForMainThread() { | 28 OffscreenContextProviderForMainThread() { |
| 29 if (!main_thread_.get() || main_thread_->DestroyedOnMainThread()) { | 29 if (!main_thread_.get() || main_thread_->DestroyedOnMainThread()) { |
| 30 main_thread_ = ContextProviderInProcess::Create(); | 30 main_thread_ = ContextProviderInProcess::CreateOffscreen(); |
| 31 if (main_thread_.get() && !main_thread_->BindToCurrentThread()) | 31 if (main_thread_.get() && !main_thread_->BindToCurrentThread()) |
| 32 main_thread_ = NULL; | 32 main_thread_ = NULL; |
| 33 } | 33 } |
| 34 return main_thread_; | 34 return main_thread_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace gpu | 37 } // namespace gpu |
| 38 } // namespace webkit | 38 } // namespace webkit |
| OLD | NEW |