Chromium Code Reviews| Index: components/mus/gpu/gpu_service_mus.h |
| diff --git a/components/mus/gpu/gpu_service_mus.h b/components/mus/gpu/gpu_service_mus.h |
| index a8d5696ea3c4065ef1a5596e3a45acf106f7e319..bbfa0cc20d498440691da430b6071f0bc6fbca69 100644 |
| --- a/components/mus/gpu/gpu_service_mus.h |
| +++ b/components/mus/gpu/gpu_service_mus.h |
| @@ -5,48 +5,75 @@ |
| #ifndef COMPONENTS_MUS_GPU_GPU_SERVICE_MUS_H_ |
| #define COMPONENTS_MUS_GPU_GPU_SERVICE_MUS_H_ |
| -#include "components/mus/public/interfaces/gpu_memory_buffer.mojom.h" |
| -#include "components/mus/public/interfaces/gpu_service.mojom.h" |
| +#include "base/synchronization/waitable_event.h" |
| +#include "base/threading/thread.h" |
| +#include "build/build_config.h" |
| +#include "gpu/command_buffer/service/gpu_preferences.h" |
| +#include "gpu/config/gpu_info.h" |
| +#include "gpu/ipc/client/gpu_channel_host.h" |
| #include "gpu/ipc/common/surface_handle.h" |
| +#include "gpu/ipc/service/gpu_channel.h" |
| +#include "gpu/ipc/service/gpu_channel_manager.h" |
| #include "gpu/ipc/service/gpu_channel_manager_delegate.h" |
| +#include "gpu/ipc/service/gpu_config.h" |
| +#include "gpu/ipc/service/x_util.h" |
| +#include "ui/gfx/native_widget_types.h" |
| + |
| +namespace base { |
| +template <typename T> |
| +struct DefaultSingletonTraits; |
| +} |
| + |
| +namespace IPC { |
| +struct ChannelHandle; |
| +} |
| + |
| +namespace gpu { |
| +class GpuChannelHost; |
| +class GpuMemoryBufferFactory; |
| +class SyncPointManager; |
| +} |
| + |
| +namespace media { |
| +class MediaService; |
| +} |
| namespace mus { |
| +class GpuMemoryBufferManagerMusLocal; |
| + |
| // TODO(fsamuel): GpuServiceMus is intended to be the Gpu thread within Mus. |
| // Similar to GpuChildThread, it is a GpuChannelManagerDelegate and will have a |
| // GpuChannelManager. |
| -class GpuServiceMus : public mojom::GpuService, |
| - public gpu::GpuChannelManagerDelegate { |
| +class GpuServiceMus : public gpu::GpuChannelManagerDelegate, |
| + public gpu::GpuChannelHostFactory { |
| public: |
| - GpuServiceMus(); |
| - ~GpuServiceMus() override; |
| + IPC::ChannelHandle EstablishGpuChannel(int client_id, |
| + uint64_t client_tracing_id, |
| + bool preempts, |
| + bool allow_view_command_buffers, |
| + bool allow_real_time_streams); |
| + gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| + const gfx::Size& size, |
| + gfx::BufferFormat format, |
| + gfx::BufferUsage usage, |
| + int client_id, |
| + int32_t surface_handle); |
| + gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle( |
| + gfx::GpuMemoryBufferHandle buffer_handle, |
| + gfx::GpuMemoryBufferId id, |
| + const gfx::Size& size, |
| + gfx::BufferFormat format, |
| + int client_id); |
| + void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| + int client_id, |
| + const gpu::SyncToken& sync_token); |
| - // mojom::GpuService overrides: |
| - void EstablishGpuChannel( |
| - bool prempts, |
| - bool allow_view_command_buffers, |
| - bool allow_real_time_streams, |
| - const mojom::GpuService::EstablishGpuChannelCallback& callback) override; |
| - |
| - void CreateGpuMemoryBuffer( |
| - mojom::GpuMemoryBufferIdPtr id, |
| - mojo::SizePtr size, |
| - mojom::BufferFormat format, |
| - mojom::BufferUsage usage, |
| - uint64_t surface_id, |
| - const mojom::GpuService::CreateGpuMemoryBufferCallback& callback) |
| - override; |
| - |
| - void CreateGpuMemoryBufferFromHandle( |
| - mojom::GpuMemoryBufferHandlePtr buffer_handle, |
| - mojom::GpuMemoryBufferIdPtr id, |
| - mojo::SizePtr size, |
| - mojom::BufferFormat format, |
| - const mojom::GpuService::CreateGpuMemoryBufferFromHandleCallback& |
| - callback) override; |
| - |
| - void DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id, |
| - const gpu::SyncToken& sync_token) override; |
| + scoped_refptr<gpu::GpuChannelHost> gpu_channel_local() const { |
| + return gpu_channel_local_; |
| + } |
| + |
| + const gpu::GPUInfo& gpu_info() const { return gpu_info_; } |
| // GpuChannelManagerDelegate overrides: |
| void DidCreateOffscreenContext(const GURL& active_url) override; |
| @@ -56,7 +83,7 @@ class GpuServiceMus : public mojom::GpuService, |
| gpu::error::ContextLostReason reason, |
| const GURL& active_url) override; |
| void GpuMemoryUmaStats(const gpu::GPUMemoryUmaStats& params) override; |
| - void StoreShaderToDisk(int32_t client_id, |
| + void StoreShaderToDisk(int client_id, |
| const std::string& key, |
| const std::string& shader) override; |
| #if defined(OS_WIN) |
| @@ -66,7 +93,66 @@ class GpuServiceMus : public mojom::GpuService, |
| #endif |
| void SetActiveURL(const GURL& url) override; |
| + // GpuChannelHostFactory overrides: |
| + bool IsMainThread() override; |
| + scoped_refptr<base::SingleThreadTaskRunner> GetIOThreadTaskRunner() override; |
| + std::unique_ptr<base::SharedMemory> AllocateSharedMemory( |
| + size_t size) override; |
| + |
| + static GpuServiceMus* GetInstance(); |
| + |
| private: |
| + friend struct base::DefaultSingletonTraits<GpuServiceMus>; |
| + |
| + GpuServiceMus(); |
| + ~GpuServiceMus() override; |
| + |
| + void Initialize(); |
| + void InitializeOnGpuThread(IPC::ChannelHandle* channel_handle, |
| + base::WaitableEvent* event); |
| + void EstablishGpuChannelOnGpuThread(int client_id, |
| + uint64_t client_tracing_id, |
| + bool preempts, |
| + bool allow_view_command_buffers, |
| + bool allow_real_time_streams, |
| + IPC::ChannelHandle* channel_handle, |
| + base::WaitableEvent* event); |
| + |
| + // The main thread message loop. |
| + base::MessageLoop* main_message_loop_; |
| + |
| + // An event that will be signalled when we shutdown. |
| + base::WaitableEvent shutdown_event_; |
| + |
| + // The main thread for GpuService. |
| + base::Thread gpu_thread_; |
| + |
| + // The thread that handles IO events for GpuService. |
| + base::Thread io_thread_; |
| + |
| + // The thread that handles IO events for GpuChannelHost local. |
|
piman
2016/05/24 22:46:54
Does this have to be different from io_thread_?
I
Peng
2016/05/25 19:42:55
Done.
|
| + base::Thread io_thread_local_; |
| + |
| + std::unique_ptr<gpu::SyncPointManager> owned_sync_point_manager_; |
| + |
| + std::unique_ptr<gpu::GpuChannelManager> gpu_channel_manager_; |
| + |
| + std::unique_ptr<media::MediaService> media_service_; |
| + |
| + std::unique_ptr<gpu::GpuMemoryBufferFactory> gpu_memory_buffer_factory_; |
| + |
| + // A GPU memory buffer manager used locally. |
| + std::unique_ptr<GpuMemoryBufferManagerMusLocal> |
| + gpu_memory_buffer_manager_mus_local_; |
| + |
| + // A GPU channel used locally. |
| + scoped_refptr<gpu::GpuChannelHost> gpu_channel_local_; |
| + |
| + gpu::GpuPreferences gpu_preferences_; |
| + |
| + // Information about the GPU, such as device and vendor ID. |
| + gpu::GPUInfo gpu_info_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(GpuServiceMus); |
| }; |