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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 settings->layer_transforms_should_scale_layer_contents = true; | 390 settings->layer_transforms_should_scale_layer_contents = true; |
391 } | 391 } |
392 | 392 |
393 virtual void SetupTree() OVERRIDE { | 393 virtual void SetupTree() OVERRIDE { |
394 root_layer_ = Layer::Create(); | 394 root_layer_ = Layer::Create(); |
395 root_layer_->SetBounds(gfx::Size(10, 20)); | 395 root_layer_->SetBounds(gfx::Size(10, 20)); |
396 | 396 |
397 bool paint_scrollbar = true; | 397 bool paint_scrollbar = true; |
398 bool has_thumb = false; | 398 bool has_thumb = false; |
399 scrollbar_ = FakePaintedScrollbarLayer::Create( | 399 scrollbar_ = FakePaintedScrollbarLayer::Create( |
400 paint_scrollbar, has_thumb, root_layer_->id()); | 400 paint_scrollbar, has_thumb, root_layer_.get()); |
401 scrollbar_->SetPosition(gfx::Point(0, 10)); | 401 scrollbar_->SetPosition(gfx::Point(0, 10)); |
402 scrollbar_->SetBounds(gfx::Size(10, 10)); | 402 scrollbar_->SetBounds(gfx::Size(10, 10)); |
403 | 403 |
404 root_layer_->AddChild(scrollbar_); | 404 root_layer_->AddChild(scrollbar_); |
405 | 405 |
406 layer_tree_host()->SetRootLayer(root_layer_); | 406 layer_tree_host()->SetRootLayer(root_layer_); |
407 LayerTreeHostTest::SetupTree(); | 407 LayerTreeHostTest::SetupTree(); |
408 } | 408 } |
409 | 409 |
410 virtual void BeginTest() OVERRIDE { | 410 virtual void BeginTest() OVERRIDE { |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 | 1141 |
1142 if (layer_tree_host()->settings().impl_side_painting) { | 1142 if (layer_tree_host()->settings().impl_side_painting) { |
1143 scoped_refptr<FakePictureLayer> layer = | 1143 scoped_refptr<FakePictureLayer> layer = |
1144 FakePictureLayer::Create(&client_); | 1144 FakePictureLayer::Create(&client_); |
1145 layer->set_always_update_resources(true); | 1145 layer->set_always_update_resources(true); |
1146 scroll_layer_ = layer; | 1146 scroll_layer_ = layer; |
1147 } else { | 1147 } else { |
1148 scroll_layer_ = FakeContentLayer::Create(&client_); | 1148 scroll_layer_ = FakeContentLayer::Create(&client_); |
1149 } | 1149 } |
1150 | 1150 |
1151 scroll_layer_->SetScrollable(true); | 1151 Layer* root_layer = layer_tree_host()->root_layer(); |
| 1152 scroll_layer_->SetScrollable(root_layer); |
| 1153 scroll_layer_->SetBounds(gfx::Size(2 * root_layer->bounds().width(), |
| 1154 2 * root_layer->bounds().height())); |
1152 scroll_layer_->SetScrollOffset(gfx::Vector2d()); | 1155 scroll_layer_->SetScrollOffset(gfx::Vector2d()); |
1153 layer_tree_host()->root_layer()->AddChild(scroll_layer_); | 1156 layer_tree_host()->root_layer()->AddChild(scroll_layer_); |
| 1157 // This test requires the page_scale and inner viewport layers to be |
| 1158 // identified. |
| 1159 layer_tree_host()->RegisterViewportLayers( |
| 1160 root_layer, scroll_layer_.get(), NULL); |
1154 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); | 1161 layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.5f, 2.f); |
1155 } | 1162 } |
1156 | 1163 |
1157 virtual void BeginTest() OVERRIDE { | 1164 virtual void BeginTest() OVERRIDE { |
1158 PostSetNeedsCommitToMainThread(); | 1165 PostSetNeedsCommitToMainThread(); |
1159 } | 1166 } |
1160 | 1167 |
1161 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) | 1168 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, float scale) |
1162 OVERRIDE { | 1169 OVERRIDE { |
1163 gfx::Vector2d offset = scroll_layer_->scroll_offset(); | 1170 gfx::Vector2d offset = scroll_layer_->scroll_offset(); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; | 1460 settings->scrollbar_animator = LayerTreeSettings::NoAnimator; |
1454 } | 1461 } |
1455 | 1462 |
1456 virtual void SetupTree() OVERRIDE { | 1463 virtual void SetupTree() OVERRIDE { |
1457 layer_ = FakeContentLayer::Create(&client_); | 1464 layer_ = FakeContentLayer::Create(&client_); |
1458 layer_->SetBounds(gfx::Size(10, 20)); | 1465 layer_->SetBounds(gfx::Size(10, 20)); |
1459 | 1466 |
1460 bool paint_scrollbar = true; | 1467 bool paint_scrollbar = true; |
1461 bool has_thumb = false; | 1468 bool has_thumb = false; |
1462 scrollbar_ = FakePaintedScrollbarLayer::Create( | 1469 scrollbar_ = FakePaintedScrollbarLayer::Create( |
1463 paint_scrollbar, has_thumb, layer_->id()); | 1470 paint_scrollbar, has_thumb, layer_); |
1464 scrollbar_->SetPosition(gfx::Point(0, 10)); | 1471 scrollbar_->SetPosition(gfx::Point(0, 10)); |
1465 scrollbar_->SetBounds(gfx::Size(10, 10)); | 1472 scrollbar_->SetBounds(gfx::Size(10, 10)); |
1466 | 1473 |
1467 layer_->AddChild(scrollbar_); | 1474 layer_->AddChild(scrollbar_); |
1468 | 1475 |
1469 layer_tree_host()->SetRootLayer(layer_); | 1476 layer_tree_host()->SetRootLayer(layer_); |
1470 LayerTreeHostTest::SetupTree(); | 1477 LayerTreeHostTest::SetupTree(); |
1471 } | 1478 } |
1472 | 1479 |
1473 virtual void BeginTest() OVERRIDE { | 1480 virtual void BeginTest() OVERRIDE { |
(...skipping 2621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4095 PostSetNeedsCommitToMainThread(); | 4102 PostSetNeedsCommitToMainThread(); |
4096 } | 4103 } |
4097 | 4104 |
4098 virtual void SetupTree() OVERRIDE { | 4105 virtual void SetupTree() OVERRIDE { |
4099 root_ = Layer::Create(); | 4106 root_ = Layer::Create(); |
4100 root_->SetBounds(gfx::Size(1, 1)); | 4107 root_->SetBounds(gfx::Size(1, 1)); |
4101 | 4108 |
4102 bool paint_scrollbar = true; | 4109 bool paint_scrollbar = true; |
4103 bool has_thumb = false; | 4110 bool has_thumb = false; |
4104 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 4111 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
4105 paint_scrollbar, has_thumb, root_->id()); | 4112 paint_scrollbar, has_thumb, root_.get()); |
4106 | 4113 |
4107 root_->AddChild(scrollbar_layer_); | 4114 root_->AddChild(scrollbar_layer_); |
4108 | 4115 |
4109 layer_tree_host()->SetRootLayer(root_); | 4116 layer_tree_host()->SetRootLayer(root_); |
4110 LayerTreeHostTest::SetupTree(); | 4117 LayerTreeHostTest::SetupTree(); |
4111 } | 4118 } |
4112 | 4119 |
4113 virtual void DidCommitAndDrawFrame() OVERRIDE { | 4120 virtual void DidCommitAndDrawFrame() OVERRIDE { |
4114 switch (layer_tree_host()->source_frame_number()) { | 4121 switch (layer_tree_host()->source_frame_number()) { |
4115 case 0: | 4122 case 0: |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5209 size_t second_output_surface_memory_limit_; | 5216 size_t second_output_surface_memory_limit_; |
5210 FakeContentLayerClient client_; | 5217 FakeContentLayerClient client_; |
5211 scoped_refptr<FakeContentLayer> root_; | 5218 scoped_refptr<FakeContentLayer> root_; |
5212 }; | 5219 }; |
5213 | 5220 |
5214 // No output to copy for delegated renderers. | 5221 // No output to copy for delegated renderers. |
5215 SINGLE_AND_MULTI_THREAD_TEST_F( | 5222 SINGLE_AND_MULTI_THREAD_TEST_F( |
5216 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 5223 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
5217 | 5224 |
5218 } // namespace cc | 5225 } // namespace cc |
OLD | NEW |