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_GPU_GPU_MAIN_H_ | 5 #ifndef SERVICES_UI_GPU_GPU_MAIN_H_ |
6 #define SERVICES_UI_GPU_GPU_MAIN_H_ | 6 #define SERVICES_UI_GPU_GPU_MAIN_H_ |
7 | 7 |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
| 9 #include "gpu/ipc/in_process_command_buffer.h" |
9 #include "gpu/ipc/service/gpu_init.h" | 10 #include "gpu/ipc/service/gpu_init.h" |
10 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" | 11 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" |
| 12 #include "services/ui/surfaces/display_compositor_factory.h" |
| 13 #include "services/ui/surfaces/display_compositor_factory_delegate.h" |
11 | 14 |
12 namespace gpu { | 15 namespace gpu { |
13 class GpuMemoryBufferFactory; | 16 class GpuMemoryBufferFactory; |
| 17 class ImageFactory; |
14 } | 18 } |
15 | 19 |
16 namespace ui { | 20 namespace ui { |
17 | 21 |
18 class GpuServiceInternal; | 22 class GpuServiceInternal; |
19 | 23 |
20 class GpuMain : public gpu::GpuSandboxHelper { | 24 class GpuMain : public gpu::GpuSandboxHelper, |
| 25 public DisplayCompositorFactoryDelegate { |
21 public: | 26 public: |
22 GpuMain(); | 27 GpuMain(); |
23 ~GpuMain() override; | 28 ~GpuMain() override; |
24 | 29 |
25 void OnStart(); | 30 void OnStart(); |
26 void Create(mojom::GpuServiceInternalRequest request); | 31 void Create(mojom::GpuServiceInternalRequest request); |
27 | 32 |
| 33 void Create(cc::mojom::DisplayCompositorFactoryRequest request); |
| 34 |
28 GpuServiceInternal* gpu_service() { return gpu_service_internal_.get(); } | 35 GpuServiceInternal* gpu_service() { return gpu_service_internal_.get(); } |
29 | 36 |
30 private: | 37 private: |
31 void InitOnGpuThread( | 38 void InitOnGpuThread( |
32 scoped_refptr<base::SingleThreadTaskRunner> io_runner, | 39 scoped_refptr<base::SingleThreadTaskRunner> io_runner, |
33 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner); | 40 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner); |
| 41 void InitOnCompositorThread( |
| 42 gpu::ImageFactory* image_factory, |
| 43 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner, |
| 44 cc::mojom::DisplayCompositorFactoryRequest request); |
34 | 45 |
35 void TearDownOnCompositorThread(); | 46 void TearDownOnCompositorThread(); |
36 void TearDownOnGpuThread(); | 47 void TearDownOnGpuThread(); |
37 void CreateOnGpuThread(mojom::GpuServiceInternalRequest request); | 48 void CreateOnGpuThread(mojom::GpuServiceInternalRequest request); |
38 | 49 |
39 // gpu::GpuSandboxHelper: | 50 // gpu::GpuSandboxHelper: |
40 void PreSandboxStartup() override; | 51 void PreSandboxStartup() override; |
41 bool EnsureSandboxInitialized( | 52 bool EnsureSandboxInitialized( |
42 gpu::GpuWatchdogThread* watchdog_thread) override; | 53 gpu::GpuWatchdogThread* watchdog_thread) override; |
43 | 54 |
| 55 // DisplayCompositorFactoryDelegate implementation: |
| 56 std::unique_ptr<gpu::GpuMemoryBufferManager> CreateGpuMemoryBufferManager() |
| 57 override; |
| 58 |
44 std::unique_ptr<gpu::GpuInit> gpu_init_; | 59 std::unique_ptr<gpu::GpuInit> gpu_init_; |
45 std::unique_ptr<GpuServiceInternal> gpu_service_internal_; | 60 std::unique_ptr<GpuServiceInternal> gpu_service_internal_; |
| 61 |
| 62 // The message-pipe used by the DisplayCompositor to request gpu memory |
| 63 // buffers. |
| 64 mojom::GpuServiceInternalPtr gpu_internal_; |
| 65 |
| 66 // The InCommandCommandBuffer::Service used by the display compositor. |
| 67 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_command_service_; |
| 68 |
| 69 std::unique_ptr<DisplayCompositorFactory> display_compositor_factory_; |
| 70 |
46 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; | 71 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; |
47 | 72 |
48 // The main thread for GpuService. | 73 // The main thread for GpuService. |
49 base::Thread gpu_thread_; | 74 base::Thread gpu_thread_; |
50 | 75 |
51 // The thread that handles IO events for GpuService. | 76 // The thread that handles IO events for GpuService. |
52 base::Thread io_thread_; | 77 base::Thread io_thread_; |
53 | 78 |
54 // The thread used for the display compositor. | 79 // The thread used for the display compositor. |
55 base::Thread compositor_thread_; | 80 base::Thread compositor_thread_; |
56 | 81 |
57 base::WeakPtrFactory<GpuMain> weak_factory_; | 82 base::WeakPtrFactory<GpuMain> weak_factory_; |
58 | 83 |
59 DISALLOW_COPY_AND_ASSIGN(GpuMain); | 84 DISALLOW_COPY_AND_ASSIGN(GpuMain); |
60 }; | 85 }; |
61 | 86 |
62 } // namespace ui | 87 } // namespace ui |
63 | 88 |
64 #endif // SERVICES_UI_GPU_GPU_MAIN_H_ | 89 #endif // SERVICES_UI_GPU_GPU_MAIN_H_ |
OLD | NEW |