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 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 settings->layer_transforms_should_scale_layer_contents = true; | 391 settings->layer_transforms_should_scale_layer_contents = true; |
392 } | 392 } |
393 | 393 |
394 virtual void SetupTree() OVERRIDE { | 394 virtual void SetupTree() OVERRIDE { |
395 root_layer_ = Layer::Create(); | 395 root_layer_ = Layer::Create(); |
396 root_layer_->SetBounds(gfx::Size(10, 20)); | 396 root_layer_->SetBounds(gfx::Size(10, 20)); |
397 | 397 |
398 bool paint_scrollbar = true; | 398 bool paint_scrollbar = true; |
399 bool has_thumb = false; | 399 bool has_thumb = false; |
400 scrollbar_ = FakePaintedScrollbarLayer::Create( | 400 scrollbar_ = FakePaintedScrollbarLayer::Create( |
401 paint_scrollbar, has_thumb, root_layer_->id()); | 401 paint_scrollbar, has_thumb, root_layer_.get()); |
402 scrollbar_->SetPosition(gfx::Point(0, 10)); | 402 scrollbar_->SetPosition(gfx::Point(0, 10)); |
403 scrollbar_->SetBounds(gfx::Size(10, 10)); | 403 scrollbar_->SetBounds(gfx::Size(10, 10)); |
404 | 404 |
405 root_layer_->AddChild(scrollbar_); | 405 root_layer_->AddChild(scrollbar_); |
406 | 406 |
407 layer_tree_host()->SetRootLayer(root_layer_); | 407 layer_tree_host()->SetRootLayer(root_layer_); |
408 LayerTreeHostTest::SetupTree(); | 408 LayerTreeHostTest::SetupTree(); |
409 } | 409 } |
410 | 410 |
411 virtual void BeginTest() OVERRIDE { | 411 virtual void BeginTest() OVERRIDE { |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 | 1142 |
1143 if (layer_tree_host()->settings().impl_side_painting) { | 1143 if (layer_tree_host()->settings().impl_side_painting) { |
1144 scoped_refptr<FakePictureLayer> layer = | 1144 scoped_refptr<FakePictureLayer> layer = |
1145 FakePictureLayer::Create(&client_); | 1145 FakePictureLayer::Create(&client_); |
1146 layer->set_always_update_resources(true); | 1146 layer->set_always_update_resources(true); |
1147 scroll_layer_ = layer; | 1147 scroll_layer_ = layer; |
1148 } else { | 1148 } else { |
1149 scroll_layer_ = FakeContentLayer::Create(&client_); | 1149 scroll_layer_ = FakeContentLayer::Create(&client_); |
1150 } | 1150 } |
1151 | 1151 |
1152 scroll_layer_->SetScrollable(true); | 1152 Layer* root_layer = layer_tree_host()->root_layer(); |
| 1153 scroll_layer_->SetScrollClipLayer(root_layer); |
| 1154 scroll_layer_->SetIsContainerForFixedPositionLayers(true); |
| 1155 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
| 1156 2 * root_layer->bounds().height())); |
1153 scroll_layer_->SetScrollOffset(gfx::Vector2d()); | 1157 scroll_layer_->SetScrollOffset(gfx::Vector2d()); |
1154 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 1158 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 1159 // This test requires the page_scale and inner viewport layers to be |
| 1160 // identified. |
| 1161 layer_tree_host()->RegisterViewportLayers( |
| 1162 root_layer, scroll_layer_.get(), NULL); |
1155 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 1163 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
1156 } | 1164 } |
1157 | 1165 |
1158 virtual void BeginTest() OVERRIDE { | 1166 virtual void BeginTest() OVERRIDE { |
1159 PostSetNeedsCommitToMainThread(); | 1167 PostSetNeedsCommitToMainThread(); |
1160 } | 1168 } |
1161 | 1169 |
1162 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) | 1170 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
1163 OVERRIDE { | 1171 OVERRIDE { |
1164 gfx::Vector2d offset = scroll_layer_->scroll_offset(); | 1172 gfx::Vector2d offset = scroll_layer_->scroll_offset(); |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1463 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1456 } | 1464 } |
1457 | 1465 |
1458 virtual void SetupTree() OVERRIDE { | 1466 virtual void SetupTree() OVERRIDE { |
1459 layer_ = FakeContentLayer::Create(&client_); | 1467 layer_ = FakeContentLayer::Create(&client_); |
1460 layer_->SetBounds(gfx::Size(10, 20)); | 1468 layer_->SetBounds(gfx::Size(10, 20)); |
1461 | 1469 |
1462 bool paint_scrollbar = true; | 1470 bool paint_scrollbar = true; |
1463 bool has_thumb = false; | 1471 bool has_thumb = false; |
1464 scrollbar_ = FakePaintedScrollbarLayer::Create( | 1472 scrollbar_ = FakePaintedScrollbarLayer::Create( |
1465 paint_scrollbar, has_thumb, layer_->id()); | 1473 paint_scrollbar, has_thumb, layer_); |
1466 scrollbar_->SetPosition(gfx::Point(0, 10)); | 1474 scrollbar_->SetPosition(gfx::Point(0, 10)); |
1467 scrollbar_->SetBounds(gfx::Size(10, 10)); | 1475 scrollbar_->SetBounds(gfx::Size(10, 10)); |
1468 | 1476 |
1469 layer_->AddChild(scrollbar_); | 1477 layer_->AddChild(scrollbar_); |
1470 | 1478 |
1471 layer_tree_host()->SetRootLayer(layer_); | 1479 layer_tree_host()->SetRootLayer(layer_); |
1472 LayerTreeHostTest::SetupTree(); | 1480 LayerTreeHostTest::SetupTree(); |
1473 } | 1481 } |
1474 | 1482 |
1475 virtual void BeginTest() OVERRIDE { | 1483 virtual void BeginTest() OVERRIDE { |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3451 PostSetNeedsCommitToMainThread(); | 3459 PostSetNeedsCommitToMainThread(); |
3452 } | 3460 } |
3453 | 3461 |
3454 virtual void SetupTree() OVERRIDE { | 3462 virtual void SetupTree() OVERRIDE { |
3455 root_ = Layer::Create(); | 3463 root_ = Layer::Create(); |
3456 root_->SetBounds(gfx::Size(1, 1)); | 3464 root_->SetBounds(gfx::Size(1, 1)); |
3457 | 3465 |
3458 bool paint_scrollbar = true; | 3466 bool paint_scrollbar = true; |
3459 bool has_thumb = false; | 3467 bool has_thumb = false; |
3460 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 3468 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
3461 paint_scrollbar, has_thumb, root_->id()); | 3469 paint_scrollbar, has_thumb, root_.get()); |
3462 | 3470 |
3463 root_->AddChild(scrollbar_layer_); | 3471 root_->AddChild(scrollbar_layer_); |
3464 | 3472 |
3465 layer_tree_host()->SetRootLayer(root_); | 3473 layer_tree_host()->SetRootLayer(root_); |
3466 LayerTreeHostTest::SetupTree(); | 3474 LayerTreeHostTest::SetupTree(); |
3467 } | 3475 } |
3468 | 3476 |
3469 virtual void DidCommitAndDrawFrame() OVERRIDE { | 3477 virtual void DidCommitAndDrawFrame() OVERRIDE { |
3470 switch (layer_tree_host()->source_frame_number()) { | 3478 switch (layer_tree_host()->source_frame_number()) { |
3471 case 0: | 3479 case 0: |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4767 | 4775 |
4768 EndTest(); | 4776 EndTest(); |
4769 } | 4777 } |
4770 | 4778 |
4771 virtual void AfterTest() OVERRIDE {} | 4779 virtual void AfterTest() OVERRIDE {} |
4772 }; | 4780 }; |
4773 | 4781 |
4774 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 4782 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
4775 | 4783 |
4776 } // namespace cc | 4784 } // namespace cc |
OLD | NEW |