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

Side by Side Diff: content/common/gpu/gpu_channel.h

Issue 1308913004: GPU Channel's now maintain a global order number for each processed IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: No need to forward declare GpuChannelMessage Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/common/gpu/gpu_channel.cc » ('j') | content/common/gpu/gpu_channel.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
9 #include <string> 8 #include <string>
10 9
11 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
15 #include "base/process/process.h" 14 #include "base/process/process.h"
16 #include "base/trace_event/memory_dump_provider.h" 15 #include "base/trace_event/memory_dump_provider.h"
17 #include "build/build_config.h" 16 #include "build/build_config.h"
18 #include "content/common/content_export.h" 17 #include "content/common/content_export.h"
(...skipping 24 matching lines...) Expand all
43 } 42 }
44 43
45 namespace IPC { 44 namespace IPC {
46 class AttachmentBroker; 45 class AttachmentBroker;
47 class MessageFilter; 46 class MessageFilter;
48 } 47 }
49 48
50 namespace content { 49 namespace content {
51 class GpuChannelManager; 50 class GpuChannelManager;
52 class GpuChannelMessageFilter; 51 class GpuChannelMessageFilter;
52 class GpuChannelMessageQueue;
53 class GpuJpegDecodeAccelerator; 53 class GpuJpegDecodeAccelerator;
54 class GpuWatchdog; 54 class GpuWatchdog;
55 55
56 // Encapsulates an IPC channel between the GPU process and one renderer 56 // Encapsulates an IPC channel between the GPU process and one renderer
57 // process. On the renderer side there's a corresponding GpuChannelHost. 57 // process. On the renderer side there's a corresponding GpuChannelHost.
58 class CONTENT_EXPORT GpuChannel 58 class CONTENT_EXPORT GpuChannel
59 : public IPC::Listener, 59 : public IPC::Listener,
60 public IPC::Sender, 60 public IPC::Sender,
61 public gpu::gles2::SubscriptionRefSet::Observer { 61 public gpu::gles2::SubscriptionRefSet::Observer {
62 public: 62 public:
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 // Called to add a listener for a particular message routing ID. 138 // Called to add a listener for a particular message routing ID.
139 // Returns true if succeeded. 139 // Returns true if succeeded.
140 bool AddRoute(int32 route_id, IPC::Listener* listener); 140 bool AddRoute(int32 route_id, IPC::Listener* listener);
141 141
142 // Called to remove a listener for a particular message routing ID. 142 // Called to remove a listener for a particular message routing ID.
143 void RemoveRoute(int32 route_id); 143 void RemoveRoute(int32 route_id);
144 144
145 gpu::PreemptionFlag* GetPreemptionFlag(); 145 gpu::PreemptionFlag* GetPreemptionFlag();
146 146
147 bool handle_messages_scheduled() const { return handle_messages_scheduled_; }
148 uint64 messages_processed() const { return messages_processed_; }
149
150 // If |preemption_flag->IsSet()|, any stub on this channel 147 // If |preemption_flag->IsSet()|, any stub on this channel
151 // should stop issuing GL commands. Setting this to NULL stops deferral. 148 // should stop issuing GL commands. Setting this to NULL stops deferral.
152 void SetPreemptByFlag( 149 void SetPreemptByFlag(
153 scoped_refptr<gpu::PreemptionFlag> preemption_flag); 150 scoped_refptr<gpu::PreemptionFlag> preemption_flag);
154 151
155 void CacheShader(const std::string& key, const std::string& shader); 152 void CacheShader(const std::string& key, const std::string& shader);
156 153
157 virtual void AddFilter(IPC::MessageFilter* filter); 154 virtual void AddFilter(IPC::MessageFilter* filter);
158 virtual void RemoveFilter(IPC::MessageFilter* filter); 155 virtual void RemoveFilter(IPC::MessageFilter* filter);
159 156
160 uint64 GetMemoryUsage(); 157 uint64 GetMemoryUsage();
161 158
162 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer( 159 scoped_refptr<gfx::GLImage> CreateImageForGpuMemoryBuffer(
163 const gfx::GpuMemoryBufferHandle& handle, 160 const gfx::GpuMemoryBufferHandle& handle,
164 const gfx::Size& size, 161 const gfx::Size& size,
165 gfx::BufferFormat format, 162 gfx::BufferFormat format,
166 uint32 internalformat); 163 uint32 internalformat);
167 164
168 bool allow_future_sync_points() const { return allow_future_sync_points_; } 165 bool allow_future_sync_points() const { return allow_future_sync_points_; }
169 166
170 void HandleUpdateValueState(unsigned int target, 167 void HandleUpdateValueState(unsigned int target,
171 const gpu::ValueState& state); 168 const gpu::ValueState& state);
172 169
173 // Visible for testing. 170 // Visible for testing.
174 const gpu::ValueStateMap* pending_valuebuffer_state() const { 171 const gpu::ValueStateMap* pending_valuebuffer_state() const {
175 return pending_valuebuffer_state_.get(); 172 return pending_valuebuffer_state_.get();
176 } 173 }
177 174
175 uint32_t GetCurrentOrderNum() const { return current_order_num_; }
176 uint32_t GetProcessedOrderNum() const { return processed_order_num_; }
177 uint32_t GetUnprocessedOrderNum() const;
178
178 protected: 179 protected:
179 // The message filter on the io thread. 180 // The message filter on the io thread.
180 scoped_refptr<GpuChannelMessageFilter> filter_; 181 scoped_refptr<GpuChannelMessageFilter> filter_;
181 182
182 // Map of routing id to command buffer stub. 183 // Map of routing id to command buffer stub.
183 base::ScopedPtrHashMap<int32, scoped_ptr<GpuCommandBufferStub>> stubs_; 184 base::ScopedPtrHashMap<int32, scoped_ptr<GpuCommandBufferStub>> stubs_;
184 185
185 private: 186 private:
186 friend class GpuChannelMessageFilter; 187 friend class GpuChannelMessageFilter;
188 friend class GpuChannelMessageQueue;
187 189
188 void OnDestroy(); 190 void OnDestroy();
189 191
190 bool OnControlMessageReceived(const IPC::Message& msg); 192 bool OnControlMessageReceived(const IPC::Message& msg);
191 193
192 void HandleMessage(); 194 void HandleMessage();
193 195
194 // Message handlers. 196 // Message handlers.
195 void OnCreateOffscreenCommandBuffer( 197 void OnCreateOffscreenCommandBuffer(
196 const gfx::Size& size, 198 const gfx::Size& size,
197 const GPUCreateCommandBufferConfig& init_params, 199 const GPUCreateCommandBufferConfig& init_params,
198 int32 route_id, 200 int32 route_id,
199 bool* succeeded); 201 bool* succeeded);
200 void OnDestroyCommandBuffer(int32 route_id); 202 void OnDestroyCommandBuffer(int32 route_id);
201 void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg); 203 void OnCreateJpegDecoder(int32 route_id, IPC::Message* reply_msg);
202 204
203 // Decrement the count of unhandled IPC messages and defer preemption. 205 // Update processed order number and defer preemption.
204 void MessageProcessed(); 206 void MessageProcessed(uint32_t order_number);
205 207
206 // The lifetime of objects of this class is managed by a GpuChannelManager. 208 // The lifetime of objects of this class is managed by a GpuChannelManager.
207 // The GpuChannelManager destroy all the GpuChannels that they own when they 209 // The GpuChannelManager destroy all the GpuChannels that they own when they
208 // are destroyed. So a raw pointer is safe. 210 // are destroyed. So a raw pointer is safe.
209 GpuChannelManager* gpu_channel_manager_; 211 GpuChannelManager* gpu_channel_manager_;
210 212
211 scoped_ptr<IPC::SyncChannel> channel_; 213 scoped_ptr<IPC::SyncChannel> channel_;
212 214
213 // Uniquely identifies the channel within this GPU process. 215 // Uniquely identifies the channel within this GPU process.
214 std::string channel_id_; 216 std::string channel_id_;
215 217
216 // Used to implement message routing functionality to CommandBuffer objects 218 // Used to implement message routing functionality to CommandBuffer objects
217 MessageRouter router_; 219 MessageRouter router_;
218 220
219 uint64 messages_processed_;
220
221 // Whether the processing of IPCs on this channel is stalled and we should 221 // Whether the processing of IPCs on this channel is stalled and we should
222 // preempt other GpuChannels. 222 // preempt other GpuChannels.
223 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; 223 scoped_refptr<gpu::PreemptionFlag> preempting_flag_;
224 224
225 // If non-NULL, all stubs on this channel should stop processing GL 225 // If non-NULL, all stubs on this channel should stop processing GL
226 // commands (via their GpuScheduler) when preempted_flag_->IsSet() 226 // commands (via their GpuScheduler) when preempted_flag_->IsSet()
227 scoped_refptr<gpu::PreemptionFlag> preempted_flag_; 227 scoped_refptr<gpu::PreemptionFlag> preempted_flag_;
228 228
229 std::deque<IPC::Message*> deferred_messages_; 229 scoped_refptr<GpuChannelMessageQueue> message_queue_;
230 230
231 // The id of the client who is on the other side of the channel. 231 // The id of the client who is on the other side of the channel.
232 int client_id_; 232 int client_id_;
233 233
234 // The tracing ID used for memory allocations associated with this client. 234 // The tracing ID used for memory allocations associated with this client.
235 uint64_t client_tracing_id_; 235 uint64_t client_tracing_id_;
236 236
237 // The task runners for the main thread and the io thread. 237 // The task runners for the main thread and the io thread.
238 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 238 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
239 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 239 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
240 240
241 // The share group that all contexts associated with a particular renderer 241 // The share group that all contexts associated with a particular renderer
242 // process use. 242 // process use.
243 scoped_refptr<gfx::GLShareGroup> share_group_; 243 scoped_refptr<gfx::GLShareGroup> share_group_;
244 244
245 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; 245 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_;
246 246
247 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_; 247 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_;
248 248
249 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; 249 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_;
250 250
251 scoped_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_; 251 scoped_ptr<GpuJpegDecodeAccelerator> jpeg_decoder_;
252 252
253 gpu::gles2::DisallowedFeatures disallowed_features_; 253 gpu::gles2::DisallowedFeatures disallowed_features_;
254 GpuWatchdog* watchdog_; 254 GpuWatchdog* watchdog_;
255 bool software_; 255 bool software_;
256 bool handle_messages_scheduled_; 256
257 IPC::Message* currently_processing_message_; 257 // Current IPC order number being processed.
258 uint32_t current_order_num_;
259
260 // Last finished IPC order number.
261 uint32_t processed_order_num_;
258 262
259 size_t num_stubs_descheduled_; 263 size_t num_stubs_descheduled_;
260 264
261 bool allow_future_sync_points_; 265 bool allow_future_sync_points_;
262 266
263 // Member variables should appear before the WeakPtrFactory, to ensure 267 // Member variables should appear before the WeakPtrFactory, to ensure
264 // that any WeakPtrs to Controller are invalidated before its members 268 // that any WeakPtrs to Controller are invalidated before its members
265 // variable's destructors are executed, rendering them invalid. 269 // variable's destructors are executed, rendering them invalid.
266 base::WeakPtrFactory<GpuChannel> weak_factory_; 270 base::WeakPtrFactory<GpuChannel> weak_factory_;
267 271
268 DISALLOW_COPY_AND_ASSIGN(GpuChannel); 272 DISALLOW_COPY_AND_ASSIGN(GpuChannel);
269 }; 273 };
270 274
271 } // namespace content 275 } // namespace content
272 276
273 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ 277 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/gpu_channel.cc » ('j') | content/common/gpu/gpu_channel.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698