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

Side by Side Diff: content/common/gpu/sync_point_manager.cc

Issue 10510013: GPU: Adding sync points for cross-channel synchronization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/sync_point_manager.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/common/gpu/sync_point_manager.h"
6
7 #include "base/logging.h"
8
9 SyncPointManager::SyncPointManager()
10 : next_sync_point_(1) {
11 }
12
13 SyncPointManager::~SyncPointManager() {
14 }
15
16 uint32 SyncPointManager::GenerateSyncPoint() {
17 base::AutoLock lock(lock_);
18 uint32 sync_point = next_sync_point_++;
19
20 // Note: wrapping would take days for a buggy/compromized renderer that would
21 // insert sync points in a loop, but if that were to happen, better explicitly
22 // crash the GPU process than risk worse.
23 // For normal operation (at most a few per frame), it would take ~a year to
24 // wrap.
25 CHECK(sync_point_map_.find(sync_point) == sync_point_map_.end());
26 sync_point_map_.insert(std::make_pair(sync_point, ClosureList()));
27 return sync_point;
28 }
29
30 void SyncPointManager::RetireSyncPoint(uint32 sync_point) {
31 DCHECK(CalledOnValidThread());
32 ClosureList list;
33 {
34 base::AutoLock lock(lock_);
35 SyncPointMap::iterator it = sync_point_map_.find(sync_point);
36 DCHECK(it != sync_point_map_.end());
37 list.swap(it->second);
38 sync_point_map_.erase(it);
39 }
40 for (ClosureList::iterator i = list.begin(); i != list.end(); ++i)
41 i->Run();
42 }
43
44 void SyncPointManager::AddSyncPointCallback(uint32 sync_point,
45 const base::Closure& callback) {
46 DCHECK(CalledOnValidThread());
47 {
48 base::AutoLock lock(lock_);
49 SyncPointMap::iterator it = sync_point_map_.find(sync_point);
50 if (it != sync_point_map_.end()) {
51 it->second.push_back(callback);
52 return;
53 }
54 }
55 callback.Run();
56 }
OLDNEW
« no previous file with comments | « content/common/gpu/sync_point_manager.h ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698