OLD | NEW |
---|---|
(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 | |
OLD | NEW |