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 "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 12 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
13 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
14 #include "mojo/public/cpp/system/buffer.h" | 14 #include "mojo/public/cpp/system/buffer.h" |
15 #include "mojo/public/cpp/system/platform_handle.h" | 15 #include "mojo/public/cpp/system/platform_handle.h" |
16 #include "services/service_manager/public/cpp/connection.h" | 16 #include "services/service_manager/public/cpp/connection.h" |
17 #include "services/ui/common/mus_gpu_memory_buffer_manager.h" | 17 #include "services/ui/common/server_gpu_memory_buffer_manager.h" |
18 #include "services/ui/ws/gpu_service_proxy_delegate.h" | 18 #include "services/ui/ws/gpu_service_proxy_delegate.h" |
19 #include "ui/gfx/buffer_format_util.h" | 19 #include "ui/gfx/buffer_format_util.h" |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 namespace ws { | 22 namespace ws { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // The client Id 1 is reserved for the display compositor. | 26 // The client Id 1 is reserved for the display compositor. |
27 const int32_t kInternalGpuChannelClientId = 2; | 27 const int32_t kInternalGpuChannelClientId = 2; |
28 | 28 |
29 // The implementation that relays requests from clients to the real | 29 // The implementation that relays requests from clients to the real |
30 // service implementation in the GPU process over mojom.GpuServiceInternal. | 30 // service implementation in the GPU process over mojom.GpuServiceInternal. |
31 class GpuServiceImpl : public mojom::GpuService { | 31 class GpuServiceImpl : public mojom::GpuService { |
32 public: | 32 public: |
33 GpuServiceImpl(int client_id, | 33 GpuServiceImpl(int client_id, |
34 gpu::GPUInfo* gpu_info, | 34 gpu::GPUInfo* gpu_info, |
35 MusGpuMemoryBufferManager* gpu_memory_buffer_manager, | 35 ServerGpuMemoryBufferManager* gpu_memory_buffer_manager, |
36 mojom::GpuServiceInternal* gpu_service_internal) | 36 mojom::GpuServiceInternal* gpu_service_internal) |
37 : client_id_(client_id), | 37 : client_id_(client_id), |
38 gpu_info_(gpu_info), | 38 gpu_info_(gpu_info), |
39 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 39 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
40 gpu_service_internal_(gpu_service_internal) { | 40 gpu_service_internal_(gpu_service_internal) { |
41 DCHECK(gpu_memory_buffer_manager_); | 41 DCHECK(gpu_memory_buffer_manager_); |
42 DCHECK(gpu_service_internal_); | 42 DCHECK(gpu_service_internal_); |
43 } | 43 } |
44 ~GpuServiceImpl() override { | 44 ~GpuServiceImpl() override { |
45 gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_); | 45 gpu_memory_buffer_manager_->DestroyAllGpuMemoryBufferForClient(client_id_); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 const gpu::SyncToken& sync_token) override { | 80 const gpu::SyncToken& sync_token) override { |
81 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_, | 81 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_, |
82 sync_token); | 82 sync_token); |
83 } | 83 } |
84 | 84 |
85 const int client_id_; | 85 const int client_id_; |
86 | 86 |
87 // The objects these pointers refer to are owned by the GpuServiceProxy | 87 // The objects these pointers refer to are owned by the GpuServiceProxy |
88 // object. | 88 // object. |
89 const gpu::GPUInfo* gpu_info_; | 89 const gpu::GPUInfo* gpu_info_; |
90 MusGpuMemoryBufferManager* gpu_memory_buffer_manager_; | 90 ServerGpuMemoryBufferManager* gpu_memory_buffer_manager_; |
91 mojom::GpuServiceInternal* gpu_service_internal_; | 91 mojom::GpuServiceInternal* gpu_service_internal_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(GpuServiceImpl); | 93 DISALLOW_COPY_AND_ASSIGN(GpuServiceImpl); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace | 96 } // namespace |
97 | 97 |
98 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate) | 98 GpuServiceProxy::GpuServiceProxy(GpuServiceProxyDelegate* delegate) |
99 : delegate_(delegate), | 99 : delegate_(delegate), |
100 next_client_id_(kInternalGpuChannelClientId + 1), | 100 next_client_id_(kInternalGpuChannelClientId + 1), |
101 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 101 main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
102 gpu_host_binding_(this) { | 102 gpu_host_binding_(this) { |
103 gpu_main_impl_ = base::MakeUnique<GpuMain>(GetProxy(&gpu_main_)); | 103 gpu_main_impl_ = base::MakeUnique<GpuMain>(GetProxy(&gpu_main_)); |
104 gpu_main_impl_->OnStart(); | 104 gpu_main_impl_->OnStart(); |
105 // TODO(sad): Once GPU process is split, this would look like: | 105 // TODO(sad): Once GPU process is split, this would look like: |
106 // connector->ConnectToInterface("gpu", &gpu_main_); | 106 // connector->ConnectToInterface("gpu", &gpu_main_); |
107 gpu_main_->CreateGpuService(GetProxy(&gpu_service_), | 107 gpu_main_->CreateGpuService(GetProxy(&gpu_service_), |
108 gpu_host_binding_.CreateInterfacePtrAndBind()); | 108 gpu_host_binding_.CreateInterfacePtrAndBind()); |
109 gpu_memory_buffer_manager_ = base::MakeUnique<MusGpuMemoryBufferManager>( | 109 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>( |
110 gpu_service_.get(), next_client_id_++); | 110 gpu_service_.get(), next_client_id_++); |
111 } | 111 } |
112 | 112 |
113 GpuServiceProxy::~GpuServiceProxy() { | 113 GpuServiceProxy::~GpuServiceProxy() { |
114 } | 114 } |
115 | 115 |
116 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { | 116 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { |
117 mojo::MakeStrongBinding( | 117 mojo::MakeStrongBinding( |
118 base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_, | 118 base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_, |
119 gpu_memory_buffer_manager_.get(), | 119 gpu_memory_buffer_manager_.get(), |
(...skipping 21 matching lines...) Expand all Loading... |
141 void GpuServiceProxy::DidLoseContext(bool offscreen, | 141 void GpuServiceProxy::DidLoseContext(bool offscreen, |
142 gpu::error::ContextLostReason reason, | 142 gpu::error::ContextLostReason reason, |
143 const GURL& active_url) {} | 143 const GURL& active_url) {} |
144 | 144 |
145 void GpuServiceProxy::StoreShaderToDisk(int32_t client_id, | 145 void GpuServiceProxy::StoreShaderToDisk(int32_t client_id, |
146 const std::string& key, | 146 const std::string& key, |
147 const std::string& shader) {} | 147 const std::string& shader) {} |
148 | 148 |
149 } // namespace ws | 149 } // namespace ws |
150 } // namespace ui | 150 } // namespace ui |
OLD | NEW |