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

Side by Side Diff: cc/CCLayerTreeHostImplTest.cpp

Issue 11111003: cc: Convert processScrollDeltas() to scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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/CCLayerTreeHostImpl.cpp ('k') | cc/CCSingleThreadProxy.cpp » ('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 "config.h" 5 #include "config.h"
6 6
7 #include "CCLayerTreeHostImpl.h" 7 #include "CCLayerTreeHostImpl.h"
8 8
9 #include "CCAnimationTestCommon.h" 9 #include "CCAnimationTestCommon.h"
10 #include "CCDelegatedRendererLayerImpl.h" 10 #include "CCDelegatedRendererLayerImpl.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 m_hostImpl->resetContentsTexturesPurged(); 240 m_hostImpl->resetContentsTexturesPurged();
241 EXPECT_TRUE(m_hostImpl->canDraw()); 241 EXPECT_TRUE(m_hostImpl->canDraw());
242 EXPECT_TRUE(m_onCanDrawStateChangedCalled); 242 EXPECT_TRUE(m_onCanDrawStateChangedCalled);
243 m_onCanDrawStateChangedCalled = false; 243 m_onCanDrawStateChangedCalled = false;
244 } 244 }
245 245
246 TEST_P(CCLayerTreeHostImplTest, scrollDeltaNoLayers) 246 TEST_P(CCLayerTreeHostImplTest, scrollDeltaNoLayers)
247 { 247 {
248 ASSERT_FALSE(m_hostImpl->rootLayer()); 248 ASSERT_FALSE(m_hostImpl->rootLayer());
249 249
250 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 250 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
251 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 251 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
252 } 252 }
253 253
254 TEST_P(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges) 254 TEST_P(CCLayerTreeHostImplTest, scrollDeltaTreeButNoChanges)
255 { 255 {
256 { 256 {
257 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 257 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
258 root->addChild(CCLayerImpl::create(2)); 258 root->addChild(CCLayerImpl::create(2));
259 root->addChild(CCLayerImpl::create(3)); 259 root->addChild(CCLayerImpl::create(3));
260 root->children()[1]->addChild(CCLayerImpl::create(4)); 260 root->children()[1]->addChild(CCLayerImpl::create(4));
261 root->children()[1]->addChild(CCLayerImpl::create(5)); 261 root->children()[1]->addChild(CCLayerImpl::create(5));
262 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6)); 262 root->children()[1]->children()[0]->addChild(CCLayerImpl::create(6));
263 m_hostImpl->setRootLayer(root.release()); 263 m_hostImpl->setRootLayer(root.release());
264 } 264 }
265 CCLayerImpl* root = m_hostImpl->rootLayer(); 265 CCLayerImpl* root = m_hostImpl->rootLayer();
266 266
267 expectClearedScrollDeltasRecursive(root); 267 expectClearedScrollDeltasRecursive(root);
268 268
269 OwnPtr<CCScrollAndScaleSet> scrollInfo; 269 scoped_ptr<CCScrollAndScaleSet> scrollInfo;
270 270
271 scrollInfo = m_hostImpl->processScrollDeltas(); 271 scrollInfo = m_hostImpl->processScrollDeltas();
272 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 272 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
273 expectClearedScrollDeltasRecursive(root); 273 expectClearedScrollDeltasRecursive(root);
274 274
275 scrollInfo = m_hostImpl->processScrollDeltas(); 275 scrollInfo = m_hostImpl->processScrollDeltas();
276 ASSERT_EQ(scrollInfo->scrolls.size(), 0u); 276 ASSERT_EQ(scrollInfo->scrolls.size(), 0u);
277 expectClearedScrollDeltasRecursive(root); 277 expectClearedScrollDeltasRecursive(root);
278 } 278 }
279 279
280 TEST_P(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) 280 TEST_P(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls)
281 { 281 {
282 IntPoint scrollPosition(20, 30); 282 IntPoint scrollPosition(20, 30);
283 IntSize scrollDelta(11, -15); 283 IntSize scrollDelta(11, -15);
284 { 284 {
285 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); 285 OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1);
286 root->setScrollPosition(scrollPosition); 286 root->setScrollPosition(scrollPosition);
287 root->setScrollable(true); 287 root->setScrollable(true);
288 root->setMaxScrollPosition(IntSize(100, 100)); 288 root->setMaxScrollPosition(IntSize(100, 100));
289 root->scrollBy(scrollDelta); 289 root->scrollBy(scrollDelta);
290 m_hostImpl->setRootLayer(root.release()); 290 m_hostImpl->setRootLayer(root.release());
291 } 291 }
292 CCLayerImpl* root = m_hostImpl->rootLayer(); 292 CCLayerImpl* root = m_hostImpl->rootLayer();
293 293
294 OwnPtr<CCScrollAndScaleSet> scrollInfo; 294 scoped_ptr<CCScrollAndScaleSet> scrollInfo;
295 295
296 scrollInfo = m_hostImpl->processScrollDeltas(); 296 scrollInfo = m_hostImpl->processScrollDeltas();
297 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 297 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
298 EXPECT_EQ(root->sentScrollDelta(), scrollDelta); 298 EXPECT_EQ(root->sentScrollDelta(), scrollDelta);
299 expectContains(*scrollInfo, root->id(), scrollDelta); 299 expectContains(*scrollInfo, root->id(), scrollDelta);
300 300
301 IntSize scrollDelta2(-5, 27); 301 IntSize scrollDelta2(-5, 27);
302 root->scrollBy(scrollDelta2); 302 root->scrollBy(scrollDelta2);
303 scrollInfo = m_hostImpl->processScrollDeltas(); 303 scrollInfo = m_hostImpl->processScrollDeltas();
304 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 304 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // We should not crash if the tree is replaced while we are scrolling. 355 // We should not crash if the tree is replaced while we are scrolling.
356 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 356 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
357 m_hostImpl->detachLayerTree(); 357 m_hostImpl->detachLayerTree();
358 358
359 setupScrollAndContentsLayers(IntSize(100, 100)); 359 setupScrollAndContentsLayers(IntSize(100, 100));
360 360
361 // We should still be scrolling, because the scrolled layer also exists in t he new tree. 361 // We should still be scrolling, because the scrolled layer also exists in t he new tree.
362 IntSize scrollDelta(0, 10); 362 IntSize scrollDelta(0, 10);
363 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 363 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
364 m_hostImpl->scrollEnd(); 364 m_hostImpl->scrollEnd();
365 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 365 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
366 expectContains(*scrollInfo, scrollLayerId, scrollDelta); 366 expectContains(*scrollInfo, scrollLayerId, scrollDelta);
367 } 367 }
368 368
369 TEST_P(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll) 369 TEST_P(CCLayerTreeHostImplTest, clearRootRenderSurfaceAndScroll)
370 { 370 {
371 setupScrollAndContentsLayers(IntSize(100, 100)); 371 setupScrollAndContentsLayers(IntSize(100, 100));
372 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 372 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
373 initializeRendererAndDrawFrame(); 373 initializeRendererAndDrawFrame();
374 374
375 // We should be able to scroll even if the root layer loses its render surfa ce after the most 375 // We should be able to scroll even if the root layer loses its render surfa ce after the most
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 scrollLayer->setImplTransform(identityScaleTransform); 488 scrollLayer->setImplTransform(identityScaleTransform);
489 scrollLayer->setScrollDelta(IntSize()); 489 scrollLayer->setScrollDelta(IntSize());
490 490
491 float pageScaleDelta = 2; 491 float pageScaleDelta = 2;
492 m_hostImpl->pinchGestureBegin(); 492 m_hostImpl->pinchGestureBegin();
493 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); 493 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
494 m_hostImpl->pinchGestureEnd(); 494 m_hostImpl->pinchGestureEnd();
495 EXPECT_TRUE(m_didRequestRedraw); 495 EXPECT_TRUE(m_didRequestRedraw);
496 EXPECT_TRUE(m_didRequestCommit); 496 EXPECT_TRUE(m_didRequestCommit);
497 497
498 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 498 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
499 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 499 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
500 500
501 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50)) ; 501 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50)) ;
502 } 502 }
503 503
504 // Scrolling after a pinch gesture should always be in local space. The scr oll deltas do not 504 // Scrolling after a pinch gesture should always be in local space. The scr oll deltas do not
505 // have the page scale factor applied. 505 // have the page scale factor applied.
506 { 506 {
507 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 507 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
508 scrollLayer->setImplTransform(identityScaleTransform); 508 scrollLayer->setImplTransform(identityScaleTransform);
509 scrollLayer->setScrollDelta(IntSize()); 509 scrollLayer->setScrollDelta(IntSize());
510 510
511 float pageScaleDelta = 2; 511 float pageScaleDelta = 2;
512 m_hostImpl->pinchGestureBegin(); 512 m_hostImpl->pinchGestureBegin();
513 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); 513 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
514 m_hostImpl->pinchGestureEnd(); 514 m_hostImpl->pinchGestureEnd();
515 515
516 IntSize scrollDelta(0, 10); 516 IntSize scrollDelta(0, 10);
517 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); 517 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted);
518 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 518 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
519 m_hostImpl->scrollEnd(); 519 m_hostImpl->scrollEnd();
520 520
521 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 521 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
522 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 522 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
523 } 523 }
524 } 524 }
525 525
526 TEST_P(CCLayerTreeHostImplTest, pinchGesture) 526 TEST_P(CCLayerTreeHostImplTest, pinchGesture)
527 { 527 {
528 setupScrollAndContentsLayers(IntSize(100, 100)); 528 setupScrollAndContentsLayers(IntSize(100, 100));
529 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 529 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
530 initializeRendererAndDrawFrame(); 530 initializeRendererAndDrawFrame();
531 531
(...skipping 10 matching lines...) Expand all
542 scrollLayer->setImplTransform(identityScaleTransform); 542 scrollLayer->setImplTransform(identityScaleTransform);
543 scrollLayer->setScrollDelta(IntSize()); 543 scrollLayer->setScrollDelta(IntSize());
544 544
545 float pageScaleDelta = 2; 545 float pageScaleDelta = 2;
546 m_hostImpl->pinchGestureBegin(); 546 m_hostImpl->pinchGestureBegin();
547 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); 547 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
548 m_hostImpl->pinchGestureEnd(); 548 m_hostImpl->pinchGestureEnd();
549 EXPECT_TRUE(m_didRequestRedraw); 549 EXPECT_TRUE(m_didRequestRedraw);
550 EXPECT_TRUE(m_didRequestCommit); 550 EXPECT_TRUE(m_didRequestCommit);
551 551
552 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 552 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
553 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 553 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
554 } 554 }
555 555
556 // Zoom-in clamping 556 // Zoom-in clamping
557 { 557 {
558 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 558 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
559 scrollLayer->setImplTransform(identityScaleTransform); 559 scrollLayer->setImplTransform(identityScaleTransform);
560 scrollLayer->setScrollDelta(IntSize()); 560 scrollLayer->setScrollDelta(IntSize());
561 float pageScaleDelta = 10; 561 float pageScaleDelta = 10;
562 562
563 m_hostImpl->pinchGestureBegin(); 563 m_hostImpl->pinchGestureBegin();
564 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); 564 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
565 m_hostImpl->pinchGestureEnd(); 565 m_hostImpl->pinchGestureEnd();
566 566
567 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 567 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
568 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); 568 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale);
569 } 569 }
570 570
571 // Zoom-out clamping 571 // Zoom-out clamping
572 { 572 {
573 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 573 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
574 scrollLayer->setImplTransform(identityScaleTransform); 574 scrollLayer->setImplTransform(identityScaleTransform);
575 scrollLayer->setScrollDelta(IntSize()); 575 scrollLayer->setScrollDelta(IntSize());
576 scrollLayer->setScrollPosition(IntPoint(50, 50)); 576 scrollLayer->setScrollPosition(IntPoint(50, 50));
577 577
578 float pageScaleDelta = 0.1f; 578 float pageScaleDelta = 0.1f;
579 m_hostImpl->pinchGestureBegin(); 579 m_hostImpl->pinchGestureBegin();
580 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); 580 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
581 m_hostImpl->pinchGestureEnd(); 581 m_hostImpl->pinchGestureEnd();
582 582
583 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 583 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
584 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 584 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
585 585
586 if (!CCSettings::pageScalePinchZoomEnabled()) { 586 if (!CCSettings::pageScalePinchZoomEnabled()) {
587 // Pushed to (0,0) via clamping against contents layer size. 587 // Pushed to (0,0) via clamping against contents layer size.
588 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 588 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
589 } else { 589 } else {
590 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); 590 EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
591 } 591 }
592 } 592 }
593 593
594 // Two-finger panning 594 // Two-finger panning
595 { 595 {
596 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 596 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
597 scrollLayer->setImplTransform(identityScaleTransform); 597 scrollLayer->setImplTransform(identityScaleTransform);
598 scrollLayer->setScrollDelta(IntSize()); 598 scrollLayer->setScrollDelta(IntSize());
599 scrollLayer->setScrollPosition(IntPoint(20, 20)); 599 scrollLayer->setScrollPosition(IntPoint(20, 20));
600 600
601 float pageScaleDelta = 1; 601 float pageScaleDelta = 1;
602 m_hostImpl->pinchGestureBegin(); 602 m_hostImpl->pinchGestureBegin();
603 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); 603 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10));
604 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); 604 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20));
605 m_hostImpl->pinchGestureEnd(); 605 m_hostImpl->pinchGestureEnd();
606 606
607 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 607 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
608 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 608 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
609 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); 609 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10));
610 } 610 }
611 } 611 }
612 612
613 TEST_P(CCLayerTreeHostImplTest, pageScaleAnimation) 613 TEST_P(CCLayerTreeHostImplTest, pageScaleAnimation)
614 { 614 {
615 setupScrollAndContentsLayers(IntSize(100, 100)); 615 setupScrollAndContentsLayers(IntSize(100, 100));
616 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 616 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
617 initializeRendererAndDrawFrame(); 617 initializeRendererAndDrawFrame();
(...skipping 14 matching lines...) Expand all
632 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 632 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
633 scrollLayer->setImplTransform(identityScaleTransform); 633 scrollLayer->setImplTransform(identityScaleTransform);
634 scrollLayer->setScrollPosition(IntPoint(50, 50)); 634 scrollLayer->setScrollPosition(IntPoint(50, 50));
635 635
636 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); 636 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
637 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); 637 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation);
638 EXPECT_TRUE(m_didRequestRedraw); 638 EXPECT_TRUE(m_didRequestRedraw);
639 m_hostImpl->animate(endTime, endTime); 639 m_hostImpl->animate(endTime, endTime);
640 EXPECT_TRUE(m_didRequestCommit); 640 EXPECT_TRUE(m_didRequestCommit);
641 641
642 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 642 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
643 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); 643 EXPECT_EQ(scrollInfo->pageScaleDelta, 2);
644 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 644 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
645 } 645 }
646 646
647 // Anchor zoom-out 647 // Anchor zoom-out
648 { 648 {
649 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 649 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
650 scrollLayer->setImplTransform(identityScaleTransform); 650 scrollLayer->setImplTransform(identityScaleTransform);
651 scrollLayer->setScrollPosition(IntPoint(50, 50)); 651 scrollLayer->setScrollPosition(IntPoint(50, 50));
652 652
653 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); 653 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
654 m_hostImpl->animate(endTime, endTime); 654 m_hostImpl->animate(endTime, endTime);
655 EXPECT_TRUE(m_didRequestRedraw); 655 EXPECT_TRUE(m_didRequestRedraw);
656 EXPECT_TRUE(m_didRequestCommit); 656 EXPECT_TRUE(m_didRequestCommit);
657 657
658 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 658 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
659 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 659 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
660 // Pushed to (0,0) via clamping against contents layer size. 660 // Pushed to (0,0) via clamping against contents layer size.
661 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 661 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
662 } 662 }
663 } 663 }
664 664
665 TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin g) 665 TEST_P(CCLayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhilePinchZoomin g)
666 { 666 {
667 setupScrollAndContentsLayers(IntSize(100, 100)); 667 setupScrollAndContentsLayers(IntSize(100, 100));
668 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 668 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
669 initializeRendererAndDrawFrame(); 669 initializeRendererAndDrawFrame();
670 670
671 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 671 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
672 ASSERT(scrollLayer); 672 ASSERT(scrollLayer);
673 673
674 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5 ; 674 const float minPageScale = CCSettings::pageScalePinchZoomEnabled() ? 1 : 0.5 ;
675 const float maxPageScale = 4; 675 const float maxPageScale = 4;
676 676
677 // Pinch zoom in. 677 // Pinch zoom in.
678 { 678 {
679 // Start a pinch in gesture at the bottom right corner of the viewport. 679 // Start a pinch in gesture at the bottom right corner of the viewport.
680 const float zoomInDelta = 2; 680 const float zoomInDelta = 2;
681 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 681 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
682 m_hostImpl->pinchGestureBegin(); 682 m_hostImpl->pinchGestureBegin();
683 m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50)); 683 m_hostImpl->pinchGestureUpdate(zoomInDelta, IntPoint(50, 50));
684 684
685 // Because we are pinch zooming in, we shouldn't get any scroll or page 685 // Because we are pinch zooming in, we shouldn't get any scroll or page
686 // scale deltas. 686 // scale deltas.
687 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 687 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
688 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); 688 EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
689 EXPECT_EQ(scrollInfo->scrolls.size(), 0u); 689 EXPECT_EQ(scrollInfo->scrolls.size(), 0u);
690 690
691 // Once the gesture ends, we get the final scroll and page scale values. 691 // Once the gesture ends, we get the final scroll and page scale values.
692 m_hostImpl->pinchGestureEnd(); 692 m_hostImpl->pinchGestureEnd();
693 scrollInfo = m_hostImpl->processScrollDeltas(); 693 scrollInfo = m_hostImpl->processScrollDeltas();
694 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta); 694 EXPECT_EQ(scrollInfo->pageScaleDelta, zoomInDelta);
695 if (!CCSettings::pageScalePinchZoomEnabled()) { 695 if (!CCSettings::pageScalePinchZoomEnabled()) {
696 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); 696 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
697 } else { 697 } else {
698 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); 698 EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
699 } 699 }
700 } 700 }
701 701
702 // Pinch zoom out. 702 // Pinch zoom out.
703 { 703 {
704 // Start a pinch out gesture at the bottom right corner of the viewport. 704 // Start a pinch out gesture at the bottom right corner of the viewport.
705 const float zoomOutDelta = 0.75; 705 const float zoomOutDelta = 0.75;
706 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 706 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
707 m_hostImpl->pinchGestureBegin(); 707 m_hostImpl->pinchGestureBegin();
708 m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50)); 708 m_hostImpl->pinchGestureUpdate(zoomOutDelta, IntPoint(50, 50));
709 709
710 // Since we are pinch zooming out, we should get an update to zoom all 710 // Since we are pinch zooming out, we should get an update to zoom all
711 // the way out to the minimum page scale. 711 // the way out to the minimum page scale.
712 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 712 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
713 if (!CCSettings::pageScalePinchZoomEnabled()) { 713 if (!CCSettings::pageScalePinchZoomEnabled()) {
714 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 714 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
715 expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0)); 715 expectContains(*scrollInfo, scrollLayer->id(), IntSize(0, 0));
716 } else { 716 } else {
717 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); 717 EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
718 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); 718 EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
719 } 719 }
720 720
721 // Once the gesture ends, we get the final scroll and page scale values. 721 // Once the gesture ends, we get the final scroll and page scale values.
722 m_hostImpl->pinchGestureEnd(); 722 m_hostImpl->pinchGestureEnd();
(...skipping 25 matching lines...) Expand all
748 const double endTime = startTime + duration; 748 const double endTime = startTime + duration;
749 749
750 // Start a page scale animation. 750 // Start a page scale animation.
751 const float pageScaleDelta = 2; 751 const float pageScaleDelta = 2;
752 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 752 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
753 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration); 753 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration);
754 754
755 // We should immediately get the final zoom and scroll values for the 755 // We should immediately get the final zoom and scroll values for the
756 // animation. 756 // animation.
757 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); 757 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation);
758 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 758 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
759 759
760 if (!CCSettings::pageScalePinchZoomEnabled()) { 760 if (!CCSettings::pageScalePinchZoomEnabled()) {
761 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 761 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
762 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); 762 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
763 } else { 763 } else {
764 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); 764 EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
765 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); 765 EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
766 } 766 }
767 767
768 // Scrolling during the animation is ignored. 768 // Scrolling during the animation is ignored.
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1135 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1136 m_hostImpl->scrollEnd(); 1136 m_hostImpl->scrollEnd();
1137 1137
1138 // Set new page scale from main thread. 1138 // Set new page scale from main thread.
1139 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale); 1139 m_hostImpl->setPageScaleFactorAndLimits(pageScale, pageScale, pageScale);
1140 1140
1141 if (!CCSettings::pageScalePinchZoomEnabled()) { 1141 if (!CCSettings::pageScalePinchZoomEnabled()) {
1142 // The scale should apply to the scroll delta. 1142 // The scale should apply to the scroll delta.
1143 expectedScrollDelta.scale(pageScale); 1143 expectedScrollDelta.scale(pageScale);
1144 } 1144 }
1145 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1145 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1146 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1146 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1147 1147
1148 // The scroll range should also have been updated. 1148 // The scroll range should also have been updated.
1149 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1149 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1150 1150
1151 // The page scale delta remains constant because the impl thread did not sca le. 1151 // The page scale delta remains constant because the impl thread did not sca le.
1152 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( )); 1152 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( ));
1153 } 1153 }
1154 1154
1155 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1155 TEST_P(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
(...skipping 13 matching lines...) Expand all
1169 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1169 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1170 m_hostImpl->scrollEnd(); 1170 m_hostImpl->scrollEnd();
1171 1171
1172 // Set new page scale on impl thread by pinching. 1172 // Set new page scale on impl thread by pinching.
1173 m_hostImpl->pinchGestureBegin(); 1173 m_hostImpl->pinchGestureBegin();
1174 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); 1174 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint());
1175 m_hostImpl->pinchGestureEnd(); 1175 m_hostImpl->pinchGestureEnd();
1176 m_hostImpl->updateRootScrollLayerImplTransform(); 1176 m_hostImpl->updateRootScrollLayerImplTransform();
1177 1177
1178 // The scroll delta is not scaled because the main thread did not scale. 1178 // The scroll delta is not scaled because the main thread did not scale.
1179 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1179 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1180 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1180 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1181 1181
1182 // The scroll range should also have been updated. 1182 // The scroll range should also have been updated.
1183 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1183 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1184 1184
1185 // The page scale delta should match the new scale on the impl side. 1185 // The page scale delta should match the new scale on the impl side.
1186 WebTransformationMatrix expectedScale; 1186 WebTransformationMatrix expectedScale;
1187 expectedScale.scale(pageScale); 1187 expectedScale.scale(pageScale);
1188 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); 1188 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
1189 } 1189 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 1258
1259 float pageScale = 2; 1259 float pageScale = 2;
1260 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); 1260 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
1261 1261
1262 m_hostImpl->updateRootScrollLayerImplTransform(); 1262 m_hostImpl->updateRootScrollLayerImplTransform();
1263 1263
1264 if (!CCSettings::pageScalePinchZoomEnabled()) { 1264 if (!CCSettings::pageScalePinchZoomEnabled()) {
1265 // The scale should apply to the scroll delta. 1265 // The scale should apply to the scroll delta.
1266 expectedScrollDelta.scale(pageScale); 1266 expectedScrollDelta.scale(pageScale);
1267 } 1267 }
1268 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1268 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1269 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1269 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1270 1270
1271 // The scroll range should not have changed. 1271 // The scroll range should not have changed.
1272 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); 1272 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll);
1273 1273
1274 // The page scale delta remains constant because the impl thread did not sca le. 1274 // The page scale delta remains constant because the impl thread did not sca le.
1275 WebTransformationMatrix identityTransform; 1275 WebTransformationMatrix identityTransform;
1276 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); 1276 EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
1277 } 1277 }
1278 1278
(...skipping 15 matching lines...) Expand all
1294 root->addChild(child.release()); 1294 root->addChild(child.release());
1295 m_hostImpl->setRootLayer(root.release()); 1295 m_hostImpl->setRootLayer(root.release());
1296 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1296 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1297 initializeRendererAndDrawFrame(); 1297 initializeRendererAndDrawFrame();
1298 { 1298 {
1299 IntSize scrollDelta(-8, -7); 1299 IntSize scrollDelta(-8, -7);
1300 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); 1300 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted);
1301 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1301 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1302 m_hostImpl->scrollEnd(); 1302 m_hostImpl->scrollEnd();
1303 1303
1304 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 1304 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
1305 1305
1306 // The grand child should have scrolled up to its limit. 1306 // The grand child should have scrolled up to its limit.
1307 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1307 CCLayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1308 CCLayerImpl* grandChild = child->children()[0]; 1308 CCLayerImpl* grandChild = child->children()[0];
1309 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5)); 1309 expectContains(*scrollInfo.get(), grandChild->id(), IntSize(0, -5));
1310 1310
1311 // The child should have only scrolled on the other axis. 1311 // The child should have only scrolled on the other axis.
1312 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0)); 1312 expectContains(*scrollInfo.get(), child->id(), IntSize(-3, 0));
1313 } 1313 }
1314 } 1314 }
(...skipping 11 matching lines...) Expand all
1326 1326
1327 m_hostImpl->setRootLayer(root.release()); 1327 m_hostImpl->setRootLayer(root.release());
1328 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1328 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1329 initializeRendererAndDrawFrame(); 1329 initializeRendererAndDrawFrame();
1330 { 1330 {
1331 IntSize scrollDelta(0, 4); 1331 IntSize scrollDelta(0, 4);
1332 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted); 1332 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted);
1333 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1333 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1334 m_hostImpl->scrollEnd(); 1334 m_hostImpl->scrollEnd();
1335 1335
1336 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 1336 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
1337 1337
1338 // Only the root should have scrolled. 1338 // Only the root should have scrolled.
1339 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 1339 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
1340 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 1340 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
1341 } 1341 }
1342 } 1342 }
1343 1343
1344 TEST_P(CCLayerTreeHostImplTest, scrollBeforeRedraw) 1344 TEST_P(CCLayerTreeHostImplTest, scrollBeforeRedraw)
1345 { 1345 {
1346 IntSize surfaceSize(10, 10); 1346 IntSize surfaceSize(10, 10);
(...skipping 22 matching lines...) Expand all
1369 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1369 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1370 initializeRendererAndDrawFrame(); 1370 initializeRendererAndDrawFrame();
1371 1371
1372 // Scroll to the right in screen coordinates with a gesture. 1372 // Scroll to the right in screen coordinates with a gesture.
1373 IntSize gestureScrollDelta(10, 0); 1373 IntSize gestureScrollDelta(10, 0);
1374 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest ure), CCInputHandlerClient::ScrollStarted); 1374 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest ure), CCInputHandlerClient::ScrollStarted);
1375 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); 1375 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta);
1376 m_hostImpl->scrollEnd(); 1376 m_hostImpl->scrollEnd();
1377 1377
1378 // The layer should have scrolled down in its local coordinates. 1378 // The layer should have scrolled down in its local coordinates.
1379 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1379 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1380 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, gestureScrollDelta.width())); 1380 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, gestureScrollDelta.width()));
1381 1381
1382 // Reset and scroll down with the wheel. 1382 // Reset and scroll down with the wheel.
1383 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); 1383 m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
1384 IntSize wheelScrollDelta(0, 10); 1384 IntSize wheelScrollDelta(0, 10);
1385 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1385 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1386 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); 1386 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta);
1387 m_hostImpl->scrollEnd(); 1387 m_hostImpl->scrollEnd();
1388 1388
1389 // The layer should have scrolled down in its local coordinates. 1389 // The layer should have scrolled down in its local coordinates.
(...skipping 26 matching lines...) Expand all
1416 { 1416 {
1417 // Scroll down in screen coordinates with a gesture. 1417 // Scroll down in screen coordinates with a gesture.
1418 IntSize gestureScrollDelta(0, 10); 1418 IntSize gestureScrollDelta(0, 10);
1419 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted); 1419 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted);
1420 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); 1420 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta);
1421 m_hostImpl->scrollEnd(); 1421 m_hostImpl->scrollEnd();
1422 1422
1423 // The child layer should have scrolled down in its local coordinates an amount proportional to 1423 // The child layer should have scrolled down in its local coordinates an amount proportional to
1424 // the angle between it and the input scroll delta. 1424 // the angle between it and the input scroll delta.
1425 IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2ra d(childLayerAngle))); 1425 IntSize expectedScrollDelta(0, gestureScrollDelta.height() * cosf(deg2ra d(childLayerAngle)));
1426 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 1426 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
1427 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); 1427 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
1428 1428
1429 // The root layer should not have scrolled, because the input delta was close to the layer's 1429 // The root layer should not have scrolled, because the input delta was close to the layer's
1430 // axis of movement. 1430 // axis of movement.
1431 EXPECT_EQ(scrollInfo->scrolls.size(), 1u); 1431 EXPECT_EQ(scrollInfo->scrolls.size(), 1u);
1432 } 1432 }
1433 1433
1434 { 1434 {
1435 // Now reset and scroll the same amount horizontally. 1435 // Now reset and scroll the same amount horizontally.
1436 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize()); 1436 m_hostImpl->rootLayer()->children()[1]->setScrollDelta(FloatSize());
1437 IntSize gestureScrollDelta(10, 0); 1437 IntSize gestureScrollDelta(10, 0);
1438 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted); 1438 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient:: Gesture), CCInputHandlerClient::ScrollStarted);
1439 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta); 1439 m_hostImpl->scrollBy(IntPoint(), gestureScrollDelta);
1440 m_hostImpl->scrollEnd(); 1440 m_hostImpl->scrollEnd();
1441 1441
1442 // The child layer should have scrolled down in its local coordinates an amount proportional to 1442 // The child layer should have scrolled down in its local coordinates an amount proportional to
1443 // the angle between it and the input scroll delta. 1443 // the angle between it and the input scroll delta.
1444 IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2ra d(childLayerAngle))); 1444 IntSize expectedScrollDelta(0, -gestureScrollDelta.width() * sinf(deg2ra d(childLayerAngle)));
1445 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 1445 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDe ltas();
1446 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta); 1446 expectContains(*scrollInfo.get(), childLayerId, expectedScrollDelta);
1447 1447
1448 // The root layer should have scrolled more, since the input scroll delt a was mostly 1448 // The root layer should have scrolled more, since the input scroll delt a was mostly
1449 // orthogonal to the child layer's vertical scroll axis. 1449 // orthogonal to the child layer's vertical scroll axis.
1450 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de g2rad(childLayerAngle)), 2), 0); 1450 IntSize expectedRootScrollDelta(gestureScrollDelta.width() * pow(cosf(de g2rad(childLayerAngle)), 2), 0);
1451 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); 1451 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta);
1452 } 1452 }
1453 } 1453 }
1454 1454
1455 TEST_P(CCLayerTreeHostImplTest, scrollScaledLayer) 1455 TEST_P(CCLayerTreeHostImplTest, scrollScaledLayer)
(...skipping 10 matching lines...) Expand all
1466 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1466 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1467 initializeRendererAndDrawFrame(); 1467 initializeRendererAndDrawFrame();
1468 1468
1469 // Scroll down in screen coordinates with a gesture. 1469 // Scroll down in screen coordinates with a gesture.
1470 IntSize scrollDelta(0, 10); 1470 IntSize scrollDelta(0, 10);
1471 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest ure), CCInputHandlerClient::ScrollStarted); 1471 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gest ure), CCInputHandlerClient::ScrollStarted);
1472 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1472 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1473 m_hostImpl->scrollEnd(); 1473 m_hostImpl->scrollEnd();
1474 1474
1475 // The layer should have scrolled down in its local coordinates, but half he amount. 1475 // The layer should have scrolled down in its local coordinates, but half he amount.
1476 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1476 scoped_ptr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
1477 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, scrollDelta.height() / scale)); 1477 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), IntSize(0, scrollDelta.height() / scale));
1478 1478
1479 // Reset and scroll down with the wheel. 1479 // Reset and scroll down with the wheel.
1480 m_hostImpl->rootLayer()->setScrollDelta(FloatSize()); 1480 m_hostImpl->rootLayer()->setScrollDelta(FloatSize());
1481 IntSize wheelScrollDelta(0, 10); 1481 IntSize wheelScrollDelta(0, 10);
1482 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1482 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1483 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta); 1483 m_hostImpl->scrollBy(IntPoint(), wheelScrollDelta);
1484 m_hostImpl->scrollEnd(); 1484 m_hostImpl->scrollEnd();
1485 1485
1486 // The scale should not have been applied to the scroll delta. 1486 // The scale should not have been applied to the scroll delta.
(...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after
4335 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4335 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
4336 testCaseIndex++; 4336 testCaseIndex++;
4337 } 4337 }
4338 } 4338 }
4339 4339
4340 INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests, 4340 INSTANTIATE_TEST_CASE_P(CCLayerTreeHostImplTests,
4341 CCLayerTreeHostImplTest, 4341 CCLayerTreeHostImplTest,
4342 ::testing::Values(false, true)); 4342 ::testing::Values(false, true));
4343 4343
4344 } // namespace 4344 } // namespace
OLDNEW
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCSingleThreadProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698