| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/public/cpp/context_provider.h" | 5 #include "services/ui/public/cpp/context_provider.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "services/shell/public/cpp/connector.h" |
| 10 #include "services/ui/public/cpp/gles2_context.h" | 11 #include "services/ui/public/cpp/gles2_context.h" |
| 11 | 12 |
| 12 namespace ui { | 13 namespace ui { |
| 13 | 14 |
| 14 ContextProvider::ContextProvider() {} | 15 ContextProvider::ContextProvider(shell::Connector* connector) |
| 16 : connector_(connector->Clone()) {} |
| 15 | 17 |
| 16 bool ContextProvider::BindToCurrentThread() { | 18 bool ContextProvider::BindToCurrentThread() { |
| 17 context_ = GLES2Context::CreateOffscreenContext(std::vector<int32_t>()); | 19 if (connector_) { |
| 20 context_ = GLES2Context::CreateOffscreenContext(std::vector<int32_t>(), |
| 21 connector_.get()); |
| 22 // We don't need the connector anymore, so release it. |
| 23 connector_.reset(); |
| 24 } |
| 18 return !!context_; | 25 return !!context_; |
| 19 } | 26 } |
| 20 | 27 |
| 21 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { | 28 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { |
| 22 return context_->interface(); | 29 return context_->interface(); |
| 23 } | 30 } |
| 24 | 31 |
| 25 gpu::ContextSupport* ContextProvider::ContextSupport() { | 32 gpu::ContextSupport* ContextProvider::ContextSupport() { |
| 26 if (!context_) | 33 if (!context_) |
| 27 return NULL; | 34 return NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 45 base::Lock* ContextProvider::GetLock() { | 52 base::Lock* ContextProvider::GetLock() { |
| 46 // This context provider is not used on multiple threads. | 53 // This context provider is not used on multiple threads. |
| 47 NOTREACHED(); | 54 NOTREACHED(); |
| 48 return nullptr; | 55 return nullptr; |
| 49 } | 56 } |
| 50 | 57 |
| 51 ContextProvider::~ContextProvider() { | 58 ContextProvider::~ContextProvider() { |
| 52 } | 59 } |
| 53 | 60 |
| 54 } // namespace ui | 61 } // namespace ui |
| OLD | NEW |