| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // There is no pending layers in single thread mode. | 130 // There is no pending layers in single thread mode. |
| 131 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); | 131 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); |
| 132 | 132 |
| 133 class LayerTreeHostPictureTestResizeViewportWithGpuRaster | 133 class LayerTreeHostPictureTestResizeViewportWithGpuRaster |
| 134 : public LayerTreeHostPictureTest { | 134 : public LayerTreeHostPictureTest { |
| 135 void InitializeSettings(LayerTreeSettings* settings) override { | 135 void InitializeSettings(LayerTreeSettings* settings) override { |
| 136 settings->gpu_rasterization_forced = true; | 136 settings->gpu_rasterization_forced = true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void SetupTree() override { | 139 void SetupTree() override { |
| 140 scoped_refptr<Layer> root = Layer::Create(); | 140 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 141 root->SetBounds(gfx::Size(768, 960)); | 141 root->SetBounds(gfx::Size(768, 960)); |
| 142 | 142 |
| 143 client_.set_fill_with_nonsolid_color(true); | 143 client_.set_fill_with_nonsolid_color(true); |
| 144 picture_ = FakePictureLayer::Create(&client_); | 144 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 145 picture_->SetBounds(gfx::Size(768, 960)); | 145 picture_->SetBounds(gfx::Size(768, 960)); |
| 146 root->AddChild(picture_); | 146 root->AddChild(picture_); |
| 147 | 147 |
| 148 layer_tree_host()->SetRootLayer(root); | 148 layer_tree_host()->SetRootLayer(root); |
| 149 LayerTreeHostPictureTest::SetupTree(); | 149 LayerTreeHostPictureTest::SetupTree(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 152 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 153 | 153 |
| 154 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 154 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( | 194 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( |
| 195 LayerTreeHostPictureTestResizeViewportWithGpuRaster); | 195 LayerTreeHostPictureTestResizeViewportWithGpuRaster); |
| 196 | 196 |
| 197 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree | 197 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree |
| 198 : public LayerTreeHostPictureTest { | 198 : public LayerTreeHostPictureTest { |
| 199 void SetupTree() override { | 199 void SetupTree() override { |
| 200 frame_ = 0; | 200 frame_ = 0; |
| 201 did_post_commit_ = false; | 201 did_post_commit_ = false; |
| 202 | 202 |
| 203 scoped_refptr<Layer> root = Layer::Create(); | 203 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 204 root->SetBounds(gfx::Size(100, 100)); | 204 root->SetBounds(gfx::Size(100, 100)); |
| 205 | 205 |
| 206 // The layer is big enough that the live tiles rect won't cover the full | 206 // The layer is big enough that the live tiles rect won't cover the full |
| 207 // layer. | 207 // layer. |
| 208 client_.set_fill_with_nonsolid_color(true); | 208 client_.set_fill_with_nonsolid_color(true); |
| 209 picture_ = FakePictureLayer::Create(&client_); | 209 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 210 picture_->SetBounds(gfx::Size(100, 100000)); | 210 picture_->SetBounds(gfx::Size(100, 100000)); |
| 211 root->AddChild(picture_); | 211 root->AddChild(picture_); |
| 212 | 212 |
| 213 layer_tree_host()->SetRootLayer(root); | 213 layer_tree_host()->SetRootLayer(root); |
| 214 LayerTreeHostPictureTest::SetupTree(); | 214 LayerTreeHostPictureTest::SetupTree(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 217 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 218 | 218 |
| 219 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 219 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 FakeContentLayerClient client_; | 292 FakeContentLayerClient client_; |
| 293 scoped_refptr<FakePictureLayer> picture_; | 293 scoped_refptr<FakePictureLayer> picture_; |
| 294 }; | 294 }; |
| 295 | 295 |
| 296 // Multi-thread only since there is no recycle tree in single thread. | 296 // Multi-thread only since there is no recycle tree in single thread. |
| 297 MULTI_THREAD_IMPL_TEST_F( | 297 MULTI_THREAD_IMPL_TEST_F( |
| 298 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); | 298 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); |
| 299 | 299 |
| 300 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { | 300 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { |
| 301 void SetupTree() override { | 301 void SetupTree() override { |
| 302 scoped_refptr<Layer> root = Layer::Create(); | 302 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 303 root->SetBounds(gfx::Size(100, 100)); | 303 root->SetBounds(gfx::Size(100, 100)); |
| 304 | 304 |
| 305 child_ = Layer::Create(); | 305 child_ = Layer::Create(layer_settings()); |
| 306 root->AddChild(child_); | 306 root->AddChild(child_); |
| 307 | 307 |
| 308 // Don't be solid color so the layer has tilings/tiles. | 308 // Don't be solid color so the layer has tilings/tiles. |
| 309 client_.set_fill_with_nonsolid_color(true); | 309 client_.set_fill_with_nonsolid_color(true); |
| 310 picture_ = FakePictureLayer::Create(&client_); | 310 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 311 picture_->SetBounds(gfx::Size(100, 100)); | 311 picture_->SetBounds(gfx::Size(100, 100)); |
| 312 child_->AddChild(picture_); | 312 child_->AddChild(picture_); |
| 313 | 313 |
| 314 layer_tree_host()->SetRootLayer(root); | 314 layer_tree_host()->SetRootLayer(root); |
| 315 LayerTreeHostPictureTest::SetupTree(); | 315 LayerTreeHostPictureTest::SetupTree(); |
| 316 } | 316 } |
| 317 | 317 |
| 318 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 318 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 319 | 319 |
| 320 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 320 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 FakeContentLayerClient client_; | 381 FakeContentLayerClient client_; |
| 382 scoped_refptr<Layer> child_; | 382 scoped_refptr<Layer> child_; |
| 383 scoped_refptr<FakePictureLayer> picture_; | 383 scoped_refptr<FakePictureLayer> picture_; |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership); | 386 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership); |
| 387 | 387 |
| 388 class LayerTreeHostPictureTestRSLLMembershipWithScale | 388 class LayerTreeHostPictureTestRSLLMembershipWithScale |
| 389 : public LayerTreeHostPictureTest { | 389 : public LayerTreeHostPictureTest { |
| 390 void SetupTree() override { | 390 void SetupTree() override { |
| 391 scoped_refptr<Layer> root = Layer::Create(); | 391 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 392 root->SetBounds(gfx::Size(100, 100)); | 392 root->SetBounds(gfx::Size(100, 100)); |
| 393 | 393 |
| 394 pinch_ = Layer::Create(); | 394 pinch_ = Layer::Create(layer_settings()); |
| 395 pinch_->SetBounds(gfx::Size(500, 500)); | 395 pinch_->SetBounds(gfx::Size(500, 500)); |
| 396 pinch_->SetScrollClipLayerId(root->id()); | 396 pinch_->SetScrollClipLayerId(root->id()); |
| 397 pinch_->SetIsContainerForFixedPositionLayers(true); | 397 pinch_->SetIsContainerForFixedPositionLayers(true); |
| 398 root->AddChild(pinch_); | 398 root->AddChild(pinch_); |
| 399 | 399 |
| 400 // Don't be solid color so the layer has tilings/tiles. | 400 // Don't be solid color so the layer has tilings/tiles. |
| 401 client_.set_fill_with_nonsolid_color(true); | 401 client_.set_fill_with_nonsolid_color(true); |
| 402 picture_ = FakePictureLayer::Create(&client_); | 402 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 403 picture_->SetBounds(gfx::Size(100, 100)); | 403 picture_->SetBounds(gfx::Size(100, 100)); |
| 404 pinch_->AddChild(picture_); | 404 pinch_->AddChild(picture_); |
| 405 | 405 |
| 406 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, pinch_); | 406 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, pinch_); |
| 407 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 407 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
| 408 layer_tree_host()->SetRootLayer(root); | 408 layer_tree_host()->SetRootLayer(root); |
| 409 LayerTreeHostPictureTest::SetupTree(); | 409 LayerTreeHostPictureTest::SetupTree(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 void InitializeSettings(LayerTreeSettings* settings) override { | 412 void InitializeSettings(LayerTreeSettings* settings) override { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 int last_frame_drawn_; | 531 int last_frame_drawn_; |
| 532 }; | 532 }; |
| 533 | 533 |
| 534 // Multi-thread only because in single thread you can't pinch zoom on the | 534 // Multi-thread only because in single thread you can't pinch zoom on the |
| 535 // compositor thread. | 535 // compositor thread. |
| 536 // Disabled due to flakiness. See http://crbug.com/460581 | 536 // Disabled due to flakiness. See http://crbug.com/460581 |
| 537 // MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 537 // MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
| 538 | 538 |
| 539 } // namespace | 539 } // namespace |
| 540 } // namespace cc | 540 } // namespace cc |
| OLD | NEW |