| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread_checker.h" | |
| 15 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
| 16 | 16 |
| 17 namespace base { |
| 18 class SequenceChecker; |
| 19 } |
| 20 |
| 17 namespace gpu { | 21 namespace gpu { |
| 18 | 22 |
| 19 // This class manages the sync points, which allow cross-channel | 23 // This class manages the sync points, which allow cross-channel |
| 20 // synchronization. | 24 // synchronization. |
| 21 class GPU_EXPORT SyncPointManager | 25 class GPU_EXPORT SyncPointManager |
| 22 : public base::RefCountedThreadSafe<SyncPointManager> { | 26 : public base::RefCountedThreadSafe<SyncPointManager> { |
| 23 public: | 27 public: |
| 24 SyncPointManager(); | 28 SyncPointManager(); |
| 25 | 29 |
| 26 // Generates a sync point, returning its ID. This can me called on any thread. | 30 // Generates a sync point, returning its ID. This can me called on any thread. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 38 void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback); | 42 void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback); |
| 39 | 43 |
| 40 bool IsSyncPointRetired(uint32 sync_point); | 44 bool IsSyncPointRetired(uint32 sync_point); |
| 41 | 45 |
| 42 private: | 46 private: |
| 43 friend class base::RefCountedThreadSafe<SyncPointManager>; | 47 friend class base::RefCountedThreadSafe<SyncPointManager>; |
| 44 typedef std::vector<base::Closure> ClosureList; | 48 typedef std::vector<base::Closure> ClosureList; |
| 45 typedef base::hash_map<uint32, ClosureList> SyncPointMap; | 49 typedef base::hash_map<uint32, ClosureList> SyncPointMap; |
| 46 | 50 |
| 47 ~SyncPointManager(); | 51 ~SyncPointManager(); |
| 52 void CheckSequencedThread(); |
| 48 | 53 |
| 49 base::ThreadChecker thread_checker_; | 54 scoped_ptr<base::SequenceChecker> sequence_checker_; |
| 50 | 55 |
| 51 // Protects the 2 fields below. Note: callbacks shouldn't be called with this | 56 // Protects the 2 fields below. Note: callbacks shouldn't be called with this |
| 52 // held. | 57 // held. |
| 53 base::Lock lock_; | 58 base::Lock lock_; |
| 54 SyncPointMap sync_point_map_; | 59 SyncPointMap sync_point_map_; |
| 55 uint32 next_sync_point_; | 60 uint32 next_sync_point_; |
| 56 | 61 |
| 57 DISALLOW_COPY_AND_ASSIGN(SyncPointManager); | 62 DISALLOW_COPY_AND_ASSIGN(SyncPointManager); |
| 58 }; | 63 }; |
| 59 | 64 |
| 60 } // namespace gpu | 65 } // namespace gpu |
| 61 | 66 |
| 62 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ | 67 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ |
| OLD | NEW |