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