OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 settings->layer_transforms_should_scale_layer_contents = true; | 385 settings->layer_transforms_should_scale_layer_contents = true; |
386 } | 386 } |
387 | 387 |
388 virtual void SetupTree() OVERRIDE { | 388 virtual void SetupTree() OVERRIDE { |
389 root_layer_ = Layer::Create(); | 389 root_layer_ = Layer::Create(); |
390 root_layer_->SetBounds(gfx::Size(10, 20)); | 390 root_layer_->SetBounds(gfx::Size(10, 20)); |
391 | 391 |
392 bool paint_scrollbar = true; | 392 bool paint_scrollbar = true; |
393 bool has_thumb = false; | 393 bool has_thumb = false; |
394 scrollbar_ = FakePaintedScrollbarLayer::Create( | 394 scrollbar_ = FakePaintedScrollbarLayer::Create( |
395 paint_scrollbar, has_thumb, root_layer_.get()); | 395 paint_scrollbar, has_thumb, root_layer_->id()); |
396 scrollbar_->SetPosition(gfx::Point(0, 10)); | 396 scrollbar_->SetPosition(gfx::Point(0, 10)); |
397 scrollbar_->SetBounds(gfx::Size(10, 10)); | 397 scrollbar_->SetBounds(gfx::Size(10, 10)); |
398 | 398 |
399 root_layer_->AddChild(scrollbar_); | 399 root_layer_->AddChild(scrollbar_); |
400 | 400 |
401 layer_tree_host()->SetRootLayer(root_layer_); | 401 layer_tree_host()->SetRootLayer(root_layer_); |
402 LayerTreeHostTest::SetupTree(); | 402 LayerTreeHostTest::SetupTree(); |
403 } | 403 } |
404 | 404 |
405 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 405 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 | 1127 |
1128 if (layer_tree_host()->settings().impl_side_painting) { | 1128 if (layer_tree_host()->settings().impl_side_painting) { |
1129 scoped_refptr<FakePictureLayer> layer = | 1129 scoped_refptr<FakePictureLayer> layer = |
1130 FakePictureLayer::Create(&client_); | 1130 FakePictureLayer::Create(&client_); |
1131 layer->set_always_update_resources(true); | 1131 layer->set_always_update_resources(true); |
1132 scroll_layer_ = layer; | 1132 scroll_layer_ = layer; |
1133 } else { | 1133 } else { |
1134 scroll_layer_ = FakeContentLayer::Create(&client_); | 1134 scroll_layer_ = FakeContentLayer::Create(&client_); |
1135 } | 1135 } |
1136 | 1136 |
1137 Layer* root_layer = layer_tree_host()->root_layer(); | 1137 scroll_layer_->SetScrollable(true); |
1138 scroll_layer_->SetScrollClipLayer(root_layer); | |
1139 scroll_layer_->SetIsContainerForFixedPositionLayers(true); | |
1140 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), | |
1141 2 * root_layer->bounds().height())); | |
1142 scroll_layer_->SetScrollOffset(gfx::Vector2d()); | 1138 scroll_layer_->SetScrollOffset(gfx::Vector2d()); |
1143 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 1139 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
1144 // This test requires the page_scale and inner viewport layers to be | |
1145 // identified. | |
1146 layer_tree_host()->RegisterViewportLayers( | |
1147 root_layer, scroll_layer_.get(), NULL); | |
1148 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 1140 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
1149 } | 1141 } |
1150 | 1142 |
1151 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1143 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
1152 | 1144 |
1153 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 1145 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, |
1154 float scale) OVERRIDE { | 1146 float scale) OVERRIDE { |
1155 gfx::Vector2d offset = scroll_layer_->scroll_offset(); | 1147 gfx::Vector2d offset = scroll_layer_->scroll_offset(); |
1156 scroll_layer_->SetScrollOffset(offset + scroll_delta); | 1148 scroll_layer_->SetScrollOffset(offset + scroll_delta); |
1157 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); | 1149 layer_tree_host()->SetPageScaleFactorAndLimits(scale, 0.5f, 2.f); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1438 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1447 } | 1439 } |
1448 | 1440 |
1449 virtual void SetupTree() OVERRIDE { | 1441 virtual void SetupTree() OVERRIDE { |
1450 layer_ = FakeContentLayer::Create(&client_); | 1442 layer_ = FakeContentLayer::Create(&client_); |
1451 layer_->SetBounds(gfx::Size(10, 20)); | 1443 layer_->SetBounds(gfx::Size(10, 20)); |
1452 | 1444 |
1453 bool paint_scrollbar = true; | 1445 bool paint_scrollbar = true; |
1454 bool has_thumb = false; | 1446 bool has_thumb = false; |
1455 scrollbar_ = FakePaintedScrollbarLayer::Create( | 1447 scrollbar_ = FakePaintedScrollbarLayer::Create( |
1456 paint_scrollbar, has_thumb, layer_); | 1448 paint_scrollbar, has_thumb, layer_->id()); |
1457 scrollbar_->SetPosition(gfx::Point(0, 10)); | 1449 scrollbar_->SetPosition(gfx::Point(0, 10)); |
1458 scrollbar_->SetBounds(gfx::Size(10, 10)); | 1450 scrollbar_->SetBounds(gfx::Size(10, 10)); |
1459 | 1451 |
1460 layer_->AddChild(scrollbar_); | 1452 layer_->AddChild(scrollbar_); |
1461 | 1453 |
1462 layer_tree_host()->SetRootLayer(layer_); | 1454 layer_tree_host()->SetRootLayer(layer_); |
1463 LayerTreeHostTest::SetupTree(); | 1455 LayerTreeHostTest::SetupTree(); |
1464 } | 1456 } |
1465 | 1457 |
1466 virtual void BeginTest() OVERRIDE { | 1458 virtual void BeginTest() OVERRIDE { |
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 protected: | 3653 protected: |
3662 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 3654 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
3663 | 3655 |
3664 virtual void SetupTree() OVERRIDE { | 3656 virtual void SetupTree() OVERRIDE { |
3665 root_ = Layer::Create(); | 3657 root_ = Layer::Create(); |
3666 root_->SetBounds(gfx::Size(1, 1)); | 3658 root_->SetBounds(gfx::Size(1, 1)); |
3667 | 3659 |
3668 bool paint_scrollbar = true; | 3660 bool paint_scrollbar = true; |
3669 bool has_thumb = false; | 3661 bool has_thumb = false; |
3670 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 3662 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
3671 paint_scrollbar, has_thumb, root_.get()); | 3663 paint_scrollbar, has_thumb, root_->id()); |
3672 | 3664 |
3673 root_->AddChild(scrollbar_layer_); | 3665 root_->AddChild(scrollbar_layer_); |
3674 | 3666 |
3675 layer_tree_host()->SetRootLayer(root_); | 3667 layer_tree_host()->SetRootLayer(root_); |
3676 LayerTreeHostTest::SetupTree(); | 3668 LayerTreeHostTest::SetupTree(); |
3677 } | 3669 } |
3678 | 3670 |
3679 virtual void DidCommitAndDrawFrame() OVERRIDE { | 3671 virtual void DidCommitAndDrawFrame() OVERRIDE { |
3680 switch (layer_tree_host()->source_frame_number()) { | 3672 switch (layer_tree_host()->source_frame_number()) { |
3681 case 0: | 3673 case 0: |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4955 | 4947 |
4956 EndTest(); | 4948 EndTest(); |
4957 } | 4949 } |
4958 | 4950 |
4959 virtual void AfterTest() OVERRIDE {} | 4951 virtual void AfterTest() OVERRIDE {} |
4960 }; | 4952 }; |
4961 | 4953 |
4962 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 4954 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
4963 | 4955 |
4964 } // namespace cc | 4956 } // namespace cc |
OLD | NEW |