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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 namespace ui { | 24 namespace ui { |
25 | 25 |
26 class GpuServiceInternal; | 26 class GpuServiceInternal; |
27 | 27 |
28 namespace ws { | 28 namespace ws { |
29 | 29 |
30 class GpuServiceProxyDelegate; | 30 class GpuServiceProxyDelegate; |
31 class MusGpuMemoryBufferManager; | 31 class MusGpuMemoryBufferManager; |
32 | 32 |
33 // The proxy implementation that relays requests from clients to the real | 33 // Sets up connection from clients to the real service implementation in the GPU |
34 // service implementation in the GPU process over mojom.GpuServiceInternal. | 34 // process. |
35 class GpuServiceProxy : public mojom::GpuService, | 35 class GpuServiceProxy : public gpu::GpuChannelHostFactory { |
36 public gpu::GpuChannelHostFactory { | |
37 public: | 36 public: |
38 explicit GpuServiceProxy(GpuServiceProxyDelegate* delegate); | 37 explicit GpuServiceProxy(GpuServiceProxyDelegate* delegate); |
39 ~GpuServiceProxy() override; | 38 ~GpuServiceProxy() override; |
40 | 39 |
41 void Add(mojom::GpuServiceRequest request); | 40 void Add(mojom::GpuServiceRequest request); |
42 | 41 |
43 private: | 42 private: |
44 void OnInitialized(const gpu::GPUInfo& gpu_info); | 43 void OnInitialized(const gpu::GPUInfo& gpu_info); |
45 void OnGpuChannelEstablished(const EstablishGpuChannelCallback& callback, | |
46 int32_t client_id, | |
47 mojo::ScopedMessagePipeHandle channel_handle); | |
48 void OnInternalGpuChannelEstablished( | 44 void OnInternalGpuChannelEstablished( |
49 mojo::ScopedMessagePipeHandle channel_handle); | 45 mojo::ScopedMessagePipeHandle channel_handle); |
50 | 46 |
51 // mojom::GpuService overrides: | |
52 void EstablishGpuChannel( | |
53 const EstablishGpuChannelCallback& callback) override; | |
54 void CreateGpuMemoryBuffer( | |
55 gfx::GpuMemoryBufferId id, | |
56 const gfx::Size& size, | |
57 gfx::BufferFormat format, | |
58 gfx::BufferUsage usage, | |
59 const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) | |
60 override; | |
61 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | |
62 const gpu::SyncToken& sync_token) override; | |
63 | |
64 // gpu::GpuChannelHostFactory overrides: | 47 // gpu::GpuChannelHostFactory overrides: |
65 bool IsMainThread() override; | 48 bool IsMainThread() override; |
66 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; | 49 scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
67 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( | 50 std::unique_ptr<base::SharedMemory> AllocateSharedMemory( |
68 size_t size) override; | 51 size_t size) override; |
69 | 52 |
70 GpuServiceProxyDelegate* delegate_; | 53 GpuServiceProxyDelegate* delegate_; |
71 int32_t next_client_id_; | 54 int32_t next_client_id_; |
72 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 55 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
73 mojom::GpuServiceInternalPtr gpu_service_; | 56 mojom::GpuServiceInternalPtr gpu_service_; |
74 mojo::BindingSet<mojom::GpuService> bindings_; | |
75 gpu::GPUInfo gpu_info_; | 57 gpu::GPUInfo gpu_info_; |
76 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 58 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
77 base::WaitableEvent shutdown_event_; | 59 base::WaitableEvent shutdown_event_; |
78 std::unique_ptr<base::Thread> io_thread_; | 60 std::unique_ptr<base::Thread> io_thread_; |
79 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 61 std::unique_ptr<MusGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
80 GpuMain gpu_main_; | 62 GpuMain gpu_main_; |
81 | 63 |
82 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); | 64 DISALLOW_COPY_AND_ASSIGN(GpuServiceProxy); |
83 }; | 65 }; |
84 | 66 |
85 } // namespace ws | 67 } // namespace ws |
86 } // namespace ui | 68 } // namespace ui |
87 | 69 |
88 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ | 70 #endif // SERVICES_UI_WS_GPU_SERVICE_PROXY_H_ |
OLD | NEW |