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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 FakeContentLayerClient client_; | 324 FakeContentLayerClient client_; |
325 scoped_refptr<FakePictureLayer> picture_; | 325 scoped_refptr<FakePictureLayer> picture_; |
326 }; | 326 }; |
327 | 327 |
328 // Multi-thread only since there is no recycle tree in single thread. | 328 // Multi-thread only since there is no recycle tree in single thread. |
329 MULTI_THREAD_IMPL_TEST_F( | 329 MULTI_THREAD_IMPL_TEST_F( |
330 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); | 330 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); |
331 | 331 |
332 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { | 332 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { |
333 void SetupTree() override { | 333 void SetupTree() override { |
334 scoped_refptr<Layer> root = Layer::Create(); | 334 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
335 root->SetBounds(gfx::Size(100, 100)); | 335 root->SetBounds(gfx::Size(100, 100)); |
336 | 336 |
337 child_ = Layer::Create(); | 337 child_ = Layer::Create(layer_settings()); |
338 root->AddChild(child_); | 338 root->AddChild(child_); |
339 | 339 |
340 // Don't be solid color so the layer has tilings/tiles. | 340 // Don't be solid color so the layer has tilings/tiles. |
341 client_.set_fill_with_nonsolid_color(true); | 341 client_.set_fill_with_nonsolid_color(true); |
342 picture_ = FakePictureLayer::Create(&client_); | 342 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
343 picture_->SetBounds(gfx::Size(100, 100)); | 343 picture_->SetBounds(gfx::Size(100, 100)); |
344 child_->AddChild(picture_); | 344 child_->AddChild(picture_); |
345 | 345 |
346 layer_tree_host()->SetRootLayer(root); | 346 layer_tree_host()->SetRootLayer(root); |
347 LayerTreeHostPictureTest::SetupTree(); | 347 LayerTreeHostPictureTest::SetupTree(); |
348 } | 348 } |
349 | 349 |
350 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 350 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
351 | 351 |
352 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 352 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 FakeContentLayerClient client_; | 413 FakeContentLayerClient client_; |
414 scoped_refptr<Layer> child_; | 414 scoped_refptr<Layer> child_; |
415 scoped_refptr<FakePictureLayer> picture_; | 415 scoped_refptr<FakePictureLayer> picture_; |
416 }; | 416 }; |
417 | 417 |
418 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership); | 418 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembership); |
419 | 419 |
420 class LayerTreeHostPictureTestRSLLMembershipWithScale | 420 class LayerTreeHostPictureTestRSLLMembershipWithScale |
421 : public LayerTreeHostPictureTest { | 421 : public LayerTreeHostPictureTest { |
422 void SetupTree() override { | 422 void SetupTree() override { |
423 scoped_refptr<Layer> root = Layer::Create(); | 423 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
424 root->SetBounds(gfx::Size(100, 100)); | 424 root->SetBounds(gfx::Size(100, 100)); |
425 | 425 |
426 pinch_ = Layer::Create(); | 426 pinch_ = Layer::Create(layer_settings()); |
427 pinch_->SetBounds(gfx::Size(500, 500)); | 427 pinch_->SetBounds(gfx::Size(500, 500)); |
428 pinch_->SetScrollClipLayerId(root->id()); | 428 pinch_->SetScrollClipLayerId(root->id()); |
429 pinch_->SetIsContainerForFixedPositionLayers(true); | 429 pinch_->SetIsContainerForFixedPositionLayers(true); |
430 root->AddChild(pinch_); | 430 root->AddChild(pinch_); |
431 | 431 |
432 // Don't be solid color so the layer has tilings/tiles. | 432 // Don't be solid color so the layer has tilings/tiles. |
433 client_.set_fill_with_nonsolid_color(true); | 433 client_.set_fill_with_nonsolid_color(true); |
434 picture_ = FakePictureLayer::Create(&client_); | 434 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
435 picture_->SetBounds(gfx::Size(100, 100)); | 435 picture_->SetBounds(gfx::Size(100, 100)); |
436 pinch_->AddChild(picture_); | 436 pinch_->AddChild(picture_); |
437 | 437 |
438 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, pinch_); | 438 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, pinch_); |
439 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 439 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
440 layer_tree_host()->SetRootLayer(root); | 440 layer_tree_host()->SetRootLayer(root); |
441 LayerTreeHostPictureTest::SetupTree(); | 441 LayerTreeHostPictureTest::SetupTree(); |
442 } | 442 } |
443 | 443 |
444 void InitializeSettings(LayerTreeSettings* settings) override { | 444 void InitializeSettings(LayerTreeSettings* settings) override { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 int last_frame_drawn_; | 563 int last_frame_drawn_; |
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 // Disabled due to flakiness. See http://crbug.com/460581 | 568 // Disabled due to flakiness. See http://crbug.com/460581 |
569 // MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 569 // MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
570 | 570 |
571 } // namespace | 571 } // namespace |
572 } // namespace cc | 572 } // namespace cc |
OLD | NEW |