| 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 "components/mus/public/cpp/context_provider.h" | 5 #include "components/mus/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 "components/mus/public/cpp/gles2_context.h" | 10 #include "components/mus/public/cpp/gles2_context.h" |
| 11 | 11 |
| 12 namespace mus { | 12 namespace mus { |
| 13 | 13 |
| 14 ContextProvider::ContextProvider( | 14 ContextProvider::ContextProvider(shell::Connector* connector) |
| 15 mojo::ScopedMessagePipeHandle command_buffer_handle) | 15 : connector_(connector) {} |
| 16 : command_buffer_handle_(std::move(command_buffer_handle)), | |
| 17 context_(nullptr) { | |
| 18 } | |
| 19 | 16 |
| 20 bool ContextProvider::BindToCurrentThread() { | 17 bool ContextProvider::BindToCurrentThread() { |
| 21 mojom::CommandBufferPtr command_buffer_ptr; | 18 context_ = |
| 22 command_buffer_ptr.Bind(mojo::InterfacePtrInfo<mus::mojom::CommandBuffer>( | 19 GLES2Context::CreateOffscreenContext(std::vector<int32_t>(), connector_); |
| 23 std::move(command_buffer_handle_), 0u)); | |
| 24 std::unique_ptr<GLES2Context> context( | |
| 25 new GLES2Context(std::vector<int32_t>(), std::move(command_buffer_ptr))); | |
| 26 if (context->Initialize()) | |
| 27 context_ = std::move(context); | |
| 28 return !!context_; | 20 return !!context_; |
| 29 } | 21 } |
| 30 | 22 |
| 31 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { | 23 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { |
| 32 return context_->interface(); | 24 return context_->interface(); |
| 33 } | 25 } |
| 34 | 26 |
| 35 gpu::ContextSupport* ContextProvider::ContextSupport() { | 27 gpu::ContextSupport* ContextProvider::ContextSupport() { |
| 36 if (!context_) | 28 if (!context_) |
| 37 return NULL; | 29 return NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 base::Lock* ContextProvider::GetLock() { | 47 base::Lock* ContextProvider::GetLock() { |
| 56 // This context provider is not used on multiple threads. | 48 // This context provider is not used on multiple threads. |
| 57 NOTREACHED(); | 49 NOTREACHED(); |
| 58 return nullptr; | 50 return nullptr; |
| 59 } | 51 } |
| 60 | 52 |
| 61 ContextProvider::~ContextProvider() { | 53 ContextProvider::~ContextProvider() { |
| 62 } | 54 } |
| 63 | 55 |
| 64 } // namespace mus | 56 } // namespace mus |
| OLD | NEW |