| 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/power_monitor/power_monitor.h" | 8 #include "base/power_monitor/power_monitor.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "gpu/ipc/in_process_command_buffer.h" | 10 #include "gpu/ipc/in_process_command_buffer.h" |
| 11 #include "gpu/ipc/service/gpu_init.h" | 11 #include "gpu/ipc/service/gpu_init.h" |
| 12 #include "services/ui/gpu/interfaces/gpu_main.mojom.h" | 12 #include "services/ui/gpu/interfaces/gpu_main.mojom.h" |
| 13 #include "services/ui/gpu/interfaces/gpu_service.mojom.h" | 13 #include "services/ui/gpu/interfaces/gpu_service.mojom.h" |
| 14 #include "services/ui/surfaces/display_compositor.h" | |
| 15 #include "services/ui/surfaces/display_provider.h" | 14 #include "services/ui/surfaces/display_provider.h" |
| 15 #include "services/ui/surfaces/mojo_frame_sink_manager.h" |
| 16 | 16 |
| 17 namespace gpu { | 17 namespace gpu { |
| 18 class GpuMemoryBufferFactory; | 18 class GpuMemoryBufferFactory; |
| 19 class ImageFactory; | 19 class ImageFactory; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 | 23 |
| 24 class GpuService; | 24 class GpuService; |
| 25 | 25 |
| 26 class GpuMain : public gpu::GpuSandboxHelper, public mojom::GpuMain { | 26 class GpuMain : public gpu::GpuSandboxHelper, public mojom::GpuMain { |
| 27 public: | 27 public: |
| 28 explicit GpuMain(mojom::GpuMainRequest request); | 28 explicit GpuMain(mojom::GpuMainRequest request); |
| 29 ~GpuMain() override; | 29 ~GpuMain() override; |
| 30 | 30 |
| 31 // mojom::GpuMain implementation: | 31 // mojom::GpuMain implementation: |
| 32 void CreateGpuService(mojom::GpuServiceRequest request, | 32 void CreateGpuService(mojom::GpuServiceRequest request, |
| 33 mojom::GpuHostPtr gpu_host, | 33 mojom::GpuHostPtr gpu_host, |
| 34 const gpu::GpuPreferences& preferences, | 34 const gpu::GpuPreferences& preferences, |
| 35 mojo::ScopedSharedBufferHandle activity_flags) override; | 35 mojo::ScopedSharedBufferHandle activity_flags) override; |
| 36 void CreateDisplayCompositor( | 36 void CreateFrameSinkManager( |
| 37 cc::mojom::DisplayCompositorRequest request, | 37 cc::mojom::FrameSinkManagerRequest request, |
| 38 cc::mojom::DisplayCompositorClientPtr client) override; | 38 cc::mojom::FrameSinkManagerClientPtr client) override; |
| 39 | 39 |
| 40 void OnStart(); | 40 void OnStart(); |
| 41 | 41 |
| 42 GpuService* gpu_service() { return gpu_service_.get(); } | 42 GpuService* gpu_service() { return gpu_service_.get(); } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 void InitOnGpuThread( | 45 void InitOnGpuThread( |
| 46 scoped_refptr<base::SingleThreadTaskRunner> io_runner, | 46 scoped_refptr<base::SingleThreadTaskRunner> io_runner, |
| 47 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner); | 47 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner); |
| 48 | 48 |
| 49 void CreateDisplayCompositorInternal( | 49 void CreateFrameSinkManagerInternal( |
| 50 cc::mojom::DisplayCompositorRequest request, | 50 cc::mojom::FrameSinkManagerRequest request, |
| 51 cc::mojom::DisplayCompositorClientPtrInfo client_info); | 51 cc::mojom::FrameSinkManagerClientPtrInfo client_info); |
| 52 void CreateDisplayCompositorOnCompositorThread( | 52 void CreateFrameSinkManagerOnCompositorThread( |
| 53 gpu::ImageFactory* image_factory, | 53 gpu::ImageFactory* image_factory, |
| 54 mojom::GpuServicePtrInfo gpu_service_info, | 54 mojom::GpuServicePtrInfo gpu_service_info, |
| 55 cc::mojom::DisplayCompositorRequest request, | 55 cc::mojom::FrameSinkManagerRequest request, |
| 56 cc::mojom::DisplayCompositorClientPtrInfo client_info); | 56 cc::mojom::FrameSinkManagerClientPtrInfo client_info); |
| 57 void CreateGpuServiceOnGpuThread(mojom::GpuServiceRequest request, | 57 void CreateGpuServiceOnGpuThread(mojom::GpuServiceRequest request, |
| 58 mojom::GpuHostPtrInfo gpu_host_info, | 58 mojom::GpuHostPtrInfo gpu_host_info, |
| 59 const gpu::GpuPreferences& preferences, | 59 const gpu::GpuPreferences& preferences, |
| 60 gpu::GpuProcessActivityFlags activity_flags); | 60 gpu::GpuProcessActivityFlags activity_flags); |
| 61 void BindGpuInternalOnGpuThread(mojom::GpuServiceRequest request); | 61 void BindGpuInternalOnGpuThread(mojom::GpuServiceRequest request); |
| 62 | 62 |
| 63 void TearDownOnCompositorThread(); | 63 void TearDownOnCompositorThread(); |
| 64 void TearDownOnGpuThread(); | 64 void TearDownOnGpuThread(); |
| 65 | 65 |
| 66 // gpu::GpuSandboxHelper: | 66 // gpu::GpuSandboxHelper: |
| 67 void PreSandboxStartup() override; | 67 void PreSandboxStartup() override; |
| 68 bool EnsureSandboxInitialized( | 68 bool EnsureSandboxInitialized( |
| 69 gpu::GpuWatchdogThread* watchdog_thread) override; | 69 gpu::GpuWatchdogThread* watchdog_thread) override; |
| 70 | 70 |
| 71 std::unique_ptr<gpu::GpuInit> gpu_init_; | 71 std::unique_ptr<gpu::GpuInit> gpu_init_; |
| 72 std::unique_ptr<GpuService> gpu_service_; | 72 std::unique_ptr<GpuService> gpu_service_; |
| 73 | 73 |
| 74 // The message-pipe used by the DisplayCompositor to request gpu memory | 74 // The message-pipe used by the FrameSinkManager to request gpu memory |
| 75 // buffers. | 75 // buffers. |
| 76 mojom::GpuServicePtr gpu_internal_; | 76 mojom::GpuServicePtr gpu_internal_; |
| 77 | 77 |
| 78 // The InCommandCommandBuffer::Service used by the display compositor. | 78 // The InCommandCommandBuffer::Service used by the frame sink manager. |
| 79 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_command_service_; | 79 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_command_service_; |
| 80 | 80 |
| 81 // If the gpu service is not yet ready then we stash pending MessagePipes in | 81 // If the gpu service is not yet ready then we stash pending MessagePipes in |
| 82 // these member variables. | 82 // these member variables. |
| 83 cc::mojom::DisplayCompositorRequest pending_display_compositor_request_; | 83 cc::mojom::FrameSinkManagerRequest pending_frame_sink_manager_request_; |
| 84 cc::mojom::DisplayCompositorClientPtrInfo | 84 cc::mojom::FrameSinkManagerClientPtrInfo |
| 85 pending_display_compositor_client_info_; | 85 pending_frame_sink_manager_client_info_; |
| 86 | 86 |
| 87 std::unique_ptr<DisplayCompositor> display_compositor_; | 87 // Provides mojo interfaces for creating and managing FrameSinks. |
| 88 std::unique_ptr<MojoFrameSinkManager> frame_sink_manager_; |
| 88 std::unique_ptr<DisplayProvider> display_provider_; | 89 std::unique_ptr<DisplayProvider> display_provider_; |
| 89 | 90 |
| 90 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; | 91 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; |
| 91 | 92 |
| 92 // The main thread for Gpu. | 93 // The main thread for Gpu. |
| 93 base::Thread gpu_thread_; | 94 base::Thread gpu_thread_; |
| 94 scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_task_runner_; | 95 scoped_refptr<base::SingleThreadTaskRunner> gpu_thread_task_runner_; |
| 95 | 96 |
| 96 // The thread that handles IO events for Gpu. | 97 // The thread that handles IO events for Gpu. |
| 97 base::Thread io_thread_; | 98 base::Thread io_thread_; |
| 98 | 99 |
| 99 // The display compositor gets its own thread in mus-gpu. The gpu service, | 100 // The frame sink manager gets its own thread in mus-gpu. The gpu service, |
| 100 // where GL commands are processed resides on its own thread. Various | 101 // where GL commands are processed resides on its own thread. Various |
| 101 // components of the display compositor such as Display, ResourceProvider, | 102 // components of the frame sink manager such as Display, ResourceProvider, |
| 102 // and GLRenderer block on sync tokens from other command buffers. Thus, | 103 // and GLRenderer block on sync tokens from other command buffers. Thus, |
| 103 // the gpu service must live on a separate thread. | 104 // the gpu service must live on a separate thread. |
| 104 base::Thread compositor_thread_; | 105 base::Thread compositor_thread_; |
| 105 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner_; | 106 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread_task_runner_; |
| 106 | 107 |
| 107 base::PowerMonitor power_monitor_; | 108 base::PowerMonitor power_monitor_; |
| 108 mojo::Binding<mojom::GpuMain> binding_; | 109 mojo::Binding<mojom::GpuMain> binding_; |
| 109 | 110 |
| 110 DISALLOW_COPY_AND_ASSIGN(GpuMain); | 111 DISALLOW_COPY_AND_ASSIGN(GpuMain); |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 } // namespace ui | 114 } // namespace ui |
| 114 | 115 |
| 115 #endif // SERVICES_UI_GPU_GPU_MAIN_H_ | 116 #endif // SERVICES_UI_GPU_GPU_MAIN_H_ |
| OLD | NEW |