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" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "gpu/config/gpu_info.h" | 11 #include "gpu/config/gpu_info.h" |
12 #include "gpu/ipc/client/gpu_channel_host.h" | 12 #include "gpu/ipc/client/gpu_channel_host.h" |
13 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
14 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
15 #include "services/ui/gpu/gpu_main.h" | 15 #include "services/ui/gpu/gpu_main.h" |
16 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" | 16 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" |
17 #include "services/ui/public/interfaces/gpu_service.mojom.h" | 17 #include "services/ui/public/interfaces/gpu_service.mojom.h" |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 | 20 |
21 class GpuServiceInternal; | |
22 class MusGpuMemoryBufferManager; | 21 class MusGpuMemoryBufferManager; |
23 | 22 |
24 namespace ws { | 23 namespace ws { |
25 | 24 |
26 class GpuServiceProxyDelegate; | 25 class GpuServiceProxyDelegate; |
27 | 26 |
28 // The proxy implementation that relays requests from clients to the real | 27 // Sets up connection from clients to the real service implementation in the GPU |
29 // service implementation in the GPU process over mojom.GpuServiceInternal. | 28 // process. |
30 class GpuServiceProxy : public mojom::GpuService { | 29 class GpuServiceProxy { |
31 public: | 30 public: |
32 explicit GpuServiceProxy(GpuServiceProxyDelegate* delegate); | 31 explicit GpuServiceProxy(GpuServiceProxyDelegate* delegate); |
33 ~GpuServiceProxy() override; | 32 ~GpuServiceProxy(); |
34 | 33 |
35 void Add(mojom::GpuServiceRequest request); | 34 void Add(mojom::GpuServiceRequest request); |
36 | 35 |
37 // Requests a cc::mojom::DisplayCompositor interface from mus-gpu. | 36 // Requests a cc::mojom::DisplayCompositor interface from mus-gpu. |
38 void CreateDisplayCompositor(cc::mojom::DisplayCompositorRequest request, | 37 void CreateDisplayCompositor(cc::mojom::DisplayCompositorRequest request, |
39 cc::mojom::DisplayCompositorClientPtr client); | 38 cc::mojom::DisplayCompositorClientPtr client); |
40 | 39 |
41 private: | 40 private: |
42 void OnInitialized(const gpu::GPUInfo& gpu_info); | 41 void OnInitialized(const gpu::GPUInfo& gpu_info); |
43 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, | |
44 int32_t client_id, | |
45 mojo::ScopedMessagePipeHandle channel_handle); | |
46 | |
47 // mojom::GpuService overrides: | |
48 void EstablishGpuChannel( | |
49 const EstablishGpuChannelCallback& callback) override; | |
50 void CreateGpuMemoryBuffer( | |
51 gfx::GpuMemoryBufferId id, | |
52 const gfx::Size& size, | |
53 gfx::BufferFormat format, | |
54 gfx::BufferUsage usage, | |
55 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) | |
56 override; | |
57 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | |
58 const gpu::SyncToken& sync_token) override; | |
59 | 42 |
60 GpuServiceProxyDelegate* const delegate_; | 43 GpuServiceProxyDelegate* const delegate_; |
61 int32_t next_client_id_; | 44 int32_t next_client_id_; |
62 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 45 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
63 mojom::GpuServiceInternalPtr gpu_service_; | 46 mojom::GpuServiceInternalPtr gpu_service_; |
64 mojo::BindingSet<mojom::GpuService> bindings_; | |
65 gpu::GPUInfo gpu_info_; | 47 gpu::GPUInfo gpu_info_; |
66 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 48 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
67 | 49 |
68 mojom::GpuMainPtr gpu_main_; | 50 mojom::GpuMainPtr gpu_main_; |
69 | 51 |
70 // TODO(fsamuel): GpuServiceProxy should not be holding onto |gpu_main_impl| | 52 // TODO(fsamuel): GpuServiceProxy should not be holding onto |gpu_main_impl| |
71 // because that will live in another process soon. | 53 // because that will live in another process soon. |
72 std::unique_ptr<GpuMain> gpu_main_impl_; | 54 std::unique_ptr<GpuMain> gpu_main_impl_; |
73 | 55 |
74 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); | 56 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); |
75 }; | 57 }; |
76 | 58 |
77 } // namespace ws | 59 } // namespace ws |
78 } // namespace ui | 60 } // namespace ui |
79 | 61 |
80 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ | 62 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ |
OLD | NEW |