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

Unified Diff: cc/animation/animation_timeline.cc

Issue 2261113002: CC Animation: Introduce some dirty flags to optimize PushProperties on commit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
Index: cc/animation/animation_timeline.cc
diff --git a/cc/animation/animation_timeline.cc b/cc/animation/animation_timeline.cc
index 5b2b10653f03bc27a1682b0892057291220ceb7d..a1877160db6f826c43d4142cfdb80df3cbe9d7c3 100644
--- a/cc/animation/animation_timeline.cc
+++ b/cc/animation/animation_timeline.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "cc/animation/animation_host.h"
#include "cc/animation/animation_player.h"
namespace cc {
@@ -15,8 +16,10 @@ scoped_refptr<AnimationTimeline> AnimationTimeline::Create(int id) {
}
AnimationTimeline::AnimationTimeline(int id)
- : id_(id), animation_host_(), is_impl_only_(false) {
-}
+ : id_(id),
+ animation_host_(),
+ needs_push_properties_(false),
+ is_impl_only_(false) {}
AnimationTimeline::~AnimationTimeline() {
for (auto& kv : id_to_player_map_)
@@ -32,6 +35,9 @@ void AnimationTimeline::SetAnimationHost(AnimationHost* animation_host) {
animation_host_ = animation_host;
for (auto& kv : id_to_player_map_)
kv.second->SetAnimationHost(animation_host);
+
+ if (needs_push_properties() && animation_host_)
+ SetNeedsPushProperties();
}
void AnimationTimeline::AttachPlayer(scoped_refptr<AnimationPlayer> player) {
@@ -39,12 +45,16 @@ void AnimationTimeline::AttachPlayer(scoped_refptr<AnimationPlayer> player) {
player->SetAnimationHost(animation_host_);
player->SetAnimationTimeline(this);
id_to_player_map_.insert(std::make_pair(player->id(), std::move(player)));
+
+ SetNeedsPushProperties();
}
void AnimationTimeline::DetachPlayer(scoped_refptr<AnimationPlayer> player) {
DCHECK(player->id());
ErasePlayer(player);
id_to_player_map_.erase(player->id());
+
+ SetNeedsPushProperties();
}
AnimationPlayer* AnimationTimeline::GetPlayerById(int player_id) const {
@@ -56,12 +66,23 @@ void AnimationTimeline::ClearPlayers() {
for (auto& kv : id_to_player_map_)
ErasePlayer(kv.second);
id_to_player_map_.clear();
+
+ SetNeedsPushProperties();
+}
+
+void AnimationTimeline::SetNeedsPushProperties() {
+ needs_push_properties_ = true;
+ if (animation_host_)
+ animation_host_->SetNeedsPushProperties();
}
void AnimationTimeline::PushPropertiesTo(AnimationTimeline* timeline_impl) {
- PushAttachedPlayersToImplThread(timeline_impl);
- RemoveDetachedPlayersFromImplThread(timeline_impl);
- PushPropertiesToImplThread(timeline_impl);
+ if (needs_push_properties_) {
+ needs_push_properties_ = false;
+ PushAttachedPlayersToImplThread(timeline_impl);
+ RemoveDetachedPlayersFromImplThread(timeline_impl);
+ PushPropertiesToImplThread(timeline_impl);
+ }
}
void AnimationTimeline::PushAttachedPlayersToImplThread(
@@ -103,9 +124,11 @@ void AnimationTimeline::PushPropertiesToImplThread(
AnimationTimeline* timeline_impl) {
for (auto& kv : id_to_player_map_) {
AnimationPlayer* player = kv.second.get();
- AnimationPlayer* player_impl = timeline_impl->GetPlayerById(player->id());
- if (player_impl)
- player->PushPropertiesTo(player_impl);
+ if (player->needs_push_properties()) {
+ AnimationPlayer* player_impl = timeline_impl->GetPlayerById(player->id());
+ if (player_impl)
+ player->PushPropertiesTo(player_impl);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698