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(); |
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_host()->SetRootLayer(root); | 27 layer_tree()->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 Loading... |
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_host()->root_layer()->AddChild(picture); | 65 layer_tree()->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 Loading... |
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_host()->SetRootLayer(root); | 161 layer_tree()->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 Loading... |
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()->source_frame_number()) { | 188 switch (layer_tree_host()->source_frame_number()) { |
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_host()->SetViewportSize(gfx::Size(768, 1056)); | 193 layer_tree()->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 Loading... |
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_host()->SetRootLayer(root); | 229 layer_tree()->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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 child_ = Layer::Create(); | 324 child_ = Layer::Create(); |
325 root->AddChild(child_); | 325 root->AddChild(child_); |
326 | 326 |
327 // Don't be solid color so the layer has tilings/tiles. | 327 // Don't be solid color so the layer has tilings/tiles. |
328 client_.set_fill_with_nonsolid_color(true); | 328 client_.set_fill_with_nonsolid_color(true); |
329 picture_ = FakePictureLayer::Create(&client_); | 329 picture_ = FakePictureLayer::Create(&client_); |
330 picture_->SetBounds(gfx::Size(100, 100)); | 330 picture_->SetBounds(gfx::Size(100, 100)); |
331 child_->AddChild(picture_); | 331 child_->AddChild(picture_); |
332 | 332 |
333 layer_tree_host()->SetRootLayer(root); | 333 layer_tree()->SetRootLayer(root); |
334 LayerTreeHostPictureTest::SetupTree(); | 334 LayerTreeHostPictureTest::SetupTree(); |
335 } | 335 } |
336 | 336 |
337 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 337 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
338 | 338 |
339 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 339 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
340 LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id()); | 340 LayerImpl* gchild = impl->sync_tree()->LayerById(picture_->id()); |
341 FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild); | 341 FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild); |
342 | 342 |
343 switch (impl->sync_tree()->source_frame_number()) { | 343 switch (impl->sync_tree()->source_frame_number()) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 pinch_->SetIsContainerForFixedPositionLayers(true); | 414 pinch_->SetIsContainerForFixedPositionLayers(true); |
415 page_scale_layer->AddChild(pinch_); | 415 page_scale_layer->AddChild(pinch_); |
416 root_clip->AddChild(page_scale_layer); | 416 root_clip->AddChild(page_scale_layer); |
417 | 417 |
418 // Don't be solid color so the layer has tilings/tiles. | 418 // Don't be solid color so the layer has tilings/tiles. |
419 client_.set_fill_with_nonsolid_color(true); | 419 client_.set_fill_with_nonsolid_color(true); |
420 picture_ = FakePictureLayer::Create(&client_); | 420 picture_ = FakePictureLayer::Create(&client_); |
421 picture_->SetBounds(gfx::Size(100, 100)); | 421 picture_->SetBounds(gfx::Size(100, 100)); |
422 pinch_->AddChild(picture_); | 422 pinch_->AddChild(picture_); |
423 | 423 |
424 layer_tree_host()->RegisterViewportLayers(NULL, page_scale_layer, pinch_, | 424 layer_tree()->RegisterViewportLayers(NULL, page_scale_layer, pinch_, |
425 nullptr); | 425 nullptr); |
426 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 426 layer_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
427 layer_tree_host()->SetRootLayer(root_clip); | 427 layer_tree()->SetRootLayer(root_clip); |
428 LayerTreeHostPictureTest::SetupTree(); | 428 LayerTreeHostPictureTest::SetupTree(); |
429 client_.set_bounds(picture_->bounds()); | 429 client_.set_bounds(picture_->bounds()); |
430 } | 430 } |
431 | 431 |
432 void InitializeSettings(LayerTreeSettings* settings) override { | 432 void InitializeSettings(LayerTreeSettings* settings) override { |
433 settings->layer_transforms_should_scale_layer_contents = true; | 433 settings->layer_transforms_should_scale_layer_contents = true; |
434 } | 434 } |
435 | 435 |
436 void BeginTest() override { | 436 void BeginTest() override { |
437 frame_ = 0; | 437 frame_ = 0; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 int last_frame_drawn_; | 563 int last_frame_drawn_; |
564 bool ready_to_draw_; | 564 bool ready_to_draw_; |
565 }; | 565 }; |
566 | 566 |
567 // Multi-thread only because in single thread you can't pinch zoom on the | 567 // Multi-thread only because in single thread you can't pinch zoom on the |
568 // compositor thread. | 568 // compositor thread. |
569 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 569 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
570 | 570 |
571 } // namespace | 571 } // namespace |
572 } // namespace cc | 572 } // namespace cc |
OLD | NEW |