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_SERVICE_INTERNAL_H_ | 5 #ifndef SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ |
6 #define SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ | 6 #define SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/non_thread_safe.h" | 10 #include "base/threading/non_thread_safe.h" |
11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
13 #include "gpu/command_buffer/service/gpu_preferences.h" | 14 #include "gpu/command_buffer/service/gpu_preferences.h" |
14 #include "gpu/config/gpu_info.h" | 15 #include "gpu/config/gpu_info.h" |
15 #include "gpu/ipc/common/surface_handle.h" | 16 #include "gpu/ipc/common/surface_handle.h" |
16 #include "gpu/ipc/service/gpu_channel.h" | 17 #include "gpu/ipc/service/gpu_channel.h" |
17 #include "gpu/ipc/service/gpu_channel_manager.h" | 18 #include "gpu/ipc/service/gpu_channel_manager.h" |
18 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 19 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
19 #include "gpu/ipc/service/gpu_config.h" | 20 #include "gpu/ipc/service/gpu_config.h" |
20 #include "gpu/ipc/service/x_util.h" | 21 #include "gpu/ipc/service/x_util.h" |
21 #include "mojo/public/cpp/bindings/binding.h" | 22 #include "mojo/public/cpp/bindings/binding.h" |
22 #include "mojo/public/cpp/bindings/binding_set.h" | 23 #include "mojo/public/cpp/bindings/binding_set.h" |
23 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" | 24 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" |
24 #include "services/ui/surfaces/display_compositor.h" | |
25 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
26 | 26 |
27 namespace gpu { | 27 namespace gpu { |
28 class GpuChannelHost; | 28 class GpuChannelHost; |
29 class GpuMemoryBufferFactory; | 29 class GpuMemoryBufferFactory; |
30 class GpuWatchdogThread; | 30 class GpuWatchdogThread; |
31 class SyncPointManager; | 31 class SyncPointManager; |
32 } | 32 } |
33 | 33 |
34 namespace media { | 34 namespace media { |
35 class MediaGpuChannelManager; | 35 class MediaGpuChannelManager; |
36 } | 36 } |
37 | 37 |
38 namespace ui { | 38 namespace ui { |
39 | 39 |
40 class GpuMain; | 40 class GpuMain; |
41 | 41 |
42 // This runs in the GPU process, and communicates with the gpu host (which is | 42 // This runs in the GPU process, and communicates with the gpu host (which is |
43 // the window server) over the mojom APIs. This is responsible for setting up | 43 // the window server) over the mojom APIs. This is responsible for setting up |
44 // the connection to clients, allocating/free'ing gpu memory etc. | 44 // the connection to clients, allocating/free'ing gpu memory etc. |
45 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate, | 45 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate, |
46 public mojom::GpuServiceInternal, | 46 public mojom::GpuServiceInternal, |
47 public base::NonThreadSafe { | 47 public base::NonThreadSafe { |
48 public: | 48 public: |
| 49 GpuServiceInternal(const gpu::GPUInfo& gpu_info, |
| 50 std::unique_ptr<gpu::GpuWatchdogThread> watchdog, |
| 51 gpu::GpuMemoryBufferFactory* memory_buffer_factory, |
| 52 scoped_refptr<base::SingleThreadTaskRunner> io_runner); |
| 53 |
49 ~GpuServiceInternal() override; | 54 ~GpuServiceInternal() override; |
50 | 55 |
51 void Add(mojom::GpuServiceInternalRequest request); | 56 void Bind(mojom::GpuServiceInternalRequest request); |
52 | |
53 void DestroyDisplayCompositor(); | |
54 | 57 |
55 private: | 58 private: |
56 friend class GpuMain; | 59 friend class GpuMain; |
57 | 60 |
58 GpuServiceInternal( | |
59 const gpu::GPUInfo& gpu_info, | |
60 std::unique_ptr<gpu::GpuWatchdogThread> watchdog, | |
61 gpu::GpuMemoryBufferFactory* memory_buffer_factory, | |
62 scoped_refptr<base::SingleThreadTaskRunner> io_runner, | |
63 scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner); | |
64 | |
65 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( | 61 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( |
66 gfx::GpuMemoryBufferHandle buffer_handle, | 62 gfx::GpuMemoryBufferHandle buffer_handle, |
67 gfx::GpuMemoryBufferId id, | 63 gfx::GpuMemoryBufferId id, |
68 const gfx::Size& size, | 64 const gfx::Size& size, |
69 gfx::BufferFormat format, | 65 gfx::BufferFormat format, |
70 int client_id); | 66 int client_id); |
71 | 67 |
| 68 gpu::SyncPointManager* sync_point_manager() { |
| 69 return owned_sync_point_manager_.get(); |
| 70 } |
| 71 |
| 72 gpu::gles2::MailboxManager* mailbox_manager() { |
| 73 return gpu_channel_manager_->mailbox_manager(); |
| 74 } |
| 75 |
| 76 gl::GLShareGroup* share_group() { |
| 77 return gpu_channel_manager_->share_group(); |
| 78 } |
| 79 |
72 // gpu::GpuChannelManagerDelegate: | 80 // gpu::GpuChannelManagerDelegate: |
73 void DidCreateOffscreenContext(const GURL& active_url) override; | 81 void DidCreateOffscreenContext(const GURL& active_url) override; |
74 void DidDestroyChannel(int client_id) override; | 82 void DidDestroyChannel(int client_id) override; |
75 void DidDestroyOffscreenContext(const GURL& active_url) override; | 83 void DidDestroyOffscreenContext(const GURL& active_url) override; |
76 void DidLoseContext(bool offscreen, | 84 void DidLoseContext(bool offscreen, |
77 gpu::error::ContextLostReason reason, | 85 gpu::error::ContextLostReason reason, |
78 const GURL& active_url) override; | 86 const GURL& active_url) override; |
79 void StoreShaderToDisk(int client_id, | 87 void StoreShaderToDisk(int client_id, |
80 const std::string& key, | 88 const std::string& key, |
81 const std::string& shader) override; | 89 const std::string& shader) override; |
(...skipping 15 matching lines...) Expand all Loading... |
97 gfx::GpuMemoryBufferId id, | 105 gfx::GpuMemoryBufferId id, |
98 const gfx::Size& size, | 106 const gfx::Size& size, |
99 gfx::BufferFormat format, | 107 gfx::BufferFormat format, |
100 gfx::BufferUsage usage, | 108 gfx::BufferUsage usage, |
101 int client_id, | 109 int client_id, |
102 gpu::SurfaceHandle surface_handle, | 110 gpu::SurfaceHandle surface_handle, |
103 const CreateGpuMemoryBufferCallback& callback) override; | 111 const CreateGpuMemoryBufferCallback& callback) override; |
104 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 112 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
105 int client_id, | 113 int client_id, |
106 const gpu::SyncToken& sync_token) override; | 114 const gpu::SyncToken& sync_token) override; |
107 void CreateDisplayCompositor( | |
108 cc::mojom::DisplayCompositorRequest request, | |
109 cc::mojom::DisplayCompositorClientPtr client) override; | |
110 | 115 |
111 void CreateDisplayCompositorOnCompositorThread( | 116 scoped_refptr<base::SingleThreadTaskRunner> gpu_runner_; |
112 mojom::GpuServiceInternalPtrInfo gpu_service_info, | |
113 cc::mojom::DisplayCompositorRequest request, | |
114 cc::mojom::DisplayCompositorClientPtrInfo client_info); | |
115 | |
116 void DestroyDisplayCompositorOnCompositorThread(); | |
117 | |
118 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; | 117 scoped_refptr<base::SingleThreadTaskRunner> io_runner_; |
119 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner_; | |
120 | 118 |
121 // An event that will be signalled when we shutdown. | 119 // An event that will be signalled when we shutdown. |
122 base::WaitableEvent shutdown_event_; | 120 base::WaitableEvent shutdown_event_; |
123 | 121 |
124 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_; | 122 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread_; |
125 | 123 |
126 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_; | 124 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_; |
127 | 125 |
128 gpu::GpuPreferences gpu_preferences_; | 126 gpu::GpuPreferences gpu_preferences_; |
129 | 127 |
130 // Information about the GPU, such as device and vendor ID. | 128 // Information about the GPU, such as device and vendor ID. |
131 gpu::GPUInfo gpu_info_; | 129 gpu::GPUInfo gpu_info_; |
132 | 130 |
133 std::unique_ptr<ui::DisplayCompositor> display_compositor_; | |
134 | |
135 // The message-pipe used by the DisplayCompositor to request gpu memory | |
136 // buffers. | |
137 mojom::GpuServiceInternalPtr gpu_internal_; | |
138 | |
139 scoped_refptr<gpu::InProcessCommandBuffer::Service> gpu_command_service_; | |
140 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; | 131 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; |
141 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; | 132 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; |
142 std::unique_ptr<media::MediaGpuChannelManager> media_gpu_channel_manager_; | 133 std::unique_ptr<media::MediaGpuChannelManager> media_gpu_channel_manager_; |
143 mojo::BindingSet<mojom::GpuServiceInternal> bindings_; | 134 mojo::BindingSet<mojom::GpuServiceInternal> bindings_; |
144 | 135 |
145 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal); | 136 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal); |
146 }; | 137 }; |
147 | 138 |
148 } // namespace ui | 139 } // namespace ui |
149 | 140 |
150 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ | 141 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ |
OLD | NEW |