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

Side by Side Diff: ui/compositor/layer_animator_collection.cc

Issue 291843012: compositor: Tick the UI animations from cc, instead of from timer callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "ui/compositor/layer_animator_collection.h"
6
7 #include <set>
8
9 #include "base/lazy_instance.h"
10 #include "base/time/time.h"
11 #include "ui/compositor/layer_animator.h"
12 #include "ui/gfx/frame_time.h"
13
14 namespace ui {
15
16 namespace {
17
18 base::LazyInstance<LayerAnimatorCollection>::Leaky g_lazy_instance;
19 }
20
21 // static
22 LayerAnimatorCollection* LayerAnimatorCollection::GetInstance() {
23 return g_lazy_instance.Pointer();
24 }
25
26 void LayerAnimatorCollection::StartAnimator(
27 scoped_refptr<LayerAnimator> animator) {
28 if (!animators_.size())
29 last_tick_time_ = gfx::FrameTime::Now();
30 animators_.insert(animator);
31 }
32
33 void LayerAnimatorCollection::StopAnimator(
34 scoped_refptr<LayerAnimator> animator) {
35 DCHECK_GT(animators_.count(animator), 0U);
36 animators_.erase(animator);
37 }
38
39 bool LayerAnimatorCollection::HasActiveAnimators() const {
40 return !animators_.empty();
41 }
42
43 void LayerAnimatorCollection::Progress(base::TimeTicks now) {
44 std::set<scoped_refptr<LayerAnimator> > list = animators_;
45 for (std::set<scoped_refptr<LayerAnimator> >::iterator iter = list.begin();
46 iter != list.end();
47 ++iter) {
48 // Make sure the animator is still valid.
49 if (animators_.count(*iter) > 0)
50 (*iter)->Step(now);
51 }
52 last_tick_time_ = now;
53 }
54
55 // private:
56 LayerAnimatorCollection::LayerAnimatorCollection()
57 : last_tick_time_(gfx::FrameTime::Now()) {
58 }
59
60 LayerAnimatorCollection::~LayerAnimatorCollection() {
61 }
62
63 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698