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 MusGpuMemoryBufferManager; | |
30 | |
19 // The proxy implementation that relays requests from clients to the real | 31 // The proxy implementation that relays requests from clients to the real |
20 // service implementation in the GPU process over mojom.GpuServiceInternal. | 32 // service implementation in the GPU process over mojom.GpuServiceInternal. |
21 class GpuServiceProxy : public mojom::GpuService { | 33 class GpuServiceProxy : public mojom::GpuService, |
Fady Samuel
2016/08/26 16:27:59
Huge optional bikeshed color: GpuServiceProxy=>Gpu
sadrul
2016/08/26 17:23:50
GpuServiceInternal could be named Gpu. I don't hav
| |
34 public gpu::GpuChannelHostFactory { | |
22 public: | 35 public: |
23 GpuServiceProxy(); | 36 class Delegate { |
Fady Samuel
2016/08/26 16:27:59
Move this Delegate to a separate file?
sky
2016/08/26 16:46:30
+1
sadrul
2016/08/26 17:23:50
Done.
| |
37 public: | |
38 virtual void OnGpuChannelEstablished( | |
39 scoped_refptr<gpu::GpuChannelHost> gpu_channel) = 0; | |
40 }; | |
41 | |
42 explicit GpuServiceProxy(Delegate* delegate); | |
24 ~GpuServiceProxy() override; | 43 ~GpuServiceProxy() override; |
25 | 44 |
26 void Add(mojom::GpuServiceRequest request); | 45 void Add(mojom::GpuServiceRequest request); |
27 | 46 |
28 private: | 47 private: |
29 void OnInitialized(const gpu::GPUInfo& gpu_info); | 48 void OnInitialized(const gpu::GPUInfo& gpu_info); |
30 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, | 49 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, |
31 int32_t client_id, | 50 int32_t client_id, |
32 mojo::ScopedMessagePipeHandle channel_handle); | 51 mojo::ScopedMessagePipeHandle channel_handle); |
52 void OnInternalGpuChannelEstablished( | |
53 mojo::ScopedMessagePipeHandle channel_handle); | |
33 | 54 |
34 // mojom::GpuService overrides: | 55 // mojom::GpuService overrides: |
35 void EstablishGpuChannel( | 56 void EstablishGpuChannel( |
36 const EstablishGpuChannelCallback& callback) override; | 57 const EstablishGpuChannelCallback& callback) override; |
37 | |
38 void CreateGpuMemoryBuffer( | 58 void CreateGpuMemoryBuffer( |
39 mojom::GpuMemoryBufferIdPtr id, | 59 mojom::GpuMemoryBufferIdPtr id, |
40 const gfx::Size& size, | 60 const gfx::Size& size, |
41 gfx::BufferFormat format, | 61 gfx::BufferFormat format, |
42 gfx::BufferUsage usage, | 62 gfx::BufferUsage usage, |
43 uint64_t surface_id, | 63 uint64_t surface_id, |
44 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) | 64 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) |
45 override; | 65 override; |
46 | |
47 void DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, | 66 void DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, |
48 const gpu::SyncToken& sync_token) override; | 67 const gpu::SyncToken& sync_token) override; |
49 | 68 |
69 // gpu::GpuChannelHostFactory overrides: | |
70 bool IsMainThread() override; | |
71 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; | |
72 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( | |
73 size_t size) override; | |
74 | |
75 Delegate* delegate_; | |
50 int32_t next_client_id_; | 76 int32_t next_client_id_; |
77 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | |
51 mojom::GpuServiceInternalPtr gpu_service_; | 78 mojom::GpuServiceInternalPtr gpu_service_; |
52 mojo::BindingSet<GpuService> bindings_; | 79 mojo::BindingSet<mojom::GpuService> bindings_; |
53 gpu::GPUInfo gpu_info_; | 80 gpu::GPUInfo gpu_info_; |
81 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | |
82 base::WaitableEvent shutdown_event_; | |
83 std::unique_ptr<base::Thread> io_thread_; | |
84 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; | |
54 | 85 |
55 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); | 86 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); |
56 }; | 87 }; |
57 | 88 |
89 } // namespace ws | |
58 } // namespace ui | 90 } // namespace ui |
59 | 91 |
60 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ | 92 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ |
OLD | NEW |