| 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_H_ | 5 #ifndef CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 namespace content { | 45 namespace content { |
| 46 class DevToolsGpuAgent; | 46 class DevToolsGpuAgent; |
| 47 class GpuChannelManager; | 47 class GpuChannelManager; |
| 48 class GpuChannelMessageFilter; | 48 class GpuChannelMessageFilter; |
| 49 class GpuWatchdog; | 49 class GpuWatchdog; |
| 50 | 50 |
| 51 // Encapsulates an IPC channel between the GPU process and one renderer | 51 // Encapsulates an IPC channel between the GPU process and one renderer |
| 52 // process. On the renderer side there's a corresponding GpuChannelHost. | 52 // process. On the renderer side there's a corresponding GpuChannelHost. |
| 53 class GpuChannel : public IPC::Listener, | 53 class GpuChannel : public IPC::Listener, public IPC::Sender { |
| 54 public IPC::Sender, | |
| 55 public base::RefCountedThreadSafe<GpuChannel> { | |
| 56 public: | 54 public: |
| 57 // Takes ownership of the renderer process handle. | 55 // Takes ownership of the renderer process handle. |
| 58 GpuChannel(GpuChannelManager* gpu_channel_manager, | 56 GpuChannel(GpuChannelManager* gpu_channel_manager, |
| 59 GpuWatchdog* watchdog, | 57 GpuWatchdog* watchdog, |
| 60 gfx::GLShareGroup* share_group, | 58 gfx::GLShareGroup* share_group, |
| 61 gpu::gles2::MailboxManager* mailbox_manager, | 59 gpu::gles2::MailboxManager* mailbox_manager, |
| 62 int client_id, | 60 int client_id, |
| 63 bool software); | 61 bool software); |
| 62 virtual ~GpuChannel(); |
| 64 | 63 |
| 65 void Init(base::MessageLoopProxy* io_message_loop, | 64 void Init(base::MessageLoopProxy* io_message_loop, |
| 66 base::WaitableEvent* shutdown_event); | 65 base::WaitableEvent* shutdown_event); |
| 67 | 66 |
| 68 // Get the GpuChannelManager that owns this channel. | 67 // Get the GpuChannelManager that owns this channel. |
| 69 GpuChannelManager* gpu_channel_manager() const { | 68 GpuChannelManager* gpu_channel_manager() const { |
| 70 return gpu_channel_manager_; | 69 return gpu_channel_manager_; |
| 71 } | 70 } |
| 72 | 71 |
| 73 // Returns the name of the associated IPC channel. | 72 // Returns the name of the associated IPC channel. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 gfx::Size* size); | 119 gfx::Size* size); |
| 121 void DeleteImage(int32 image_id); | 120 void DeleteImage(int32 image_id); |
| 122 | 121 |
| 123 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | 122 gfx::GLShareGroup* share_group() const { return share_group_.get(); } |
| 124 | 123 |
| 125 GpuCommandBufferStub* LookupCommandBuffer(int32 route_id); | 124 GpuCommandBufferStub* LookupCommandBuffer(int32 route_id); |
| 126 | 125 |
| 127 void LoseAllContexts(); | 126 void LoseAllContexts(); |
| 128 void MarkAllContextsLost(); | 127 void MarkAllContextsLost(); |
| 129 | 128 |
| 130 // Destroy channel and all contained contexts. | |
| 131 void DestroySoon(); | |
| 132 | |
| 133 // Called to add a listener for a particular message routing ID. | 129 // Called to add a listener for a particular message routing ID. |
| 134 // Returns true if succeeded. | 130 // Returns true if succeeded. |
| 135 bool AddRoute(int32 route_id, IPC::Listener* listener); | 131 bool AddRoute(int32 route_id, IPC::Listener* listener); |
| 136 | 132 |
| 137 // Called to remove a listener for a particular message routing ID. | 133 // Called to remove a listener for a particular message routing ID. |
| 138 void RemoveRoute(int32 route_id); | 134 void RemoveRoute(int32 route_id); |
| 139 | 135 |
| 140 gpu::PreemptionFlag* GetPreemptionFlag(); | 136 gpu::PreemptionFlag* GetPreemptionFlag(); |
| 141 | 137 |
| 142 bool handle_messages_scheduled() const { return handle_messages_scheduled_; } | 138 bool handle_messages_scheduled() const { return handle_messages_scheduled_; } |
| 143 uint64 messages_processed() const { return messages_processed_; } | 139 uint64 messages_processed() const { return messages_processed_; } |
| 144 | 140 |
| 145 // If |preemption_flag->IsSet()|, any stub on this channel | 141 // If |preemption_flag->IsSet()|, any stub on this channel |
| 146 // should stop issuing GL commands. Setting this to NULL stops deferral. | 142 // should stop issuing GL commands. Setting this to NULL stops deferral. |
| 147 void SetPreemptByFlag( | 143 void SetPreemptByFlag( |
| 148 scoped_refptr<gpu::PreemptionFlag> preemption_flag); | 144 scoped_refptr<gpu::PreemptionFlag> preemption_flag); |
| 149 | 145 |
| 150 void CacheShader(const std::string& key, const std::string& shader); | 146 void CacheShader(const std::string& key, const std::string& shader); |
| 151 | 147 |
| 152 void AddFilter(IPC::MessageFilter* filter); | 148 void AddFilter(IPC::MessageFilter* filter); |
| 153 void RemoveFilter(IPC::MessageFilter* filter); | 149 void RemoveFilter(IPC::MessageFilter* filter); |
| 154 | 150 |
| 155 uint64 GetMemoryUsage(); | 151 uint64 GetMemoryUsage(); |
| 156 | 152 |
| 157 protected: | |
| 158 virtual ~GpuChannel(); | |
| 159 | |
| 160 private: | 153 private: |
| 161 friend class base::RefCountedThreadSafe<GpuChannel>; | |
| 162 friend class GpuChannelMessageFilter; | 154 friend class GpuChannelMessageFilter; |
| 163 | 155 |
| 164 void OnDestroy(); | 156 void OnDestroy(); |
| 165 | 157 |
| 166 bool OnControlMessageReceived(const IPC::Message& msg); | 158 bool OnControlMessageReceived(const IPC::Message& msg); |
| 167 | 159 |
| 168 void HandleMessage(); | 160 void HandleMessage(); |
| 169 | 161 |
| 170 // Message handlers. | 162 // Message handlers. |
| 171 void OnCreateOffscreenCommandBuffer( | 163 void OnCreateOffscreenCommandBuffer( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 scoped_ptr<DevToolsGpuAgent> devtools_gpu_agent_; | 224 scoped_ptr<DevToolsGpuAgent> devtools_gpu_agent_; |
| 233 | 225 |
| 234 size_t num_stubs_descheduled_; | 226 size_t num_stubs_descheduled_; |
| 235 | 227 |
| 236 DISALLOW_COPY_AND_ASSIGN(GpuChannel); | 228 DISALLOW_COPY_AND_ASSIGN(GpuChannel); |
| 237 }; | 229 }; |
| 238 | 230 |
| 239 } // namespace content | 231 } // namespace content |
| 240 | 232 |
| 241 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 233 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ |
| OLD | NEW |