Chromium Code Reviews| 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..2c26be1c656677899ee029e5cb9c8b83a31e01fe 100644 |
| --- a/cc/trees/layer_tree_host_unittest_picture.cc |
| +++ b/cc/trees/layer_tree_host_unittest_picture.cc |
| @@ -36,6 +36,7 @@ class LayerTreeHostPictureTestTwinLayer |
| : public LayerTreeHostPictureTest { |
| void SetupTree() override { |
| SetupTreeWithSinglePictureLayer(gfx::Size(1, 1)); |
| + picture_id = root_picture_layer_->id(); |
| } |
| void BeginTest() override { |
| @@ -52,13 +53,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_id = picture->id(); |
|
ajuma
2016/04/20 21:40:52
Changing picture_id on the main thread will access
sunxd
2016/04/21 17:31:16
Done.
|
| layer_tree_host()->root_layer()->AddChild(picture); |
| break; |
| } |
| @@ -73,16 +75,16 @@ 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(); |
| - 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 +92,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 +114,12 @@ class LayerTreeHostPictureTestTwinLayer |
| } |
| void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| - LayerImpl* active_root_impl = impl->active_tree()->root_layer(); |
| - if (active_root_impl->children().empty()) { |
| + 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 +129,7 @@ class LayerTreeHostPictureTestTwinLayer |
| void AfterTest() override { EXPECT_EQ(5, activates_); } |
| int activates_; |
| + int picture_id; |
|
ajuma
2016/04/20 21:40:52
nit: picture_id_
sunxd
2016/04/21 17:31:16
Done.
|
| }; |
| // There is no pending layers in single thread mode. |
| @@ -153,7 +157,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 +226,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 +275,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 +329,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 +349,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 +434,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 +459,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_) |