diff options
Diffstat (limited to 'chromium/content/browser/gpu/browser_gpu_channel_host_factory.h')
-rw-r--r-- | chromium/content/browser/gpu/browser_gpu_channel_host_factory.h | 99 |
1 files changed, 46 insertions, 53 deletions
diff --git a/chromium/content/browser/gpu/browser_gpu_channel_host_factory.h b/chromium/content/browser/gpu/browser_gpu_channel_host_factory.h index 8b461e4aec5..dc85f67ff45 100644 --- a/chromium/content/browser/gpu/browser_gpu_channel_host_factory.h +++ b/chromium/content/browser/gpu/browser_gpu_channel_host_factory.h @@ -9,15 +9,15 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/process/process.h" -#include "base/synchronization/waitable_event.h" #include "content/common/gpu/client/gpu_channel_host.h" -#include "ipc/ipc_channel_handle.h" +#include "content/common/gpu/client/gpu_memory_buffer_factory_host.h" +#include "ipc/message_filter.h" namespace content { class CONTENT_EXPORT BrowserGpuChannelHostFactory - : public GpuChannelHostFactory { + : public GpuChannelHostFactory, + public GpuMemoryBufferFactoryHost { public: static void Initialize(bool establish_gpu_channel); static void Terminate(); @@ -27,12 +27,12 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory virtual bool IsMainThread() OVERRIDE; virtual base::MessageLoop* GetMainLoop() OVERRIDE; virtual scoped_refptr<base::MessageLoopProxy> GetIOLoopProxy() OVERRIDE; - virtual base::WaitableEvent* GetShutDownEvent() OVERRIDE; virtual scoped_ptr<base::SharedMemory> AllocateSharedMemory( size_t size) OVERRIDE; - virtual int32 CreateViewCommandBuffer( + virtual CreateCommandBufferResult CreateViewCommandBuffer( int32 surface_id, - const GPUCreateCommandBufferConfig& init_params) OVERRIDE; + const GPUCreateCommandBufferConfig& init_params, + int32 route_id) OVERRIDE; virtual void CreateImage( gfx::PluginWindowHandle window, int32 image_id, @@ -41,7 +41,18 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( size_t width, size_t height, - unsigned internalformat) OVERRIDE; + unsigned internalformat, + unsigned usage) OVERRIDE; + + // GpuMemoryBufferFactoryHost implementation. + virtual void CreateGpuMemoryBuffer( + const gfx::GpuMemoryBufferHandle& handle, + const gfx::Size& size, + unsigned internalformat, + unsigned usage, + const CreateGpuMemoryBufferCallback& callback) OVERRIDE; + virtual void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, + int32 sync_point) OVERRIDE; // Specify a task runner and callback to be used for a set of messages. The // callback will be set up on the current GpuProcessHost, identified by @@ -63,47 +74,10 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory static bool CanUseForTesting(); private: - struct CreateRequest { - CreateRequest(); - ~CreateRequest(); - base::WaitableEvent event; - int gpu_host_id; - int32 route_id; - }; - - class EstablishRequest : public base::RefCountedThreadSafe<EstablishRequest> { - public: - explicit EstablishRequest(CauseForGpuLaunch cause, - int gpu_client_id, - int gpu_host_id); - void Wait(); - void Cancel(); - - int gpu_host_id() { return gpu_host_id_; } - IPC::ChannelHandle& channel_handle() { return channel_handle_; } - gpu::GPUInfo gpu_info() { return gpu_info_; } - - private: - friend class base::RefCountedThreadSafe<EstablishRequest>; - ~EstablishRequest(); - void EstablishOnIO(); - void OnEstablishedOnIO(const IPC::ChannelHandle& channel_handle, - const gpu::GPUInfo& gpu_info); - void FinishOnIO(); - void FinishOnMain(); - - base::WaitableEvent event_; - CauseForGpuLaunch cause_for_gpu_launch_; - const int gpu_client_id_; - int gpu_host_id_; - bool reused_gpu_process_; - IPC::ChannelHandle channel_handle_; - gpu::GPUInfo gpu_info_; - bool finished_; - scoped_refptr<base::MessageLoopProxy> main_loop_; - }; - - explicit BrowserGpuChannelHostFactory(bool establish_gpu_channel); + struct CreateRequest; + class EstablishRequest; + + BrowserGpuChannelHostFactory(); virtual ~BrowserGpuChannelHostFactory(); void GpuChannelEstablished(); @@ -111,7 +85,8 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory CreateRequest* request, int32 surface_id, const GPUCreateCommandBufferConfig& init_params); - static void CommandBufferCreatedOnIO(CreateRequest* request, int32 route_id); + static void CommandBufferCreatedOnIO(CreateRequest* request, + CreateCommandBufferResult result); void CreateImageOnIO( gfx::PluginWindowHandle window, int32 image_id, @@ -121,9 +96,22 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory static void OnImageCreated( const CreateImageCallback& callback, const gfx::Size size); void DeleteImageOnIO(int32 image_id, int32 sync_point); - static void AddFilterOnIO( - int gpu_host_id, - scoped_refptr<IPC::ChannelProxy::MessageFilter> filter); + static void AddFilterOnIO(int gpu_host_id, + scoped_refptr<IPC::MessageFilter> filter); + + void CreateGpuMemoryBufferOnIO(const gfx::GpuMemoryBufferHandle& handle, + const gfx::Size& size, + unsigned internalformat, + unsigned usage, + uint32 request_id); + void GpuMemoryBufferCreatedOnIO( + uint32 request_id, + const gfx::GpuMemoryBufferHandle& handle); + void OnGpuMemoryBufferCreated( + uint32 request_id, + const gfx::GpuMemoryBufferHandle& handle); + void DestroyGpuMemoryBufferOnIO(const gfx::GpuMemoryBufferHandle& handle, + int32 sync_point); const int gpu_client_id_; scoped_ptr<base::WaitableEvent> shutdown_event_; @@ -132,6 +120,11 @@ class CONTENT_EXPORT BrowserGpuChannelHostFactory scoped_refptr<EstablishRequest> pending_request_; std::vector<base::Closure> established_callbacks_; + uint32 next_create_gpu_memory_buffer_request_id_; + typedef std::map<uint32, CreateGpuMemoryBufferCallback> + CreateGpuMemoryBufferCallbackMap; + CreateGpuMemoryBufferCallbackMap create_gpu_memory_buffer_requests_; + static BrowserGpuChannelHostFactory* instance_; DISALLOW_COPY_AND_ASSIGN(BrowserGpuChannelHostFactory); |