| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 185 } |
| 186 | 186 |
| 187 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { | 187 static void ExpectClearedScrollDeltasRecursive(LayerImpl* layer) { |
| 188 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); | 188 ASSERT_EQ(layer->ScrollDelta(), gfx::Vector2d()); |
| 189 for (size_t i = 0; i < layer->children().size(); ++i) | 189 for (size_t i = 0; i < layer->children().size(); ++i) |
| 190 ExpectClearedScrollDeltasRecursive(layer->children()[i]); | 190 ExpectClearedScrollDeltasRecursive(layer->children()[i]); |
| 191 } | 191 } |
| 192 | 192 |
| 193 static void ExpectContains(const ScrollAndScaleSet& scroll_info, | 193 static void ExpectContains(const ScrollAndScaleSet& scroll_info, |
| 194 int id, | 194 int id, |
| 195 const gfx::Vector2d& scroll_delta) { | 195 const gfx::Vector2dF& scroll_delta) { |
| 196 int times_encountered = 0; | 196 int times_encountered = 0; |
| 197 | 197 |
| 198 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { | 198 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { |
| 199 if (scroll_info.scrolls[i].layer_id != id) | 199 if (scroll_info.scrolls[i].layer_id != id) |
| 200 continue; | 200 continue; |
| 201 EXPECT_VECTOR_EQ(scroll_delta, scroll_info.scrolls[i].scroll_delta); | 201 EXPECT_VECTOR2DF_NEAR(scroll_delta, scroll_info.scrolls[i].scroll_delta, |
| 202 1.0e-10); |
| 202 times_encountered++; | 203 times_encountered++; |
| 203 } | 204 } |
| 204 | 205 |
| 205 ASSERT_EQ(1, times_encountered); | 206 ASSERT_EQ(1, times_encountered); |
| 206 } | 207 } |
| 207 | 208 |
| 208 static void ExpectNone(const ScrollAndScaleSet& scroll_info, int id) { | 209 static void ExpectNone(const ScrollAndScaleSet& scroll_info, int id) { |
| 209 int times_encountered = 0; | 210 int times_encountered = 0; |
| 210 | 211 |
| 211 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { | 212 for (size_t i = 0; i < scroll_info.scrolls.size(); ++i) { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 562 |
| 562 // We should still be scrolling, because the scrolled layer also exists in the | 563 // We should still be scrolling, because the scrolled layer also exists in the |
| 563 // new tree. | 564 // new tree. |
| 564 gfx::Vector2d scroll_delta(0, 10); | 565 gfx::Vector2d scroll_delta(0, 10); |
| 565 host_impl_->ScrollBy(gfx::Point(), scroll_delta); | 566 host_impl_->ScrollBy(gfx::Point(), scroll_delta); |
| 566 host_impl_->ScrollEnd(); | 567 host_impl_->ScrollEnd(); |
| 567 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 568 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 568 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); | 569 ExpectContains(*scroll_info, scroll_layer->id(), scroll_delta); |
| 569 } | 570 } |
| 570 | 571 |
| 571 TEST_F(LayerTreeHostImplTest, WheelEventHandlers) { | 572 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnWheelEventHandlers) { |
| 572 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 573 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 573 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 574 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 574 DrawFrame(); | 575 DrawFrame(); |
| 575 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 576 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 576 | 577 |
| 578 // With registered event handlers, wheel scrolls don't necessarily |
| 579 // have to go to the main thread. |
| 577 root->SetHaveWheelEventHandlers(true); | 580 root->SetHaveWheelEventHandlers(true); |
| 581 EXPECT_EQ(InputHandler::ScrollStarted, |
| 582 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 583 host_impl_->ScrollEnd(); |
| 578 | 584 |
| 579 // With registered event handlers, wheel scrolls have to go to the main | 585 // But typically the scroll-blocks-on mode will require them to. |
| 580 // thread. | 586 root->SetScrollBlocksOn(ScrollBlocksOnWheelEvent | ScrollBlocksOnStartTouch); |
| 581 EXPECT_EQ(InputHandler::ScrollOnMainThread, | 587 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 582 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); | 588 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 583 | 589 |
| 584 // But gesture scrolls can still be handled. | 590 // But gesture scrolls can still be handled. |
| 585 EXPECT_EQ(InputHandler::ScrollStarted, | 591 EXPECT_EQ(InputHandler::ScrollStarted, |
| 586 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); | 592 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 593 host_impl_->ScrollEnd(); |
| 594 |
| 595 // And if the handlers go away, wheel scrolls can again be processed |
| 596 // on impl (despite the scroll-blocks-on mode). |
| 597 root->SetHaveWheelEventHandlers(false); |
| 598 EXPECT_EQ(InputHandler::ScrollStarted, |
| 599 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 600 host_impl_->ScrollEnd(); |
| 601 } |
| 602 |
| 603 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnTouchEventHandlers) { |
| 604 LayerImpl* scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 605 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 606 DrawFrame(); |
| 607 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 608 |
| 609 LayerImpl* child = 0; |
| 610 { |
| 611 scoped_ptr<LayerImpl> child_layer = |
| 612 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 613 child = child_layer.get(); |
| 614 child_layer->SetDrawsContent(true); |
| 615 child_layer->SetPosition(gfx::PointF(0, 20)); |
| 616 child_layer->SetBounds(gfx::Size(50, 50)); |
| 617 child_layer->SetContentBounds(gfx::Size(50, 50)); |
| 618 scroll->AddChild(child_layer.Pass()); |
| 619 } |
| 620 |
| 621 // Touch handler regions determine whether touch events block scroll. |
| 622 root->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); |
| 623 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
| 624 root->SetScrollBlocksOn(ScrollBlocksOnStartTouch | ScrollBlocksOnWheelEvent); |
| 625 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 10))); |
| 626 |
| 627 // But they don't influence the actual handling of the scroll gestures. |
| 628 EXPECT_EQ(InputHandler::ScrollStarted, |
| 629 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 630 host_impl_->ScrollEnd(); |
| 631 |
| 632 // It's the union of scroll-blocks-on mode bits across all layers in the |
| 633 // scroll paret chain that matters. |
| 634 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 635 root->SetScrollBlocksOn(ScrollBlocksOnNone); |
| 636 EXPECT_FALSE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 637 child->SetScrollBlocksOn(ScrollBlocksOnStartTouch); |
| 638 EXPECT_TRUE(host_impl_->DoTouchEventsBlockScrollAt(gfx::Point(10, 30))); |
| 639 } |
| 640 |
| 641 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnScrollEventHandlers) { |
| 642 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 643 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 644 DrawFrame(); |
| 645 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 646 |
| 647 // With registered scroll handlers, scrolls don't generally have to go |
| 648 // to the main thread. |
| 649 root->SetHaveScrollEventHandlers(true); |
| 650 EXPECT_EQ(InputHandler::ScrollStarted, |
| 651 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 652 host_impl_->ScrollEnd(); |
| 653 |
| 654 // Even the default scroll blocks on mode doesn't require this. |
| 655 root->SetScrollBlocksOn(ScrollBlocksOnWheelEvent | ScrollBlocksOnStartTouch); |
| 656 EXPECT_EQ(InputHandler::ScrollStarted, |
| 657 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 658 host_impl_->ScrollEnd(); |
| 659 |
| 660 // But the page can opt in to blocking on scroll event handlers. |
| 661 root->SetScrollBlocksOn(ScrollBlocksOnScrollEvent); |
| 662 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 663 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 664 |
| 665 // Gesture and Wheel scrolls behave identically in this regard. |
| 666 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 667 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel)); |
| 668 |
| 669 // And if the handlers go away, scrolls can again be processed on impl |
| 670 // (despite the scroll-blocks-on mode). |
| 671 root->SetHaveScrollEventHandlers(false); |
| 672 EXPECT_EQ(InputHandler::ScrollStarted, |
| 673 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); |
| 674 host_impl_->ScrollEnd(); |
| 675 } |
| 676 |
| 677 TEST_F(LayerTreeHostImplTest, ScrollBlocksOnLayerTopology) { |
| 678 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 679 |
| 680 // Create a normal scrollable root layer |
| 681 LayerImpl* root_scroll = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 682 LayerImpl* root_child = root_scroll->children()[0]; |
| 683 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 684 DrawFrame(); |
| 685 |
| 686 // Create two child scrollable layers |
| 687 LayerImpl* child1 = 0; |
| 688 { |
| 689 scoped_ptr<LayerImpl> scrollable_child_clip_1 = |
| 690 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 691 scoped_ptr<LayerImpl> scrollable_child_1 = CreateScrollableLayer( |
| 692 7, gfx::Size(10, 10), scrollable_child_clip_1.get()); |
| 693 child1 = scrollable_child_1.get(); |
| 694 scrollable_child_1->SetPosition(gfx::Point(5, 5)); |
| 695 scrollable_child_1->SetHaveWheelEventHandlers(true); |
| 696 scrollable_child_1->SetHaveScrollEventHandlers(true); |
| 697 scrollable_child_clip_1->AddChild(scrollable_child_1.Pass()); |
| 698 root_child->AddChild(scrollable_child_clip_1.Pass()); |
| 699 } |
| 700 |
| 701 LayerImpl* child2 = 0; |
| 702 { |
| 703 scoped_ptr<LayerImpl> scrollable_child_clip_2 = |
| 704 LayerImpl::Create(host_impl_->active_tree(), 8); |
| 705 scoped_ptr<LayerImpl> scrollable_child_2 = CreateScrollableLayer( |
| 706 9, gfx::Size(10, 10), scrollable_child_clip_2.get()); |
| 707 child2 = scrollable_child_2.get(); |
| 708 scrollable_child_2->SetPosition(gfx::Point(5, 20)); |
| 709 scrollable_child_2->SetHaveWheelEventHandlers(true); |
| 710 scrollable_child_2->SetHaveScrollEventHandlers(true); |
| 711 scrollable_child_clip_2->AddChild(scrollable_child_2.Pass()); |
| 712 root_child->AddChild(scrollable_child_clip_2.Pass()); |
| 713 } |
| 714 |
| 715 // Scroll-blocks-on on a layer affects scrolls that hit that layer. |
| 716 EXPECT_EQ(InputHandler::ScrollStarted, |
| 717 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture)); |
| 718 host_impl_->ScrollEnd(); |
| 719 child1->SetScrollBlocksOn(ScrollBlocksOnScrollEvent); |
| 720 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 721 host_impl_->ScrollBegin(gfx::Point(10, 10), InputHandler::Gesture)); |
| 722 |
| 723 // But not those that hit only other layers. |
| 724 EXPECT_EQ(InputHandler::ScrollStarted, |
| 725 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 726 host_impl_->ScrollEnd(); |
| 727 |
| 728 // It's the union of bits set across the scroll ancestor chain that matters. |
| 729 EXPECT_EQ(InputHandler::ScrollStarted, |
| 730 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 731 host_impl_->ScrollEnd(); |
| 732 EXPECT_EQ(InputHandler::ScrollStarted, |
| 733 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Wheel)); |
| 734 host_impl_->ScrollEnd(); |
| 735 root->SetScrollBlocksOn(ScrollBlocksOnWheelEvent); |
| 736 EXPECT_EQ(InputHandler::ScrollStarted, |
| 737 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 738 host_impl_->ScrollEnd(); |
| 739 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 740 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Wheel)); |
| 741 child2->SetScrollBlocksOn(ScrollBlocksOnScrollEvent); |
| 742 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 743 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Wheel)); |
| 744 EXPECT_EQ(InputHandler::ScrollOnMainThread, |
| 745 host_impl_->ScrollBegin(gfx::Point(10, 25), InputHandler::Gesture)); |
| 587 } | 746 } |
| 588 | 747 |
| 589 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { | 748 TEST_F(LayerTreeHostImplTest, FlingOnlyWhenScrollingTouchscreen) { |
| 590 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 749 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 591 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 750 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 592 DrawFrame(); | 751 DrawFrame(); |
| 593 | 752 |
| 594 // Ignore the fling since no layer is being scrolled | 753 // Ignore the fling since no layer is being scrolled |
| 595 EXPECT_EQ(InputHandler::ScrollIgnored, | 754 EXPECT_EQ(InputHandler::ScrollIgnored, |
| 596 host_impl_->FlingScrollBegin()); | 755 host_impl_->FlingScrollBegin()); |
| (...skipping 2939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3536 // Scroll to the right in screen coordinates with a gesture. | 3695 // Scroll to the right in screen coordinates with a gesture. |
| 3537 gfx::Vector2d gesture_scroll_delta(10, 0); | 3696 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 3538 EXPECT_EQ(InputHandler::ScrollStarted, | 3697 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3539 host_impl_->ScrollBegin(gfx::Point(), | 3698 host_impl_->ScrollBegin(gfx::Point(), |
| 3540 InputHandler::Gesture)); | 3699 InputHandler::Gesture)); |
| 3541 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3700 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 3542 host_impl_->ScrollEnd(); | 3701 host_impl_->ScrollEnd(); |
| 3543 | 3702 |
| 3544 // The layer should have scrolled down in its local coordinates. | 3703 // The layer should have scrolled down in its local coordinates. |
| 3545 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); | 3704 scoped_ptr<ScrollAndScaleSet> scroll_info = host_impl_->ProcessScrollDeltas(); |
| 3546 ExpectContains(*scroll_info.get(), | 3705 ExpectContains(*scroll_info.get(), scroll_layer->id(), |
| 3547 scroll_layer->id(), | 3706 gfx::Vector2dF(0, gesture_scroll_delta.x())); |
| 3548 gfx::Vector2d(0, gesture_scroll_delta.x())); | |
| 3549 | 3707 |
| 3550 // Reset and scroll down with the wheel. | 3708 // Reset and scroll down with the wheel. |
| 3551 scroll_layer->SetScrollDelta(gfx::Vector2dF()); | 3709 scroll_layer->SetScrollDelta(gfx::Vector2dF()); |
| 3552 gfx::Vector2d wheel_scroll_delta(0, 10); | 3710 gfx::Vector2d wheel_scroll_delta(0, 10); |
| 3553 EXPECT_EQ(InputHandler::ScrollStarted, | 3711 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3554 host_impl_->ScrollBegin(gfx::Point(), | 3712 host_impl_->ScrollBegin(gfx::Point(), |
| 3555 InputHandler::Wheel)); | 3713 InputHandler::Wheel)); |
| 3556 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); | 3714 host_impl_->ScrollBy(gfx::Point(), wheel_scroll_delta); |
| 3557 host_impl_->ScrollEnd(); | 3715 host_impl_->ScrollEnd(); |
| 3558 | 3716 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3599 // Scroll down in screen coordinates with a gesture. | 3757 // Scroll down in screen coordinates with a gesture. |
| 3600 gfx::Vector2d gesture_scroll_delta(0, 10); | 3758 gfx::Vector2d gesture_scroll_delta(0, 10); |
| 3601 EXPECT_EQ(InputHandler::ScrollStarted, | 3759 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3602 host_impl_->ScrollBegin(gfx::Point(1, 1), | 3760 host_impl_->ScrollBegin(gfx::Point(1, 1), |
| 3603 InputHandler::Gesture)); | 3761 InputHandler::Gesture)); |
| 3604 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3762 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 3605 host_impl_->ScrollEnd(); | 3763 host_impl_->ScrollEnd(); |
| 3606 | 3764 |
| 3607 // The child layer should have scrolled down in its local coordinates an | 3765 // The child layer should have scrolled down in its local coordinates an |
| 3608 // amount proportional to the angle between it and the input scroll delta. | 3766 // amount proportional to the angle between it and the input scroll delta. |
| 3609 gfx::Vector2d expected_scroll_delta( | 3767 gfx::Vector2dF expected_scroll_delta( |
| 3610 0, | 3768 0, gesture_scroll_delta.y() * |
| 3611 gesture_scroll_delta.y() * | 3769 std::cos(MathUtil::Deg2Rad(child_layer_angle))); |
| 3612 std::cos(MathUtil::Deg2Rad(child_layer_angle))); | |
| 3613 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3770 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3614 host_impl_->ProcessScrollDeltas(); | 3771 host_impl_->ProcessScrollDeltas(); |
| 3615 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 3772 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
| 3616 | 3773 |
| 3617 // The root scroll layer should not have scrolled, because the input delta | 3774 // The root scroll layer should not have scrolled, because the input delta |
| 3618 // was close to the layer's axis of movement. | 3775 // was close to the layer's axis of movement. |
| 3619 EXPECT_EQ(scroll_info->scrolls.size(), 1u); | 3776 EXPECT_EQ(scroll_info->scrolls.size(), 1u); |
| 3620 } | 3777 } |
| 3621 { | 3778 { |
| 3622 // Now reset and scroll the same amount horizontally. | 3779 // Now reset and scroll the same amount horizontally. |
| 3623 child_ptr->SetScrollDelta(gfx::Vector2dF()); | 3780 child_ptr->SetScrollDelta(gfx::Vector2dF()); |
| 3624 gfx::Vector2d gesture_scroll_delta(10, 0); | 3781 gfx::Vector2d gesture_scroll_delta(10, 0); |
| 3625 EXPECT_EQ(InputHandler::ScrollStarted, | 3782 EXPECT_EQ(InputHandler::ScrollStarted, |
| 3626 host_impl_->ScrollBegin(gfx::Point(1, 1), | 3783 host_impl_->ScrollBegin(gfx::Point(1, 1), |
| 3627 InputHandler::Gesture)); | 3784 InputHandler::Gesture)); |
| 3628 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); | 3785 host_impl_->ScrollBy(gfx::Point(), gesture_scroll_delta); |
| 3629 host_impl_->ScrollEnd(); | 3786 host_impl_->ScrollEnd(); |
| 3630 | 3787 |
| 3631 // The child layer should have scrolled down in its local coordinates an | 3788 // The child layer should have scrolled down in its local coordinates an |
| 3632 // amount proportional to the angle between it and the input scroll delta. | 3789 // amount proportional to the angle between it and the input scroll delta. |
| 3633 gfx::Vector2d expected_scroll_delta( | 3790 gfx::Vector2dF expected_scroll_delta( |
| 3634 0, | 3791 0, -gesture_scroll_delta.x() * |
| 3635 -gesture_scroll_delta.x() * | 3792 std::sin(MathUtil::Deg2Rad(child_layer_angle))); |
| 3636 std::sin(MathUtil::Deg2Rad(child_layer_angle))); | |
| 3637 scoped_ptr<ScrollAndScaleSet> scroll_info = | 3793 scoped_ptr<ScrollAndScaleSet> scroll_info = |
| 3638 host_impl_->ProcessScrollDeltas(); | 3794 host_impl_->ProcessScrollDeltas(); |
| 3639 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); | 3795 ExpectContains(*scroll_info.get(), child_layer_id, expected_scroll_delta); |
| 3640 | 3796 |
| 3641 // The root scroll layer should have scrolled more, since the input scroll | 3797 // The root scroll layer should have scrolled more, since the input scroll |
| 3642 // delta was mostly orthogonal to the child layer's vertical scroll axis. | 3798 // delta was mostly orthogonal to the child layer's vertical scroll axis. |
| 3643 gfx::Vector2d expected_root_scroll_delta( | 3799 gfx::Vector2dF expected_root_scroll_delta( |
| 3644 gesture_scroll_delta.x() * | 3800 gesture_scroll_delta.x() * |
| 3645 std::pow(std::cos(MathUtil::Deg2Rad(child_layer_angle)), 2), | 3801 std::pow(std::cos(MathUtil::Deg2Rad(child_layer_angle)), 2), |
| 3646 0); | 3802 0); |
| 3647 ExpectContains(*scroll_info.get(), | 3803 ExpectContains(*scroll_info.get(), |
| 3648 scroll_layer->id(), | 3804 scroll_layer->id(), |
| 3649 expected_root_scroll_delta); | 3805 expected_root_scroll_delta); |
| 3650 } | 3806 } |
| 3651 } | 3807 } |
| 3652 | 3808 |
| 3653 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 3809 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
| (...skipping 4372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8026 // surface. | 8182 // surface. |
| 8027 EXPECT_EQ(0, num_lost_surfaces_); | 8183 EXPECT_EQ(0, num_lost_surfaces_); |
| 8028 host_impl_->DidLoseOutputSurface(); | 8184 host_impl_->DidLoseOutputSurface(); |
| 8029 EXPECT_EQ(1, num_lost_surfaces_); | 8185 EXPECT_EQ(1, num_lost_surfaces_); |
| 8030 host_impl_->DidLoseOutputSurface(); | 8186 host_impl_->DidLoseOutputSurface(); |
| 8031 EXPECT_LE(1, num_lost_surfaces_); | 8187 EXPECT_LE(1, num_lost_surfaces_); |
| 8032 } | 8188 } |
| 8033 | 8189 |
| 8034 } // namespace | 8190 } // namespace |
| 8035 } // namespace cc | 8191 } // namespace cc |
| OLD | NEW |