| 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/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 565 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 566 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 566 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 567 initializeRendererAndDrawFrame(); | 567 initializeRendererAndDrawFrame(); |
| 568 | 568 |
| 569 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 569 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 570 DCHECK(scrollLayer); | 570 DCHECK(scrollLayer); |
| 571 | 571 |
| 572 const float minPageScale = 1, maxPageScale = 4; | 572 const float minPageScale = 1, maxPageScale = 4; |
| 573 const gfx::Transform identityScaleTransform; | 573 const gfx::Transform identityScaleTransform; |
| 574 | 574 |
| 575 // The impl-based pinch zoom should adjust the max scroll position. |
| 576 { |
| 577 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 578 m_hostImpl->activeTree()->SetPageScaleDelta(1); |
| 579 scrollLayer->setImplTransform(identityScaleTransform); |
| 580 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 581 |
| 582 float pageScaleDelta = 2; |
| 583 m_hostImpl->pinchGestureBegin(); |
| 584 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); |
| 585 m_hostImpl->pinchGestureEnd(); |
| 586 EXPECT_TRUE(m_didRequestRedraw); |
| 587 EXPECT_TRUE(m_didRequestCommit); |
| 588 |
| 589 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 590 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 591 |
| 592 EXPECT_EQ(gfx::Vector2d(75, 75), m_hostImpl->rootLayer()->maxScrollOffse
t()); |
| 593 } |
| 594 |
| 575 // Scrolling after a pinch gesture should always be in local space. The scr
oll deltas do not | 595 // Scrolling after a pinch gesture should always be in local space. The scr
oll deltas do not |
| 576 // have the page scale factor applied. | 596 // have the page scale factor applied. |
| 577 { | 597 { |
| 578 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 598 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 599 m_hostImpl->activeTree()->SetPageScaleDelta(1); |
| 579 scrollLayer->setImplTransform(identityScaleTransform); | 600 scrollLayer->setImplTransform(identityScaleTransform); |
| 580 scrollLayer->setScrollDelta(gfx::Vector2d()); | 601 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 581 | 602 |
| 582 float pageScaleDelta = 2; | 603 float pageScaleDelta = 2; |
| 583 m_hostImpl->pinchGestureBegin(); | 604 m_hostImpl->pinchGestureBegin(); |
| 584 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); | 605 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); |
| 585 m_hostImpl->pinchGestureEnd(); | 606 m_hostImpl->pinchGestureEnd(); |
| 586 | 607 |
| 587 gfx::Vector2d scrollDelta(0, 10); | 608 gfx::Vector2d scrollDelta(0, 10); |
| 588 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); | 609 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::
Wheel), InputHandlerClient::ScrollStarted); |
| 589 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 610 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 590 m_hostImpl->scrollEnd(); | 611 m_hostImpl->scrollEnd(); |
| 591 | 612 |
| 592 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 613 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 593 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); | 614 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD
elta); |
| 594 } | 615 } |
| 595 } | 616 } |
| 596 | 617 |
| 597 TEST_P(LayerTreeHostImplTest, pinchGesture) | 618 TEST_P(LayerTreeHostImplTest, pinchGesture) |
| 598 { | 619 { |
| 620 // This test is specific to the page-scale based pinch zoom. |
| 621 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
| 622 return; |
| 623 |
| 599 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 624 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 600 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 625 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 601 initializeRendererAndDrawFrame(); | 626 initializeRendererAndDrawFrame(); |
| 602 | 627 |
| 603 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 628 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
| 604 DCHECK(scrollLayer); | 629 DCHECK(scrollLayer); |
| 605 | 630 |
| 606 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled
? 1 : 0.5; | 631 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled
? 1 : 0.5; |
| 607 const float maxPageScale = 4; | 632 const float maxPageScale = 4; |
| 608 const gfx::Transform identityScaleTransform; | 633 const gfx::Transform identityScaleTransform; |
| 609 | 634 |
| 610 // Basic pinch zoom in gesture | 635 // Basic pinch zoom in gesture |
| 611 { | 636 { |
| 612 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 637 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 613 scrollLayer->setImplTransform(identityScaleTransform); | 638 scrollLayer->setImplTransform(identityScaleTransform); |
| 614 scrollLayer->setScrollDelta(gfx::Vector2d()); | 639 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 615 | 640 |
| 616 float pageScaleDelta = 2; | 641 float pageScaleDelta = 2; |
| 617 m_hostImpl->pinchGestureBegin(); | 642 m_hostImpl->pinchGestureBegin(); |
| 618 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); | 643 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); |
| 619 m_hostImpl->pinchGestureEnd(); | 644 m_hostImpl->pinchGestureEnd(); |
| 620 EXPECT_TRUE(m_didRequestRedraw); | 645 EXPECT_TRUE(m_didRequestRedraw); |
| 621 EXPECT_TRUE(m_didRequestCommit); | 646 EXPECT_TRUE(m_didRequestCommit); |
| 622 | 647 |
| 623 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 648 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 624 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 649 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 625 } | 650 } |
| 626 | 651 |
| 627 // Zoom-in clamping | 652 // Zoom-in clamping |
| 628 { | 653 { |
| 629 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 654 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 630 scrollLayer->setImplTransform(identityScaleTransform); | 655 scrollLayer->setImplTransform(identityScaleTransform); |
| 631 scrollLayer->setScrollDelta(gfx::Vector2d()); | 656 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 632 float pageScaleDelta = 10; | 657 float pageScaleDelta = 10; |
| 633 | 658 |
| 634 m_hostImpl->pinchGestureBegin(); | 659 m_hostImpl->pinchGestureBegin(); |
| 635 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); | 660 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); |
| 636 m_hostImpl->pinchGestureEnd(); | 661 m_hostImpl->pinchGestureEnd(); |
| 637 | 662 |
| 638 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 663 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 639 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); | 664 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); |
| 640 } | 665 } |
| 641 | 666 |
| 642 // Zoom-out clamping | 667 // Zoom-out clamping |
| 643 { | 668 { |
| 644 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 669 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 645 scrollLayer->setImplTransform(identityScaleTransform); | 670 scrollLayer->setImplTransform(identityScaleTransform); |
| 646 scrollLayer->setScrollDelta(gfx::Vector2d()); | 671 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 647 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 672 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); |
| 648 | 673 |
| 649 float pageScaleDelta = 0.1f; | 674 float pageScaleDelta = 0.1f; |
| 650 m_hostImpl->pinchGestureBegin(); | 675 m_hostImpl->pinchGestureBegin(); |
| 651 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); | 676 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); |
| 652 m_hostImpl->pinchGestureEnd(); | 677 m_hostImpl->pinchGestureEnd(); |
| 653 | 678 |
| 654 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 679 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 655 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 680 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 656 | 681 |
| 657 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 682 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 658 // Pushed to (0,0) via clamping against contents layer size. | 683 // Pushed to (0,0) via clamping against contents layer size. |
| 659 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -5
0)); | 684 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -5
0)); |
| 660 } else { | 685 } else { |
| 661 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 686 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 662 } | 687 } |
| 663 } | 688 } |
| 664 | 689 |
| 665 // Two-finger panning should not happen based on pinch events only | 690 // Two-finger panning should not happen based on pinch events only |
| 666 { | 691 { |
| 667 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 692 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 668 scrollLayer->setImplTransform(identityScaleTransform); | 693 scrollLayer->setImplTransform(identityScaleTransform); |
| 669 scrollLayer->setScrollDelta(gfx::Vector2d()); | 694 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 670 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); | 695 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); |
| 671 | 696 |
| 672 float pageScaleDelta = 1; | 697 float pageScaleDelta = 1; |
| 673 m_hostImpl->pinchGestureBegin(); | 698 m_hostImpl->pinchGestureBegin(); |
| 674 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); | 699 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
| 675 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); | 700 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
| 676 m_hostImpl->pinchGestureEnd(); | 701 m_hostImpl->pinchGestureEnd(); |
| 677 | 702 |
| 678 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 703 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 679 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 704 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 680 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 705 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 681 } | 706 } |
| 682 | 707 |
| 683 // Two-finger panning should work with interleaved scroll events | 708 // Two-finger panning should work with interleaved scroll events |
| 684 { | 709 { |
| 685 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 710 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 686 scrollLayer->setImplTransform(identityScaleTransform); | 711 scrollLayer->setImplTransform(identityScaleTransform); |
| 687 scrollLayer->setScrollDelta(gfx::Vector2d()); | 712 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 688 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); | 713 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); |
| 689 | 714 |
| 690 float pageScaleDelta = 1; | 715 float pageScaleDelta = 1; |
| 691 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); | 716 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); |
| 692 m_hostImpl->pinchGestureBegin(); | 717 m_hostImpl->pinchGestureBegin(); |
| 693 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); | 718 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
| 694 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); | 719 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
| 695 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); | 720 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 714 const float minPageScale = 0.5; | 739 const float minPageScale = 0.5; |
| 715 const float maxPageScale = 4; | 740 const float maxPageScale = 4; |
| 716 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 741 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
| 717 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 742 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
| 718 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 743 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
| 719 const base::TimeTicks endTime = startTime + duration; | 744 const base::TimeTicks endTime = startTime + duration; |
| 720 const gfx::Transform identityScaleTransform; | 745 const gfx::Transform identityScaleTransform; |
| 721 | 746 |
| 722 // Non-anchor zoom-in | 747 // Non-anchor zoom-in |
| 723 { | 748 { |
| 724 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 749 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 725 scrollLayer->setImplTransform(identityScaleTransform); | 750 scrollLayer->setImplTransform(identityScaleTransform); |
| 726 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 751 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); |
| 727 | 752 |
| 728 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start
Time, duration); | 753 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start
Time, duration); |
| 729 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); | 754 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); |
| 730 EXPECT_TRUE(m_didRequestRedraw); | 755 EXPECT_TRUE(m_didRequestRedraw); |
| 731 m_hostImpl->animate(endTime, base::Time()); | 756 m_hostImpl->animate(endTime, base::Time()); |
| 732 EXPECT_TRUE(m_didRequestCommit); | 757 EXPECT_TRUE(m_didRequestCommit); |
| 733 | 758 |
| 734 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 759 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 735 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); | 760 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); |
| 736 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); | 761 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); |
| 737 } | 762 } |
| 738 | 763 |
| 739 // Anchor zoom-out | 764 // Anchor zoom-out |
| 740 { | 765 { |
| 741 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 766 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, minPageScale, m
axPageScale); |
| 742 scrollLayer->setImplTransform(identityScaleTransform); | 767 scrollLayer->setImplTransform(identityScaleTransform); |
| 743 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); | 768 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); |
| 744 | 769 |
| 745 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPage
Scale, startTime, duration); | 770 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(25, 25), true, minPage
Scale, startTime, duration); |
| 746 m_hostImpl->animate(endTime, base::Time()); | 771 m_hostImpl->animate(endTime, base::Time()); |
| 747 EXPECT_TRUE(m_didRequestRedraw); | 772 EXPECT_TRUE(m_didRequestRedraw); |
| 748 EXPECT_TRUE(m_didRequestCommit); | 773 EXPECT_TRUE(m_didRequestCommit); |
| 749 | 774 |
| 750 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 775 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 751 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 776 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 752 // Pushed to (0,0) via clamping against contents layer size. | 777 // Pushed to (0,0) via clamping against contents layer size. |
| 753 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); | 778 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -50)); |
| 754 } | 779 } |
| 755 } | 780 } |
| 756 | 781 |
| 757 TEST_P(LayerTreeHostImplTest, compositorFrameMetadata) | 782 TEST_P(LayerTreeHostImplTest, compositorFrameMetadata) |
| 758 { | 783 { |
| 784 // This test is specific to the page-scale based pinch zoom. |
| 785 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
| 786 return; |
| 787 |
| 759 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 788 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 760 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 789 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 761 m_hostImpl->setPageScaleFactorAndLimits(1.0f, 0.5f, 4.0f); | 790 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1.0f, 0.5f, 4.0f); |
| 762 initializeRendererAndDrawFrame(); | 791 initializeRendererAndDrawFrame(); |
| 763 | 792 |
| 764 { | 793 { |
| 765 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada
ta(); | 794 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada
ta(); |
| 766 EXPECT_EQ(gfx::Vector2dF(0.0f, 0.0f), metadata.root_scroll_offset); | 795 EXPECT_EQ(gfx::Vector2dF(0.0f, 0.0f), metadata.root_scroll_offset); |
| 767 EXPECT_EQ(1.0f, metadata.page_scale_factor); | 796 EXPECT_EQ(1.0f, metadata.page_scale_factor); |
| 768 EXPECT_EQ(gfx::SizeF(50.0f, 50.0f), metadata.viewport_size); | 797 EXPECT_EQ(gfx::SizeF(50.0f, 50.0f), metadata.viewport_size); |
| 769 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); | 798 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); |
| 770 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 799 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 771 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); | 800 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 795 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset); | 824 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset); |
| 796 EXPECT_EQ(2, metadata.page_scale_factor); | 825 EXPECT_EQ(2, metadata.page_scale_factor); |
| 797 EXPECT_EQ(gfx::SizeF(25.0f, 25.0f), metadata.viewport_size); | 826 EXPECT_EQ(gfx::SizeF(25.0f, 25.0f), metadata.viewport_size); |
| 798 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); | 827 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); |
| 799 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 828 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 800 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); | 829 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); |
| 801 } | 830 } |
| 802 | 831 |
| 803 // Likewise if set from the main thread. | 832 // Likewise if set from the main thread. |
| 804 m_hostImpl->processScrollDeltas(); | 833 m_hostImpl->processScrollDeltas(); |
| 805 m_hostImpl->setPageScaleFactorAndLimits(4.0f, 0.5f, 4.0f); | 834 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(4.0f, 0.5f, 4.0f); |
| 835 m_hostImpl->activeTree()->SetPageScaleDelta(1.0f); |
| 806 { | 836 { |
| 807 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada
ta(); | 837 CompositorFrameMetadata metadata = m_hostImpl->makeCompositorFrameMetada
ta(); |
| 808 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset); | 838 EXPECT_EQ(gfx::Vector2dF(0.0f, 10.0f), metadata.root_scroll_offset); |
| 809 EXPECT_EQ(4.0f, metadata.page_scale_factor); | 839 EXPECT_EQ(4.0f, metadata.page_scale_factor); |
| 810 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); | 840 EXPECT_EQ(gfx::SizeF(12.5f, 12.5f), metadata.viewport_size); |
| 811 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); | 841 EXPECT_EQ(gfx::SizeF(100.0f, 100.0f), metadata.root_layer_size); |
| 812 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); | 842 EXPECT_EQ(0.5f, metadata.min_page_scale_factor); |
| 813 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); | 843 EXPECT_EQ(4.0f, metadata.max_page_scale_factor); |
| 814 } | 844 } |
| 815 } | 845 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); | 1183 m_hostImpl->activeTree()->SetRootLayer(scrollLayer.Pass()); |
| 1154 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1184 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1155 initializeRendererAndDrawFrame(); | 1185 initializeRendererAndDrawFrame(); |
| 1156 | 1186 |
| 1157 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. | 1187 // Scrolling fails because the content layer is asking to be scrolled on the
main thread. |
| 1158 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); | 1188 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollOnMainThread); |
| 1159 } | 1189 } |
| 1160 | 1190 |
| 1161 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) | 1191 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) |
| 1162 { | 1192 { |
| 1193 // This test is specific to the page-scale based pinch zoom. |
| 1194 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
| 1195 return; |
| 1196 |
| 1163 gfx::Size surfaceSize(10, 10); | 1197 gfx::Size surfaceSize(10, 10); |
| 1164 float pageScale = 2; | 1198 float pageScale = 2; |
| 1165 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1199 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1166 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1200 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1167 m_hostImpl->activeTree()->DidBecomeActive(); | 1201 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1168 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1202 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1169 initializeRendererAndDrawFrame(); | 1203 initializeRendererAndDrawFrame(); |
| 1170 | 1204 |
| 1171 gfx::Vector2d scrollDelta(0, 10); | 1205 gfx::Vector2d scrollDelta(0, 10); |
| 1172 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1206 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1173 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1207 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
| 1174 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1208 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1175 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1209 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1176 m_hostImpl->scrollEnd(); | 1210 m_hostImpl->scrollEnd(); |
| 1177 | 1211 |
| 1178 // Set new page scale from main thread. | 1212 // Set new page scale from main thread. |
| 1179 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); | 1213 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(pageScale, pageScale,
pageScale); |
| 1180 | 1214 |
| 1181 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 1215 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 1182 // The scale should apply to the scroll delta. | 1216 // The scale should apply to the scroll delta. |
| 1183 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1217 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
| 1184 } | 1218 } |
| 1185 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1219 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1186 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1220 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
| 1187 | 1221 |
| 1188 // The scroll range should also have been updated. | 1222 // The scroll range should also have been updated. |
| 1189 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1223 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1212 } | 1246 } |
| 1213 | 1247 |
| 1214 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1248 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
| 1215 { | 1249 { |
| 1216 gfx::Size surfaceSize(10, 10); | 1250 gfx::Size surfaceSize(10, 10); |
| 1217 float pageScale = 2; | 1251 float pageScale = 2; |
| 1218 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1252 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
| 1219 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1253 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1220 m_hostImpl->activeTree()->DidBecomeActive(); | 1254 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1221 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1255 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1222 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1256 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(1, 1, pageScale); |
| 1223 initializeRendererAndDrawFrame(); | 1257 initializeRendererAndDrawFrame(); |
| 1224 | 1258 |
| 1225 gfx::Vector2d scrollDelta(0, 10); | 1259 gfx::Vector2d scrollDelta(0, 10); |
| 1226 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1260 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1227 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1261 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
| 1228 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1262 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1229 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1263 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1230 m_hostImpl->scrollEnd(); | 1264 m_hostImpl->scrollEnd(); |
| 1231 | 1265 |
| 1232 // Set new page scale on impl thread by pinching. | 1266 // Set new page scale on impl thread by pinching. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale); | 1322 EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale); |
| 1289 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale); | 1323 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale); |
| 1290 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale); | 1324 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale); |
| 1291 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale); | 1325 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale); |
| 1292 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale
); | 1326 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale
); |
| 1293 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale
); | 1327 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale
); |
| 1294 } | 1328 } |
| 1295 | 1329 |
| 1296 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) | 1330 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) |
| 1297 { | 1331 { |
| 1332 // This test is specific to the page-scale based pinch zoom. |
| 1333 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
| 1334 return; |
| 1335 |
| 1298 gfx::Size surfaceSize(10, 10); | 1336 gfx::Size surfaceSize(10, 10); |
| 1299 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); | 1337 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); |
| 1300 root->setBounds(surfaceSize); | 1338 root->setBounds(surfaceSize); |
| 1301 root->setContentBounds(surfaceSize); | 1339 root->setContentBounds(surfaceSize); |
| 1302 // Also mark the root scrollable so it becomes the root scroll layer. | 1340 // Also mark the root scrollable so it becomes the root scroll layer. |
| 1303 root->setScrollable(true); | 1341 root->setScrollable(true); |
| 1304 int scrollLayerId = 2; | 1342 int scrollLayerId = 2; |
| 1305 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); | 1343 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); |
| 1306 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); | 1344 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); |
| 1307 m_hostImpl->activeTree()->DidBecomeActive(); | 1345 m_hostImpl->activeTree()->DidBecomeActive(); |
| 1308 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1346 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
| 1309 initializeRendererAndDrawFrame(); | 1347 initializeRendererAndDrawFrame(); |
| 1310 | 1348 |
| 1311 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; | 1349 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; |
| 1312 | 1350 |
| 1313 gfx::Vector2d scrollDelta(0, 10); | 1351 gfx::Vector2d scrollDelta(0, 10); |
| 1314 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1352 gfx::Vector2d expectedScrollDelta(scrollDelta); |
| 1315 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1353 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); |
| 1316 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1354 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
| 1317 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1355 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
| 1318 m_hostImpl->scrollEnd(); | 1356 m_hostImpl->scrollEnd(); |
| 1319 | 1357 |
| 1320 float pageScale = 2; | 1358 float pageScale = 2; |
| 1321 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1359 m_hostImpl->activeTree()->SetPageScaleFactorAndLimits(pageScale, 1, pageScal
e); |
| 1322 | 1360 |
| 1323 drawOneFrame(); | 1361 drawOneFrame(); |
| 1324 | 1362 |
| 1325 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 1363 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 1326 // The scale should apply to the scroll delta. | 1364 // The scale should apply to the scroll delta. |
| 1327 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1365 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
| 1328 } | 1366 } |
| 1329 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1367 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
| 1330 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1368 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
| 1331 | 1369 |
| (...skipping 2839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4171 m_hostImpl->didDrawAllLayers(frame); | 4209 m_hostImpl->didDrawAllLayers(frame); |
| 4172 } | 4210 } |
| 4173 } | 4211 } |
| 4174 | 4212 |
| 4175 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4213 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4176 LayerTreeHostImplTest, | 4214 LayerTreeHostImplTest, |
| 4177 ::testing::Values(false, true)); | 4215 ::testing::Values(false, true)); |
| 4178 | 4216 |
| 4179 } // namespace | 4217 } // namespace |
| 4180 } // namespace cc | 4218 } // namespace cc |
| OLD | NEW |