| Index: cc/trees/layer_tree_host_unittest_picture.cc
|
| diff --git a/cc/trees/layer_tree_host_unittest_picture.cc b/cc/trees/layer_tree_host_unittest_picture.cc
|
| index c41a25259cd2bcf41472ca67d66cb6ad841afab5..319e609aef7478897865941acb6fbc749e6b89d1 100644
|
| --- a/cc/trees/layer_tree_host_unittest_picture.cc
|
| +++ b/cc/trees/layer_tree_host_unittest_picture.cc
|
| @@ -36,6 +36,8 @@ class LayerTreeHostPictureTestTwinLayer
|
| : public LayerTreeHostPictureTest {
|
| void SetupTree() override {
|
| SetupTreeWithSinglePictureLayer(gfx::Size(1, 1));
|
| + picture_id1_ = root_picture_layer_->id();
|
| + picture_id2_ = -1;
|
| }
|
|
|
| void BeginTest() override {
|
| @@ -52,13 +54,14 @@ class LayerTreeHostPictureTestTwinLayer
|
| case 2:
|
| // Drop the picture layer from the tree so the activate will have an
|
| // active layer without a pending twin.
|
| - layer_tree_host()->root_layer()->children()[0]->RemoveFromParent();
|
| + root_picture_layer_->RemoveFromParent();
|
| break;
|
| case 3: {
|
| // Add a new picture layer so the activate will have a pending layer
|
| // without an active twin.
|
| scoped_refptr<FakePictureLayer> picture =
|
| FakePictureLayer::Create(&client_);
|
| + picture_id2_ = picture->id();
|
| layer_tree_host()->root_layer()->AddChild(picture);
|
| break;
|
| }
|
| @@ -73,16 +76,19 @@ class LayerTreeHostPictureTestTwinLayer
|
| }
|
|
|
| void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* pending_root_impl = impl->pending_tree()->root_layer();
|
| LayerImpl* active_root_impl = impl->active_tree()->root_layer();
|
| + int picture_id = impl->active_tree()->source_frame_number() < 2
|
| + ? picture_id1_
|
| + : picture_id2_;
|
|
|
| - if (pending_root_impl->children().empty()) {
|
| + if (!impl->pending_tree()->LayerById(picture_id)) {
|
| EXPECT_EQ(2, activates_);
|
| return;
|
| }
|
|
|
| FakePictureLayerImpl* pending_picture_impl =
|
| - static_cast<FakePictureLayerImpl*>(pending_root_impl->children()[0]);
|
| + static_cast<FakePictureLayerImpl*>(
|
| + impl->pending_tree()->LayerById(picture_id));
|
|
|
| if (!active_root_impl) {
|
| EXPECT_EQ(0, activates_);
|
| @@ -90,14 +96,15 @@ class LayerTreeHostPictureTestTwinLayer
|
| return;
|
| }
|
|
|
| - if (active_root_impl->children().empty()) {
|
| + if (!impl->active_tree()->LayerById(picture_id)) {
|
| EXPECT_EQ(3, activates_);
|
| EXPECT_EQ(nullptr, pending_picture_impl->GetPendingOrActiveTwinLayer());
|
| return;
|
| }
|
|
|
| FakePictureLayerImpl* active_picture_impl =
|
| - static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]);
|
| + static_cast<FakePictureLayerImpl*>(
|
| + impl->active_tree()->LayerById(picture_id));
|
|
|
| // After the first activation, when we commit again, we'll have a pending
|
| // and active layer. Then we recreate a picture layer in the 4th activate
|
| @@ -111,12 +118,15 @@ class LayerTreeHostPictureTestTwinLayer
|
| }
|
|
|
| void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* active_root_impl = impl->active_tree()->root_layer();
|
| - if (active_root_impl->children().empty()) {
|
| + int picture_id = impl->active_tree()->source_frame_number() < 3
|
| + ? picture_id1_
|
| + : picture_id2_;
|
| + if (!impl->active_tree()->LayerById(picture_id)) {
|
| EXPECT_EQ(2, activates_);
|
| } else {
|
| FakePictureLayerImpl* active_picture_impl =
|
| - static_cast<FakePictureLayerImpl*>(active_root_impl->children()[0]);
|
| + static_cast<FakePictureLayerImpl*>(
|
| + impl->active_tree()->LayerById(picture_id));
|
| EXPECT_EQ(nullptr, active_picture_impl->GetPendingOrActiveTwinLayer());
|
| }
|
|
|
| @@ -126,6 +136,8 @@ class LayerTreeHostPictureTestTwinLayer
|
| void AfterTest() override { EXPECT_EQ(5, activates_); }
|
|
|
| int activates_;
|
| + int picture_id1_;
|
| + int picture_id2_;
|
| };
|
|
|
| // There is no pending layers in single thread mode.
|
| @@ -153,7 +165,7 @@ class LayerTreeHostPictureTestResizeViewportWithGpuRaster
|
| void BeginTest() override { PostSetNeedsCommitToMainThread(); }
|
|
|
| void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* child = impl->sync_tree()->root_layer()->children()[0];
|
| + LayerImpl* child = impl->sync_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture_impl =
|
| static_cast<FakePictureLayerImpl*>(child);
|
| gfx::Size tile_size =
|
| @@ -222,7 +234,7 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
|
| void BeginTest() override { PostSetNeedsCommitToMainThread(); }
|
|
|
| void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* child = impl->active_tree()->root_layer()->children()[0];
|
| + LayerImpl* child = impl->active_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture_impl =
|
| static_cast<FakePictureLayerImpl*>(child);
|
| switch (++frame_) {
|
| @@ -271,7 +283,7 @@ class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree
|
| }
|
|
|
| void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* child = impl->sync_tree()->root_layer()->children()[0];
|
| + LayerImpl* child = impl->sync_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture_impl =
|
| static_cast<FakePictureLayerImpl*>(child);
|
| PictureLayerTiling* tiling = picture_impl->HighResTiling();
|
| @@ -325,9 +337,7 @@ class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest {
|
| void BeginTest() override { PostSetNeedsCommitToMainThread(); }
|
|
|
| void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* root = impl->sync_tree()->root_layer();
|
| - LayerImpl* child = root->children()[0];
|
| - LayerImpl* gchild = child->children()[0];
|
| + LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild);
|
|
|
| switch (impl->sync_tree()->source_frame_number()) {
|
| @@ -347,9 +357,7 @@ class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest {
|
| }
|
|
|
| void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* root = impl->active_tree()->root_layer();
|
| - LayerImpl* child = root->children()[0];
|
| - LayerImpl* gchild = child->children()[0];
|
| + LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild);
|
|
|
| switch (impl->active_tree()->source_frame_number()) {
|
| @@ -434,9 +442,7 @@ class LayerTreeHostPictureTestRSLLMembershipWithScale
|
| }
|
|
|
| void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* root = impl->sync_tree()->root_layer();
|
| - LayerImpl* pinch = root->children()[0]->children()[0];
|
| - LayerImpl* gchild = pinch->children()[0];
|
| + LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild);
|
| ready_to_draw_ = false;
|
|
|
| @@ -461,9 +467,7 @@ class LayerTreeHostPictureTestRSLLMembershipWithScale
|
| }
|
|
|
| void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
|
| - LayerImpl* root = impl->active_tree()->root_layer();
|
| - LayerImpl* pinch = root->children()[0]->children()[0];
|
| - LayerImpl* gchild = pinch->children()[0];
|
| + LayerImpl* gchild = impl->active_tree()->LayerById(picture_->id());
|
| FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild);
|
|
|
| if (frame_ != last_frame_drawn_)
|
|
|