| 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(); | 20 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 21 root->SetBounds(size); | 21 root->SetBounds(size); |
| 22 | 22 |
| 23 root_picture_layer_ = FakePictureLayer::Create(&client_); | 23 root_picture_layer_ = FakePictureLayer::Create(layer_settings(), &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 } | 28 } |
| 29 | 29 |
| 30 scoped_refptr<FakePictureLayer> root_picture_layer_; | 30 scoped_refptr<FakePictureLayer> root_picture_layer_; |
| 31 FakeContentLayerClient client_; | 31 FakeContentLayerClient client_; |
| 32 }; | 32 }; |
| 33 | 33 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 break; | 50 break; |
| 51 case 2: | 51 case 2: |
| 52 // Drop the picture layer from the tree so the activate will have an | 52 // Drop the picture layer from the tree so the activate will have an |
| 53 // active layer without a pending twin. | 53 // active layer without a pending twin. |
| 54 layer_tree_host()->root_layer()->children()[0]->RemoveFromParent(); | 54 layer_tree_host()->root_layer()->children()[0]->RemoveFromParent(); |
| 55 break; | 55 break; |
| 56 case 3: { | 56 case 3: { |
| 57 // Add a new picture layer so the activate will have a pending layer | 57 // Add a new picture layer so the activate will have a pending layer |
| 58 // without an active twin. | 58 // without an active twin. |
| 59 scoped_refptr<FakePictureLayer> picture = | 59 scoped_refptr<FakePictureLayer> picture = |
| 60 FakePictureLayer::Create(&client_); | 60 FakePictureLayer::Create(layer_settings(), &client_); |
| 61 layer_tree_host()->root_layer()->AddChild(picture); | 61 layer_tree_host()->root_layer()->AddChild(picture); |
| 62 break; | 62 break; |
| 63 } | 63 } |
| 64 case 4: | 64 case 4: |
| 65 // Active while there are pending and active twins again. | 65 // Active while there are pending and active twins again. |
| 66 layer_tree_host()->SetNeedsCommit(); | 66 layer_tree_host()->SetNeedsCommit(); |
| 67 break; | 67 break; |
| 68 case 5: | 68 case 5: |
| 69 EndTest(); | 69 EndTest(); |
| 70 break; | 70 break; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // There is no pending layers in single thread mode. | 138 // There is no pending layers in single thread mode. |
| 139 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); | 139 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); |
| 140 | 140 |
| 141 class LayerTreeHostPictureTestResizeViewportWithGpuRaster | 141 class LayerTreeHostPictureTestResizeViewportWithGpuRaster |
| 142 : public LayerTreeHostPictureTest { | 142 : public LayerTreeHostPictureTest { |
| 143 void InitializeSettings(LayerTreeSettings* settings) override { | 143 void InitializeSettings(LayerTreeSettings* settings) override { |
| 144 settings->gpu_rasterization_forced = true; | 144 settings->gpu_rasterization_forced = true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void SetupTree() override { | 147 void SetupTree() override { |
| 148 scoped_refptr<Layer> root = Layer::Create(); | 148 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 149 root->SetBounds(gfx::Size(768, 960)); | 149 root->SetBounds(gfx::Size(768, 960)); |
| 150 | 150 |
| 151 client_.set_fill_with_nonsolid_color(true); | 151 client_.set_fill_with_nonsolid_color(true); |
| 152 picture_ = FakePictureLayer::Create(&client_); | 152 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 153 picture_->SetBounds(gfx::Size(768, 960)); | 153 picture_->SetBounds(gfx::Size(768, 960)); |
| 154 root->AddChild(picture_); | 154 root->AddChild(picture_); |
| 155 | 155 |
| 156 layer_tree_host()->SetRootLayer(root); | 156 layer_tree_host()->SetRootLayer(root); |
| 157 LayerTreeHostPictureTest::SetupTree(); | 157 LayerTreeHostPictureTest::SetupTree(); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 160 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 161 | 161 |
| 162 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 162 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 201 |
| 202 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( | 202 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( |
| 203 LayerTreeHostPictureTestResizeViewportWithGpuRaster); | 203 LayerTreeHostPictureTestResizeViewportWithGpuRaster); |
| 204 | 204 |
| 205 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree | 205 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree |
| 206 : public LayerTreeHostPictureTest { | 206 : public LayerTreeHostPictureTest { |
| 207 void SetupTree() override { | 207 void SetupTree() override { |
| 208 frame_ = 0; | 208 frame_ = 0; |
| 209 did_post_commit_ = false; | 209 did_post_commit_ = false; |
| 210 | 210 |
| 211 scoped_refptr<Layer> root = Layer::Create(); | 211 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 212 root->SetBounds(gfx::Size(100, 100)); | 212 root->SetBounds(gfx::Size(100, 100)); |
| 213 | 213 |
| 214 // The layer is big enough that the live tiles rect won't cover the full | 214 // The layer is big enough that the live tiles rect won't cover the full |
| 215 // layer. | 215 // layer. |
| 216 client_.set_fill_with_nonsolid_color(true); | 216 client_.set_fill_with_nonsolid_color(true); |
| 217 picture_ = FakePictureLayer::Create(&client_); | 217 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 218 picture_->SetBounds(gfx::Size(100, 100000)); | 218 picture_->SetBounds(gfx::Size(100, 100000)); |
| 219 root->AddChild(picture_); | 219 root->AddChild(picture_); |
| 220 | 220 |
| 221 layer_tree_host()->SetRootLayer(root); | 221 layer_tree_host()->SetRootLayer(root); |
| 222 LayerTreeHostPictureTest::SetupTree(); | 222 LayerTreeHostPictureTest::SetupTree(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 225 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 226 | 226 |
| 227 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 227 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 FakeContentLayerClient client_; | 326 FakeContentLayerClient client_; |
| 327 scoped_refptr<FakePictureLayer> picture_; | 327 scoped_refptr<FakePictureLayer> picture_; |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 // Multi-thread only since there is no recycle tree in single thread. | 330 // Multi-thread only since there is no recycle tree in single thread. |
| 331 MULTI_THREAD_IMPL_TEST_F( | 331 MULTI_THREAD_IMPL_TEST_F( |
| 332 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); | 332 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); |
| 333 | 333 |
| 334 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { | 334 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { |
| 335 void SetupTree() override { | 335 void SetupTree() override { |
| 336 scoped_refptr<Layer> root = Layer::Create(); | 336 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 337 root->SetBounds(gfx::Size(100, 100)); | 337 root->SetBounds(gfx::Size(100, 100)); |
| 338 | 338 |
| 339 child_ = Layer::Create(); | 339 child_ = Layer::Create(layer_settings()); |
| 340 root->AddChild(child_); | 340 root->AddChild(child_); |
| 341 | 341 |
| 342 // Don't be solid color so the layer has tilings/tiles. | 342 // Don't be solid color so the layer has tilings/tiles. |
| 343 client_.set_fill_with_nonsolid_color(true); | 343 client_.set_fill_with_nonsolid_color(true); |
| 344 picture_ = FakePictureLayer::Create(&client_); | 344 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 345 picture_->SetBounds(gfx::Size(100, 100)); | 345 picture_->SetBounds(gfx::Size(100, 100)); |
| 346 child_->AddChild(picture_); | 346 child_->AddChild(picture_); |
| 347 | 347 |
| 348 layer_tree_host()->SetRootLayer(root); | 348 layer_tree_host()->SetRootLayer(root); |
| 349 LayerTreeHostPictureTest::SetupTree(); | 349 LayerTreeHostPictureTest::SetupTree(); |
| 350 } | 350 } |
| 351 | 351 |
| 352 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 352 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 353 | 353 |
| 354 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 354 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 FakeContentLayerClient client_; | 415 FakeContentLayerClient client_; |
| 416 scoped_refptr<Layer> child_; | 416 scoped_refptr<Layer> child_; |
| 417 scoped_refptr<FakePictureLayer> picture_; | 417 scoped_refptr<FakePictureLayer> picture_; |
| 418 }; | 418 }; |
| 419 | 419 |
| 420 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership); | 420 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership); |
| 421 | 421 |
| 422 class LayerTreeHostPictureTestRSLLMembershipWithScale | 422 class LayerTreeHostPictureTestRSLLMembershipWithScale |
| 423 : public LayerTreeHostPictureTest { | 423 : public LayerTreeHostPictureTest { |
| 424 void SetupTree() override { | 424 void SetupTree() override { |
| 425 scoped_refptr<Layer> root = Layer::Create(); | 425 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 426 root->SetBounds(gfx::Size(100, 100)); | 426 root->SetBounds(gfx::Size(100, 100)); |
| 427 | 427 |
| 428 pinch_ = Layer::Create(); | 428 pinch_ = Layer::Create(layer_settings()); |
| 429 pinch_->SetBounds(gfx::Size(500, 500)); | 429 pinch_->SetBounds(gfx::Size(500, 500)); |
| 430 pinch_->SetScrollClipLayerId(root->id()); | 430 pinch_->SetScrollClipLayerId(root->id()); |
| 431 pinch_->SetIsContainerForFixedPositionLayers(true); | 431 pinch_->SetIsContainerForFixedPositionLayers(true); |
| 432 root->AddChild(pinch_); | 432 root->AddChild(pinch_); |
| 433 | 433 |
| 434 // Don't be solid color so the layer has tilings/tiles. | 434 // Don't be solid color so the layer has tilings/tiles. |
| 435 client_.set_fill_with_nonsolid_color(true); | 435 client_.set_fill_with_nonsolid_color(true); |
| 436 picture_ = FakePictureLayer::Create(&client_); | 436 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 437 picture_->SetBounds(gfx::Size(100, 100)); | 437 picture_->SetBounds(gfx::Size(100, 100)); |
| 438 pinch_->AddChild(picture_); | 438 pinch_->AddChild(picture_); |
| 439 | 439 |
| 440 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, pinch_); | 440 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, pinch_); |
| 441 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 441 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
| 442 layer_tree_host()->SetRootLayer(root); | 442 layer_tree_host()->SetRootLayer(root); |
| 443 LayerTreeHostPictureTest::SetupTree(); | 443 LayerTreeHostPictureTest::SetupTree(); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void InitializeSettings(LayerTreeSettings* settings) override { | 446 void InitializeSettings(LayerTreeSettings* settings) override { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 int last_frame_drawn_; | 565 int last_frame_drawn_; |
| 566 }; | 566 }; |
| 567 | 567 |
| 568 // Multi-thread only because in single thread you can't pinch zoom on the | 568 // Multi-thread only because in single thread you can't pinch zoom on the |
| 569 // compositor thread. | 569 // compositor thread. |
| 570 // Disabled due to flakiness. See http://crbug.com/460581 | 570 // Disabled due to flakiness. See http://crbug.com/460581 |
| 571 // MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 571 // MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
| 572 | 572 |
| 573 } // namespace | 573 } // namespace |
| 574 } // namespace cc | 574 } // namespace cc |
| OLD | NEW |