Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: components/mus/public/cpp/lib/context_provider.cc

Issue 1976703003: Impl mus::mojom::GpuService to enable using Chrome IPC version gpu CmdBuf in mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/command_buffer_client_impl.cc ('k') | components/mus/public/cpp/lib/gles2_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698