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 GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
6 #define CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/containers/scoped_ptr_hash_map.h" | 14 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
20 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
21 #include "base/trace_event/memory_dump_provider.h" | 21 #include "base/trace_event/memory_dump_provider.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "content/common/content_export.h" | |
24 #include "content/common/gpu/gpu_command_buffer_stub.h" | |
25 #include "content/common/gpu/gpu_memory_manager.h" | |
26 #include "gpu/command_buffer/service/valuebuffer_manager.h" | 23 #include "gpu/command_buffer/service/valuebuffer_manager.h" |
| 24 #include "gpu/gpu_export.h" |
27 #include "gpu/ipc/common/gpu_stream_constants.h" | 25 #include "gpu/ipc/common/gpu_stream_constants.h" |
| 26 #include "gpu/ipc/service/gpu_command_buffer_stub.h" |
| 27 #include "gpu/ipc/service/gpu_memory_manager.h" |
28 #include "ipc/ipc_sync_channel.h" | 28 #include "ipc/ipc_sync_channel.h" |
29 #include "ipc/message_router.h" | 29 #include "ipc/message_router.h" |
30 #include "ui/gfx/geometry/size.h" | 30 #include "ui/gfx/geometry/size.h" |
31 #include "ui/gfx/native_widget_types.h" | 31 #include "ui/gfx/native_widget_types.h" |
32 #include "ui/gl/gl_share_group.h" | 32 #include "ui/gl/gl_share_group.h" |
33 #include "ui/gl/gpu_preference.h" | 33 #include "ui/gl/gpu_preference.h" |
34 | 34 |
35 struct GPUCreateCommandBufferConfig; | 35 struct GPUCreateCommandBufferConfig; |
36 | 36 |
37 namespace base { | 37 namespace base { |
38 class WaitableEvent; | 38 class WaitableEvent; |
39 } | 39 } |
40 | 40 |
41 namespace gpu { | |
42 class PreemptionFlag; | |
43 class SyncPointOrderData; | |
44 class SyncPointManager; | |
45 union ValueState; | |
46 class ValueStateMap; | |
47 namespace gles2 { | |
48 class SubscriptionRefSet; | |
49 } | |
50 } | |
51 | |
52 namespace IPC { | 41 namespace IPC { |
53 class MessageFilter; | 42 class MessageFilter; |
54 } | 43 } |
55 | 44 |
56 namespace content { | 45 namespace gpu { |
| 46 |
| 47 class PreemptionFlag; |
| 48 class SyncPointOrderData; |
| 49 class SyncPointManager; |
| 50 union ValueState; |
| 51 class ValueStateMap; |
57 class GpuChannelManager; | 52 class GpuChannelManager; |
58 class GpuChannelMessageFilter; | 53 class GpuChannelMessageFilter; |
59 class GpuChannelMessageQueue; | 54 class GpuChannelMessageQueue; |
60 class GpuWatchdog; | 55 class GpuWatchdog; |
61 | 56 |
| 57 namespace gles2 { |
| 58 class SubscriptionRefSet; |
| 59 } |
| 60 |
62 // Encapsulates an IPC channel between the GPU process and one renderer | 61 // Encapsulates an IPC channel between the GPU process and one renderer |
63 // process. On the renderer side there's a corresponding GpuChannelHost. | 62 // process. On the renderer side there's a corresponding GpuChannelHost. |
64 class CONTENT_EXPORT GpuChannel | 63 class GPU_EXPORT GpuChannel |
65 : public IPC::Listener, | 64 : public IPC::Listener, |
66 public IPC::Sender, | 65 public IPC::Sender, |
67 public gpu::gles2::SubscriptionRefSet::Observer { | 66 public gles2::SubscriptionRefSet::Observer { |
68 public: | 67 public: |
69 // Takes ownership of the renderer process handle. | 68 // Takes ownership of the renderer process handle. |
70 GpuChannel(GpuChannelManager* gpu_channel_manager, | 69 GpuChannel(GpuChannelManager* gpu_channel_manager, |
71 gpu::SyncPointManager* sync_point_manager, | 70 SyncPointManager* sync_point_manager, |
72 GpuWatchdog* watchdog, | 71 GpuWatchdog* watchdog, |
73 gfx::GLShareGroup* share_group, | 72 gfx::GLShareGroup* share_group, |
74 gpu::gles2::MailboxManager* mailbox_manager, | 73 gles2::MailboxManager* mailbox_manager, |
75 gpu::PreemptionFlag* preempting_flag, | 74 PreemptionFlag* preempting_flag, |
76 gpu::PreemptionFlag* preempted_flag, | 75 PreemptionFlag* preempted_flag, |
77 base::SingleThreadTaskRunner* task_runner, | 76 base::SingleThreadTaskRunner* task_runner, |
78 base::SingleThreadTaskRunner* io_task_runner, | 77 base::SingleThreadTaskRunner* io_task_runner, |
79 int32_t client_id, | 78 int32_t client_id, |
80 uint64_t client_tracing_id, | 79 uint64_t client_tracing_id, |
81 bool allow_view_command_buffers, | 80 bool allow_view_command_buffers, |
82 bool allow_real_time_streams); | 81 bool allow_real_time_streams); |
83 ~GpuChannel() override; | 82 ~GpuChannel() override; |
84 | 83 |
85 // Initializes the IPC channel. Caller takes ownership of the client FD in | 84 // Initializes the IPC channel. Caller takes ownership of the client FD in |
86 // the returned handle and is responsible for closing it. | 85 // the returned handle and is responsible for closing it. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 140 |
142 uint64_t GetMemoryUsage(); | 141 uint64_t GetMemoryUsage(); |
143 | 142 |
144 scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer( | 143 scoped_refptr<gl::GLImage> CreateImageForGpuMemoryBuffer( |
145 const gfx::GpuMemoryBufferHandle& handle, | 144 const gfx::GpuMemoryBufferHandle& handle, |
146 const gfx::Size& size, | 145 const gfx::Size& size, |
147 gfx::BufferFormat format, | 146 gfx::BufferFormat format, |
148 uint32_t internalformat); | 147 uint32_t internalformat); |
149 | 148 |
150 void HandleUpdateValueState(unsigned int target, | 149 void HandleUpdateValueState(unsigned int target, |
151 const gpu::ValueState& state); | 150 const ValueState& state); |
152 | 151 |
153 GpuChannelMessageFilter* filter() const { return filter_.get(); } | 152 GpuChannelMessageFilter* filter() const { return filter_.get(); } |
154 | 153 |
155 // Visible for testing. | 154 // Visible for testing. |
156 const gpu::ValueStateMap* pending_valuebuffer_state() const { | 155 const ValueStateMap* pending_valuebuffer_state() const { |
157 return pending_valuebuffer_state_.get(); | 156 return pending_valuebuffer_state_.get(); |
158 } | 157 } |
159 | 158 |
160 // Returns the global order number for the last processed IPC message. | 159 // Returns the global order number for the last processed IPC message. |
161 uint32_t GetProcessedOrderNum() const; | 160 uint32_t GetProcessedOrderNum() const; |
162 | 161 |
163 // Returns the global order number for the last unprocessed IPC message. | 162 // Returns the global order number for the last unprocessed IPC message. |
164 uint32_t GetUnprocessedOrderNum() const; | 163 uint32_t GetUnprocessedOrderNum() const; |
165 | 164 |
166 // Returns the shared sync point global order data for the stream. | 165 // Returns the shared sync point global order data for the stream. |
167 scoped_refptr<gpu::SyncPointOrderData> GetSyncPointOrderData( | 166 scoped_refptr<SyncPointOrderData> GetSyncPointOrderData( |
168 int32_t stream_id); | 167 int32_t stream_id); |
169 | 168 |
170 void PostHandleOutOfOrderMessage(const IPC::Message& message); | 169 void PostHandleOutOfOrderMessage(const IPC::Message& message); |
171 void PostHandleMessage(const scoped_refptr<GpuChannelMessageQueue>& queue); | 170 void PostHandleMessage(const scoped_refptr<GpuChannelMessageQueue>& queue); |
172 | 171 |
173 // Synchronously handle the message to make testing convenient. | 172 // Synchronously handle the message to make testing convenient. |
174 void HandleMessageForTesting(const IPC::Message& msg); | 173 void HandleMessageForTesting(const IPC::Message& msg); |
175 | 174 |
176 #if defined(OS_ANDROID) | 175 #if defined(OS_ANDROID) |
177 const GpuCommandBufferStub* GetOneStub() const; | 176 const GpuCommandBufferStub* GetOneStub() const; |
(...skipping 13 matching lines...) Expand all Loading... |
191 | 190 |
192 // Some messages such as WaitForGetOffsetInRange and WaitForTokenInRange are | 191 // Some messages such as WaitForGetOffsetInRange and WaitForTokenInRange are |
193 // processed as soon as possible because the client is blocked until they | 192 // processed as soon as possible because the client is blocked until they |
194 // are completed. | 193 // are completed. |
195 void HandleOutOfOrderMessage(const IPC::Message& msg); | 194 void HandleOutOfOrderMessage(const IPC::Message& msg); |
196 | 195 |
197 void HandleMessageHelper(const IPC::Message& msg); | 196 void HandleMessageHelper(const IPC::Message& msg); |
198 | 197 |
199 scoped_refptr<GpuChannelMessageQueue> CreateStream( | 198 scoped_refptr<GpuChannelMessageQueue> CreateStream( |
200 int32_t stream_id, | 199 int32_t stream_id, |
201 gpu::GpuStreamPriority stream_priority); | 200 GpuStreamPriority stream_priority); |
202 | 201 |
203 scoped_refptr<GpuChannelMessageQueue> LookupStream(int32_t stream_id); | 202 scoped_refptr<GpuChannelMessageQueue> LookupStream(int32_t stream_id); |
204 | 203 |
205 void DestroyStreamIfNecessary( | 204 void DestroyStreamIfNecessary( |
206 const scoped_refptr<GpuChannelMessageQueue>& queue); | 205 const scoped_refptr<GpuChannelMessageQueue>& queue); |
207 | 206 |
208 void AddRouteToStream(int32_t route_id, int32_t stream_id); | 207 void AddRouteToStream(int32_t route_id, int32_t stream_id); |
209 void RemoveRouteFromStream(int32_t route_id); | 208 void RemoveRouteFromStream(int32_t route_id); |
210 | 209 |
211 // Message handlers for control messages. | 210 // Message handlers for control messages. |
212 void OnCreateCommandBuffer(gpu::SurfaceHandle surface_handle, | 211 void OnCreateCommandBuffer(SurfaceHandle surface_handle, |
213 const gfx::Size& size, | 212 const gfx::Size& size, |
214 const GPUCreateCommandBufferConfig& init_params, | 213 const GPUCreateCommandBufferConfig& init_params, |
215 int32_t route_id, | 214 int32_t route_id, |
216 bool* succeeded); | 215 bool* succeeded); |
217 void OnDestroyCommandBuffer(int32_t route_id); | 216 void OnDestroyCommandBuffer(int32_t route_id); |
218 | 217 |
219 | 218 |
220 // The lifetime of objects of this class is managed by a GpuChannelManager. | 219 // The lifetime of objects of this class is managed by a GpuChannelManager. |
221 // The GpuChannelManager destroy all the GpuChannels that they own when they | 220 // The GpuChannelManager destroy all the GpuChannels that they own when they |
222 // are destroyed. So a raw pointer is safe. | 221 // are destroyed. So a raw pointer is safe. |
223 GpuChannelManager* const gpu_channel_manager_; | 222 GpuChannelManager* const gpu_channel_manager_; |
224 | 223 |
225 // Sync point manager. Outlives the channel and is guaranteed to outlive the | 224 // Sync point manager. Outlives the channel and is guaranteed to outlive the |
226 // message loop. | 225 // message loop. |
227 gpu::SyncPointManager* const sync_point_manager_; | 226 SyncPointManager* const sync_point_manager_; |
228 | 227 |
229 scoped_ptr<IPC::SyncChannel> channel_; | 228 scoped_ptr<IPC::SyncChannel> channel_; |
230 | 229 |
231 IPC::Listener* unhandled_message_listener_; | 230 IPC::Listener* unhandled_message_listener_; |
232 | 231 |
233 // Uniquely identifies the channel within this GPU process. | 232 // Uniquely identifies the channel within this GPU process. |
234 std::string channel_id_; | 233 std::string channel_id_; |
235 | 234 |
236 // Used to implement message routing functionality to CommandBuffer objects | 235 // Used to implement message routing functionality to CommandBuffer objects |
237 IPC::MessageRouter router_; | 236 IPC::MessageRouter router_; |
238 | 237 |
239 // Whether the processing of IPCs on this channel is stalled and we should | 238 // Whether the processing of IPCs on this channel is stalled and we should |
240 // preempt other GpuChannels. | 239 // preempt other GpuChannels. |
241 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; | 240 scoped_refptr<PreemptionFlag> preempting_flag_; |
242 | 241 |
243 // If non-NULL, all stubs on this channel should stop processing GL | 242 // If non-NULL, all stubs on this channel should stop processing GL |
244 // commands (via their CommandExecutor) when preempted_flag_->IsSet() | 243 // commands (via their CommandExecutor) when preempted_flag_->IsSet() |
245 scoped_refptr<gpu::PreemptionFlag> preempted_flag_; | 244 scoped_refptr<PreemptionFlag> preempted_flag_; |
246 | 245 |
247 // The id of the client who is on the other side of the channel. | 246 // The id of the client who is on the other side of the channel. |
248 const int32_t client_id_; | 247 const int32_t client_id_; |
249 | 248 |
250 // The tracing ID used for memory allocations associated with this client. | 249 // The tracing ID used for memory allocations associated with this client. |
251 const uint64_t client_tracing_id_; | 250 const uint64_t client_tracing_id_; |
252 | 251 |
253 // The task runners for the main thread and the io thread. | 252 // The task runners for the main thread and the io thread. |
254 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 253 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
255 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 254 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
256 | 255 |
257 // The share group that all contexts associated with a particular renderer | 256 // The share group that all contexts associated with a particular renderer |
258 // process use. | 257 // process use. |
259 scoped_refptr<gfx::GLShareGroup> share_group_; | 258 scoped_refptr<gfx::GLShareGroup> share_group_; |
260 | 259 |
261 scoped_refptr<gpu::gles2::MailboxManager> mailbox_manager_; | 260 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
262 | 261 |
263 scoped_refptr<gpu::gles2::SubscriptionRefSet> subscription_ref_set_; | 262 scoped_refptr<gles2::SubscriptionRefSet> subscription_ref_set_; |
264 | 263 |
265 scoped_refptr<gpu::ValueStateMap> pending_valuebuffer_state_; | 264 scoped_refptr<ValueStateMap> pending_valuebuffer_state_; |
266 | 265 |
267 gpu::gles2::DisallowedFeatures disallowed_features_; | 266 gles2::DisallowedFeatures disallowed_features_; |
268 GpuWatchdog* const watchdog_; | 267 GpuWatchdog* const watchdog_; |
269 | 268 |
270 // Map of stream id to appropriate message queue. | 269 // Map of stream id to appropriate message queue. |
271 base::hash_map<int32_t, scoped_refptr<GpuChannelMessageQueue>> streams_; | 270 base::hash_map<int32_t, scoped_refptr<GpuChannelMessageQueue>> streams_; |
272 | 271 |
273 // Multimap of stream id to route ids. | 272 // Multimap of stream id to route ids. |
274 base::hash_map<int32_t, int> streams_to_num_routes_; | 273 base::hash_map<int32_t, int> streams_to_num_routes_; |
275 | 274 |
276 // Map of route id to stream id; | 275 // Map of route id to stream id; |
277 base::hash_map<int32_t, int32_t> routes_to_streams_; | 276 base::hash_map<int32_t, int32_t> routes_to_streams_; |
(...skipping 16 matching lines...) Expand all Loading... |
294 // - it counts and timestamps each message forwarded to the channel | 293 // - it counts and timestamps each message forwarded to the channel |
295 // so that we can preempt other channels if a message takes too long to | 294 // so that we can preempt other channels if a message takes too long to |
296 // process. To guarantee fairness, we must wait a minimum amount of time | 295 // process. To guarantee fairness, we must wait a minimum amount of time |
297 // before preempting and we limit the amount of time that we can preempt in | 296 // before preempting and we limit the amount of time that we can preempt in |
298 // one shot (see constants above). | 297 // one shot (see constants above). |
299 // - it handles the GpuCommandBufferMsg_InsertSyncPoint message on the IO | 298 // - it handles the GpuCommandBufferMsg_InsertSyncPoint message on the IO |
300 // thread, generating the sync point ID and responding immediately, and then | 299 // thread, generating the sync point ID and responding immediately, and then |
301 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message | 300 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message |
302 // into the channel's queue. | 301 // into the channel's queue. |
303 // - it generates mailbox names for clients of the GPU process on the IO thread. | 302 // - it generates mailbox names for clients of the GPU process on the IO thread. |
304 class GpuChannelMessageFilter : public IPC::MessageFilter { | 303 class GPU_EXPORT GpuChannelMessageFilter : public IPC::MessageFilter { |
305 public: | 304 public: |
306 GpuChannelMessageFilter(); | 305 GpuChannelMessageFilter(); |
307 | 306 |
308 // IPC::MessageFilter implementation. | 307 // IPC::MessageFilter implementation. |
309 void OnFilterAdded(IPC::Sender* sender) override; | 308 void OnFilterAdded(IPC::Sender* sender) override; |
310 void OnFilterRemoved() override; | 309 void OnFilterRemoved() override; |
311 void OnChannelConnected(int32_t peer_pid) override; | 310 void OnChannelConnected(int32_t peer_pid) override; |
312 void OnChannelError() override; | 311 void OnChannelError() override; |
313 void OnChannelClosing() override; | 312 void OnChannelClosing() override; |
314 bool OnMessageReceived(const IPC::Message& message) override; | 313 bool OnMessageReceived(const IPC::Message& message) override; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 352 |
354 private: | 353 private: |
355 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessage); | 354 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessage); |
356 }; | 355 }; |
357 | 356 |
358 class GpuChannelMessageQueue | 357 class GpuChannelMessageQueue |
359 : public base::RefCountedThreadSafe<GpuChannelMessageQueue> { | 358 : public base::RefCountedThreadSafe<GpuChannelMessageQueue> { |
360 public: | 359 public: |
361 static scoped_refptr<GpuChannelMessageQueue> Create( | 360 static scoped_refptr<GpuChannelMessageQueue> Create( |
362 int32_t stream_id, | 361 int32_t stream_id, |
363 gpu::GpuStreamPriority stream_priority, | 362 GpuStreamPriority stream_priority, |
364 GpuChannel* channel, | 363 GpuChannel* channel, |
365 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 364 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
366 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, | 365 const scoped_refptr<PreemptionFlag>& preempting_flag, |
367 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, | 366 const scoped_refptr<PreemptionFlag>& preempted_flag, |
368 gpu::SyncPointManager* sync_point_manager); | 367 SyncPointManager* sync_point_manager); |
369 | 368 |
370 void Disable(); | 369 void Disable(); |
371 void DisableIO(); | 370 void DisableIO(); |
372 | 371 |
373 int32_t stream_id() const { return stream_id_; } | 372 int32_t stream_id() const { return stream_id_; } |
374 gpu::GpuStreamPriority stream_priority() const { return stream_priority_; } | 373 GpuStreamPriority stream_priority() const { return stream_priority_; } |
375 | 374 |
376 bool IsScheduled() const; | 375 bool IsScheduled() const; |
377 void OnRescheduled(bool scheduled); | 376 void OnRescheduled(bool scheduled); |
378 | 377 |
379 bool HasQueuedMessages() const; | 378 bool HasQueuedMessages() const; |
380 | 379 |
381 base::TimeTicks GetNextMessageTimeTick() const; | 380 base::TimeTicks GetNextMessageTimeTick() const; |
382 | 381 |
383 scoped_refptr<gpu::SyncPointOrderData> GetSyncPointOrderData(); | 382 scoped_refptr<SyncPointOrderData> GetSyncPointOrderData(); |
384 | 383 |
385 // Returns the global order number for the last unprocessed IPC message. | 384 // Returns the global order number for the last unprocessed IPC message. |
386 uint32_t GetUnprocessedOrderNum() const; | 385 uint32_t GetUnprocessedOrderNum() const; |
387 | 386 |
388 // Returns the global order number for the last unprocessed IPC message. | 387 // Returns the global order number for the last unprocessed IPC message. |
389 uint32_t GetProcessedOrderNum() const; | 388 uint32_t GetProcessedOrderNum() const; |
390 | 389 |
391 // Should be called before a message begins to be processed. Returns false if | 390 // Should be called before a message begins to be processed. Returns false if |
392 // there are no messages to process. | 391 // there are no messages to process. |
393 const GpuChannelMessage* BeginMessageProcessing(); | 392 const GpuChannelMessage* BeginMessageProcessing(); |
(...skipping 19 matching lines...) Expand all Loading... |
413 // We are currently preempting (i.e. no stub is descheduled). | 412 // We are currently preempting (i.e. no stub is descheduled). |
414 PREEMPTING, | 413 PREEMPTING, |
415 // We would like to preempt, but some stub is descheduled. | 414 // We would like to preempt, but some stub is descheduled. |
416 WOULD_PREEMPT_DESCHEDULED, | 415 WOULD_PREEMPT_DESCHEDULED, |
417 }; | 416 }; |
418 | 417 |
419 friend class base::RefCountedThreadSafe<GpuChannelMessageQueue>; | 418 friend class base::RefCountedThreadSafe<GpuChannelMessageQueue>; |
420 | 419 |
421 GpuChannelMessageQueue( | 420 GpuChannelMessageQueue( |
422 int32_t stream_id, | 421 int32_t stream_id, |
423 gpu::GpuStreamPriority stream_priority, | 422 GpuStreamPriority stream_priority, |
424 GpuChannel* channel, | 423 GpuChannel* channel, |
425 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 424 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
426 const scoped_refptr<gpu::PreemptionFlag>& preempting_flag, | 425 const scoped_refptr<PreemptionFlag>& preempting_flag, |
427 const scoped_refptr<gpu::PreemptionFlag>& preempted_flag, | 426 const scoped_refptr<PreemptionFlag>& preempted_flag, |
428 gpu::SyncPointManager* sync_point_manager); | 427 SyncPointManager* sync_point_manager); |
429 ~GpuChannelMessageQueue(); | 428 ~GpuChannelMessageQueue(); |
430 | 429 |
431 void UpdatePreemptionState(); | 430 void UpdatePreemptionState(); |
432 void UpdatePreemptionStateHelper(); | 431 void UpdatePreemptionStateHelper(); |
433 | 432 |
434 void UpdateStateIdle(); | 433 void UpdateStateIdle(); |
435 void UpdateStateWaiting(); | 434 void UpdateStateWaiting(); |
436 void UpdateStateChecking(); | 435 void UpdateStateChecking(); |
437 void UpdateStatePreempting(); | 436 void UpdateStatePreempting(); |
438 void UpdateStateWouldPreemptDescheduled(); | 437 void UpdateStateWouldPreemptDescheduled(); |
439 | 438 |
440 void TransitionToIdle(); | 439 void TransitionToIdle(); |
441 void TransitionToWaiting(); | 440 void TransitionToWaiting(); |
442 void TransitionToChecking(); | 441 void TransitionToChecking(); |
443 void TransitionToPreempting(); | 442 void TransitionToPreempting(); |
444 void TransitionToWouldPreemptDescheduled(); | 443 void TransitionToWouldPreemptDescheduled(); |
445 | 444 |
446 bool ShouldTransitionToIdle() const; | 445 bool ShouldTransitionToIdle() const; |
447 | 446 |
448 const int32_t stream_id_; | 447 const int32_t stream_id_; |
449 const gpu::GpuStreamPriority stream_priority_; | 448 const GpuStreamPriority stream_priority_; |
450 | 449 |
451 // These can be accessed from both IO and main threads and are protected by | 450 // These can be accessed from both IO and main threads and are protected by |
452 // |channel_lock_|. | 451 // |channel_lock_|. |
453 bool enabled_; | 452 bool enabled_; |
454 bool scheduled_; | 453 bool scheduled_; |
455 GpuChannel* const channel_; | 454 GpuChannel* const channel_; |
456 std::deque<scoped_ptr<GpuChannelMessage>> channel_messages_; | 455 std::deque<scoped_ptr<GpuChannelMessage>> channel_messages_; |
457 mutable base::Lock channel_lock_; | 456 mutable base::Lock channel_lock_; |
458 | 457 |
459 // The following are accessed on the IO thread only. | 458 // The following are accessed on the IO thread only. |
460 // No lock is necessary for preemption state because it's only accessed on the | 459 // No lock is necessary for preemption state because it's only accessed on the |
461 // IO thread. | 460 // IO thread. |
462 PreemptionState preemption_state_; | 461 PreemptionState preemption_state_; |
463 // Maximum amount of time that we can spend in PREEMPTING. | 462 // Maximum amount of time that we can spend in PREEMPTING. |
464 // It is reset when we transition to IDLE. | 463 // It is reset when we transition to IDLE. |
465 base::TimeDelta max_preemption_time_; | 464 base::TimeDelta max_preemption_time_; |
466 // This timer is used and runs tasks on the IO thread. | 465 // This timer is used and runs tasks on the IO thread. |
467 scoped_ptr<base::OneShotTimer> timer_; | 466 scoped_ptr<base::OneShotTimer> timer_; |
468 base::ThreadChecker io_thread_checker_; | 467 base::ThreadChecker io_thread_checker_; |
469 | 468 |
470 // Keeps track of sync point related state such as message order numbers. | 469 // Keeps track of sync point related state such as message order numbers. |
471 scoped_refptr<gpu::SyncPointOrderData> sync_point_order_data_; | 470 scoped_refptr<SyncPointOrderData> sync_point_order_data_; |
472 | 471 |
473 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 472 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
474 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; | 473 scoped_refptr<PreemptionFlag> preempting_flag_; |
475 scoped_refptr<gpu::PreemptionFlag> preempted_flag_; | 474 scoped_refptr<PreemptionFlag> preempted_flag_; |
476 gpu::SyncPointManager* const sync_point_manager_; | 475 SyncPointManager* const sync_point_manager_; |
477 | 476 |
478 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); | 477 DISALLOW_COPY_AND_ASSIGN(GpuChannelMessageQueue); |
479 }; | 478 }; |
480 | 479 |
481 } // namespace content | 480 } // namespace gpu |
482 | 481 |
483 #endif // CONTENT_COMMON_GPU_GPU_CHANNEL_H_ | 482 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_H_ |
OLD | NEW |