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