Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11293121: Add latency measurement system (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: create cc::LatencyInfo Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } 93 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
94 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER RIDE { } 94 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER RIDE { }
95 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; } 95 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; }
96 virtual void onHasPendingTreeStateChanged(bool hasPendingTree) OVERRIDE { m_ hasPendingTree = hasPendingTree; } 96 virtual void onHasPendingTreeStateChanged(bool hasPendingTree) OVERRIDE { m_ hasPendingTree = hasPendingTree; }
97 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } 97 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; }
98 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } 98 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; }
99 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { } 99 virtual void setNeedsManageTilesOnImplThread() OVERRIDE { }
100 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, base::Time wallClockTime) OVERRIDE { } 100 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, base::Time wallClockTime) OVERRIDE { }
101 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } 101 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; }
102 virtual void sendManagedMemoryStats() OVERRIDE { } 102 virtual void sendManagedMemoryStats() OVERRIDE { }
103 virtual void onReceivedLatencyInfo(const LatencyInfo& latencyInfo) OVERRIDE { }
103 104
104 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; } 105 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; }
105 106
106 void createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputS urface) 107 void createLayerTreeHost(bool partialSwap, scoped_ptr<OutputSurface> outputS urface)
107 { 108 {
108 LayerTreeSettings settings; 109 LayerTreeSettings settings;
109 settings.minimumOcclusionTrackingSize = gfx::Size(); 110 settings.minimumOcclusionTrackingSize = gfx::Size();
110 settings.partialSwapEnabled = partialSwap; 111 settings.partialSwapEnabled = partialSwap;
111 112
112 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy); 113 m_hostImpl = LayerTreeHostImpl::create(settings, this, &m_proxy);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); 358 EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2);
358 } 359 }
359 360
360 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) 361 TEST_P(LayerTreeHostImplTest, scrollRootCallsCommitAndRedraw)
361 { 362 {
362 setupScrollAndContentsLayers(gfx::Size(100, 100)); 363 setupScrollAndContentsLayers(gfx::Size(100, 100));
363 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 364 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
364 initializeRendererAndDrawFrame(); 365 initializeRendererAndDrawFrame();
365 366
366 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 367 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
367 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 368 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10));
368 m_hostImpl->scrollEnd(); 369 m_hostImpl->scrollEnd();
369 EXPECT_TRUE(m_didRequestRedraw); 370 EXPECT_TRUE(m_didRequestRedraw);
370 EXPECT_TRUE(m_didRequestCommit); 371 EXPECT_TRUE(m_didRequestCommit);
371 } 372 }
372 373
373 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer) 374 TEST_P(LayerTreeHostImplTest, scrollWithoutRootLayer)
374 { 375 {
375 // We should not crash when trying to scroll an empty layer tree. 376 // We should not crash when trying to scroll an empty layer tree.
376 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 377 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
377 } 378 }
(...skipping 22 matching lines...) Expand all
400 initializeRendererAndDrawFrame(); 401 initializeRendererAndDrawFrame();
401 402
402 // We should not crash if the tree is replaced while we are scrolling. 403 // We should not crash if the tree is replaced while we are scrolling.
403 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 404 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
404 m_hostImpl->detachLayerTree(); 405 m_hostImpl->detachLayerTree();
405 406
406 setupScrollAndContentsLayers(gfx::Size(100, 100)); 407 setupScrollAndContentsLayers(gfx::Size(100, 100));
407 408
408 // We should still be scrolling, because the scrolled layer also exists in t he new tree. 409 // We should still be scrolling, because the scrolled layer also exists in t he new tree.
409 gfx::Vector2d scrollDelta(0, 10); 410 gfx::Vector2d scrollDelta(0, 10);
410 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 411 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
411 m_hostImpl->scrollEnd(); 412 m_hostImpl->scrollEnd();
412 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 413 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
413 expectContains(*scrollInfo, scrollLayerId, scrollDelta); 414 expectContains(*scrollInfo, scrollLayerId, scrollDelta);
414 } 415 }
415 416
416 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) 417 TEST_P(LayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
417 { 418 {
418 setupScrollAndContentsLayers(gfx::Size(100, 100)); 419 setupScrollAndContentsLayers(gfx::Size(100, 100));
419 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 420 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
420 initializeRendererAndDrawFrame(); 421 initializeRendererAndDrawFrame();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 467 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
467 468
468 initializeRendererAndDrawFrame(); 469 initializeRendererAndDrawFrame();
469 470
470 // All scroll types inside the non-fast scrollable region should fail. 471 // All scroll types inside the non-fast scrollable region should fail.
471 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread); 472 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread);
472 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge sture), InputHandlerClient::ScrollOnMainThread); 473 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Ge sture), InputHandlerClient::ScrollOnMainThread);
473 474
474 // All scroll types outside this region should succeed. 475 // All scroll types outside this region should succeed.
475 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted); 476 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted);
476 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 477 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10));
477 m_hostImpl->scrollEnd(); 478 m_hostImpl->scrollEnd();
478 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge sture), InputHandlerClient::ScrollStarted); 479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(75, 75), InputHandlerClient::Ge sture), InputHandlerClient::ScrollStarted);
479 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 480 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10));
480 m_hostImpl->scrollEnd(); 481 m_hostImpl->scrollEnd();
481 } 482 }
482 483
483 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset) 484 TEST_P(LayerTreeHostImplTest, nonFastScrollableRegionWithOffset)
484 { 485 {
485 setupScrollAndContentsLayers(gfx::Size(200, 200)); 486 setupScrollAndContentsLayers(gfx::Size(200, 200));
486 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); 487 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
487 488
488 LayerImpl* root = m_hostImpl->rootLayer(); 489 LayerImpl* root = m_hostImpl->rootLayer();
489 root->setContentsScale(2, 2); 490 root->setContentsScale(2, 2);
490 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50)); 491 root->setNonFastScrollableRegion(gfx::Rect(0, 0, 50, 50));
491 root->setPosition(gfx::PointF(-25, 0)); 492 root->setPosition(gfx::PointF(-25, 0));
492 493
493 initializeRendererAndDrawFrame(); 494 initializeRendererAndDrawFrame();
494 495
495 // This point would fall into the non-fast scrollable region except that we' ve moved the layer down by 25 pixels. 496 // This point would fall into the non-fast scrollable region except that we' ve moved the layer down by 25 pixels.
496 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted); 497 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollStarted);
497 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); 498 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 1));
498 m_hostImpl->scrollEnd(); 499 m_hostImpl->scrollEnd();
499 500
500 // This point is still inside the non-fast region. 501 // This point is still inside the non-fast region.
501 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread); 502 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh eel), InputHandlerClient::ScrollOnMainThread);
502 } 503 }
503 504
504 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue) 505 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue)
505 { 506 {
506 setupScrollAndContentsLayers(gfx::Size(200, 200)); 507 setupScrollAndContentsLayers(gfx::Size(200, 200));
507 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); 508 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100));
508 509
509 initializeRendererAndDrawFrame(); 510 initializeRendererAndDrawFrame();
510 511
511 EXPECT_EQ(InputHandlerClient::ScrollStarted, 512 EXPECT_EQ(InputHandlerClient::ScrollStarted,
512 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); 513 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
513 514
514 // Trying to scroll to the left/top will not succeed. 515 // Trying to scroll to the left/top will not succeed.
515 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 516 EXPECT_FALSE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 0)));
516 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); 517 EXPECT_FALSE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, -10)));
517 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); 518 EXPECT_FALSE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, -10))) ;
518 519
519 // Scrolling to the right/bottom will succeed. 520 // Scrolling to the right/bottom will succeed.
520 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 0))); 521 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(10, 0)));
521 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10))); 522 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10)));
522 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 10))); 523 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(10, 10)));
523 524
524 // Scrolling to left/top will now succeed. 525 // Scrolling to left/top will now succeed.
525 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 526 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 0)));
526 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); 527 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, -10)));
527 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); 528 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, -10)));
528 529
529 // Scrolling diagonally against an edge will succeed. 530 // Scrolling diagonally against an edge will succeed.
530 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, -10))); 531 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(10, -10)));
531 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 532 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 0)));
532 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 10))); 533 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(-10, 10)));
533 534
534 // Trying to scroll more than the available space will also succeed. 535 // Trying to scroll more than the available space will also succeed.
535 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(5000, 5000))); 536 EXPECT_TRUE(m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(5000, 5000)) );
536 } 537 }
537 538
538 TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor) 539 TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor)
539 { 540 {
540 setupScrollAndContentsLayers(gfx::Size(100, 100)); 541 setupScrollAndContentsLayers(gfx::Size(100, 100));
541 542
542 float deviceScaleFactor = 2; 543 float deviceScaleFactor = 2;
543 gfx::Size layoutViewport(25, 25); 544 gfx::Size layoutViewport(25, 25);
544 gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, d eviceScaleFactor))); 545 gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, d eviceScaleFactor)));
545 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); 546 m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 scrollLayer->setImplTransform(identityScaleTransform); 595 scrollLayer->setImplTransform(identityScaleTransform);
595 scrollLayer->setScrollDelta(gfx::Vector2d()); 596 scrollLayer->setScrollDelta(gfx::Vector2d());
596 597
597 float pageScaleDelta = 2; 598 float pageScaleDelta = 2;
598 m_hostImpl->pinchGestureBegin(); 599 m_hostImpl->pinchGestureBegin();
599 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0)); 600 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(0, 0));
600 m_hostImpl->pinchGestureEnd(); 601 m_hostImpl->pinchGestureEnd();
601 602
602 gfx::Vector2d scrollDelta(0, 10); 603 gfx::Vector2d scrollDelta(0, 10);
603 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 604 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
604 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 605 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
605 m_hostImpl->scrollEnd(); 606 m_hostImpl->scrollEnd();
606 607
607 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 608 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
608 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 609 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
609 } 610 }
610 } 611 }
611 612
612 TEST_P(LayerTreeHostImplTest, pinchGesture) 613 TEST_P(LayerTreeHostImplTest, pinchGesture)
613 { 614 {
614 setupScrollAndContentsLayers(gfx::Size(100, 100)); 615 setupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 { 700 {
700 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 701 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
701 scrollLayer->setImplTransform(identityScaleTransform); 702 scrollLayer->setImplTransform(identityScaleTransform);
702 scrollLayer->setScrollDelta(gfx::Vector2d()); 703 scrollLayer->setScrollDelta(gfx::Vector2d());
703 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); 704 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20));
704 705
705 float pageScaleDelta = 1; 706 float pageScaleDelta = 1;
706 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); 707 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel);
707 m_hostImpl->pinchGestureBegin(); 708 m_hostImpl->pinchGestureBegin();
708 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); 709 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10));
709 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); 710 m_hostImpl->scrollBy(0, gfx::Point(10, 10), gfx::Vector2d(-10, -10));
710 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); 711 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20));
711 m_hostImpl->pinchGestureEnd(); 712 m_hostImpl->pinchGestureEnd();
712 m_hostImpl->scrollEnd(); 713 m_hostImpl->scrollEnd();
713 714
714 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 715 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
715 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 716 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
716 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); 717 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10));
717 } 718 }
718 } 719 }
719 720
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 // We should immediately get the final zoom and scroll values for the 867 // We should immediately get the final zoom and scroll values for the
867 // animation. 868 // animation.
868 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); 869 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
869 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 870 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
870 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 871 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
871 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); 872 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget);
872 873
873 // Scrolling during the animation is ignored. 874 // Scrolling during the animation is ignored.
874 const gfx::Vector2d scrollDelta(0, 10); 875 const gfx::Vector2d scrollDelta(0, 10);
875 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH andlerClient::Wheel), InputHandlerClient::ScrollStarted); 876 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH andlerClient::Wheel), InputHandlerClient::ScrollStarted);
876 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 877 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
877 m_hostImpl->scrollEnd(); 878 m_hostImpl->scrollEnd();
878 879
879 // The final page scale and scroll deltas should match what we got 880 // The final page scale and scroll deltas should match what we got
880 // earlier. 881 // earlier.
881 m_hostImpl->animate(endTime, base::Time()); 882 m_hostImpl->animate(endTime, base::Time());
882 scrollInfo = m_hostImpl->processScrollDeltas(); 883 scrollInfo = m_hostImpl->processScrollDeltas();
883 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 884 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
884 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); 885 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget);
885 } 886 }
886 887
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 scrollLayer->setContentBounds(surfaceSize); 1141 scrollLayer->setContentBounds(surfaceSize);
1141 scrollLayer->setPosition(gfx::PointF(0, 0)); 1142 scrollLayer->setPosition(gfx::PointF(0, 0));
1142 scrollLayer->setAnchorPoint(gfx::PointF(0, 0)); 1143 scrollLayer->setAnchorPoint(gfx::PointF(0, 0));
1143 scrollLayer->addChild(contentLayer.Pass()); 1144 scrollLayer->addChild(contentLayer.Pass());
1144 1145
1145 m_hostImpl->setRootLayer(scrollLayer.Pass()); 1146 m_hostImpl->setRootLayer(scrollLayer.Pass());
1146 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1147 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1147 initializeRendererAndDrawFrame(); 1148 initializeRendererAndDrawFrame();
1148 1149
1149 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1150 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1150 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 1151 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10));
1151 m_hostImpl->scrollEnd(); 1152 m_hostImpl->scrollEnd();
1152 EXPECT_TRUE(m_didRequestRedraw); 1153 EXPECT_TRUE(m_didRequestRedraw);
1153 EXPECT_TRUE(m_didRequestCommit); 1154 EXPECT_TRUE(m_didRequestCommit);
1154 } 1155 }
1155 1156
1156 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw) 1157 TEST_P(LayerTreeHostImplTest, scrollChildCallsCommitAndRedraw)
1157 { 1158 {
1158 gfx::Size surfaceSize(10, 10); 1159 gfx::Size surfaceSize(10, 10);
1159 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1160 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1160 root->setBounds(surfaceSize); 1161 root->setBounds(surfaceSize);
1161 root->setContentBounds(surfaceSize); 1162 root->setContentBounds(surfaceSize);
1162 root->addChild(createScrollableLayer(2, surfaceSize)); 1163 root->addChild(createScrollableLayer(2, surfaceSize));
1163 m_hostImpl->setRootLayer(root.Pass()); 1164 m_hostImpl->setRootLayer(root.Pass());
1164 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1165 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1165 initializeRendererAndDrawFrame(); 1166 initializeRendererAndDrawFrame();
1166 1167
1167 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1168 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1168 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10)); 1169 m_hostImpl->scrollBy(0, gfx::Point(), gfx::Vector2d(0, 10));
1169 m_hostImpl->scrollEnd(); 1170 m_hostImpl->scrollEnd();
1170 EXPECT_TRUE(m_didRequestRedraw); 1171 EXPECT_TRUE(m_didRequestRedraw);
1171 EXPECT_TRUE(m_didRequestCommit); 1172 EXPECT_TRUE(m_didRequestCommit);
1172 } 1173 }
1173 1174
1174 TEST_P(LayerTreeHostImplTest, scrollMissesChild) 1175 TEST_P(LayerTreeHostImplTest, scrollMissesChild)
1175 { 1176 {
1176 gfx::Size surfaceSize(10, 10); 1177 gfx::Size surfaceSize(10, 10);
1177 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1178 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1178 root->addChild(createScrollableLayer(2, surfaceSize)); 1179 root->addChild(createScrollableLayer(2, surfaceSize));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 float pageScale = 2; 1234 float pageScale = 2;
1234 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1235 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1235 m_hostImpl->setRootLayer(root.Pass()); 1236 m_hostImpl->setRootLayer(root.Pass());
1236 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1237 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1237 initializeRendererAndDrawFrame(); 1238 initializeRendererAndDrawFrame();
1238 1239
1239 gfx::Vector2d scrollDelta(0, 10); 1240 gfx::Vector2d scrollDelta(0, 10);
1240 gfx::Vector2d expectedScrollDelta(scrollDelta); 1241 gfx::Vector2d expectedScrollDelta(scrollDelta);
1241 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1242 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1242 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1243 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1243 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1244 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
1244 m_hostImpl->scrollEnd(); 1245 m_hostImpl->scrollEnd();
1245 1246
1246 // Set new page scale from main thread. 1247 // Set new page scale from main thread.
1247 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); 1248 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale);
1248 1249
1249 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { 1250 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
1250 // The scale should apply to the scroll delta. 1251 // The scale should apply to the scroll delta.
1251 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1252 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1252 } 1253 }
1253 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1254 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1287 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1287 m_hostImpl->setRootLayer(root.Pass()); 1288 m_hostImpl->setRootLayer(root.Pass());
1288 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1289 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1289 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1290 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1290 initializeRendererAndDrawFrame(); 1291 initializeRendererAndDrawFrame();
1291 1292
1292 gfx::Vector2d scrollDelta(0, 10); 1293 gfx::Vector2d scrollDelta(0, 10);
1293 gfx::Vector2d expectedScrollDelta(scrollDelta); 1294 gfx::Vector2d expectedScrollDelta(scrollDelta);
1294 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1295 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1295 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1296 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1296 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1297 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
1297 m_hostImpl->scrollEnd(); 1298 m_hostImpl->scrollEnd();
1298 1299
1299 // Set new page scale on impl thread by pinching. 1300 // Set new page scale on impl thread by pinching.
1300 m_hostImpl->pinchGestureBegin(); 1301 m_hostImpl->pinchGestureBegin();
1301 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 1302 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
1302 m_hostImpl->pinchGestureEnd(); 1303 m_hostImpl->pinchGestureEnd();
1303 drawOneFrame(); 1304 drawOneFrame();
1304 1305
1305 // The scroll delta is not scaled because the main thread did not scale. 1306 // The scroll delta is not scaled because the main thread did not scale.
1306 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1307 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 m_hostImpl->setRootLayer(root.Pass()); 1374 m_hostImpl->setRootLayer(root.Pass());
1374 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1375 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1375 initializeRendererAndDrawFrame(); 1376 initializeRendererAndDrawFrame();
1376 1377
1377 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1378 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1378 1379
1379 gfx::Vector2d scrollDelta(0, 10); 1380 gfx::Vector2d scrollDelta(0, 10);
1380 gfx::Vector2d expectedScrollDelta(scrollDelta); 1381 gfx::Vector2d expectedScrollDelta(scrollDelta);
1381 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); 1382 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
1382 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1383 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1383 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1384 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
1384 m_hostImpl->scrollEnd(); 1385 m_hostImpl->scrollEnd();
1385 1386
1386 float pageScale = 2; 1387 float pageScale = 2;
1387 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); 1388 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
1388 1389
1389 drawOneFrame(); 1390 drawOneFrame();
1390 1391
1391 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { 1392 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
1392 // The scale should apply to the scroll delta. 1393 // The scale should apply to the scroll delta.
1393 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1394 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
(...skipping 24 matching lines...) Expand all
1418 child->setScrollOffset(gfx::Vector2d(3, 0)); 1419 child->setScrollOffset(gfx::Vector2d(3, 0));
1419 child->addChild(grandChild.Pass()); 1420 child->addChild(grandChild.Pass());
1420 1421
1421 root->addChild(child.Pass()); 1422 root->addChild(child.Pass());
1422 m_hostImpl->setRootLayer(root.Pass()); 1423 m_hostImpl->setRootLayer(root.Pass());
1423 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1424 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1424 initializeRendererAndDrawFrame(); 1425 initializeRendererAndDrawFrame();
1425 { 1426 {
1426 gfx::Vector2d scrollDelta(-8, -7); 1427 gfx::Vector2d scrollDelta(-8, -7);
1427 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1428 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1428 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1429 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
1429 m_hostImpl->scrollEnd(); 1430 m_hostImpl->scrollEnd();
1430 1431
1431 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1432 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1432 1433
1433 // The grand child should have scrolled up to its limit. 1434 // The grand child should have scrolled up to its limit.
1434 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1435 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1435 LayerImpl* grandChild = child->children()[0]; 1436 LayerImpl* grandChild = child->children()[0];
1436 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5) ); 1437 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5) );
1437 1438
1438 // The child should have only scrolled on the other axis. 1439 // The child should have only scrolled on the other axis.
(...skipping 11 matching lines...) Expand all
1450 1451
1451 child->setScrollable(false); 1452 child->setScrollable(false);
1452 root->addChild(child.Pass()); 1453 root->addChild(child.Pass());
1453 1454
1454 m_hostImpl->setRootLayer(root.Pass()); 1455 m_hostImpl->setRootLayer(root.Pass());
1455 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1456 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1456 initializeRendererAndDrawFrame(); 1457 initializeRendererAndDrawFrame();
1457 { 1458 {
1458 gfx::Vector2d scrollDelta(0, 4); 1459 gfx::Vector2d scrollDelta(0, 4);
1459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1460 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1460 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1461 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
1461 m_hostImpl->scrollEnd(); 1462 m_hostImpl->scrollEnd();
1462 1463
1463 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1464 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1464 1465
1465 // Only the root should have scrolled. 1466 // Only the root should have scrolled.
1466 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 1467 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
1467 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 1468 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
1468 } 1469 }
1469 } 1470 }
1470 1471
(...skipping 21 matching lines...) Expand all
1492 rotateTransform.Rotate(-90); 1493 rotateTransform.Rotate(-90);
1493 m_hostImpl->rootLayer()->setTransform(rotateTransform); 1494 m_hostImpl->rootLayer()->setTransform(rotateTransform);
1494 1495
1495 gfx::Size surfaceSize(50, 50); 1496 gfx::Size surfaceSize(50, 50);
1496 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1497 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1497 initializeRendererAndDrawFrame(); 1498 initializeRendererAndDrawFrame();
1498 1499
1499 // Scroll to the right in screen coordinates with a gesture. 1500 // Scroll to the right in screen coordinates with a gesture.
1500 gfx::Vector2d gestureScrollDelta(10, 0); 1501 gfx::Vector2d gestureScrollDelta(10, 0);
1501 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1502 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1502 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1503 m_hostImpl->scrollBy(0, gfx::Point(), gestureScrollDelta);
1503 m_hostImpl->scrollEnd(); 1504 m_hostImpl->scrollEnd();
1504 1505
1505 // The layer should have scrolled down in its local coordinates. 1506 // The layer should have scrolled down in its local coordinates.
1506 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1507 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1507 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, gestureScrollDelta.x())); 1508 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, gestureScrollDelta.x()));
1508 1509
1509 // Reset and scroll down with the wheel. 1510 // Reset and scroll down with the wheel.
1510 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); 1511 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
1511 gfx::Vector2d wheelScrollDelta(0, 10); 1512 gfx::Vector2d wheelScrollDelta(0, 10);
1512 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1513 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1513 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); 1514 m_hostImpl->scrollBy(0, gfx::Point(), wheelScrollDelta);
1514 m_hostImpl->scrollEnd(); 1515 m_hostImpl->scrollEnd();
1515 1516
1516 // The layer should have scrolled down in its local coordinates. 1517 // The layer should have scrolled down in its local coordinates.
1517 scrollInfo = m_hostImpl->processScrollDeltas(); 1518 scrollInfo = m_hostImpl->processScrollDeltas();
1518 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1519 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1519 } 1520 }
1520 1521
1521 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1522 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1522 { 1523 {
1523 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1524 setupScrollAndContentsLayers(gfx::Size(100, 100));
(...skipping 13 matching lines...) Expand all
1537 m_hostImpl->rootLayer()->addChild(child.Pass()); 1538 m_hostImpl->rootLayer()->addChild(child.Pass());
1538 1539
1539 gfx::Size surfaceSize(50, 50); 1540 gfx::Size surfaceSize(50, 50);
1540 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1541 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1541 initializeRendererAndDrawFrame(); 1542 initializeRendererAndDrawFrame();
1542 1543
1543 { 1544 {
1544 // Scroll down in screen coordinates with a gesture. 1545 // Scroll down in screen coordinates with a gesture.
1545 gfx::Vector2d gestureScrollDelta(0, 10); 1546 gfx::Vector2d gestureScrollDelta(0, 10);
1546 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted); 1547 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted);
1547 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1548 m_hostImpl->scrollBy(0, gfx::Point(), gestureScrollDelta);
1548 m_hostImpl->scrollEnd(); 1549 m_hostImpl->scrollEnd();
1549 1550
1550 // The child layer should have scrolled down in its local coordinates an amount proportional to 1551 // The child layer should have scrolled down in its local coordinates an amount proportional to
1551 // the angle between it and the input scroll delta. 1552 // the angle between it and the input scroll delta.
1552 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M athUtil::Deg2Rad(childLayerAngle))); 1553 gfx::Vector2d expectedScrollDelta(0, gestureScrollDelta.y() * std::cos(M athUtil::Deg2Rad(childLayerAngle)));
1553 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1554 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1554 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); 1555 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
1555 1556
1556 // The root layer should not have scrolled, because the input delta was close to the layer's 1557 // The root layer should not have scrolled, because the input delta was close to the layer's
1557 // axis of movement. 1558 // axis of movement.
1558 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); 1559 EXPECT_EQ(scrollInfo->scrolls.size(), 1u);
1559 } 1560 }
1560 1561
1561 { 1562 {
1562 // Now reset and scroll the same amount horizontally. 1563 // Now reset and scroll the same amount horizontally.
1563 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF()) ; 1564 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(gfx::Vector2dF()) ;
1564 gfx::Vector2d gestureScrollDelta(10, 0); 1565 gfx::Vector2d gestureScrollDelta(10, 0);
1565 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted); 1566 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient:: Gesture), InputHandlerClient::ScrollStarted);
1566 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1567 m_hostImpl->scrollBy(0, gfx::Point(), gestureScrollDelta);
1567 m_hostImpl->scrollEnd(); 1568 m_hostImpl->scrollEnd();
1568 1569
1569 // The child layer should have scrolled down in its local coordinates an amount proportional to 1570 // The child layer should have scrolled down in its local coordinates an amount proportional to
1570 // the angle between it and the input scroll delta. 1571 // the angle between it and the input scroll delta.
1571 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin( MathUtil::Deg2Rad(childLayerAngle))); 1572 gfx::Vector2d expectedScrollDelta(0, -gestureScrollDelta.x() * std::sin( MathUtil::Deg2Rad(childLayerAngle)));
1572 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1573 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1573 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); 1574 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
1574 1575
1575 // The root layer should have scrolled more, since the input scroll delt a was mostly 1576 // The root layer should have scrolled more, since the input scroll delt a was mostly
1576 // orthogonal to the child layer's vertical scroll axis. 1577 // orthogonal to the child layer's vertical scroll axis.
(...skipping 12 matching lines...) Expand all
1589 scaleTransform.Scale(scale, scale); 1590 scaleTransform.Scale(scale, scale);
1590 m_hostImpl->rootLayer()->setTransform(scaleTransform); 1591 m_hostImpl->rootLayer()->setTransform(scaleTransform);
1591 1592
1592 gfx::Size surfaceSize(50, 50); 1593 gfx::Size surfaceSize(50, 50);
1593 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1594 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1594 initializeRendererAndDrawFrame(); 1595 initializeRendererAndDrawFrame();
1595 1596
1596 // Scroll down in screen coordinates with a gesture. 1597 // Scroll down in screen coordinates with a gesture.
1597 gfx::Vector2d scrollDelta(0, 10); 1598 gfx::Vector2d scrollDelta(0, 10);
1598 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1599 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1599 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1600 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
1600 m_hostImpl->scrollEnd(); 1601 m_hostImpl->scrollEnd();
1601 1602
1602 // The layer should have scrolled down in its local coordinates, but half he amount. 1603 // The layer should have scrolled down in its local coordinates, but half he amount.
1603 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1604 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1604 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, scrollDelta.y() / scale)); 1605 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), gfx::Vector 2d(0, scrollDelta.y() / scale));
1605 1606
1606 // Reset and scroll down with the wheel. 1607 // Reset and scroll down with the wheel.
1607 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF()); 1608 m_hostImpl->rootLayer()->setScrollDelta(gfx::Vector2dF());
1608 gfx::Vector2d wheelScrollDelta(0, 10); 1609 gfx::Vector2d wheelScrollDelta(0, 10);
1609 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1610 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1610 m_hostImpl->scrollBy(gfx::Point(), wheelScrollDelta); 1611 m_hostImpl->scrollBy(0, gfx::Point(), wheelScrollDelta);
1611 m_hostImpl->scrollEnd(); 1612 m_hostImpl->scrollEnd();
1612 1613
1613 // The scale should not have been applied to the scroll delta. 1614 // The scale should not have been applied to the scroll delta.
1614 scrollInfo = m_hostImpl->processScrollDeltas(); 1615 scrollInfo = m_hostImpl->processScrollDeltas();
1615 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta); 1616 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), wheelScroll Delta);
1616 } 1617 }
1617 1618
1618 class BlendStateTrackerContext: public FakeWebGraphicsContext3D { 1619 class BlendStateTrackerContext: public FakeWebGraphicsContext3D {
1619 public: 1620 public:
1620 BlendStateTrackerContext() : m_blend(false) { } 1621 BlendStateTrackerContext() : m_blend(false) { }
(...skipping 2854 matching lines...) Expand 10 before | Expand all | Expand 10 after
4475 // so no point in continuing without it. 4476 // so no point in continuing without it.
4476 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4477 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4477 return; 4478 return;
4478 4479
4479 m_didRequestCommit = false; 4480 m_didRequestCommit = false;
4480 m_didRequestRedraw = false; 4481 m_didRequestRedraw = false;
4481 4482
4482 // This scroll will force the viewport to pan horizontally. 4483 // This scroll will force the viewport to pan horizontally.
4483 gfx::Vector2d scrollDelta(5, 0); 4484 gfx::Vector2d scrollDelta(5, 0);
4484 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4485 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4485 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4486 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
4486 m_hostImpl->scrollEnd(); 4487 m_hostImpl->scrollEnd();
4487 4488
4488 EXPECT_EQ(true, m_didRequestCommit); 4489 EXPECT_EQ(true, m_didRequestCommit);
4489 EXPECT_EQ(true, m_didRequestRedraw); 4490 EXPECT_EQ(true, m_didRequestRedraw);
4490 4491
4491 m_didRequestCommit = false; 4492 m_didRequestCommit = false;
4492 m_didRequestRedraw = false; 4493 m_didRequestRedraw = false;
4493 4494
4494 // This scroll will force the viewport to pan vertically. 4495 // This scroll will force the viewport to pan vertically.
4495 scrollDelta = gfx::Vector2d(0, 5); 4496 scrollDelta = gfx::Vector2d(0, 5);
4496 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4497 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4497 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4498 m_hostImpl->scrollBy(0, gfx::Point(), scrollDelta);
4498 m_hostImpl->scrollEnd(); 4499 m_hostImpl->scrollEnd();
4499 4500
4500 EXPECT_EQ(true, m_didRequestCommit); 4501 EXPECT_EQ(true, m_didRequestCommit);
4501 EXPECT_EQ(true, m_didRequestRedraw); 4502 EXPECT_EQ(true, m_didRequestRedraw);
4502 } 4503 }
4503 4504
4504 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1 ) 4505 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportForcesCommitDeviceScaleFactor1 )
4505 { 4506 {
4506 pinchZoomPanViewportForcesCommitRedraw(1); 4507 pinchZoomPanViewportForcesCommitRedraw(1);
4507 } 4508 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4546 // so no point in continuing without it. 4547 // so no point in continuing without it.
4547 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4548 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4548 return; 4549 return;
4549 4550
4550 gfx::Vector2d scrollDelta(5, 0); 4551 gfx::Vector2d scrollDelta(5, 0);
4551 // TODO(wjmaclean): Fix the math here so that the expectedTranslation is 4552 // TODO(wjmaclean): Fix the math here so that the expectedTranslation is
4552 // scaled instead of the scroll input. 4553 // scaled instead of the scroll input.
4553 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); 4554 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4554 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4555 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4555 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4556 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4556 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4557 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4557 m_hostImpl->scrollEnd(); 4558 m_hostImpl->scrollEnd();
4558 drawOneFrame(); 4559 drawOneFrame();
4559 4560
4560 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); 4561 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor());
4561 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4562 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4562 4563
4563 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4564 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4564 // No change expected. 4565 // No change expected.
4565 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4566 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4566 // None of the scroll delta should have been used for document scroll. 4567 // None of the scroll delta should have been used for document scroll.
4567 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4568 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4568 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4569 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4569 4570
4570 // Test scroll in y-direction also. 4571 // Test scroll in y-direction also.
4571 scrollDelta = gfx::Vector2d(0, 5); 4572 scrollDelta = gfx::Vector2d(0, 5);
4572 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4573 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4573 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4574 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4574 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4575 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4575 m_hostImpl->scrollEnd(); 4576 m_hostImpl->scrollEnd();
4576 drawOneFrame(); 4577 drawOneFrame();
4577 4578
4578 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); 4579 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor());
4579 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4580 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4580 4581
4581 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4582 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4582 // No change expected. 4583 // No change expected.
4583 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4584 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4584 // None of the scroll delta should have been used for document scroll. 4585 // None of the scroll delta should have been used for document scroll.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
4631 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4632 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4632 return; 4633 return;
4633 4634
4634 // Scroll document only: scrollDelta chosen to move document horizontally 4635 // Scroll document only: scrollDelta chosen to move document horizontally
4635 // to its max scroll offset. 4636 // to its max scroll offset.
4636 gfx::Vector2d scrollDelta(3, 0); 4637 gfx::Vector2d scrollDelta(3, 0);
4637 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); 4638 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4638 gfx::Vector2d expectedScrollDelta(scrollDelta); 4639 gfx::Vector2d expectedScrollDelta(scrollDelta);
4639 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4640 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4640 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4641 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4641 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4642 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4642 m_hostImpl->scrollEnd(); 4643 m_hostImpl->scrollEnd();
4643 drawOneFrame(); 4644 drawOneFrame();
4644 4645
4645 // The scroll delta is not scaled because the main thread did not scale. 4646 // The scroll delta is not scaled because the main thread did not scale.
4646 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4647 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4647 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4648 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4648 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4649 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4649 4650
4650 // Verify we did not change the implTransform this time. 4651 // Verify we did not change the implTransform this time.
4651 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4652 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4652 4653
4653 // Further scrolling should move the pinchZoomViewport only. 4654 // Further scrolling should move the pinchZoomViewport only.
4654 scrollDelta = gfx::Vector2d(2, 0); 4655 scrollDelta = gfx::Vector2d(2, 0);
4655 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4656 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4656 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4657 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4657 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4658 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4658 m_hostImpl->scrollEnd(); 4659 m_hostImpl->scrollEnd();
4659 drawOneFrame(); 4660 drawOneFrame();
4660 4661
4661 gfx::Vector2d expectedPanDelta(scrollDelta); 4662 gfx::Vector2d expectedPanDelta(scrollDelta);
4662 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4663 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4663 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4664 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4664 4665
4665 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4666 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4666 4667
4667 // The scroll delta on the main thread should not have been affected by this . 4668 // The scroll delta on the main thread should not have been affected by this .
4668 scrollInfo = m_hostImpl->processScrollDeltas(); 4669 scrollInfo = m_hostImpl->processScrollDeltas();
4669 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4670 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4670 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4671 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4671 4672
4672 // Perform same test sequence in y-direction also. 4673 // Perform same test sequence in y-direction also.
4673 // Document only scroll. 4674 // Document only scroll.
4674 scrollDelta = gfx::Vector2d(0, 4); 4675 scrollDelta = gfx::Vector2d(0, 4);
4675 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4676 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4676 expectedScrollDelta += scrollDelta; 4677 expectedScrollDelta += scrollDelta;
4677 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4678 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4678 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4679 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4679 m_hostImpl->scrollEnd(); 4680 m_hostImpl->scrollEnd();
4680 drawOneFrame(); 4681 drawOneFrame();
4681 4682
4682 // The scroll delta is not scaled because the main thread did not scale. 4683 // The scroll delta is not scaled because the main thread did not scale.
4683 scrollInfo = m_hostImpl->processScrollDeltas(); 4684 scrollInfo = m_hostImpl->processScrollDeltas();
4684 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4685 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4685 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4686 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4686 4687
4687 // Verify we did not change the implTransform this time. 4688 // Verify we did not change the implTransform this time.
4688 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4689 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4689 4690
4690 // pinchZoomViewport scroll only. 4691 // pinchZoomViewport scroll only.
4691 scrollDelta = gfx::Vector2d(0, 1); 4692 scrollDelta = gfx::Vector2d(0, 1);
4692 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4693 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4693 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4694 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4694 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4695 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4695 m_hostImpl->scrollEnd(); 4696 m_hostImpl->scrollEnd();
4696 drawOneFrame(); 4697 drawOneFrame();
4697 4698
4698 expectedPanDelta = scrollDelta; 4699 expectedPanDelta = scrollDelta;
4699 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4700 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4700 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4701 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4701 4702
4702 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4703 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4703 4704
4704 // The scroll delta on the main thread should not have been affected by this . 4705 // The scroll delta on the main thread should not have been affected by this .
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4754 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4755 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4755 return; 4756 return;
4756 4757
4757 // Scroll document and pann zoomViewport in one scroll-delta. 4758 // Scroll document and pann zoomViewport in one scroll-delta.
4758 gfx::Vector2d scrollDelta(5, 0); 4759 gfx::Vector2d scrollDelta(5, 0);
4759 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); 4760 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4760 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. 4761 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll.
4761 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4762 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4762 4763
4763 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4764 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4764 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4765 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4765 m_hostImpl->scrollEnd(); 4766 m_hostImpl->scrollEnd();
4766 drawOneFrame(); 4767 drawOneFrame();
4767 4768
4768 // The scroll delta is not scaled because the main thread did not scale. 4769 // The scroll delta is not scaled because the main thread did not scale.
4769 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4770 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4770 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4771 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4771 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4772 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4772 4773
4773 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. 4774 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan.
4774 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4775 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4775 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4776 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4776 4777
4777 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4778 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4778 4779
4779 // Perform same test sequence in y-direction also. 4780 // Perform same test sequence in y-direction also.
4780 scrollDelta = gfx::Vector2d(0, 5); 4781 scrollDelta = gfx::Vector2d(0, 5);
4781 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting())); 4782 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4782 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. 4783 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll.
4783 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4784 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4784 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); 4785 m_hostImpl->scrollBy(0, gfx::Point(), scrollDeltaInZoomedViewport);
4785 m_hostImpl->scrollEnd(); 4786 m_hostImpl->scrollEnd();
4786 drawOneFrame(); 4787 drawOneFrame();
4787 4788
4788 // The scroll delta is not scaled because the main thread did not scale. 4789 // The scroll delta is not scaled because the main thread did not scale.
4789 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan. 4790 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan.
4790 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4791 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4791 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4792 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4792 4793
4793 expectedPanDelta = gfx::Vector2d(0, 1); 4794 expectedPanDelta = gfx::Vector2d(0, 1);
4794 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4795 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4845 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); 4846 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize());
4846 drawFrameAndTestDamage(noDamage); 4847 drawFrameAndTestDamage(noDamage);
4847 } 4848 }
4848 4849
4849 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4850 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4850 LayerTreeHostImplTest, 4851 LayerTreeHostImplTest,
4851 ::testing::Values(false, true)); 4852 ::testing::Values(false, true));
4852 4853
4853 } // namespace 4854 } // namespace
4854 } // namespace cc 4855 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698