Index: cc/trees/layer_tree_host_unittest_animation.cc |
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc |
index 011c0e76099c356e9e48e3c5c2521d8bbc839fee..a75f6c4b32482be48e49e58df36c0681b0d14851 100644 |
--- a/cc/trees/layer_tree_host_unittest_animation.cc |
+++ b/cc/trees/layer_tree_host_unittest_animation.cc |
@@ -44,6 +44,7 @@ class LayerTreeHostAnimationTest : public LayerTreeTest { |
void AttachPlayersToTimeline() { |
layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
+ layer_tree_host()->SetElementIdsForTesting(); |
timeline_->AttachPlayer(player_.get()); |
timeline_->AttachPlayer(player_child_.get()); |
} |
@@ -145,7 +146,7 @@ class LayerTreeHostAnimationTestAddAnimation |
void BeginTest() override { |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
} |
@@ -186,7 +187,7 @@ class LayerTreeHostAnimationTestCheckerboardDoesNotStarveDraws |
void BeginTest() override { |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
PostAddAnimationToMainThreadPlayer(player_.get()); |
} |
@@ -224,7 +225,7 @@ class LayerTreeHostAnimationTestAnimationsGetDeleted |
void BeginTest() override { |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
PostAddAnimationToMainThreadPlayer(player_.get()); |
} |
@@ -270,7 +271,7 @@ class LayerTreeHostAnimationTestAddAnimationWithTimingFunction |
layer_tree_host()->root_layer()->AddChild(picture_); |
AttachPlayersToTimeline(); |
- player_child_->AttachElement(picture_->id()); |
+ player_child_->AttachElement(picture_->element_id()); |
} |
void BeginTest() override { |
@@ -336,7 +337,7 @@ class LayerTreeHostAnimationTestSynchronizeAnimationStartTimes |
AttachPlayersToTimeline(); |
player_child_->set_animation_delegate(this); |
- player_child_->AttachElement(picture_->id()); |
+ player_child_->AttachElement(picture_->element_id()); |
} |
void BeginTest() override { |
@@ -390,7 +391,7 @@ class LayerTreeHostAnimationTestAnimationFinishedEvents |
public: |
void BeginTest() override { |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
PostAddInstantAnimationToMainThreadPlayer(player_.get()); |
} |
@@ -426,7 +427,7 @@ class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity |
LayerTreeHostAnimationTest::SetupTree(); |
AttachPlayersToTimeline(); |
- player_->AttachElement(update_check_layer_->id()); |
+ player_->AttachElement(update_check_layer_->element_id()); |
} |
void BeginTest() override { |
@@ -474,7 +475,8 @@ class LayerTreeHostAnimationTestLayerAddedWithAnimation |
AttachPlayersToTimeline(); |
scoped_refptr<Layer> layer = Layer::Create(); |
- player_->AttachElement(layer->id()); |
+ layer->SetElementId(ElementId(42, 0)); |
+ player_->AttachElement(layer->element_id()); |
player_->set_animation_delegate(this); |
// Any valid AnimationCurve will do here. |
@@ -625,7 +627,7 @@ class LayerTreeHostAnimationTestCheckerboardDoesntStartAnimations |
layer_tree_host()->root_layer()->AddChild(picture_); |
AttachPlayersToTimeline(); |
- player_child_->AttachElement(picture_->id()); |
+ player_child_->AttachElement(picture_->element_id()); |
player_child_->set_animation_delegate(this); |
} |
@@ -714,7 +716,7 @@ class LayerTreeHostAnimationTestScrollOffsetChangesArePropagated |
layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
AttachPlayersToTimeline(); |
- player_child_->AttachElement(scroll_layer_->id()); |
+ player_child_->AttachElement(scroll_layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
@@ -772,7 +774,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationTakeover |
layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
AttachPlayersToTimeline(); |
- player_child_->AttachElement(scroll_layer_->id()); |
+ player_child_->AttachElement(scroll_layer_->element_id()); |
// Allows NotifyAnimationTakeover to get called. |
player_child_->set_animation_delegate(this); |
} |
@@ -786,7 +788,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationTakeover |
layer_tree_host() |
->animation_host() |
->scroll_offset_animations() |
- .AddTakeoverUpdate(scroll_layer_->id()); |
+ .AddTakeoverUpdate(scroll_layer_->element_id()); |
EXPECT_TRUE(layer_tree_host() |
->animation_host() |
->scroll_offset_animations() |
@@ -797,7 +799,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationTakeover |
void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
if (host_impl->sync_tree()->source_frame_number() == 0) { |
host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
- scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), |
+ scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f), |
gfx::ScrollOffset(10, 20)); |
} |
} |
@@ -835,7 +837,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted |
layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
AttachPlayersToTimeline(); |
- player_child_->AttachElement(scroll_layer_->id()); |
+ player_child_->AttachElement(scroll_layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
@@ -847,7 +849,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted |
layer_tree_host() |
->animation_host() |
->scroll_offset_animations() |
- .AddAdjustmentUpdate(scroll_layer_->id(), |
+ .AddAdjustmentUpdate(scroll_layer_->element_id(), |
gfx::Vector2dF(100.f, 100.f)); |
EXPECT_TRUE(layer_tree_host() |
->animation_host() |
@@ -870,7 +872,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted |
// WillCommitCompleteOnThread. |
Animation* animation = |
host_impl->animation_host() |
- ->GetElementAnimationsForElementId(scroll_layer_->id()) |
+ ->GetElementAnimationsForElementId(scroll_layer_->element_id()) |
->GetAnimation(TargetProperty::SCROLL_OFFSET); |
ScrollOffsetAnimationCurve* curve = |
animation->curve()->ToScrollOffsetAnimationCurve(); |
@@ -887,7 +889,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted |
void WillCommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
if (host_impl->sync_tree()->source_frame_number() == 0) { |
host_impl->animation_host()->ImplOnlyScrollAnimationCreate( |
- scroll_layer_->id(), gfx::ScrollOffset(650.f, 750.f), |
+ scroll_layer_->element_id(), gfx::ScrollOffset(650.f, 750.f), |
gfx::ScrollOffset(10, 20)); |
} |
} |
@@ -896,7 +898,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationAdjusted |
if (host_impl->sync_tree()->source_frame_number() == 1) { |
Animation* animation = |
host_impl->animation_host() |
- ->GetElementAnimationsForElementId(scroll_layer_->id()) |
+ ->GetElementAnimationsForElementId(scroll_layer_->element_id()) |
->GetAnimation(TargetProperty::SCROLL_OFFSET); |
ScrollOffsetAnimationCurve* curve = |
animation->curve()->ToScrollOffsetAnimationCurve(); |
@@ -950,7 +952,7 @@ class LayerTreeHostAnimationTestScrollOffsetAnimationRemoval |
animation->set_needs_synchronized_start_time(true); |
AttachPlayersToTimeline(); |
- player_child_->AttachElement(scroll_layer_->id()); |
+ player_child_->AttachElement(scroll_layer_->element_id()); |
player_child_->AddAnimation(std::move(animation)); |
} |
@@ -1058,16 +1060,18 @@ class LayerTreeHostAnimationTestAnimationsAddedToNewAndExistingLayers |
void DidCommit() override { |
if (layer_tree_host()->source_frame_number() == 1) { |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
AddAnimatedTransformToPlayer(player_.get(), 4, 1, 1); |
} else if (layer_tree_host()->source_frame_number() == 2) { |
AddOpacityTransitionToPlayer(player_.get(), 1, 0.f, 0.5f, true); |
scoped_refptr<Layer> layer = Layer::Create(); |
layer_tree_host()->root_layer()->AddChild(layer); |
+ |
+ layer_tree_host()->SetElementIdsForTesting(); |
layer->SetBounds(gfx::Size(4, 4)); |
- player_child_->AttachElement(layer->id()); |
+ player_child_->AttachElement(layer->element_id()); |
player_child_->set_animation_delegate(this); |
AddOpacityTransitionToPlayer(player_child_.get(), 1, 0.f, 0.5f, true); |
} |
@@ -1155,7 +1159,9 @@ class LayerTreeHostAnimationTestPendingTreeAnimatesFirstCommit |
layer_->SetTransform(start_transform); |
layer_tree_host()->root_layer()->AddChild(layer_); |
- player_->AttachElement(layer_->id()); |
+ layer_tree_host()->SetElementIdsForTesting(); |
+ |
+ player_->AttachElement(layer_->element_id()); |
AttachPlayersToTimeline(); |
} |
@@ -1225,9 +1231,11 @@ class LayerTreeHostAnimationTestAnimatedLayerRemovedAndAdded |
layer_->SetBounds(gfx::Size(4, 4)); |
layer_tree_host()->root_layer()->AddChild(layer_); |
+ layer_tree_host()->SetElementIdsForTesting(); |
+ |
layer_tree_host()->animation_host()->AddAnimationTimeline(timeline_.get()); |
timeline_->AttachPlayer(player_.get()); |
- player_->AttachElement(layer_->id()); |
+ player_->AttachElement(layer_->element_id()); |
DCHECK(player_->element_animations()); |
AddOpacityTransitionToPlayer(player_.get(), 10000.0, 0.1f, 0.9f, true); |
@@ -1309,8 +1317,8 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
- player_child_->AttachElement(layer_->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
+ player_child_->AttachElement(layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
@@ -1338,11 +1346,12 @@ class LayerTreeHostAnimationTestAddAnimationAfterAnimating |
host_impl->animation_host()->active_element_animations_for_testing(); |
EXPECT_EQ(2u, element_animations_copy.size()); |
for (auto& it : element_animations_copy) { |
- int id = it.first; |
- if (id == host_impl->active_tree()->root_layer_for_testing()->id()) { |
+ ElementId id = it.first; |
+ if (id == |
+ host_impl->active_tree()->root_layer_for_testing()->element_id()) { |
Animation* anim = it.second->GetAnimation(TargetProperty::TRANSFORM); |
EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
- } else if (id == layer_->id()) { |
+ } else if (id == layer_->element_id()) { |
Animation* anim = it.second->GetAnimation(TargetProperty::OPACITY); |
EXPECT_GT((anim->start_time() - base::TimeTicks()).InSecondsF(), 0); |
} |
@@ -1371,8 +1380,8 @@ class LayerTreeHostAnimationTestRemoveAnimation |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
- player_child_->AttachElement(layer_->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
+ player_child_->AttachElement(layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
@@ -1450,7 +1459,7 @@ class LayerTreeHostAnimationTestIsAnimating |
layer_tree_host()->root_layer()->AddChild(layer_); |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_->id()); |
+ player_->AttachElement(layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
@@ -1532,8 +1541,8 @@ class LayerTreeHostAnimationTestAnimationFinishesDuringCommit |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
- player_child_->AttachElement(layer_->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
+ player_child_->AttachElement(layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
@@ -1606,7 +1615,7 @@ class LayerTreeHostAnimationTestNotifyAnimationFinished |
layer_tree_host()->root_layer()->AddChild(picture_); |
AttachPlayersToTimeline(); |
- player_->AttachElement(picture_->id()); |
+ player_->AttachElement(picture_->element_id()); |
player_->set_animation_delegate(this); |
} |
@@ -1654,7 +1663,7 @@ class LayerTreeHostAnimationTestChangeAnimationPlayer |
LayerTreeHostAnimationTest::SetupTree(); |
AttachPlayersToTimeline(); |
timeline_->DetachPlayer(player_child_.get()); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
TransformOperations start; |
start.AppendTranslate(5.f, 5.f, 0.f); |
@@ -1691,7 +1700,8 @@ class LayerTreeHostAnimationTestChangeAnimationPlayer |
timeline_->DetachPlayer(player_.get()); |
player_ = nullptr; |
timeline_->AttachPlayer(player_child_.get()); |
- player_child_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_child_->AttachElement( |
+ layer_tree_host()->root_layer()->element_id()); |
AddAnimatedTransformToPlayer(player_child_.get(), 1.0, 10, 10); |
Animation* animation = player_child_->element_animations()->GetAnimation( |
TargetProperty::TRANSFORM); |
@@ -1717,7 +1727,7 @@ class LayerTreeHostAnimationTestSetPotentiallyAnimatingOnLacDestruction |
LayerTreeHostAnimationTest::SetupTree(); |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
AddAnimatedTransformToPlayer(player_.get(), 1.0, 5, 5); |
} |
@@ -1801,8 +1811,8 @@ class LayerTreeHostAnimationTestRebuildPropertyTreesOnAnimationSetNeedsCommit |
AttachPlayersToTimeline(); |
- player_->AttachElement(layer_tree_host()->root_layer()->id()); |
- player_child_->AttachElement(layer_->id()); |
+ player_->AttachElement(layer_tree_host()->root_layer()->element_id()); |
+ player_child_->AttachElement(layer_->element_id()); |
} |
void BeginTest() override { PostSetNeedsCommitToMainThread(); } |