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

Unified Diff: cc/animation/animation_host_perftest.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: Do not change SetNeedsCommit invalidation, leave it as-is. Created 4 years, 3 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
« no previous file with comments | « cc/animation/animation_host.cc ('k') | cc/animation/animation_player.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/animation/animation_host_perftest.cc
diff --git a/cc/animation/animation_host_perftest.cc b/cc/animation/animation_host_perftest.cc
index 3d43ff69450bb3597a3af5908a4f3236893c535a..ca20b3ed23454ebeea3b5df7d5e3748ab1b967f0 100644
--- a/cc/animation/animation_host_perftest.cc
+++ b/cc/animation/animation_host_perftest.cc
@@ -23,6 +23,13 @@ namespace cc {
class AnimationHostPerfTest : public testing::Test {
protected:
+ AnimationHostPerfTest()
+ : root_layer_impl_(),
+ first_timeline_id_(),
+ last_timeline_id_(),
+ first_player_id_(),
+ last_player_id_() {}
+
void SetUp() override {
LayerTreeSettings settings;
layer_tree_host_ =
@@ -52,12 +59,12 @@ class AnimationHostPerfTest : public testing::Test {
}
void CreatePlayers(const int num_players) {
- scoped_refptr<AnimationTimeline> timeline =
+ all_players_timeline_ =
AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
- host()->AddAnimationTimeline(timeline);
+ host()->AddAnimationTimeline(all_players_timeline_);
- const int first_player_id = AnimationIdProvider::NextPlayerId();
- int last_player_id = first_player_id;
+ first_player_id_ = AnimationIdProvider::NextPlayerId();
+ last_player_id_ = first_player_id_;
for (int i = 0; i < num_players; ++i) {
scoped_refptr<Layer> layer = Layer::Create();
@@ -65,10 +72,10 @@ class AnimationHostPerfTest : public testing::Test {
layer->SetElementId(LayerIdToElementIdForTesting(layer->id()));
scoped_refptr<AnimationPlayer> player =
- AnimationPlayer::Create(last_player_id);
- last_player_id = AnimationIdProvider::NextPlayerId();
+ AnimationPlayer::Create(last_player_id_);
+ last_player_id_ = AnimationIdProvider::NextPlayerId();
- timeline->AttachPlayer(player);
+ all_players_timeline_->AttachPlayer(player);
player->AttachElement(layer->element_id());
EXPECT_TRUE(player->element_animations());
}
@@ -78,20 +85,20 @@ class AnimationHostPerfTest : public testing::Test {
// Check impl instances created.
scoped_refptr<AnimationTimeline> timeline_impl =
- host_impl()->GetTimelineById(timeline->id());
+ host_impl()->GetTimelineById(all_players_timeline_->id());
EXPECT_TRUE(timeline_impl);
- for (int i = first_player_id; i < last_player_id; ++i)
+ for (int i = first_player_id_; i < last_player_id_; ++i)
EXPECT_TRUE(timeline_impl->GetPlayerById(i));
}
void CreateTimelines(const int num_timelines) {
- const int first_timeline_id = AnimationIdProvider::NextTimelineId();
- int last_timeline_id = first_timeline_id;
+ first_timeline_id_ = AnimationIdProvider::NextTimelineId();
+ last_timeline_id_ = first_timeline_id_;
for (int i = 0; i < num_timelines; ++i) {
scoped_refptr<AnimationTimeline> timeline =
- AnimationTimeline::Create(last_timeline_id);
- last_timeline_id = AnimationIdProvider::NextTimelineId();
+ AnimationTimeline::Create(last_timeline_id_);
+ last_timeline_id_ = AnimationIdProvider::NextTimelineId();
host()->AddAnimationTimeline(timeline);
}
@@ -99,13 +106,26 @@ class AnimationHostPerfTest : public testing::Test {
layer_tree_host_->CommitAndCreateLayerImplTree();
// Check impl instances created.
- for (int i = first_timeline_id; i < last_timeline_id; ++i)
+ for (int i = first_timeline_id_; i < last_timeline_id_; ++i)
EXPECT_TRUE(host_impl()->GetTimelineById(i));
}
+ void SetAllTimelinesNeedPushProperties() const {
+ for (int i = first_timeline_id_; i < last_timeline_id_; ++i)
+ host_impl()->GetTimelineById(i)->SetNeedsPushProperties();
+ }
+
+ void SetAllPlayersNeedPushProperties() const {
+ for (int i = first_player_id_; i < last_player_id_; ++i)
+ all_players_timeline_->GetPlayerById(i)->SetNeedsPushProperties();
+ }
+
void DoTest() {
timer_.Reset();
do {
+ // Invalidate dirty flags.
+ SetAllTimelinesNeedPushProperties();
+ SetAllPlayersNeedPushProperties();
host()->PushPropertiesTo(host_impl());
timer_.NextLap();
} while (!timer_.HasTimeLimitExpired());
@@ -114,12 +134,19 @@ class AnimationHostPerfTest : public testing::Test {
"runs/s", true);
}
- protected:
+ private:
StubLayerTreeHostSingleThreadClient single_thread_client_;
FakeLayerTreeHostClient fake_client_;
std::unique_ptr<FakeLayerTreeHost> layer_tree_host_;
scoped_refptr<Layer> root_layer_;
LayerImpl* root_layer_impl_;
+ scoped_refptr<AnimationTimeline> all_players_timeline_;
+
+ int first_timeline_id_;
+ int last_timeline_id_;
+
+ int first_player_id_;
+ int last_player_id_;
LapTimer timer_;
TestTaskGraphRunner task_graph_runner_;
« no previous file with comments | « cc/animation/animation_host.cc ('k') | cc/animation/animation_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698