Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: cc/trees/layer_tree_host_unittest_picture.cc

Issue 2661523003: cc: Merge LayerTree into the LayerTreeHost. (Closed)
Patch Set: auto Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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();
21 root->SetBounds(size); 21 root->SetBounds(size);
22 22
23 root_picture_layer_ = FakePictureLayer::Create(&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()->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 };
34 34
35 class LayerTreeHostPictureTestTwinLayer 35 class LayerTreeHostPictureTestTwinLayer
36 : public LayerTreeHostPictureTest { 36 : public LayerTreeHostPictureTest {
37 void SetupTree() override { 37 void SetupTree() override {
(...skipping 17 matching lines...) Expand all
55 // Drop the picture layer from the tree so the activate will have an 55 // Drop the picture layer from the tree so the activate will have an
56 // active layer without a pending twin. 56 // active layer without a pending twin.
57 root_picture_layer_->RemoveFromParent(); 57 root_picture_layer_->RemoveFromParent();
58 break; 58 break;
59 case 3: { 59 case 3: {
60 // Add a new picture layer so the activate will have a pending layer 60 // Add a new picture layer so the activate will have a pending layer
61 // without an active twin. 61 // without an active twin.
62 scoped_refptr<FakePictureLayer> picture = 62 scoped_refptr<FakePictureLayer> picture =
63 FakePictureLayer::Create(&client_); 63 FakePictureLayer::Create(&client_);
64 picture_id2_ = picture->id(); 64 picture_id2_ = picture->id();
65 layer_tree()->root_layer()->AddChild(picture); 65 layer_tree_host()->root_layer()->AddChild(picture);
66 break; 66 break;
67 } 67 }
68 case 4: 68 case 4:
69 // Active while there are pending and active twins again. 69 // Active while there are pending and active twins again.
70 layer_tree_host()->SetNeedsCommit(); 70 layer_tree_host()->SetNeedsCommit();
71 break; 71 break;
72 case 5: 72 case 5:
73 EndTest(); 73 EndTest();
74 break; 74 break;
75 } 75 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 void SetupTree() override { 152 void SetupTree() override {
153 scoped_refptr<Layer> root = Layer::Create(); 153 scoped_refptr<Layer> root = Layer::Create();
154 root->SetBounds(gfx::Size(768, 960)); 154 root->SetBounds(gfx::Size(768, 960));
155 client_.set_bounds(root->bounds()); 155 client_.set_bounds(root->bounds());
156 client_.set_fill_with_nonsolid_color(true); 156 client_.set_fill_with_nonsolid_color(true);
157 picture_ = FakePictureLayer::Create(&client_); 157 picture_ = FakePictureLayer::Create(&client_);
158 picture_->SetBounds(gfx::Size(768, 960)); 158 picture_->SetBounds(gfx::Size(768, 960));
159 root->AddChild(picture_); 159 root->AddChild(picture_);
160 160
161 layer_tree()->SetRootLayer(root); 161 layer_tree_host()->SetRootLayer(root);
162 LayerTreeHostPictureTest::SetupTree(); 162 LayerTreeHostPictureTest::SetupTree();
163 } 163 }
164 164
165 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 165 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
166 166
167 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { 167 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
168 LayerImpl* child = impl->sync_tree()->LayerById(picture_->id()); 168 LayerImpl* child = impl->sync_tree()->LayerById(picture_->id());
169 FakePictureLayerImpl* picture_impl = 169 FakePictureLayerImpl* picture_impl =
170 static_cast<FakePictureLayerImpl*>(child); 170 static_cast<FakePictureLayerImpl*>(child);
171 gfx::Size tile_size = 171 gfx::Size tile_size =
(...skipping 11 matching lines...) Expand all
183 EXPECT_NE(gfx::Size(768, 256), tile_size); 183 EXPECT_NE(gfx::Size(768, 256), tile_size);
184 } 184 }
185 } 185 }
186 186
187 void DidCommit() override { 187 void DidCommit() override {
188 switch (layer_tree_host()->SourceFrameNumber()) { 188 switch (layer_tree_host()->SourceFrameNumber()) {
189 case 1: 189 case 1:
190 // Change the picture layer's size along with the viewport, so it will 190 // Change the picture layer's size along with the viewport, so it will
191 // consider picking a new tile size. 191 // consider picking a new tile size.
192 picture_->SetBounds(gfx::Size(768, 1056)); 192 picture_->SetBounds(gfx::Size(768, 1056));
193 layer_tree()->SetViewportSize(gfx::Size(768, 1056)); 193 layer_tree_host()->SetViewportSize(gfx::Size(768, 1056));
194 break; 194 break;
195 case 2: 195 case 2:
196 EndTest(); 196 EndTest();
197 } 197 }
198 } 198 }
199 199
200 void AfterTest() override {} 200 void AfterTest() override {}
201 201
202 gfx::Size tile_size_; 202 gfx::Size tile_size_;
203 FakeContentLayerClient client_; 203 FakeContentLayerClient client_;
(...skipping 15 matching lines...) Expand all
219 // layer. 219 // layer.
220 client_.set_fill_with_nonsolid_color(true); 220 client_.set_fill_with_nonsolid_color(true);
221 picture_ = FakePictureLayer::Create(&client_); 221 picture_ = FakePictureLayer::Create(&client_);
222 picture_->SetBounds(gfx::Size(100, 100000)); 222 picture_->SetBounds(gfx::Size(100, 100000));
223 root->AddChild(picture_); 223 root->AddChild(picture_);
224 224
225 // picture_'s transform is going to be changing on the compositor thread, so 225 // picture_'s transform is going to be changing on the compositor thread, so
226 // force it to have a transform node by making it scrollable. 226 // force it to have a transform node by making it scrollable.
227 picture_->SetScrollClipLayerId(root->id()); 227 picture_->SetScrollClipLayerId(root->id());
228 228
229 layer_tree()->SetRootLayer(root); 229 layer_tree_host()->SetRootLayer(root);
230 LayerTreeHostPictureTest::SetupTree(); 230 LayerTreeHostPictureTest::SetupTree();
231 client_.set_bounds(picture_->bounds()); 231 client_.set_bounds(picture_->bounds());
232 } 232 }
233 233
234 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 234 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
235 235
236 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { 236 void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
237 LayerImpl* child = impl->active_tree()->LayerById(picture_->id()); 237 LayerImpl* child = impl->active_tree()->LayerById(picture_->id());
238 FakePictureLayerImpl* picture_impl = 238 FakePictureLayerImpl* picture_impl =
239 static_cast<FakePictureLayerImpl*>(child); 239 static_cast<FakePictureLayerImpl*>(child);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 child_ = Layer::Create(); 332 child_ = Layer::Create();
333 root->AddChild(child_); 333 root->AddChild(child_);
334 334
335 // Don't be solid color so the layer has tilings/tiles. 335 // Don't be solid color so the layer has tilings/tiles.
336 client_.set_fill_with_nonsolid_color(true); 336 client_.set_fill_with_nonsolid_color(true);
337 picture_ = FakePictureLayer::Create(&client_); 337 picture_ = FakePictureLayer::Create(&client_);
338 picture_->SetBounds(gfx::Size(100, 100)); 338 picture_->SetBounds(gfx::Size(100, 100));
339 child_->AddChild(picture_); 339 child_->AddChild(picture_);
340 340
341 layer_tree()->SetRootLayer(root); 341 layer_tree_host()->SetRootLayer(root);
342 LayerTreeHostPictureTest::SetupTree(); 342 LayerTreeHostPictureTest::SetupTree();
343 } 343 }
344 344
345 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 345 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
346 346
347 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { 347 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override {
348 LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id()); 348 LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id());
349 FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild); 349 FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild);
350 350
351 switch (impl->sync_tree()->source_frame_number()) { 351 switch (impl->sync_tree()->source_frame_number()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 pinch_->SetIsContainerForFixedPositionLayers(true); 422 pinch_->SetIsContainerForFixedPositionLayers(true);
423 page_scale_layer->AddChild(pinch_); 423 page_scale_layer->AddChild(pinch_);
424 root_clip->AddChild(page_scale_layer); 424 root_clip->AddChild(page_scale_layer);
425 425
426 // Don't be solid color so the layer has tilings/tiles. 426 // Don't be solid color so the layer has tilings/tiles.
427 client_.set_fill_with_nonsolid_color(true); 427 client_.set_fill_with_nonsolid_color(true);
428 picture_ = FakePictureLayer::Create(&client_); 428 picture_ = FakePictureLayer::Create(&client_);
429 picture_->SetBounds(gfx::Size(100, 100)); 429 picture_->SetBounds(gfx::Size(100, 100));
430 pinch_->AddChild(picture_); 430 pinch_->AddChild(picture_);
431 431
432 layer_tree()->RegisterViewportLayers(NULL, page_scale_layer, pinch_, 432 layer_tree_host()->RegisterViewportLayers(NULL, page_scale_layer, pinch_,
433 nullptr); 433 nullptr);
434 layer_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); 434 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f);
435 layer_tree()->SetRootLayer(root_clip); 435 layer_tree_host()->SetRootLayer(root_clip);
436 LayerTreeHostPictureTest::SetupTree(); 436 LayerTreeHostPictureTest::SetupTree();
437 client_.set_bounds(picture_->bounds()); 437 client_.set_bounds(picture_->bounds());
438 } 438 }
439 439
440 void InitializeSettings(LayerTreeSettings* settings) override { 440 void InitializeSettings(LayerTreeSettings* settings) override {
441 settings->layer_transforms_should_scale_layer_contents = true; 441 settings->layer_transforms_should_scale_layer_contents = true;
442 } 442 }
443 443
444 void BeginTest() override { 444 void BeginTest() override {
445 frame_ = 0; 445 frame_ = 0;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 585
586 will_change_layer_ = FakePictureLayer::Create(&client_); 586 will_change_layer_ = FakePictureLayer::Create(&client_);
587 will_change_layer_->SetHasWillChangeTransformHint(true); 587 will_change_layer_->SetHasWillChangeTransformHint(true);
588 will_change_layer_->SetBounds(size); 588 will_change_layer_->SetBounds(size);
589 root->AddChild(will_change_layer_); 589 root->AddChild(will_change_layer_);
590 590
591 normal_layer_ = FakePictureLayer::Create(&client_); 591 normal_layer_ = FakePictureLayer::Create(&client_);
592 normal_layer_->SetBounds(size); 592 normal_layer_->SetBounds(size);
593 root->AddChild(normal_layer_); 593 root->AddChild(normal_layer_);
594 594
595 layer_tree()->SetRootLayer(root); 595 layer_tree_host()->SetRootLayer(root);
596 layer_tree()->SetViewportSize(size); 596 layer_tree_host()->SetViewportSize(size);
597 597
598 client_.set_fill_with_nonsolid_color(true); 598 client_.set_fill_with_nonsolid_color(true);
599 client_.set_bounds(size); 599 client_.set_bounds(size);
600 } 600 }
601 601
602 void InitializeSettings(LayerTreeSettings* settings) override { 602 void InitializeSettings(LayerTreeSettings* settings) override {
603 settings->layer_transforms_should_scale_layer_contents = true; 603 settings->layer_transforms_should_scale_layer_contents = true;
604 } 604 }
605 605
606 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 606 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 ASSERT_EQ(1u, normal_layer->tilings()->num_tilings()); 651 ASSERT_EQ(1u, normal_layer->tilings()->num_tilings());
652 EXPECT_EQ(4.f, normal_layer->tilings()->tiling_at(0)->contents_scale()); 652 EXPECT_EQ(4.f, normal_layer->tilings()->tiling_at(0)->contents_scale());
653 EndTest(); 653 EndTest();
654 break; 654 break;
655 } 655 }
656 } 656 }
657 657
658 void ScaleRootUp() { 658 void ScaleRootUp() {
659 gfx::Transform transform; 659 gfx::Transform transform;
660 transform.Scale(2, 2); 660 transform.Scale(2, 2);
661 layer_tree_host()->GetLayerTree()->root_layer()->SetTransform(transform); 661 layer_tree_host()->root_layer()->SetTransform(transform);
662 } 662 }
663 663
664 void ScaleRootUpAndRecalculateScales() { 664 void ScaleRootUpAndRecalculateScales() {
665 gfx::Transform transform; 665 gfx::Transform transform;
666 transform.Scale(4, 4); 666 transform.Scale(4, 4);
667 layer_tree_host()->GetLayerTree()->root_layer()->SetTransform(transform); 667 layer_tree_host()->root_layer()->SetTransform(transform);
668 layer_tree_host()->SetNeedsRecalculateRasterScales(); 668 layer_tree_host()->SetNeedsRecalculateRasterScales();
669 } 669 }
670 670
671 void AfterTest() override {} 671 void AfterTest() override {}
672 672
673 scoped_refptr<FakePictureLayer> will_change_layer_; 673 scoped_refptr<FakePictureLayer> will_change_layer_;
674 scoped_refptr<FakePictureLayer> normal_layer_; 674 scoped_refptr<FakePictureLayer> normal_layer_;
675 }; 675 };
676 676
677 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostPictureTestForceRecalculateScales); 677 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostPictureTestForceRecalculateScales);
678 678
679 } // namespace 679 } // namespace
680 } // namespace cc 680 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_occlusion.cc ('k') | cc/trees/layer_tree_host_unittest_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698