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

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
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 namespace cc {
11
12 namespace {
13
14 static AnimationRegistrar::AnimationControllerSet*
15 s_active_main_thread_controllers = 0;
16 static AnimationRegistrar::AnimationControllerSet*
17 s_main_thread_controllers = 0;
18 static AnimationRegistrar::AnimationControllerSet*
19 s_active_compositor_thread_controllers = 0;
20 static AnimationRegistrar::AnimationControllerSet*
21 s_compositor_thread_controllers = 0;
22
23 AnimationRegistrar::AnimationControllerSet& getControllers(
24 AnimationRegistrar::ThreadName thread_name, bool just_active) {
25 AnimationRegistrar::AnimationControllerSet** controllers = 0;
26
27 if (just_active)
28 controllers = thread_name == AnimationRegistrar::MainThread
29 ? &s_main_thread_controllers
30 : &s_compositor_thread_controllers;
31 else
32 controllers = thread_name == AnimationRegistrar::MainThread
33 ? &s_active_main_thread_controllers
34 : &s_active_compositor_thread_controllers;
35
36 if (!*controllers)
37 *controllers = new AnimationRegistrar::AnimationControllerSet;
38
39 return **controllers;
40 }
41
42 } // namespace
43
44 // static.
45 void AnimationRegistrar::Activate(
46 LayerAnimationController* controller,
47 AnimationRegistrar::ThreadName thread_name) {
48 getControllers(thread_name, true).insert(controller);
49 }
50
51 // static.
52 void AnimationRegistrar::Deactivate(
53 LayerAnimationController* controller,
54 AnimationRegistrar::ThreadName thread_name) {
55 AnimationControllerSet& controllers = getControllers(thread_name, true);
56 if (ContainsKey(controllers, controller))
57 controllers.erase(controller);
58 }
59
60 // static.
61 const AnimationRegistrar::AnimationControllerSet&
62 AnimationRegistrar::GetActiveControllers(
63 AnimationRegistrar::ThreadName thread_name) {
64 return getControllers(thread_name, true);
65 }
66
67 // static.
68 void AnimationRegistrar::Register(
69 LayerAnimationController* controller,
70 AnimationRegistrar::ThreadName thread_name) {
71 getControllers(thread_name, false).insert(controller);
72 }
73
74 // static.
75 void AnimationRegistrar::Unregister(
76 LayerAnimationController* controller,
77 AnimationRegistrar::ThreadName thread_name) {
78 AnimationControllerSet& controllers = getControllers(thread_name, false);
79 if (ContainsKey(controllers, controller))
80 controllers.erase(controller);
81
82 // An unregistered controller cannot be active.
83 Deactivate(controller, thread_name);
84 }
85
86 // static.
87 const AnimationRegistrar::AnimationControllerSet&
88 AnimationRegistrar::GetAllControllers(
89 AnimationRegistrar::ThreadName thread_name) {
90 return getControllers(thread_name, false);
91 }
92
93
94 } // namespace cc
OLDNEW
« cc/animation_registrar.h ('K') | « cc/animation_registrar.h ('k') | cc/cc.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698