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

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_ =
23 std::move(command_buffer_handle_), 0u)); 21 GLES2Context::CreateOffscreenContext(std::vector<int32_t>(),
24 std::unique_ptr<GLES2Context> context( 22 connector_.get());
25 new GLES2Context(std::vector<int32_t>(), std::move(command_buffer_ptr))); 23 // We don't need the connector anymore, so release it.
26 if (context->Initialize()) 24 connector_.reset();
27 context_ = std::move(context); 25 }
28 return !!context_; 26 return !!context_;
29 } 27 }
30 28
31 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { 29 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() {
32 return context_->interface(); 30 return context_->interface();
33 } 31 }
34 32
35 gpu::ContextSupport* ContextProvider::ContextSupport() { 33 gpu::ContextSupport* ContextProvider::ContextSupport() {
36 if (!context_) 34 if (!context_)
37 return NULL; 35 return NULL;
(...skipping 17 matching lines...) Expand all
55 base::Lock* ContextProvider::GetLock() { 53 base::Lock* ContextProvider::GetLock() {
56 // This context provider is not used on multiple threads. 54 // This context provider is not used on multiple threads.
57 NOTREACHED(); 55 NOTREACHED();
58 return nullptr; 56 return nullptr;
59 } 57 }
60 58
61 ContextProvider::~ContextProvider() { 59 ContextProvider::~ContextProvider() {
62 } 60 }
63 61
64 } // namespace mus 62 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698