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

Unified Diff: ui/compositor/layer_animator_collection.cc

Issue 427103002: compositor: Add rAF-like functionality for the UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« ui/compositor/compositor.cc ('K') | « ui/compositor/layer_animator_collection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer_animator_collection.cc
diff --git a/ui/compositor/layer_animator_collection.cc b/ui/compositor/layer_animator_collection.cc
index 12142d88827175352af7545b0924940c5ff6eaa4..0e0fc05b43fb38b8204dc09a4416664ef7233490 100644
--- a/ui/compositor/layer_animator_collection.cc
+++ b/ui/compositor/layer_animator_collection.cc
@@ -13,9 +13,8 @@
namespace ui {
LayerAnimatorCollection::LayerAnimatorCollection(
- LayerAnimatorCollectionDelegate* delegate)
- : delegate_(delegate),
- last_tick_time_(gfx::FrameTime::Now()) {
+ AnimationFrameTaskProvider* provider)
+ : provider_(provider), last_tick_time_(gfx::FrameTime::Now()) {
}
LayerAnimatorCollection::~LayerAnimatorCollection() {
@@ -27,21 +26,24 @@ void LayerAnimatorCollection::StartAnimator(
if (!animators_.size())
last_tick_time_ = gfx::FrameTime::Now();
animators_.insert(animator);
- if (delegate_)
- delegate_->ScheduleAnimationForLayerCollection();
+ if (!raf_callback_ && provider_)
+ raf_callback_ = provider_->RequestAnimationFrameTask(this);
}
void LayerAnimatorCollection::StopAnimator(
scoped_refptr<LayerAnimator> animator) {
DCHECK_GT(animators_.count(animator), 0U);
animators_.erase(animator);
+ if (animators_.empty() && raf_callback_)
+ raf_callback_.reset();
}
bool LayerAnimatorCollection::HasActiveAnimators() const {
return !animators_.empty();
}
-void LayerAnimatorCollection::Progress(base::TimeTicks now) {
+AnimationFrameTaskStatus LayerAnimatorCollection::Progress(
+ base::TimeTicks now) {
last_tick_time_ = now;
std::set<scoped_refptr<LayerAnimator> > list = animators_;
for (std::set<scoped_refptr<LayerAnimator> >::iterator iter = list.begin();
@@ -51,6 +53,8 @@ void LayerAnimatorCollection::Progress(base::TimeTicks now) {
if (animators_.count(*iter) > 0)
(*iter)->Step(now);
}
+ return HasActiveAnimators() ? ANIMATION_FRAME_TASK_CONTINUE
+ : ANIMATION_FRAME_TASK_END;
}
} // namespace ui
« ui/compositor/compositor.cc ('K') | « ui/compositor/layer_animator_collection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698