| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include "cc/test/fake_content_layer_client.h" | 7 #include "cc/test/fake_content_layer_client.h" |
| 8 #include "cc/test/fake_picture_layer.h" | 8 #include "cc/test/fake_picture_layer.h" |
| 9 #include "cc/test/fake_picture_layer_impl.h" | 9 #include "cc/test/fake_picture_layer_impl.h" |
| 10 #include "cc/test/layer_tree_test.h" | 10 #include "cc/test/layer_tree_test.h" |
| 11 #include "cc/trees/layer_tree_impl.h" | 11 #include "cc/trees/layer_tree_impl.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 // These tests deal with picture layers. | 16 // These tests deal with picture layers. |
| 17 class LayerTreeHostPictureTest : public LayerTreeTest { | 17 class LayerTreeHostPictureTest : public LayerTreeTest { |
| 18 protected: | 18 protected: |
| 19 void SetupTreeWithSinglePictureLayer(const gfx::Size& size) { | 19 void SetupTreeWithSinglePictureLayer(const gfx::Size& size) { |
| 20 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 20 scoped_refptr<Layer> root = Layer::Create(); |
| 21 root->SetBounds(size); | 21 root->SetBounds(size); |
| 22 | 22 |
| 23 root_picture_layer_ = FakePictureLayer::Create(layer_settings(), &client_); | 23 root_picture_layer_ = FakePictureLayer::Create(&client_); |
| 24 root_picture_layer_->SetBounds(size); | 24 root_picture_layer_->SetBounds(size); |
| 25 root->AddChild(root_picture_layer_); | 25 root->AddChild(root_picture_layer_); |
| 26 | 26 |
| 27 layer_tree_host()->SetRootLayer(root); | 27 layer_tree_host()->SetRootLayer(root); |
| 28 client_.set_bounds(size); | 28 client_.set_bounds(size); |
| 29 } | 29 } |
| 30 | 30 |
| 31 scoped_refptr<FakePictureLayer> root_picture_layer_; | 31 scoped_refptr<FakePictureLayer> root_picture_layer_; |
| 32 FakeContentLayerClient client_; | 32 FakeContentLayerClient client_; |
| 33 }; | 33 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 51 break; | 51 break; |
| 52 case 2: | 52 case 2: |
| 53 // Drop the picture layer from the tree so the activate will have an | 53 // Drop the picture layer from the tree so the activate will have an |
| 54 // active layer without a pending twin. | 54 // active layer without a pending twin. |
| 55 layer_tree_host()->root_layer()->children()[0]->RemoveFromParent(); | 55 layer_tree_host()->root_layer()->children()[0]->RemoveFromParent(); |
| 56 break; | 56 break; |
| 57 case 3: { | 57 case 3: { |
| 58 // Add a new picture layer so the activate will have a pending layer | 58 // Add a new picture layer so the activate will have a pending layer |
| 59 // without an active twin. | 59 // without an active twin. |
| 60 scoped_refptr<FakePictureLayer> picture = | 60 scoped_refptr<FakePictureLayer> picture = |
| 61 FakePictureLayer::Create(layer_settings(), &client_); | 61 FakePictureLayer::Create(&client_); |
| 62 layer_tree_host()->root_layer()->AddChild(picture); | 62 layer_tree_host()->root_layer()->AddChild(picture); |
| 63 break; | 63 break; |
| 64 } | 64 } |
| 65 case 4: | 65 case 4: |
| 66 // Active while there are pending and active twins again. | 66 // Active while there are pending and active twins again. |
| 67 layer_tree_host()->SetNeedsCommit(); | 67 layer_tree_host()->SetNeedsCommit(); |
| 68 break; | 68 break; |
| 69 case 5: | 69 case 5: |
| 70 EndTest(); | 70 EndTest(); |
| 71 break; | 71 break; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // There is no pending layers in single thread mode. | 134 // There is no pending layers in single thread mode. |
| 135 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer); | 135 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestTwinLayer); |
| 136 | 136 |
| 137 class LayerTreeHostPictureTestResizeViewportWithGpuRaster | 137 class LayerTreeHostPictureTestResizeViewportWithGpuRaster |
| 138 : public LayerTreeHostPictureTest { | 138 : public LayerTreeHostPictureTest { |
| 139 void InitializeSettings(LayerTreeSettings* settings) override { | 139 void InitializeSettings(LayerTreeSettings* settings) override { |
| 140 settings->gpu_rasterization_forced = true; | 140 settings->gpu_rasterization_forced = true; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void SetupTree() override { | 143 void SetupTree() override { |
| 144 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 144 scoped_refptr<Layer> root = Layer::Create(); |
| 145 root->SetBounds(gfx::Size(768, 960)); | 145 root->SetBounds(gfx::Size(768, 960)); |
| 146 client_.set_bounds(root->bounds()); | 146 client_.set_bounds(root->bounds()); |
| 147 client_.set_fill_with_nonsolid_color(true); | 147 client_.set_fill_with_nonsolid_color(true); |
| 148 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 148 picture_ = FakePictureLayer::Create(&client_); |
| 149 picture_->SetBounds(gfx::Size(768, 960)); | 149 picture_->SetBounds(gfx::Size(768, 960)); |
| 150 root->AddChild(picture_); | 150 root->AddChild(picture_); |
| 151 | 151 |
| 152 layer_tree_host()->SetRootLayer(root); | 152 layer_tree_host()->SetRootLayer(root); |
| 153 LayerTreeHostPictureTest::SetupTree(); | 153 LayerTreeHostPictureTest::SetupTree(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 156 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 157 | 157 |
| 158 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 158 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 SINGLE_AND_MULTI_THREAD_TEST_F( | 198 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 199 LayerTreeHostPictureTestResizeViewportWithGpuRaster); | 199 LayerTreeHostPictureTestResizeViewportWithGpuRaster); |
| 200 | 200 |
| 201 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree | 201 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree |
| 202 : public LayerTreeHostPictureTest { | 202 : public LayerTreeHostPictureTest { |
| 203 void SetupTree() override { | 203 void SetupTree() override { |
| 204 frame_ = 0; | 204 frame_ = 0; |
| 205 did_post_commit_ = false; | 205 did_post_commit_ = false; |
| 206 | 206 |
| 207 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 207 scoped_refptr<Layer> root = Layer::Create(); |
| 208 root->SetBounds(gfx::Size(100, 100)); | 208 root->SetBounds(gfx::Size(100, 100)); |
| 209 // The layer is big enough that the live tiles rect won't cover the full | 209 // The layer is big enough that the live tiles rect won't cover the full |
| 210 // layer. | 210 // layer. |
| 211 client_.set_fill_with_nonsolid_color(true); | 211 client_.set_fill_with_nonsolid_color(true); |
| 212 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 212 picture_ = FakePictureLayer::Create(&client_); |
| 213 picture_->SetBounds(gfx::Size(100, 100000)); | 213 picture_->SetBounds(gfx::Size(100, 100000)); |
| 214 root->AddChild(picture_); | 214 root->AddChild(picture_); |
| 215 | 215 |
| 216 // picture_'s transform is going to be changing on the compositor thread, so | 216 // picture_'s transform is going to be changing on the compositor thread, so |
| 217 // force it to have a transform node by making it scrollable. | 217 // force it to have a transform node by making it scrollable. |
| 218 picture_->SetScrollClipLayerId(root->id()); | 218 picture_->SetScrollClipLayerId(root->id()); |
| 219 | 219 |
| 220 layer_tree_host()->SetRootLayer(root); | 220 layer_tree_host()->SetRootLayer(root); |
| 221 LayerTreeHostPictureTest::SetupTree(); | 221 LayerTreeHostPictureTest::SetupTree(); |
| 222 client_.set_bounds(picture_->bounds()); | 222 client_.set_bounds(picture_->bounds()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 bool did_post_commit_; | 301 bool did_post_commit_; |
| 302 FakeContentLayerClient client_; | 302 FakeContentLayerClient client_; |
| 303 scoped_refptr<FakePictureLayer> picture_; | 303 scoped_refptr<FakePictureLayer> picture_; |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 // Multi-thread only since there is no recycle tree in single thread. | 306 // Multi-thread only since there is no recycle tree in single thread. |
| 307 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); | 307 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); |
| 308 | 308 |
| 309 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { | 309 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { |
| 310 void SetupTree() override { | 310 void SetupTree() override { |
| 311 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 311 scoped_refptr<Layer> root = Layer::Create(); |
| 312 root->SetBounds(gfx::Size(100, 100)); | 312 root->SetBounds(gfx::Size(100, 100)); |
| 313 client_.set_bounds(root->bounds()); | 313 client_.set_bounds(root->bounds()); |
| 314 | 314 |
| 315 child_ = Layer::Create(layer_settings()); | 315 child_ = Layer::Create(); |
| 316 root->AddChild(child_); | 316 root->AddChild(child_); |
| 317 | 317 |
| 318 // Don't be solid color so the layer has tilings/tiles. | 318 // Don't be solid color so the layer has tilings/tiles. |
| 319 client_.set_fill_with_nonsolid_color(true); | 319 client_.set_fill_with_nonsolid_color(true); |
| 320 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 320 picture_ = FakePictureLayer::Create(&client_); |
| 321 picture_->SetBounds(gfx::Size(100, 100)); | 321 picture_->SetBounds(gfx::Size(100, 100)); |
| 322 child_->AddChild(picture_); | 322 child_->AddChild(picture_); |
| 323 | 323 |
| 324 layer_tree_host()->SetRootLayer(root); | 324 layer_tree_host()->SetRootLayer(root); |
| 325 LayerTreeHostPictureTest::SetupTree(); | 325 LayerTreeHostPictureTest::SetupTree(); |
| 326 } | 326 } |
| 327 | 327 |
| 328 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 328 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 329 | 329 |
| 330 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 330 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 FakeContentLayerClient client_; | 391 FakeContentLayerClient client_; |
| 392 scoped_refptr<Layer> child_; | 392 scoped_refptr<Layer> child_; |
| 393 scoped_refptr<FakePictureLayer> picture_; | 393 scoped_refptr<FakePictureLayer> picture_; |
| 394 }; | 394 }; |
| 395 | 395 |
| 396 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembership); | 396 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembership); |
| 397 | 397 |
| 398 class LayerTreeHostPictureTestRSLLMembershipWithScale | 398 class LayerTreeHostPictureTestRSLLMembershipWithScale |
| 399 : public LayerTreeHostPictureTest { | 399 : public LayerTreeHostPictureTest { |
| 400 void SetupTree() override { | 400 void SetupTree() override { |
| 401 scoped_refptr<Layer> root_clip = Layer::Create(layer_settings()); | 401 scoped_refptr<Layer> root_clip = Layer::Create(); |
| 402 root_clip->SetBounds(gfx::Size(100, 100)); | 402 root_clip->SetBounds(gfx::Size(100, 100)); |
| 403 scoped_refptr<Layer> page_scale_layer = Layer::Create(layer_settings()); | 403 scoped_refptr<Layer> page_scale_layer = Layer::Create(); |
| 404 page_scale_layer->SetBounds(gfx::Size(100, 100)); | 404 page_scale_layer->SetBounds(gfx::Size(100, 100)); |
| 405 | 405 |
| 406 pinch_ = Layer::Create(layer_settings()); | 406 pinch_ = Layer::Create(); |
| 407 pinch_->SetBounds(gfx::Size(500, 500)); | 407 pinch_->SetBounds(gfx::Size(500, 500)); |
| 408 pinch_->SetScrollClipLayerId(root_clip->id()); | 408 pinch_->SetScrollClipLayerId(root_clip->id()); |
| 409 pinch_->SetIsContainerForFixedPositionLayers(true); | 409 pinch_->SetIsContainerForFixedPositionLayers(true); |
| 410 page_scale_layer->AddChild(pinch_); | 410 page_scale_layer->AddChild(pinch_); |
| 411 root_clip->AddChild(page_scale_layer); | 411 root_clip->AddChild(page_scale_layer); |
| 412 | 412 |
| 413 // Don't be solid color so the layer has tilings/tiles. | 413 // Don't be solid color so the layer has tilings/tiles. |
| 414 client_.set_fill_with_nonsolid_color(true); | 414 client_.set_fill_with_nonsolid_color(true); |
| 415 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 415 picture_ = FakePictureLayer::Create(&client_); |
| 416 picture_->SetBounds(gfx::Size(100, 100)); | 416 picture_->SetBounds(gfx::Size(100, 100)); |
| 417 pinch_->AddChild(picture_); | 417 pinch_->AddChild(picture_); |
| 418 | 418 |
| 419 layer_tree_host()->RegisterViewportLayers(NULL, page_scale_layer, pinch_, | 419 layer_tree_host()->RegisterViewportLayers(NULL, page_scale_layer, pinch_, |
| 420 nullptr); | 420 nullptr); |
| 421 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 421 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
| 422 layer_tree_host()->SetRootLayer(root_clip); | 422 layer_tree_host()->SetRootLayer(root_clip); |
| 423 LayerTreeHostPictureTest::SetupTree(); | 423 LayerTreeHostPictureTest::SetupTree(); |
| 424 client_.set_bounds(picture_->bounds()); | 424 client_.set_bounds(picture_->bounds()); |
| 425 } | 425 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 int last_frame_drawn_; | 562 int last_frame_drawn_; |
| 563 bool ready_to_draw_; | 563 bool ready_to_draw_; |
| 564 }; | 564 }; |
| 565 | 565 |
| 566 // Multi-thread only because in single thread you can't pinch zoom on the | 566 // Multi-thread only because in single thread you can't pinch zoom on the |
| 567 // compositor thread. | 567 // compositor thread. |
| 568 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 568 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
| 569 | 569 |
| 570 } // namespace | 570 } // namespace |
| 571 } // namespace cc | 571 } // namespace cc |
| OLD | NEW |