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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/sync_point_manager.h ('k') | content/content_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/sync_point_manager.cc
diff --git a/content/common/gpu/sync_point_manager.cc b/content/common/gpu/sync_point_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..edf51040c31700eb246a210554f57acafd39958a
--- /dev/null
+++ b/content/common/gpu/sync_point_manager.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/common/gpu/sync_point_manager.h"
+
+#include "base/logging.h"
+
+SyncPointManager::SyncPointManager()
+ : next_sync_point_(1) {
+}
+
+SyncPointManager::~SyncPointManager() {
+}
+
+uint32 SyncPointManager::GenerateSyncPoint() {
+ base::AutoLock lock(lock_);
+ uint32 sync_point = next_sync_point_++;
+
+ // Note: wrapping would take days for a buggy/compromized renderer that would
+ // insert sync points in a loop, but if that were to happen, better explicitly
+ // crash the GPU process than risk worse.
+ // For normal operation (at most a few per frame), it would take ~a year to
+ // wrap.
+ CHECK(sync_point_map_.find(sync_point) == sync_point_map_.end());
+ sync_point_map_.insert(std::make_pair(sync_point, ClosureList()));
+ return sync_point;
+}
+
+void SyncPointManager::RetireSyncPoint(uint32 sync_point) {
+ DCHECK(CalledOnValidThread());
+ ClosureList list;
+ {
+ base::AutoLock lock(lock_);
+ SyncPointMap::iterator it = sync_point_map_.find(sync_point);
+ DCHECK(it != sync_point_map_.end());
+ list.swap(it->second);
+ sync_point_map_.erase(it);
+ }
+ for (ClosureList::iterator i = list.begin(); i != list.end(); ++i)
+ i->Run();
+}
+
+void SyncPointManager::AddSyncPointCallback(uint32 sync_point,
+ const base::Closure& callback) {
+ DCHECK(CalledOnValidThread());
+ {
+ base::AutoLock lock(lock_);
+ SyncPointMap::iterator it = sync_point_map_.find(sync_point);
+ if (it != sync_point_map_.end()) {
+ it->second.push_back(callback);
+ return;
+ }
+ }
+ callback.Run();
+}
« 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