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" |
(...skipping 10 matching lines...) Expand all Loading... |
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::Gpu { |
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 ServerGpuMemoryBufferManager* 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_); |
46 } | 46 } |
47 | 47 |
48 private: | 48 private: |
49 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, | 49 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, |
50 mojo::ScopedMessagePipeHandle channel_handle) { | 50 mojo::ScopedMessagePipeHandle channel_handle) { |
51 callback.Run(client_id_, std::move(channel_handle), *gpu_info_); | 51 callback.Run(client_id_, std::move(channel_handle), *gpu_info_); |
52 } | 52 } |
53 | 53 |
54 // mojom::GpuService overrides: | 54 // mojom::Gpu overrides: |
55 void EstablishGpuChannel( | 55 void EstablishGpuChannel( |
56 const EstablishGpuChannelCallback& callback) override { | 56 const EstablishGpuChannelCallback& callback) override { |
57 // TODO(sad): crbug.com/617415 figure out how to generate a meaningful | 57 // TODO(sad): crbug.com/617415 figure out how to generate a meaningful |
58 // tracing id. | 58 // tracing id. |
59 const uint64_t client_tracing_id = 0; | 59 const uint64_t client_tracing_id = 0; |
60 constexpr bool is_gpu_host = false; | 60 constexpr bool is_gpu_host = false; |
61 gpu_service_internal_->EstablishGpuChannel( | 61 gpu_service_internal_->EstablishGpuChannel( |
62 client_id_, client_tracing_id, is_gpu_host, | 62 client_id_, client_tracing_id, is_gpu_host, |
63 base::Bind(&GpuServiceImpl::OnGpuChannelEstablished, | 63 base::Bind(&GpuServiceImpl::OnGpuChannelEstablished, |
64 base::Unretained(this), callback)); | 64 base::Unretained(this), callback)); |
65 } | 65 } |
66 | 66 |
67 void CreateGpuMemoryBuffer( | 67 void CreateGpuMemoryBuffer( |
68 gfx::GpuMemoryBufferId id, | 68 gfx::GpuMemoryBufferId id, |
69 const gfx::Size& size, | 69 const gfx::Size& size, |
70 gfx::BufferFormat format, | 70 gfx::BufferFormat format, |
71 gfx::BufferUsage usage, | 71 gfx::BufferUsage usage, |
72 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) | 72 const mojom::Gpu::CreateGpuMemoryBufferCallback& callback) override { |
73 override { | |
74 auto handle = gpu_memory_buffer_manager_->CreateGpuMemoryBufferHandle( | 73 auto handle = gpu_memory_buffer_manager_->CreateGpuMemoryBufferHandle( |
75 id, client_id_, size, format, usage, gpu::kNullSurfaceHandle); | 74 id, client_id_, size, format, usage, gpu::kNullSurfaceHandle); |
76 callback.Run(handle); | 75 callback.Run(handle); |
77 } | 76 } |
78 | 77 |
79 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 78 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
80 const gpu::SyncToken& sync_token) override { | 79 const gpu::SyncToken& sync_token) override { |
81 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_, | 80 gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id, client_id_, |
82 sync_token); | 81 sync_token); |
83 } | 82 } |
(...skipping 22 matching lines...) Expand all Loading... |
106 // connector->ConnectToInterface("gpu", &gpu_main_); | 105 // connector->ConnectToInterface("gpu", &gpu_main_); |
107 gpu_main_->CreateGpuService(GetProxy(&gpu_service_), | 106 gpu_main_->CreateGpuService(GetProxy(&gpu_service_), |
108 gpu_host_binding_.CreateInterfacePtrAndBind()); | 107 gpu_host_binding_.CreateInterfacePtrAndBind()); |
109 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>( | 108 gpu_memory_buffer_manager_ = base::MakeUnique<ServerGpuMemoryBufferManager>( |
110 gpu_service_.get(), next_client_id_++); | 109 gpu_service_.get(), next_client_id_++); |
111 } | 110 } |
112 | 111 |
113 GpuServiceProxy::~GpuServiceProxy() { | 112 GpuServiceProxy::~GpuServiceProxy() { |
114 } | 113 } |
115 | 114 |
116 void GpuServiceProxy::Add(mojom::GpuServiceRequest request) { | 115 void GpuServiceProxy::Add(mojom::GpuRequest request) { |
117 mojo::MakeStrongBinding( | 116 mojo::MakeStrongBinding( |
118 base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_, | 117 base::MakeUnique<GpuServiceImpl>(next_client_id_++, &gpu_info_, |
119 gpu_memory_buffer_manager_.get(), | 118 gpu_memory_buffer_manager_.get(), |
120 gpu_service_.get()), | 119 gpu_service_.get()), |
121 std::move(request)); | 120 std::move(request)); |
122 } | 121 } |
123 | 122 |
124 void GpuServiceProxy::CreateDisplayCompositor( | 123 void GpuServiceProxy::CreateDisplayCompositor( |
125 cc::mojom::DisplayCompositorRequest request, | 124 cc::mojom::DisplayCompositorRequest request, |
126 cc::mojom::DisplayCompositorClientPtr client) { | 125 cc::mojom::DisplayCompositorClientPtr client) { |
(...skipping 14 matching lines...) Expand all Loading... |
141 void GpuServiceProxy::DidLoseContext(bool offscreen, | 140 void GpuServiceProxy::DidLoseContext(bool offscreen, |
142 gpu::error::ContextLostReason reason, | 141 gpu::error::ContextLostReason reason, |
143 const GURL& active_url) {} | 142 const GURL& active_url) {} |
144 | 143 |
145 void GpuServiceProxy::StoreShaderToDisk(int32_t client_id, | 144 void GpuServiceProxy::StoreShaderToDisk(int32_t client_id, |
146 const std::string& key, | 145 const std::string& key, |
147 const std::string& shader) {} | 146 const std::string& shader) {} |
148 | 147 |
149 } // namespace ws | 148 } // namespace ws |
150 } // namespace ui | 149 } // namespace ui |
OLD | NEW |