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_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
| 1155 2 * root_layer->bounds().height())); |
1153 scroll_layer_->SetScrollOffset(gfx::Vector2d()); | 1156 scroll_layer_->SetScrollOffset(gfx::Vector2d()); |
1154 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 1157 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 1158 // This test requires the page_scale and inner viewport layers to be |
| 1159 // identified. |
| 1160 layer_tree_host()->RegisterViewportLayers( |
| 1161 root_layer, scroll_layer_.get(), NULL); |
1155 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 1162 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
1156 } | 1163 } |
1157 | 1164 |
1158 virtual void BeginTest() OVERRIDE { | 1165 virtual void BeginTest() OVERRIDE { |
1159 PostSetNeedsCommitToMainThread(); | 1166 PostSetNeedsCommitToMainThread(); |
1160 } | 1167 } |
1161 | 1168 |
1162 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) | 1169 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
1163 OVERRIDE { | 1170 OVERRIDE { |
1164 gfx::Vector2d offset = scroll_layer_->scroll_offset(); | 1171 gfx::Vector2d offset = scroll_layer_->scroll_offset(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1461 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1455 } | 1462 } |
1456 | 1463 |
1457 virtual void SetupTree() OVERRIDE { | 1464 virtual void SetupTree() OVERRIDE { |
1458 layer_ = FakeContentLayer::Create(&client_); | 1465 layer_ = FakeContentLayer::Create(&client_); |
1459 layer_->SetBounds(gfx::Size(10, 20)); | 1466 layer_->SetBounds(gfx::Size(10, 20)); |
1460 | 1467 |
1461 bool paint_scrollbar = true; | 1468 bool paint_scrollbar = true; |
1462 bool has_thumb = false; | 1469 bool has_thumb = false; |
1463 scrollbar_ = FakePaintedScrollbarLayer::Create( | 1470 scrollbar_ = FakePaintedScrollbarLayer::Create( |
1464 paint_scrollbar, has_thumb, layer_->id()); | 1471 paint_scrollbar, has_thumb, layer_); |
1465 scrollbar_->SetPosition(gfx::Point(0, 10)); | 1472 scrollbar_->SetPosition(gfx::Point(0, 10)); |
1466 scrollbar_->SetBounds(gfx::Size(10, 10)); | 1473 scrollbar_->SetBounds(gfx::Size(10, 10)); |
1467 | 1474 |
1468 layer_->AddChild(scrollbar_); | 1475 layer_->AddChild(scrollbar_); |
1469 | 1476 |
1470 layer_tree_host()->SetRootLayer(layer_); | 1477 layer_tree_host()->SetRootLayer(layer_); |
1471 LayerTreeHostTest::SetupTree(); | 1478 LayerTreeHostTest::SetupTree(); |
1472 } | 1479 } |
1473 | 1480 |
1474 virtual void BeginTest() OVERRIDE { | 1481 virtual void BeginTest() OVERRIDE { |
(...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3450 PostSetNeedsCommitToMainThread(); | 3457 PostSetNeedsCommitToMainThread(); |
3451 } | 3458 } |
3452 | 3459 |
3453 virtual void SetupTree() OVERRIDE { | 3460 virtual void SetupTree() OVERRIDE { |
3454 root_ = Layer::Create(); | 3461 root_ = Layer::Create(); |
3455 root_->SetBounds(gfx::Size(1, 1)); | 3462 root_->SetBounds(gfx::Size(1, 1)); |
3456 | 3463 |
3457 bool paint_scrollbar = true; | 3464 bool paint_scrollbar = true; |
3458 bool has_thumb = false; | 3465 bool has_thumb = false; |
3459 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 3466 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
3460 paint_scrollbar, has_thumb, root_->id()); | 3467 paint_scrollbar, has_thumb, root_.get()); |
3461 | 3468 |
3462 root_->AddChild(scrollbar_layer_); | 3469 root_->AddChild(scrollbar_layer_); |
3463 | 3470 |
3464 layer_tree_host()->SetRootLayer(root_); | 3471 layer_tree_host()->SetRootLayer(root_); |
3465 LayerTreeHostTest::SetupTree(); | 3472 LayerTreeHostTest::SetupTree(); |
3466 } | 3473 } |
3467 | 3474 |
3468 virtual void DidCommitAndDrawFrame() OVERRIDE { | 3475 virtual void DidCommitAndDrawFrame() OVERRIDE { |
3469 switch (layer_tree_host()->source_frame_number()) { | 3476 switch (layer_tree_host()->source_frame_number()) { |
3470 case 0: | 3477 case 0: |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4766 | 4773 |
4767 EndTest(); | 4774 EndTest(); |
4768 } | 4775 } |
4769 | 4776 |
4770 virtual void AfterTest() OVERRIDE {} | 4777 virtual void AfterTest() OVERRIDE {} |
4771 }; | 4778 }; |
4772 | 4779 |
4773 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 4780 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
4774 | 4781 |
4775 } // namespace cc | 4782 } // namespace cc |
OLD | NEW |