| 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 GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <functional> | 10 #include <functional> |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 uint64_t client_id); | 277 uint64_t client_id); |
| 278 | 278 |
| 279 // Creates a sync point client which cannot process order numbers but can only | 279 // Creates a sync point client which cannot process order numbers but can only |
| 280 // Wait out of order. | 280 // Wait out of order. |
| 281 scoped_ptr<SyncPointClient> CreateSyncPointClientWaiter(); | 281 scoped_ptr<SyncPointClient> CreateSyncPointClientWaiter(); |
| 282 | 282 |
| 283 // Finds the state of an already created sync point client. | 283 // Finds the state of an already created sync point client. |
| 284 scoped_refptr<SyncPointClientState> GetSyncPointClientState( | 284 scoped_refptr<SyncPointClientState> GetSyncPointClientState( |
| 285 CommandBufferNamespace namespace_id, uint64_t client_id); | 285 CommandBufferNamespace namespace_id, uint64_t client_id); |
| 286 | 286 |
| 287 // Generates a sync point, returning its ID. This can me called on any thread. | |
| 288 // IDs start at a random number. Never return 0. | |
| 289 uint32_t GenerateSyncPoint(); | |
| 290 | |
| 291 // Retires a sync point. This will call all the registered callbacks for this | |
| 292 // sync point. This can only be called on the main thread. | |
| 293 void RetireSyncPoint(uint32_t sync_point); | |
| 294 | |
| 295 // Adds a callback to the sync point. The callback will be called when the | |
| 296 // sync point is retired, or immediately (from within that function) if the | |
| 297 // sync point was already retired (or not created yet). This can only be | |
| 298 // called on the main thread. | |
| 299 void AddSyncPointCallback(uint32_t sync_point, const base::Closure& callback); | |
| 300 | |
| 301 bool IsSyncPointRetired(uint32_t sync_point); | |
| 302 | |
| 303 private: | 287 private: |
| 304 friend class SyncPointClient; | 288 friend class SyncPointClient; |
| 305 friend class SyncPointOrderData; | 289 friend class SyncPointOrderData; |
| 306 | 290 |
| 307 typedef std::vector<base::Closure> ClosureList; | |
| 308 typedef base::hash_map<uint32_t, ClosureList> SyncPointMap; | |
| 309 typedef base::hash_map<uint64_t, SyncPointClient*> ClientMap; | 291 typedef base::hash_map<uint64_t, SyncPointClient*> ClientMap; |
| 310 | 292 |
| 311 bool IsSyncPointRetiredLocked(uint32_t sync_point); | |
| 312 uint32_t GenerateOrderNumber(); | 293 uint32_t GenerateOrderNumber(); |
| 313 void DestroySyncPointClient(CommandBufferNamespace namespace_id, | 294 void DestroySyncPointClient(CommandBufferNamespace namespace_id, |
| 314 uint64_t client_id); | 295 uint64_t client_id); |
| 315 | 296 |
| 316 // Order number is global for all clients. | 297 // Order number is global for all clients. |
| 317 base::AtomicSequenceNumber global_order_num_; | 298 base::AtomicSequenceNumber global_order_num_; |
| 318 | 299 |
| 319 // Client map holds a map of clients id to client for each namespace. | 300 // Client map holds a map of clients id to client for each namespace. |
| 320 base::Lock client_maps_lock_; | 301 base::Lock client_maps_lock_; |
| 321 ClientMap client_maps_[NUM_COMMAND_BUFFER_NAMESPACES]; | 302 ClientMap client_maps_[NUM_COMMAND_BUFFER_NAMESPACES]; |
| 322 | 303 |
| 323 // Protects the 2 fields below. Note: callbacks shouldn't be called with this | |
| 324 // held. | |
| 325 base::Lock lock_; | |
| 326 SyncPointMap sync_point_map_; | |
| 327 uint32_t next_sync_point_; | |
| 328 | |
| 329 DISALLOW_COPY_AND_ASSIGN(SyncPointManager); | 304 DISALLOW_COPY_AND_ASSIGN(SyncPointManager); |
| 330 }; | 305 }; |
| 331 | 306 |
| 332 } // namespace gpu | 307 } // namespace gpu |
| 333 | 308 |
| 334 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ | 309 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ |
| OLD | NEW |