Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Unified Diff: components/mus/gpu/gpu_service_mus.h

Issue 1976703003: Impl mus::mojom::GpuService to enable using Chrome IPC version gpu CmdBuf in mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/gpu/gpu_service_impl.cc ('k') | components/mus/gpu/gpu_service_mus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0dcd4efb4366f91a556b8a01b11ec0a1106a624a..7d6ffdc1c73742349d970b89daeec29506a4ca89 100644
--- a/components/mus/gpu/gpu_service_mus.h
+++ b/components/mus/gpu/gpu_service_mus.h
@@ -5,48 +5,80 @@
#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/callback.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;
-
- // 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,
+ typedef base::Callback<void(const IPC::ChannelHandle&)>
+ EstablishGpuChannelCallback;
+ void EstablishGpuChannel(int client_id,
+ uint64_t client_tracing_id,
+ bool preempts,
+ bool allow_view_command_buffers,
+ bool allow_real_time_streams,
+ const EstablishGpuChannelCallback& callback);
+ gfx::GpuMemoryBufferHandle CreateGpuMemoryBuffer(
+ gfx::GpuMemoryBufferId id,
const gfx::Size& 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,
+ gfx::BufferFormat format,
+ gfx::BufferUsage usage,
+ int client_id,
+ gpu::SurfaceHandle surface_handle);
+ gfx::GpuMemoryBufferHandle CreateGpuMemoryBufferFromeHandle(
+ gfx::GpuMemoryBufferHandle buffer_handle,
+ gfx::GpuMemoryBufferId id,
const gfx::Size& size,
- mojom::BufferFormat format,
- const mojom::GpuService::CreateGpuMemoryBufferFromHandleCallback&
- callback) override;
+ gfx::BufferFormat format,
+ int client_id);
+ void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
+ int client_id,
+ const gpu::SyncToken& sync_token);
+
+ scoped_refptr<gpu::GpuChannelHost> gpu_channel_local() const {
+ return gpu_channel_local_;
+ }
- void DestroyGpuMemoryBuffer(mojom::GpuMemoryBufferIdPtr id,
- const gpu::SyncToken& sync_token) override;
+ const gpu::GPUInfo& gpu_info() const { return gpu_info_; }
// GpuChannelManagerDelegate overrides:
void DidCreateOffscreenContext(const GURL& active_url) override;
@@ -56,7 +88,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 +98,62 @@ 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);
+
+ // 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_;
+
+ 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);
};
« no previous file with comments | « components/mus/gpu/gpu_service_impl.cc ('k') | components/mus/gpu/gpu_service_mus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698