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

Unified Diff: cc/animation_registrar.cc

Issue 11443004: Maintain global lists of animation controllers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 | « cc/animation_registrar.h ('k') | cc/cc.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation_registrar.cc
diff --git a/cc/animation_registrar.cc b/cc/animation_registrar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..22cee3c397fcdbe2c6e3f49d618100c2fd2638d2
--- /dev/null
+++ b/cc/animation_registrar.cc
@@ -0,0 +1,68 @@
+// Copyright 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 "cc/animation_registrar.h"
+
+#include "base/stl_util.h"
+#include "cc/layer_animation_controller.h"
+
+#if defined(COMPILER_GCC)
+namespace BASE_HASH_NAMESPACE {
+template<>
+struct hash<cc::AnimationRegistrar::ThreadName> {
+ size_t operator()(cc::AnimationRegistrar::ThreadName thread_name) const {
+ return hash<size_t>()(static_cast<size_t>(thread_name));
+ }
+};
+} // namespace BASE_HASH_NAMESPACE
+#endif // COMPILER
+
+namespace cc {
+
+namespace {
+
+typedef base::hash_map<AnimationRegistrar::ThreadName,
+ AnimationRegistrar::AnimationControllerSet*>
+ AnimationRegistrarMap;
+
+static AnimationRegistrarMap* s_registrar_map = 0;
jamesr 2012/12/05 02:25:49 in some situations we'll need to have multiple com
+
+AnimationRegistrar::AnimationControllerSet& getAnimationControllerSet(
+ AnimationRegistrar::ThreadName thread_name) {
+ if (!s_registrar_map)
+ s_registrar_map = new AnimationRegistrarMap;
+
+ if (!ContainsKey(*s_registrar_map, thread_name))
+ (*s_registrar_map)[thread_name] =
+ new AnimationRegistrar::AnimationControllerSet;
+ return *(*s_registrar_map)[thread_name];
+}
+
+
+} // namespace
+
+// static.
+void AnimationRegistrar::ActivateAnimationController(
+ LayerAnimationController* controller,
+ AnimationRegistrar::ThreadName thread_name) {
+ getAnimationControllerSet(thread_name).insert(controller);
+}
+
+// static.
+void AnimationRegistrar::DeactivateAnimationController(
+ LayerAnimationController* controller,
+ AnimationRegistrar::ThreadName thread_name) {
+ AnimationControllerSet& controllers = getAnimationControllerSet(thread_name);
+ if (ContainsKey(controllers, controller))
+ controllers.erase(controller);
+}
+
+// static.
+const AnimationRegistrar::AnimationControllerSet&
+AnimationRegistrar::GetActiveControllers(
+ AnimationRegistrar::ThreadName thread_name) {
+ return getAnimationControllerSet(thread_name);
+}
+
+} // namespace cc
« no previous file with comments | « cc/animation_registrar.h ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698