| 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/service/gpu_preferences.h" | 13 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 14 #include "gpu/config/gpu_info.h" | 14 #include "gpu/config/gpu_info.h" |
| 15 #include "gpu/ipc/common/surface_handle.h" | 15 #include "gpu/ipc/common/surface_handle.h" |
| 16 #include "gpu/ipc/service/gpu_channel.h" | 16 #include "gpu/ipc/service/gpu_channel.h" |
| 17 #include "gpu/ipc/service/gpu_channel_manager.h" | 17 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 18 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | 18 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| 19 #include "gpu/ipc/service/gpu_config.h" | 19 #include "gpu/ipc/service/gpu_config.h" |
| 20 #include "gpu/ipc/service/x_util.h" | 20 #include "gpu/ipc/service/x_util.h" |
| 21 #include "mojo/public/cpp/bindings/binding.h" | 21 #include "mojo/public/cpp/bindings/binding.h" |
| 22 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" | 22 #include "services/ui/gpu/interfaces/gpu_service_internal.mojom.h" |
| 23 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
| 24 | 24 |
| 25 namespace base { | |
| 26 template <typename T> | |
| 27 struct DefaultSingletonTraits; | |
| 28 } | |
| 29 | |
| 30 namespace gpu { | 25 namespace gpu { |
| 31 class GpuChannelHost; | 26 class GpuChannelHost; |
| 32 class GpuMemoryBufferFactory; | 27 class GpuMemoryBufferFactory; |
| 33 class GpuWatchdogThread; | 28 class GpuWatchdogThread; |
| 34 class SyncPointManager; | 29 class SyncPointManager; |
| 35 } | 30 } |
| 36 | 31 |
| 37 namespace media { | 32 namespace media { |
| 38 class MediaService; | 33 class MediaService; |
| 39 } | 34 } |
| 40 | 35 |
| 41 namespace ui { | 36 namespace ui { |
| 42 | 37 |
| 38 class GpuMain; |
| 39 |
| 43 // This runs in the GPU process, and communicates with the gpu host (which is | 40 // This runs in the GPU process, and communicates with the gpu host (which is |
| 44 // the window server) over the mojom APIs. This is responsible for setting up | 41 // the window server) over the mojom APIs. This is responsible for setting up |
| 45 // the connection to clients, allocating/free'ing gpu memory etc. | 42 // the connection to clients, allocating/free'ing gpu memory etc. |
| 46 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate, | 43 class GpuServiceInternal : public gpu::GpuChannelManagerDelegate, |
| 47 public mojom::GpuServiceInternal, | 44 public mojom::GpuServiceInternal, |
| 48 public base::NonThreadSafe { | 45 public base::NonThreadSafe { |
| 49 public: | 46 public: |
| 47 ~GpuServiceInternal() override; |
| 48 |
| 50 void Add(mojom::GpuServiceInternalRequest request); | 49 void Add(mojom::GpuServiceInternalRequest request); |
| 51 | 50 |
| 52 // TODO(sad): This should not be a singleton. | |
| 53 static GpuServiceInternal* GetInstance(); | |
| 54 | |
| 55 gpu::GpuChannelManager* gpu_channel_manager() const { | 51 gpu::GpuChannelManager* gpu_channel_manager() const { |
| 56 return gpu_channel_manager_.get(); | 52 return gpu_channel_manager_.get(); |
| 57 } | 53 } |
| 58 | 54 |
| 59 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory() const { | 55 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory() const { |
| 60 return gpu_memory_buffer_factory_.get(); | 56 return gpu_memory_buffer_factory_; |
| 61 } | 57 } |
| 62 | 58 |
| 63 // TODO(sad): These should be mojom API. | 59 // TODO(sad): These should be mojom API. |
| 64 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( | 60 gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer( |
| 65 gfx::GpuMemoryBufferId id, | 61 gfx::GpuMemoryBufferId id, |
| 66 const gfx::Size& size, | 62 const gfx::Size& size, |
| 67 gfx::BufferFormat format, | 63 gfx::BufferFormat format, |
| 68 gfx::BufferUsage usage, | 64 gfx::BufferUsage usage, |
| 69 int client_id, | 65 int client_id, |
| 70 gpu::SurfaceHandle surface_handle); | 66 gpu::SurfaceHandle surface_handle); |
| 71 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 67 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 72 int client_id, | 68 int client_id, |
| 73 const gpu::SyncToken& sync_token); | 69 const gpu::SyncToken& sync_token); |
| 74 | 70 |
| 75 private: | 71 private: |
| 76 friend struct base::DefaultSingletonTraits<GpuServiceInternal>; | 72 friend class GpuMain; |
| 77 | 73 |
| 78 GpuServiceInternal(); | 74 GpuServiceInternal(const gpu::GPUInfo& gpu_info, |
| 79 ~GpuServiceInternal() override; | 75 gpu::GpuWatchdogThread* watchdog, |
| 76 gpu::GpuMemoryBufferFactory* memory_buffer_factory); |
| 80 | 77 |
| 81 void EstablishGpuChannelInternal(int32_t client_id, | 78 void EstablishGpuChannelInternal(int32_t client_id, |
| 82 uint64_t client_tracing_id, | 79 uint64_t client_tracing_id, |
| 83 bool preempts, | 80 bool preempts, |
| 84 bool allow_view_command_buffers, | 81 bool allow_view_command_buffers, |
| 85 bool allow_real_time_streams, | 82 bool allow_real_time_streams, |
| 86 const EstablishGpuChannelCallback& callback); | 83 const EstablishGpuChannelCallback& callback); |
| 87 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( | 84 gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( |
| 88 gfx::GpuMemoryBufferHandle buffer_handle, | 85 gfx::GpuMemoryBufferHandle buffer_handle, |
| 89 gfx::GpuMemoryBufferId id, | 86 gfx::GpuMemoryBufferId id, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 127 |
| 131 // An event that will be signalled when we shutdown. | 128 // An event that will be signalled when we shutdown. |
| 132 base::WaitableEvent shutdown_event_; | 129 base::WaitableEvent shutdown_event_; |
| 133 | 130 |
| 134 // The main thread for GpuService. | 131 // The main thread for GpuService. |
| 135 base::Thread gpu_thread_; | 132 base::Thread gpu_thread_; |
| 136 | 133 |
| 137 // The thread that handles IO events for GpuService. | 134 // The thread that handles IO events for GpuService. |
| 138 base::Thread io_thread_; | 135 base::Thread io_thread_; |
| 139 | 136 |
| 140 scoped_refptr<gpu::GpuWatchdogThread> watchdog_thread_; | 137 gpu::GpuWatchdogThread* watchdog_thread_; |
| 141 | 138 |
| 142 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; | 139 std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; |
| 143 | 140 |
| 144 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; | 141 std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; |
| 145 | 142 |
| 146 std::unique_ptr<media::MediaService> media_service_; | 143 std::unique_ptr<media::MediaService> media_service_; |
| 147 | 144 |
| 148 std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; | 145 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory_; |
| 149 | 146 |
| 150 gpu::GpuPreferences gpu_preferences_; | 147 gpu::GpuPreferences gpu_preferences_; |
| 151 | 148 |
| 152 // Information about the GPU, such as device and vendor ID. | 149 // Information about the GPU, such as device and vendor ID. |
| 153 gpu::GPUInfo gpu_info_; | 150 gpu::GPUInfo gpu_info_; |
| 154 | 151 |
| 155 mojo::Binding<mojom::GpuServiceInternal> binding_; | 152 mojo::Binding<mojom::GpuServiceInternal> binding_; |
| 156 | 153 |
| 157 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal); | 154 DISALLOW_COPY_AND_ASSIGN(GpuServiceInternal); |
| 158 }; | 155 }; |
| 159 | 156 |
| 160 } // namespace ui | 157 } // namespace ui |
| 161 | 158 |
| 162 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ | 159 #endif // SERVICES_UI_GPU_GPU_SERVICE_INTERNAL_H_ |
| OLD | NEW |