| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 } | 40 } |
| 41 | 41 |
| 42 namespace IPC { | 42 namespace IPC { |
| 43 struct ChannelHandle; | 43 struct ChannelHandle; |
| 44 } | 44 } |
| 45 | 45 |
| 46 struct GPUCreateCommandBufferConfig; | 46 struct GPUCreateCommandBufferConfig; |
| 47 | 47 |
| 48 namespace content { | 48 namespace content { |
| 49 class GpuChannel; | 49 class GpuChannel; |
| 50 class GpuMemoryBufferFactory; |
| 50 class GpuWatchdog; | 51 class GpuWatchdog; |
| 51 class MessageRouter; | 52 class MessageRouter; |
| 52 class SyncPointManager; | 53 class SyncPointManager; |
| 53 | 54 |
| 54 // A GpuChannelManager is a thread responsible for issuing rendering commands | 55 // A GpuChannelManager is a thread responsible for issuing rendering commands |
| 55 // managing the lifetimes of GPU channels and forwarding IPC requests from the | 56 // managing the lifetimes of GPU channels and forwarding IPC requests from the |
| 56 // browser process to them based on the corresponding renderer ID. | 57 // browser process to them based on the corresponding renderer ID. |
| 57 class GpuChannelManager : public IPC::Listener, | 58 class GpuChannelManager : public IPC::Listener, |
| 58 public IPC::Sender { | 59 public IPC::Sender { |
| 59 public: | 60 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 GpuEventsDispatcher* gpu_devtools_events_dispatcher() { | 92 GpuEventsDispatcher* gpu_devtools_events_dispatcher() { |
| 92 return &gpu_devtools_events_dispatcher_; | 93 return &gpu_devtools_events_dispatcher_; |
| 93 } | 94 } |
| 94 | 95 |
| 95 GpuChannel* LookupChannel(int32 client_id); | 96 GpuChannel* LookupChannel(int32 client_id); |
| 96 | 97 |
| 97 SyncPointManager* sync_point_manager() { return sync_point_manager_.get(); } | 98 SyncPointManager* sync_point_manager() { return sync_point_manager_.get(); } |
| 98 | 99 |
| 99 gfx::GLSurface* GetDefaultOffscreenSurface(); | 100 gfx::GLSurface* GetDefaultOffscreenSurface(); |
| 100 | 101 |
| 102 GpuMemoryBufferFactory* gpu_memory_buffer_factory() { |
| 103 return gpu_memory_buffer_factory_.get(); |
| 104 } |
| 105 |
| 101 private: | 106 private: |
| 102 struct ImageOperation { | 107 struct GpuMemoryBufferOperation { |
| 103 ImageOperation(int32 sync_point, base::Closure callback); | 108 GpuMemoryBufferOperation(int32 sync_point, base::Closure callback); |
| 104 ~ImageOperation(); | 109 ~GpuMemoryBufferOperation(); |
| 105 | 110 |
| 106 int32 sync_point; | 111 int32 sync_point; |
| 107 base::Closure callback; | 112 base::Closure callback; |
| 108 }; | 113 }; |
| 109 typedef base::ScopedPtrHashMap<int, GpuChannel> GpuChannelMap; | 114 typedef base::ScopedPtrHashMap<int, GpuChannel> GpuChannelMap; |
| 110 typedef std::deque<ImageOperation*> ImageOperationQueue; | 115 typedef std::deque<GpuMemoryBufferOperation*> GpuMemoryBufferOperationQueue; |
| 111 | 116 |
| 112 // Message handlers. | 117 // Message handlers. |
| 113 void OnEstablishChannel(int client_id, bool share_context); | 118 void OnEstablishChannel(int client_id, bool share_context); |
| 114 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); | 119 void OnCloseChannel(const IPC::ChannelHandle& channel_handle); |
| 115 void OnVisibilityChanged( | 120 void OnVisibilityChanged( |
| 116 int32 render_view_id, int32 client_id, bool visible); | 121 int32 render_view_id, int32 client_id, bool visible); |
| 117 void OnCreateViewCommandBuffer( | 122 void OnCreateViewCommandBuffer( |
| 118 const gfx::GLSurfaceHandle& window, | 123 const gfx::GLSurfaceHandle& window, |
| 119 int32 render_view_id, | 124 int32 render_view_id, |
| 120 int32 client_id, | 125 int32 client_id, |
| 121 const GPUCreateCommandBufferConfig& init_params, | 126 const GPUCreateCommandBufferConfig& init_params, |
| 122 int32 route_id); | 127 int32 route_id); |
| 123 void CreateImage( | |
| 124 gfx::PluginWindowHandle window, int32 client_id, int32 image_id); | |
| 125 void OnCreateImage( | |
| 126 gfx::PluginWindowHandle window, int32 client_id, int32 image_id); | |
| 127 void DeleteImage(int32 client_id, int32 image_id); | |
| 128 void OnDeleteImage(int32 client_id, int32 image_id, int32 sync_point); | |
| 129 void OnDeleteImageSyncPointRetired(ImageOperation*); | |
| 130 void OnLoadedShader(std::string shader); | 128 void OnLoadedShader(std::string shader); |
| 129 void CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, |
| 130 const gfx::Size& size, |
| 131 unsigned internalformat, |
| 132 unsigned usage); |
| 131 void OnCreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, | 133 void OnCreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, |
| 132 const gfx::Size& size, | 134 const gfx::Size& size, |
| 133 unsigned internalformat, | 135 unsigned internalformat, |
| 134 unsigned usage); | 136 unsigned usage); |
| 137 void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle); |
| 135 void OnDestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, | 138 void OnDestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, |
| 136 int32 sync_point); | 139 int32 sync_point); |
| 140 void OnDestroyGpuMemoryBufferSyncPointRetired( |
| 141 GpuMemoryBufferOperation* gpu_memory_buffer_operation); |
| 137 | 142 |
| 138 void OnLoseAllContexts(); | 143 void OnLoseAllContexts(); |
| 139 | 144 |
| 140 scoped_refptr<base::MessageLoopProxy> io_message_loop_; | 145 scoped_refptr<base::MessageLoopProxy> io_message_loop_; |
| 141 base::WaitableEvent* shutdown_event_; | 146 base::WaitableEvent* shutdown_event_; |
| 142 | 147 |
| 143 // Used to send and receive IPC messages from the browser process. | 148 // Used to send and receive IPC messages from the browser process. |
| 144 MessageRouter* const router_; | 149 MessageRouter* const router_; |
| 145 | 150 |
| 146 // These objects manage channels to individual renderer processes there is | 151 // These objects manage channels to individual renderer processes there is |
| 147 // one channel for each renderer process that has connected to this GPU | 152 // one channel for each renderer process that has connected to this GPU |
| 148 // process. | 153 // process. |
| 149 GpuChannelMap gpu_channels_; | 154 GpuChannelMap gpu_channels_; |
| 150 scoped_refptr<gfx::GLShareGroup> share_group_; | 155 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 151 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 156 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; |
| 152 GpuMemoryManager gpu_memory_manager_; | 157 GpuMemoryManager gpu_memory_manager_; |
| 153 GpuEventsDispatcher gpu_devtools_events_dispatcher_; | 158 GpuEventsDispatcher gpu_devtools_events_dispatcher_; |
| 154 GpuWatchdog* watchdog_; | 159 GpuWatchdog* watchdog_; |
| 155 scoped_refptr<SyncPointManager> sync_point_manager_; | 160 scoped_refptr<SyncPointManager> sync_point_manager_; |
| 156 scoped_ptr<gpu::gles2::ProgramCache> program_cache_; | 161 scoped_ptr<gpu::gles2::ProgramCache> program_cache_; |
| 157 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; | 162 scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; |
| 158 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; | 163 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; |
| 159 ImageOperationQueue image_operations_; | 164 GpuMemoryBufferOperationQueue gpu_memory_buffer_operations_; |
| 165 scoped_ptr<GpuMemoryBufferFactory> gpu_memory_buffer_factory_; |
| 160 | 166 |
| 161 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); | 167 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); |
| 162 }; | 168 }; |
| 163 | 169 |
| 164 } // namespace content | 170 } // namespace content |
| 165 | 171 |
| 166 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ | 172 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_MANAGER_H_ |
| OLD | NEW |