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 #ifndef SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ | 5 #ifndef SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ |
6 #define SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ | 6 #define SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ |
7 | 7 |
| 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread.h" |
8 #include "gpu/config/gpu_info.h" | 11 #include "gpu/config/gpu_info.h" |
| 12 #include "gpu/ipc/client/gpu_channel_host.h" |
9 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" | 15 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" |
12 #include "services/ui/public/interfaces/gpu_memory_buffer.mojom.h" | 16 #include "services/ui/public/interfaces/gpu_memory_buffer.mojom.h" |
13 #include "services/ui/public/interfaces/gpu_service.mojom.h" | 17 #include "services/ui/public/interfaces/gpu_service.mojom.h" |
14 | 18 |
| 19 namespace gpu { |
| 20 class GpuChannelHost; |
| 21 } |
| 22 |
15 namespace ui { | 23 namespace ui { |
16 | 24 |
17 class GpuServiceInternal; | 25 class GpuServiceInternal; |
18 | 26 |
| 27 namespace ws { |
| 28 |
| 29 class GpuServiceProxyDelegate; |
| 30 class MusGpuMemoryBufferManager; |
| 31 |
19 // The proxy implementation that relays requests from clients to the real | 32 // The proxy implementation that relays requests from clients to the real |
20 // service implementation in the GPU process over mojom.GpuServiceInternal. | 33 // service implementation in the GPU process over mojom.GpuServiceInternal. |
21 class GpuServiceProxy : public mojom::GpuService { | 34 class GpuServiceProxy : public mojom::GpuService, |
| 35 public gpu::GpuChannelHostFactory { |
22 public: | 36 public: |
23 GpuServiceProxy(); | 37 explicit GpuServiceProxy(GpuServiceProxyDelegate* delegate); |
24 ~GpuServiceProxy() override; | 38 ~GpuServiceProxy() override; |
25 | 39 |
26 void Add(mojom::GpuServiceRequest request); | 40 void Add(mojom::GpuServiceRequest request); |
27 | 41 |
28 private: | 42 private: |
29 void OnInitialized(const gpu::GPUInfo& gpu_info); | 43 void OnInitialized(const gpu::GPUInfo& gpu_info); |
30 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, | 44 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, |
31 int32_t client_id, | 45 int32_t client_id, |
32 mojo::ScopedMessagePipeHandle channel_handle); | 46 mojo::ScopedMessagePipeHandle channel_handle); |
| 47 void OnInternalGpuChannelEstablished( |
| 48 mojo::ScopedMessagePipeHandle channel_handle); |
33 | 49 |
34 // mojom::GpuService overrides: | 50 // mojom::GpuService overrides: |
35 void EstablishGpuChannel( | 51 void EstablishGpuChannel( |
36 const EstablishGpuChannelCallback& callback) override; | 52 const EstablishGpuChannelCallback& callback) override; |
37 | |
38 void CreateGpuMemoryBuffer( | 53 void CreateGpuMemoryBuffer( |
39 mojom::GpuMemoryBufferIdPtr id, | 54 mojom::GpuMemoryBufferIdPtr id, |
40 const gfx::Size& size, | 55 const gfx::Size& size, |
41 gfx::BufferFormat format, | 56 gfx::BufferFormat format, |
42 gfx::BufferUsage usage, | 57 gfx::BufferUsage usage, |
43 uint64_t surface_id, | 58 uint64_t surface_id, |
44 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) | 59 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) |
45 override; | 60 override; |
46 | |
47 void DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, | 61 void DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, |
48 const gpu::SyncToken& sync_token) override; | 62 const gpu::SyncToken& sync_token) override; |
49 | 63 |
| 64 // gpu::GpuChannelHostFactory overrides: |
| 65 bool IsMainThread() override; |
| 66 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
| 67 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( |
| 68 size_t size) override; |
| 69 |
| 70 GpuServiceProxyDelegate* delegate_; |
50 int32_t next_client_id_; | 71 int32_t next_client_id_; |
| 72 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
51 mojom::GpuServiceInternalPtr gpu_service_; | 73 mojom::GpuServiceInternalPtr gpu_service_; |
52 mojo::BindingSet<GpuService> bindings_; | 74 mojo::BindingSet<mojom::GpuService> bindings_; |
53 gpu::GPUInfo gpu_info_; | 75 gpu::GPUInfo gpu_info_; |
| 76 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| 77 base::WaitableEvent shutdown_event_; |
| 78 std::unique_ptr<base::Thread> io_thread_; |
| 79 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
54 | 80 |
55 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); | 81 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); |
56 }; | 82 }; |
57 | 83 |
| 84 } // namespace ws |
58 } // namespace ui | 85 } // namespace ui |
59 | 86 |
60 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ | 87 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ |
OLD | NEW |