Chromium Code Reviews

Side by Side Diff: gpu/command_buffer/service/sync_point_manager.h

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 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 // InProcessCommandBuffer allows threaded calls since it can call into
29 // SyncPointManager from client threads, or from multiple service threads
30 // used in Android WebView.
31 static SyncPointManager* Create(bool allow_threaded_calls);
25 32
26 // Generates a sync point, returning its ID. This can me called on any thread. 33 // Generates a sync point, returning its ID. This can me called on any thread.
27 // IDs start at a random number. Never return 0. 34 // IDs start at a random number. Never return 0.
28 uint32 GenerateSyncPoint(); 35 uint32 GenerateSyncPoint();
29 36
30 // Retires a sync point. This will call all the registered callbacks for this 37 // Retires a sync point. This will call all the registered callbacks for this
31 // sync point. This can only be called on the main thread. 38 // sync point. This can only be called on the main thread.
32 void RetireSyncPoint(uint32 sync_point); 39 void RetireSyncPoint(uint32 sync_point);
33 40
34 // Adds a callback to the sync point. The callback will be called when the 41 // Adds a callback to the sync point. The callback will be called when the
35 // sync point is retired, or immediately (from within that function) if the 42 // sync point is retired, or immediately (from within that function) if the
36 // sync point was already retired (or not created yet). This can only be 43 // sync point was already retired (or not created yet). This can only be
37 // called on the main thread. 44 // called on the main thread.
38 void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback); 45 void AddSyncPointCallback(uint32 sync_point, const base::Closure& callback);
39 46
40 bool IsSyncPointRetired(uint32 sync_point); 47 bool IsSyncPointRetired(uint32 sync_point);
41 48
42 private: 49 private:
43 friend class base::RefCountedThreadSafe<SyncPointManager>; 50 friend class base::RefCountedThreadSafe<SyncPointManager>;
44 typedef std::vector<base::Closure> ClosureList; 51 typedef std::vector<base::Closure> ClosureList;
45 typedef base::hash_map<uint32, ClosureList> SyncPointMap; 52 typedef base::hash_map<uint32, ClosureList> SyncPointMap;
46 53
54 explicit SyncPointManager(bool allow_threaded_calls);
47 ~SyncPointManager(); 55 ~SyncPointManager();
56 void CheckSequencedThread();
48 57
49 base::ThreadChecker thread_checker_; 58 scoped_ptr<base::SequenceChecker> sequence_checker_;
50 59
51 // Protects the 2 fields below. Note: callbacks shouldn't be called with this 60 // Protects the 2 fields below. Note: callbacks shouldn't be called with this
52 // held. 61 // held.
53 base::Lock lock_; 62 base::Lock lock_;
54 SyncPointMap sync_point_map_; 63 SyncPointMap sync_point_map_;
55 uint32 next_sync_point_; 64 uint32 next_sync_point_;
56 65
57 DISALLOW_COPY_AND_ASSIGN(SyncPointManager); 66 DISALLOW_COPY_AND_ASSIGN(SyncPointManager);
58 }; 67 };
59 68
60 } // namespace gpu 69 } // namespace gpu
61 70
62 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_ 71 #endif // GPU_COMMAND_BUFFER_SERVICE_SYNC_POINT_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/shader_translator.h ('k') | gpu/command_buffer/service/sync_point_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine