OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/location.h" | 7 #include "base/location.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 scroll_amount_(2, -1), | 562 scroll_amount_(2, -1), |
563 num_scrolls_(0) {} | 563 num_scrolls_(0) {} |
564 | 564 |
565 void SetupTree() override { | 565 void SetupTree() override { |
566 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 566 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
567 | 567 |
568 scoped_refptr<Layer> root_layer = Layer::Create(); | 568 scoped_refptr<Layer> root_layer = Layer::Create(); |
569 root_layer->SetBounds(gfx::Size(10, 10)); | 569 root_layer->SetBounds(gfx::Size(10, 10)); |
570 | 570 |
571 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); | 571 root_scroll_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); |
572 root_scroll_layer_->SetElementId( | 572 root_scroll_layer_->SetElementId(root_scroll_layer_->id()); |
573 LayerIdToElementIdForTesting(root_scroll_layer_->id())); | |
574 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); | 573 root_scroll_layer_->SetBounds(gfx::Size(110, 110)); |
575 root_scroll_layer_->SetPosition(gfx::PointF()); | 574 root_scroll_layer_->SetPosition(gfx::PointF()); |
576 root_scroll_layer_->SetIsDrawable(true); | 575 root_scroll_layer_->SetIsDrawable(true); |
577 | 576 |
578 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_, | 577 CreateVirtualViewportLayers(root_layer.get(), root_scroll_layer_, |
579 root_layer->bounds(), root_layer->bounds(), | 578 root_layer->bounds(), root_layer->bounds(), |
580 layer_tree_host()); | 579 layer_tree_host()); |
581 | 580 |
582 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); | 581 child_layer_ = FakePictureLayer::Create(&fake_content_layer_client_); |
583 child_layer_->set_did_scroll_callback( | 582 child_layer_->set_did_scroll_callback( |
584 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, | 583 base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll, |
585 base::Unretained(this))); | 584 base::Unretained(this))); |
586 child_layer_->SetElementId( | 585 child_layer_->SetElementId(child_layer_->id()); |
587 LayerIdToElementIdForTesting(child_layer_->id())); | |
588 child_layer_->SetBounds(gfx::Size(110, 110)); | 586 child_layer_->SetBounds(gfx::Size(110, 110)); |
589 | 587 |
590 if (scroll_child_layer_) { | 588 if (scroll_child_layer_) { |
591 // Scrolls on the child layer will happen at 5, 5. If they are treated | 589 // Scrolls on the child layer will happen at 5, 5. If they are treated |
592 // like device pixels, and device scale factor is 2, then they will | 590 // like device pixels, and device scale factor is 2, then they will |
593 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. | 591 // be considered at 2.5, 2.5 in logical pixels, and will miss this layer. |
594 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); | 592 child_layer_->SetPosition(gfx::PointF(5.f, 5.f)); |
595 } else { | 593 } else { |
596 // Adjust the child layer horizontally so that scrolls will never hit it. | 594 // Adjust the child layer horizontally so that scrolls will never hit it. |
597 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); | 595 child_layer_->SetPosition(gfx::PointF(60.f, 5.f)); |
598 } | 596 } |
599 | 597 |
600 scoped_refptr<Layer> outer_container_layer = | 598 scoped_refptr<Layer> outer_container_layer = |
601 layer_tree_host()->outer_viewport_scroll_layer()->parent(); | 599 layer_tree_host()->outer_viewport_scroll_layer()->parent(); |
602 | 600 |
603 child_layer_->SetIsDrawable(true); | 601 child_layer_->SetIsDrawable(true); |
604 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); | 602 child_layer_->SetScrollClipLayerId(outer_container_layer->id()); |
605 child_layer_->SetElementId( | 603 child_layer_->SetElementId(child_layer_->id()); |
606 LayerIdToElementIdForTesting(child_layer_->id())); | |
607 child_layer_->SetBounds(root_scroll_layer_->bounds()); | 604 child_layer_->SetBounds(root_scroll_layer_->bounds()); |
608 root_scroll_layer_->AddChild(child_layer_); | 605 root_scroll_layer_->AddChild(child_layer_); |
609 | 606 |
610 if (scroll_child_layer_) { | 607 if (scroll_child_layer_) { |
611 expected_scroll_layer_ = child_layer_; | 608 expected_scroll_layer_ = child_layer_; |
612 expected_no_scroll_layer_ = root_scroll_layer_; | 609 expected_no_scroll_layer_ = root_scroll_layer_; |
613 } else { | 610 } else { |
614 expected_scroll_layer_ = root_scroll_layer_; | 611 expected_scroll_layer_ = root_scroll_layer_; |
615 expected_no_scroll_layer_ = child_layer_; | 612 expected_no_scroll_layer_ = child_layer_; |
616 } | 613 } |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 Layer* layer_; | 1430 Layer* layer_; |
1434 }; | 1431 }; |
1435 | 1432 |
1436 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { | 1433 Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { |
1437 scoped_refptr<PictureLayer> scroll_layer = | 1434 scoped_refptr<PictureLayer> scroll_layer = |
1438 PictureLayer::Create(&fake_content_layer_client_); | 1435 PictureLayer::Create(&fake_content_layer_client_); |
1439 scroll_layer->SetBounds(gfx::Size(110, 110)); | 1436 scroll_layer->SetBounds(gfx::Size(110, 110)); |
1440 scroll_layer->SetPosition(gfx::PointF()); | 1437 scroll_layer->SetPosition(gfx::PointF()); |
1441 scroll_layer->SetIsDrawable(true); | 1438 scroll_layer->SetIsDrawable(true); |
1442 scroll_layer->SetScrollClipLayerId(parent->id()); | 1439 scroll_layer->SetScrollClipLayerId(parent->id()); |
1443 scroll_layer->SetElementId( | 1440 scroll_layer->SetElementId(scroll_layer->id()); |
1444 LayerIdToElementIdForTesting(scroll_layer->id())); | |
1445 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, | 1441 scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, |
1446 parent->bounds().height() + 100)); | 1442 parent->bounds().height() + 100)); |
1447 scroll_layer->set_did_scroll_callback(base::Bind( | 1443 scroll_layer->set_did_scroll_callback(base::Bind( |
1448 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); | 1444 &FakeLayerScrollClient::DidScroll, base::Unretained(client))); |
1449 client->owner_ = this; | 1445 client->owner_ = this; |
1450 client->layer_ = scroll_layer.get(); | 1446 client->layer_ = scroll_layer.get(); |
1451 parent->AddChild(scroll_layer); | 1447 parent->AddChild(scroll_layer); |
1452 return scroll_layer.get(); | 1448 return scroll_layer.get(); |
1453 } | 1449 } |
1454 | 1450 |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 CompletionEvent* impl_side_invalidation_event_ = nullptr; | 2256 CompletionEvent* impl_side_invalidation_event_ = nullptr; |
2261 | 2257 |
2262 // Main thread. | 2258 // Main thread. |
2263 int num_of_deltas_ = 0; | 2259 int num_of_deltas_ = 0; |
2264 }; | 2260 }; |
2265 | 2261 |
2266 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplSideInvalidation); | 2262 MULTI_THREAD_TEST_F(LayerTreeHostScrollTestImplSideInvalidation); |
2267 | 2263 |
2268 } // namespace | 2264 } // namespace |
2269 } // namespace cc | 2265 } // namespace cc |
OLD | NEW |