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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/animation_registrar.h ('k') | cc/cc.gyp » ('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 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 "cc/animation_registrar.h"
6
7 #include "base/stl_util.h"
8 #include "cc/layer_animation_controller.h"
9
10 #if defined(COMPILER_GCC)
11 namespace BASE_HASH_NAMESPACE {
12 template<>
13 struct hash<cc::AnimationRegistrar::ThreadName> {
14 size_t operator()(cc::AnimationRegistrar::ThreadName thread_name) const {
15 return hash<size_t>()(static_cast<size_t>(thread_name));
16 }
17 };
18 } // namespace BASE_HASH_NAMESPACE
19 #endif // COMPILER
20
21 namespace cc {
22
23 namespace {
24
25 typedef base::hash_map<AnimationRegistrar::ThreadName,
26 AnimationRegistrar::AnimationControllerSet*>
27 AnimationRegistrarMap;
28
29 static AnimationRegistrarMap* s_registrar_map = 0;
jamesr 2012/12/05 02:25:49 in some situations we'll need to have multiple com
30
31 AnimationRegistrar::AnimationControllerSet& getAnimationControllerSet(
32 AnimationRegistrar::ThreadName thread_name) {
33 if (!s_registrar_map)
34 s_registrar_map = new AnimationRegistrarMap;
35
36 if (!ContainsKey(*s_registrar_map, thread_name))
37 (*s_registrar_map)[thread_name] =
38 new AnimationRegistrar::AnimationControllerSet;
39 return *(*s_registrar_map)[thread_name];
40 }
41
42
43 } // namespace
44
45 // static.
46 void AnimationRegistrar::ActivateAnimationController(
47 LayerAnimationController* controller,
48 AnimationRegistrar::ThreadName thread_name) {
49 getAnimationControllerSet(thread_name).insert(controller);
50 }
51
52 // static.
53 void AnimationRegistrar::DeactivateAnimationController(
54 LayerAnimationController* controller,
55 AnimationRegistrar::ThreadName thread_name) {
56 AnimationControllerSet& controllers = getAnimationControllerSet(thread_name);
57 if (ContainsKey(controllers, controller))
58 controllers.erase(controller);
59 }
60
61 // static.
62 const AnimationRegistrar::AnimationControllerSet&
63 AnimationRegistrar::GetActiveControllers(
64 AnimationRegistrar::ThreadName thread_name) {
65 return getAnimationControllerSet(thread_name);
66 }
67
68 } // namespace cc
OLDNEW
« 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