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

Side by Side Diff: services/ui/ws/gpu_service_proxy.cc

Issue 2329543002: services/ui: Use new gpu::GpuInit to do the GPU initialization. (Closed)
Patch Set: nullcheck Created 4 years, 3 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
« no previous file with comments | « services/ui/ws/gpu_service_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ws/gpu_service_proxy.h" 5 #include "services/ui/ws/gpu_service_proxy.h"
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "gpu/ipc/client/gpu_channel_host.h" 11 #include "gpu/ipc/client/gpu_channel_host.h"
12 #include "services/shell/public/cpp/connection.h" 12 #include "services/shell/public/cpp/connection.h"
13 #include "services/ui/gpu/gpu_service_internal.h"
14 #include "services/ui/ws/gpu_service_proxy_delegate.h" 13 #include "services/ui/ws/gpu_service_proxy_delegate.h"
15 #include "services/ui/ws/mus_gpu_memory_buffer_manager.h" 14 #include "services/ui/ws/mus_gpu_memory_buffer_manager.h"
16 15
17 namespace ui { 16 namespace ui {
18 namespace ws { 17 namespace ws {
19 18
20 namespace { 19 namespace {
21 20
22 const int32_t kInternalGpuChannelClientId = 1; 21 const int32_t kInternalGpuChannelClientId = 1;
23 const uint64_t kInternalGpuChannelClientTracingId = 1; 22 const uint64_t kInternalGpuChannelClientTracingId = 1;
24 23
25 } // namespace 24 } // namespace
26 25
27 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate) 26 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate)
28 : delegate_(delegate), 27 : delegate_(delegate),
29 next_client_id_(kInternalGpuChannelClientId), 28 next_client_id_(kInternalGpuChannelClientId),
30 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), 29 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()),
31 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, 30 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC,
32 base::WaitableEvent::InitialState::NOT_SIGNALED) { 31 base::WaitableEvent::InitialState::NOT_SIGNALED) {
33 // TODO(sad): Once GPU process is split, this would look like: 32 // TODO(sad): Once GPU process is split, this would look like:
34 // connector->ConnectToInterface("mojo:gpu", &gpu_service_); 33 // connector->ConnectToInterface("mojo:gpu", &gpu_service_);
35 GpuServiceInternal::GetInstance()->Add(GetProxy(&gpu_service_)); 34 gpu_main_.Add(GetProxy(&gpu_service_));
36 gpu_service_->Initialize( 35 gpu_service_->Initialize(
37 base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this))); 36 base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this)));
38 } 37 }
39 38
40 GpuServiceProxy::~GpuServiceProxy() {} 39 GpuServiceProxy::~GpuServiceProxy() {}
41 40
42 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { 41 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) {
43 bindings_.AddBinding(this, std::move(request)); 42 bindings_.AddBinding(this, std::move(request));
44 } 43 }
45 44
46 void GpuServiceProxy::OnInitialized(const gpu::GPUInfo& gpu_info) { 45 void GpuServiceProxy::OnInitialized(const gpu::GPUInfo& gpu_info) {
47 gpu_info_ = gpu_info; 46 gpu_info_ = gpu_info;
48 47
49 constexpr bool is_gpu_host = true; 48 constexpr bool is_gpu_host = true;
50 gpu_service_->EstablishGpuChannel( 49 gpu_service_->EstablishGpuChannel(
51 kInternalGpuChannelClientId, kInternalGpuChannelClientTracingId, 50 kInternalGpuChannelClientId, kInternalGpuChannelClientTracingId,
52 is_gpu_host, base::Bind(&GpuServiceProxy::OnInternalGpuChannelEstablished, 51 is_gpu_host, base::Bind(&GpuServiceProxy::OnInternalGpuChannelEstablished,
53 base::Unretained(this))); 52 base::Unretained(this)));
54 next_client_id_ = kInternalGpuChannelClientId + 1; 53 next_client_id_ = kInternalGpuChannelClientId + 1;
55 } 54 }
56 55
57 void GpuServiceProxy::OnInternalGpuChannelEstablished( 56 void GpuServiceProxy::OnInternalGpuChannelEstablished(
58 mojo::ScopedMessagePipeHandle channel_handle) { 57 mojo::ScopedMessagePipeHandle channel_handle) {
59 io_thread_.reset(new base::Thread("GPUIOThread")); 58 io_thread_.reset(new base::Thread("GPUIOThread"));
60 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0); 59 base::Thread::Options thread_options(base::MessageLoop::TYPE_IO, 0);
61 thread_options.priority = base::ThreadPriority::NORMAL; 60 thread_options.priority = base::ThreadPriority::NORMAL;
62 CHECK(io_thread_->StartWithOptions(thread_options)); 61 CHECK(io_thread_->StartWithOptions(thread_options));
63 62
64 gpu_memory_buffer_manager_.reset(new MusGpuMemoryBufferManager( 63 gpu_memory_buffer_manager_.reset(new MusGpuMemoryBufferManager(
65 GpuServiceInternal::GetInstance(), kInternalGpuChannelClientId)); 64 gpu_main_.gpu_service(), kInternalGpuChannelClientId));
66 gpu_channel_ = gpu::GpuChannelHost::Create( 65 gpu_channel_ = gpu::GpuChannelHost::Create(
67 this, kInternalGpuChannelClientId, gpu_info_, 66 this, kInternalGpuChannelClientId, gpu_info_,
68 IPC::ChannelHandle(channel_handle.release()), &shutdown_event_, 67 IPC::ChannelHandle(channel_handle.release()), &shutdown_event_,
69 gpu_memory_buffer_manager_.get()); 68 gpu_memory_buffer_manager_.get());
70 if (delegate_) 69 if (delegate_)
71 delegate_->OnGpuChannelEstablished(gpu_channel_); 70 delegate_->OnGpuChannelEstablished(gpu_channel_);
72 } 71 }
73 72
74 void GpuServiceProxy::OnGpuChannelEstablished( 73 void GpuServiceProxy::OnGpuChannelEstablished(
75 const EstablishGpuChannelCallback& callback, 74 const EstablishGpuChannelCallback& callback,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 std::unique_ptr<base::SharedMemory> GpuServiceProxy::AllocateSharedMemory( 117 std::unique_ptr<base::SharedMemory> GpuServiceProxy::AllocateSharedMemory(
119 size_t size) { 118 size_t size) {
120 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); 119 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory());
121 if (!shm->CreateAnonymous(size)) 120 if (!shm->CreateAnonymous(size))
122 shm.reset(); 121 shm.reset();
123 return shm; 122 return shm;
124 } 123 }
125 124
126 } // namespace ws 125 } // namespace ws
127 } // namespace ui 126 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/gpu_service_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698