| 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(layer_settings()); | 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(layer_settings(), &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 client_.set_bounds(size); |
| 28 } | 29 } |
| 29 | 30 |
| 30 scoped_refptr<FakePictureLayer> root_picture_layer_; | 31 scoped_refptr<FakePictureLayer> root_picture_layer_; |
| 31 FakeContentLayerClient client_; | 32 FakeContentLayerClient client_; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 class LayerTreeHostPictureTestTwinLayer | 35 class LayerTreeHostPictureTestTwinLayer |
| 35 : public LayerTreeHostPictureTest { | 36 : public LayerTreeHostPictureTest { |
| 36 void SetupTree() override { | 37 void SetupTree() override { |
| 37 SetupTreeWithSinglePictureLayer(gfx::Size(1, 1)); | 38 SetupTreeWithSinglePictureLayer(gfx::Size(1, 1)); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 133 |
| 133 class LayerTreeHostPictureTestResizeViewportWithGpuRaster | 134 class LayerTreeHostPictureTestResizeViewportWithGpuRaster |
| 134 : public LayerTreeHostPictureTest { | 135 : public LayerTreeHostPictureTest { |
| 135 void InitializeSettings(LayerTreeSettings* settings) override { | 136 void InitializeSettings(LayerTreeSettings* settings) override { |
| 136 settings->gpu_rasterization_forced = true; | 137 settings->gpu_rasterization_forced = true; |
| 137 } | 138 } |
| 138 | 139 |
| 139 void SetupTree() override { | 140 void SetupTree() override { |
| 140 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 141 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 141 root->SetBounds(gfx::Size(768, 960)); | 142 root->SetBounds(gfx::Size(768, 960)); |
| 142 | 143 client_.set_bounds(root->bounds()); |
| 143 client_.set_fill_with_nonsolid_color(true); | 144 client_.set_fill_with_nonsolid_color(true); |
| 144 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 145 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 145 picture_->SetBounds(gfx::Size(768, 960)); | 146 picture_->SetBounds(gfx::Size(768, 960)); |
| 146 root->AddChild(picture_); | 147 root->AddChild(picture_); |
| 147 | 148 |
| 148 layer_tree_host()->SetRootLayer(root); | 149 layer_tree_host()->SetRootLayer(root); |
| 149 LayerTreeHostPictureTest::SetupTree(); | 150 LayerTreeHostPictureTest::SetupTree(); |
| 150 } | 151 } |
| 151 | 152 |
| 152 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 153 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 LayerTreeHostPictureTestResizeViewportWithGpuRaster); | 196 LayerTreeHostPictureTestResizeViewportWithGpuRaster); |
| 196 | 197 |
| 197 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree | 198 class LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree |
| 198 : public LayerTreeHostPictureTest { | 199 : public LayerTreeHostPictureTest { |
| 199 void SetupTree() override { | 200 void SetupTree() override { |
| 200 frame_ = 0; | 201 frame_ = 0; |
| 201 did_post_commit_ = false; | 202 did_post_commit_ = false; |
| 202 | 203 |
| 203 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 204 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 204 root->SetBounds(gfx::Size(100, 100)); | 205 root->SetBounds(gfx::Size(100, 100)); |
| 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(layer_settings(), &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 // picture_'s transform is going to be changing on the compositor thread, so | 213 // picture_'s transform is going to be changing on the compositor thread, so |
| 214 // force it to have a transform node by making it scrollable. | 214 // force it to have a transform node by making it scrollable. |
| 215 picture_->SetScrollClipLayerId(root->id()); | 215 picture_->SetScrollClipLayerId(root->id()); |
| 216 | 216 |
| 217 layer_tree_host()->SetRootLayer(root); | 217 layer_tree_host()->SetRootLayer(root); |
| 218 LayerTreeHostPictureTest::SetupTree(); | 218 LayerTreeHostPictureTest::SetupTree(); |
| 219 client_.set_bounds(picture_->bounds()); |
| 219 } | 220 } |
| 220 | 221 |
| 221 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 222 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 222 | 223 |
| 223 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | 224 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { |
| 224 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; | 225 LayerImpl* child = impl->active_tree()->root_layer()->children()[0]; |
| 225 FakePictureLayerImpl* picture_impl = | 226 FakePictureLayerImpl* picture_impl = |
| 226 static_cast<FakePictureLayerImpl*>(child); | 227 static_cast<FakePictureLayerImpl*>(child); |
| 227 switch (++frame_) { | 228 switch (++frame_) { |
| 228 case 1: { | 229 case 1: { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 scoped_refptr<FakePictureLayer> picture_; | 302 scoped_refptr<FakePictureLayer> picture_; |
| 302 }; | 303 }; |
| 303 | 304 |
| 304 // Multi-thread only since there is no recycle tree in single thread. | 305 // Multi-thread only since there is no recycle tree in single thread. |
| 305 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); | 306 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestChangeLiveTilesRectWithRecycleTree); |
| 306 | 307 |
| 307 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { | 308 class LayerTreeHostPictureTestRSLLMembership : public LayerTreeHostPictureTest { |
| 308 void SetupTree() override { | 309 void SetupTree() override { |
| 309 scoped_refptr<Layer> root = Layer::Create(layer_settings()); | 310 scoped_refptr<Layer> root = Layer::Create(layer_settings()); |
| 310 root->SetBounds(gfx::Size(100, 100)); | 311 root->SetBounds(gfx::Size(100, 100)); |
| 312 client_.set_bounds(root->bounds()); |
| 311 | 313 |
| 312 child_ = Layer::Create(layer_settings()); | 314 child_ = Layer::Create(layer_settings()); |
| 313 root->AddChild(child_); | 315 root->AddChild(child_); |
| 314 | 316 |
| 315 // Don't be solid color so the layer has tilings/tiles. | 317 // Don't be solid color so the layer has tilings/tiles. |
| 316 client_.set_fill_with_nonsolid_color(true); | 318 client_.set_fill_with_nonsolid_color(true); |
| 317 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 319 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 318 picture_->SetBounds(gfx::Size(100, 100)); | 320 picture_->SetBounds(gfx::Size(100, 100)); |
| 319 child_->AddChild(picture_); | 321 child_->AddChild(picture_); |
| 320 | 322 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 // Don't be solid color so the layer has tilings/tiles. | 409 // Don't be solid color so the layer has tilings/tiles. |
| 408 client_.set_fill_with_nonsolid_color(true); | 410 client_.set_fill_with_nonsolid_color(true); |
| 409 picture_ = FakePictureLayer::Create(layer_settings(), &client_); | 411 picture_ = FakePictureLayer::Create(layer_settings(), &client_); |
| 410 picture_->SetBounds(gfx::Size(100, 100)); | 412 picture_->SetBounds(gfx::Size(100, 100)); |
| 411 pinch_->AddChild(picture_); | 413 pinch_->AddChild(picture_); |
| 412 | 414 |
| 413 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, nullptr); | 415 layer_tree_host()->RegisterViewportLayers(NULL, root, pinch_, nullptr); |
| 414 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 416 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
| 415 layer_tree_host()->SetRootLayer(root); | 417 layer_tree_host()->SetRootLayer(root); |
| 416 LayerTreeHostPictureTest::SetupTree(); | 418 LayerTreeHostPictureTest::SetupTree(); |
| 419 client_.set_bounds(picture_->bounds()); |
| 417 } | 420 } |
| 418 | 421 |
| 419 void InitializeSettings(LayerTreeSettings* settings) override { | 422 void InitializeSettings(LayerTreeSettings* settings) override { |
| 420 settings->layer_transforms_should_scale_layer_contents = true; | 423 settings->layer_transforms_should_scale_layer_contents = true; |
| 421 } | 424 } |
| 422 | 425 |
| 423 void BeginTest() override { | 426 void BeginTest() override { |
| 424 frame_ = 0; | 427 frame_ = 0; |
| 425 draws_in_frame_ = 0; | 428 draws_in_frame_ = 0; |
| 426 last_frame_drawn_ = -1; | 429 last_frame_drawn_ = -1; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 int last_frame_drawn_; | 557 int last_frame_drawn_; |
| 555 bool ready_to_draw_; | 558 bool ready_to_draw_; |
| 556 }; | 559 }; |
| 557 | 560 |
| 558 // Multi-thread only because in single thread you can't pinch zoom on the | 561 // Multi-thread only because in single thread you can't pinch zoom on the |
| 559 // compositor thread. | 562 // compositor thread. |
| 560 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); | 563 MULTI_THREAD_TEST_F(LayerTreeHostPictureTestRSLLMembershipWithScale); |
| 561 | 564 |
| 562 } // namespace | 565 } // namespace |
| 563 } // namespace cc | 566 } // namespace cc |
| OLD | NEW |