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" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 | 129 |
130 ++activates_; | 130 ++activates_; |
131 } | 131 } |
132 | 132 |
133 void AfterTest() override { EXPECT_EQ(5, activates_); } | 133 void AfterTest() override { EXPECT_EQ(5, activates_); } |
134 | 134 |
135 int activates_; | 135 int activates_; |
136 }; | 136 }; |
137 | 137 |
138 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); | 138 // There is no pending layers in single thread mode. |
| 139 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestTwinLayer); |
139 | 140 |
140 class LayerTreeHostPictureTestResizeViewportWithGpuRaster | 141 class LayerTreeHostPictureTestResizeViewportWithGpuRaster |
141 : public LayerTreeHostPictureTest { | 142 : public LayerTreeHostPictureTest { |
142 void InitializeSettings(LayerTreeSettings* settings) override { | 143 void InitializeSettings(LayerTreeSettings* settings) override { |
143 settings->gpu_rasterization_forced = true; | 144 settings->gpu_rasterization_forced = true; |
144 } | 145 } |
145 | 146 |
146 void SetupTree() override { | 147 void SetupTree() override { |
147 scoped_refptr<Layer> root = Layer::Create(); | 148 scoped_refptr<Layer> root = Layer::Create(); |
148 root->SetBounds(gfx::Size(768, 960)); | 149 root->SetBounds(gfx::Size(768, 960)); |
149 | 150 |
150 client_.set_fill_with_nonsolid_color(true); | 151 client_.set_fill_with_nonsolid_color(true); |
151 picture_ = FakePictureLayer::Create(&client_); | 152 picture_ = FakePictureLayer::Create(&client_); |
152 picture_->SetBounds(gfx::Size(768, 960)); | 153 picture_->SetBounds(gfx::Size(768, 960)); |
153 root->AddChild(picture_); | 154 root->AddChild(picture_); |
154 | 155 |
155 layer_tree_host()->SetRootLayer(root); | 156 layer_tree_host()->SetRootLayer(root); |
156 LayerTreeHostPictureTest::SetupTree(); | 157 LayerTreeHostPictureTest::SetupTree(); |
157 } | 158 } |
158 | 159 |
159 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 160 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
160 | 161 |
161 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 162 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
162 LayerImpl* child = impl->sync_tree()->root_layer()->children()[0]; | 163 LayerImpl* child = impl->sync_tree()->root_layer()->children()[0]; |
163 FakePictureLayerImpl* picture_impl = | 164 FakePictureLayerImpl* picture_impl = |
164 static_cast<FakePictureLayerImpl*>(child); | 165 static_cast<FakePictureLayerImpl*>(child); |
165 gfx::Size tile_size = | 166 gfx::Size tile_size = |
166 picture_impl->HighResTiling()->TileAt(0, 0)->content_rect().size(); | 167 picture_impl->HighResTiling()->TileAt(0, 0)->content_rect().size(); |
167 | 168 |
168 switch (impl->sync_tree()->source_frame_number()) { | 169 switch (impl->sync_tree()->source_frame_number()) { |
169 case 0: | 170 case 0: |
170 tile_size_ = tile_size; | 171 tile_size_ = tile_size; |
171 // GPU Raster picks a tile size based on the viewport size. | 172 // GPU Raster picks a tile size based on the viewport size. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 318 } |
318 | 319 |
319 void AfterTest() override {} | 320 void AfterTest() override {} |
320 | 321 |
321 int frame_; | 322 int frame_; |
322 bool did_post_commit_; | 323 bool did_post_commit_; |
323 FakeContentLayerClient client_; | 324 FakeContentLayerClient client_; |
324 scoped_refptr<FakePictureLayer> picture_; | 325 scoped_refptr<FakePictureLayer> picture_; |
325 }; | 326 }; |
326 | 327 |
327 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( | 328 // Multi-thread only since there is no recycle tree in single thread. |
| 329 MULTI_THREAD_IMPL_TEST_F( |
328 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); | 330 LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); |
329 | 331 |
330 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { | 332 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { |
331 void SetupTree() override { | 333 void SetupTree() override { |
332 scoped_refptr<Layer> root = Layer::Create(); | 334 scoped_refptr<Layer> root = Layer::Create(); |
333 root->SetBounds(gfx::Size(100, 100)); | 335 root->SetBounds(gfx::Size(100, 100)); |
334 | 336 |
335 child_ = Layer::Create(); | 337 child_ = Layer::Create(); |
336 root->AddChild(child_); | 338 root->AddChild(child_); |
337 | 339 |
338 // Don't be solid color so the layer has tilings/tiles. | 340 // Don't be solid color so the layer has tilings/tiles. |
339 client_.set_fill_with_nonsolid_color(true); | 341 client_.set_fill_with_nonsolid_color(true); |
340 picture_ = FakePictureLayer::Create(&client_); | 342 picture_ = FakePictureLayer::Create(&client_); |
341 picture_->SetBounds(gfx::Size(100, 100)); | 343 picture_->SetBounds(gfx::Size(100, 100)); |
342 child_->AddChild(picture_); | 344 child_->AddChild(picture_); |
343 | 345 |
344 layer_tree_host()->SetRootLayer(root); | 346 layer_tree_host()->SetRootLayer(root); |
345 LayerTreeHostPictureTest::SetupTree(); | 347 LayerTreeHostPictureTest::SetupTree(); |
346 } | 348 } |
347 | 349 |
348 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 350 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
349 | 351 |
350 void WillActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 352 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
351 LayerImpl* root = impl->sync_tree()->root_layer(); | 353 LayerImpl* root = impl->sync_tree()->root_layer(); |
352 LayerImpl* child = root->children()[0]; | 354 LayerImpl* child = root->children()[0]; |
353 LayerImpl* gchild = child->children()[0]; | 355 LayerImpl* gchild = child->children()[0]; |
354 FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild); | 356 FakePictureLayerImpl* picture = static_cast<FakePictureLayerImpl*>(gchild); |
355 | 357 |
356 switch (impl->sync_tree()->source_frame_number()) { | 358 switch (impl->sync_tree()->source_frame_number()) { |
357 case 0: | 359 case 0: |
358 // On 1st commit the layer has tilings. | 360 // On 1st commit the layer has tilings. |
359 EXPECT_GT(picture->tilings()->num_tilings(), 0u); | 361 EXPECT_GT(picture->tilings()->num_tilings(), 0u); |
360 break; | 362 break; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 int draws_in_frame_; | 562 int draws_in_frame_; |
561 int last_frame_drawn_; | 563 int last_frame_drawn_; |
562 }; | 564 }; |
563 | 565 |
564 // 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 |
565 // compositor thread. | 567 // compositor thread. |
566 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 568 MULTI_THREAD_IMPL_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
567 | 569 |
568 } // namespace | 570 } // namespace |
569 } // namespace cc | 571 } // namespace cc |
OLD | NEW |