| OLD | NEW |
| 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/ws/gpu_service_proxy_delegate.h" | 13 #include "services/ui/ws/gpu_service_proxy_delegate.h" |
| 14 #include "services/ui/ws/mus_gpu_memory_buffer_manager.h" | 14 #include "services/ui/ws/mus_gpu_memory_buffer_manager.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 namespace ws { | 17 namespace ws { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const int32_t kInternalGpuChannelClientId = 1; | 21 const int32_t kInternalGpuChannelClientId = 1; |
| 22 const uint64_t kInternalGpuChannelClientTracingId = 1; | 22 const uint64_t kInternalGpuChannelClientTracingId = 1; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate) | 26 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate, |
| 27 shell::Connector* connector) |
| 27 : delegate_(delegate), | 28 : delegate_(delegate), |
| 28 next_client_id_(kInternalGpuChannelClientId), | 29 next_client_id_(kInternalGpuChannelClientId), |
| 29 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 30 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 30 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 31 shutdown_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 31 base::WaitableEvent::InitialState::NOT_SIGNALED) { | 32 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 33 gpu_main_(connector) { |
| 32 // TODO(sad): Once GPU process is split, this would look like: | 34 // TODO(sad): Once GPU process is split, this would look like: |
| 33 // connector->ConnectToInterface("mojo:gpu", &gpu_service_); | 35 // connector->ConnectToInterface("mojo:gpu", &gpu_service_); |
| 34 gpu_main_.Add(GetProxy(&gpu_service_)); | 36 gpu_main_.Add(GetProxy(&gpu_service_)); |
| 35 gpu_service_->Initialize( | 37 gpu_service_->Initialize( |
| 36 base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this))); | 38 base::Bind(&GpuServiceProxy::OnInitialized, base::Unretained(this))); |
| 37 } | 39 } |
| 38 | 40 |
| 39 GpuServiceProxy::~GpuServiceProxy() {} | 41 GpuServiceProxy::~GpuServiceProxy() {} |
| 40 | 42 |
| 41 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { | 43 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 std::unique_ptr<base::SharedMemory> GpuServiceProxy::AllocateSharedMemory( | 119 std::unique_ptr<base::SharedMemory> GpuServiceProxy::AllocateSharedMemory( |
| 118 size_t size) { | 120 size_t size) { |
| 119 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); | 121 std::unique_ptr<base::SharedMemory> shm(new base::SharedMemory()); |
| 120 if (!shm->CreateAnonymous(size)) | 122 if (!shm->CreateAnonymous(size)) |
| 121 shm.reset(); | 123 shm.reset(); |
| 122 return shm; | 124 return shm; |
| 123 } | 125 } |
| 124 | 126 |
| 125 } // namespace ws | 127 } // namespace ws |
| 126 } // namespace ui | 128 } // namespace ui |
| OLD | NEW |