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

Side by Side Diff: cc/CCLayerTreeHostImplTest.cpp

Issue 10916279: Chromium compositor change implementing page-scale driven pinch-zoom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove dependency on content_common from cc for access to kEnablePinchZoomInCompositor. 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
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); 445 m_hostImpl->setViewportSize(layoutViewport, deviceViewport);
446 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 446 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
447 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25)); 447 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(25, 25));
448 448
449 deviceScaleFactor = 1; 449 deviceScaleFactor = 1;
450 m_hostImpl->setViewportSize(layoutViewport, layoutViewport); 450 m_hostImpl->setViewportSize(layoutViewport, layoutViewport);
451 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); 451 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor);
452 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75)); 452 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(75, 75));
453 } 453 }
454 454
455 TEST_F(CCLayerTreeHostImplTest, implPinchZoom)
456 {
457 CCSettings::setPageScalePinchZoomEnabled(true);
458 setupScrollAndContentsLayers(IntSize(100, 100));
459 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
460 initializeRendererAndDrawFrame();
461
462 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
463 ASSERT(scrollLayer);
464
465 const float minPageScale = 1, maxPageScale = 4;
466 const WebTransformationMatrix identityScaleTransform;
467
468 // The impl-based pinch zoome should not adjust the max scroll position.
469 {
470 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
471 scrollLayer->setImplTransform(identityScaleTransform);
472 scrollLayer->setScrollDelta(IntSize());
473
474 float pageScaleDelta = 2;
475 m_hostImpl->pinchGestureBegin();
476 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
477 m_hostImpl->pinchGestureEnd();
478 EXPECT_TRUE(m_didRequestRedraw);
479 EXPECT_TRUE(m_didRequestCommit);
480
481 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
482 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
483
484 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), IntSize(50, 50)) ;
485 }
486
487 // Scrolling after a pinch gesture should always be in local space. The scr oll deltas do not
488 // have the page scale factor applied.
489 {
490 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
491 scrollLayer->setImplTransform(identityScaleTransform);
492 scrollLayer->setScrollDelta(IntSize());
493
494 float pageScaleDelta = 2;
495 m_hostImpl->pinchGestureBegin();
496 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
497 m_hostImpl->pinchGestureEnd();
498
499 IntSize scrollDelta(0, 10);
500 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient:: Wheel), CCInputHandlerClient::ScrollStarted);
501 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
502 m_hostImpl->scrollEnd();
503
504 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
505 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
506 }
507 }
508
455 TEST_F(CCLayerTreeHostImplTest, pinchGesture) 509 TEST_F(CCLayerTreeHostImplTest, pinchGesture)
aelias_OOO_until_Jul13 2012/09/26 23:15:09 Hmm... all of these tests should really be run in
Jeff Timanus 2012/10/01 21:42:36 I converted all of these tests to parametrized, an
456 { 510 {
457 setupScrollAndContentsLayers(IntSize(100, 100)); 511 setupScrollAndContentsLayers(IntSize(100, 100));
458 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 512 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
459 initializeRendererAndDrawFrame(); 513 initializeRendererAndDrawFrame();
460 514
461 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 515 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
462 ASSERT(scrollLayer); 516 ASSERT(scrollLayer);
463 517
464 const float minPageScale = 0.5, maxPageScale = 4; 518 const float minPageScale = 0.5, maxPageScale = 4;
519 const WebTransformationMatrix identityScaleTransform;
465 520
466 // Basic pinch zoom in gesture 521 // Basic pinch zoom in gesture
467 { 522 {
468 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 523 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
469 scrollLayer->setPageScaleDelta(1); 524 scrollLayer->setImplTransform(identityScaleTransform);
470 scrollLayer->setScrollDelta(IntSize()); 525 scrollLayer->setScrollDelta(IntSize());
471 526
472 float pageScaleDelta = 2; 527 float pageScaleDelta = 2;
473 m_hostImpl->pinchGestureBegin(); 528 m_hostImpl->pinchGestureBegin();
474 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); 529 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
475 m_hostImpl->pinchGestureEnd(); 530 m_hostImpl->pinchGestureEnd();
476 EXPECT_TRUE(m_didRequestRedraw); 531 EXPECT_TRUE(m_didRequestRedraw);
477 EXPECT_TRUE(m_didRequestCommit); 532 EXPECT_TRUE(m_didRequestCommit);
478 533
479 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 534 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
480 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 535 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
481 } 536 }
482 537
483 // Zoom-in clamping 538 // Zoom-in clamping
484 { 539 {
485 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 540 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
486 scrollLayer->setPageScaleDelta(1); 541 scrollLayer->setImplTransform(identityScaleTransform);
487 scrollLayer->setScrollDelta(IntSize()); 542 scrollLayer->setScrollDelta(IntSize());
488 float pageScaleDelta = 10; 543 float pageScaleDelta = 10;
489 544
490 m_hostImpl->pinchGestureBegin(); 545 m_hostImpl->pinchGestureBegin();
491 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50)); 546 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(50, 50));
492 m_hostImpl->pinchGestureEnd(); 547 m_hostImpl->pinchGestureEnd();
493 548
494 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 549 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
495 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale); 550 EXPECT_EQ(scrollInfo->pageScaleDelta, maxPageScale);
496 } 551 }
497 552
498 // Zoom-out clamping 553 // Zoom-out clamping
499 { 554 {
500 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 555 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
501 scrollLayer->setPageScaleDelta(1); 556 scrollLayer->setImplTransform(identityScaleTransform);
502 scrollLayer->setScrollDelta(IntSize()); 557 scrollLayer->setScrollDelta(IntSize());
503 scrollLayer->setScrollPosition(IntPoint(50, 50)); 558 scrollLayer->setScrollPosition(IntPoint(50, 50));
504 559
505 float pageScaleDelta = 0.1f; 560 float pageScaleDelta = 0.1f;
506 m_hostImpl->pinchGestureBegin(); 561 m_hostImpl->pinchGestureBegin();
507 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0)); 562 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(0, 0));
508 m_hostImpl->pinchGestureEnd(); 563 m_hostImpl->pinchGestureEnd();
509 564
510 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 565 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
511 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 566 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
512 567
513 // Pushed to (0,0) via clamping against contents layer size. 568 // Pushed to (0,0) via clamping against contents layer size.
514 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 569 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
515 } 570 }
516 571
517 // Two-finger panning 572 // Two-finger panning
518 { 573 {
519 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 574 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
520 scrollLayer->setPageScaleDelta(1); 575 scrollLayer->setImplTransform(identityScaleTransform);
521 scrollLayer->setScrollDelta(IntSize()); 576 scrollLayer->setScrollDelta(IntSize());
522 scrollLayer->setScrollPosition(IntPoint(20, 20)); 577 scrollLayer->setScrollPosition(IntPoint(20, 20));
523 578
524 float pageScaleDelta = 1; 579 float pageScaleDelta = 1;
525 m_hostImpl->pinchGestureBegin(); 580 m_hostImpl->pinchGestureBegin();
526 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); 581 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10));
527 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); 582 m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20));
528 m_hostImpl->pinchGestureEnd(); 583 m_hostImpl->pinchGestureEnd();
529 584
530 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 585 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
531 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 586 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
532 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); 587 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10));
533 } 588 }
534 } 589 }
535 590
536 TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) 591 TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation)
537 { 592 {
538 setupScrollAndContentsLayers(IntSize(100, 100)); 593 setupScrollAndContentsLayers(IntSize(100, 100));
539 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 594 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
540 initializeRendererAndDrawFrame(); 595 initializeRendererAndDrawFrame();
541 596
542 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 597 CCLayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
543 ASSERT(scrollLayer); 598 ASSERT(scrollLayer);
544 599
545 const float minPageScale = 0.5, maxPageScale = 4; 600 const float minPageScale = 0.5, maxPageScale = 4;
546 const double startTime = 1; 601 const double startTime = 1;
547 const double duration = 0.1; 602 const double duration = 0.1;
548 const double halfwayThroughAnimation = startTime + duration / 2; 603 const double halfwayThroughAnimation = startTime + duration / 2;
549 const double endTime = startTime + duration; 604 const double endTime = startTime + duration;
605 const WebTransformationMatrix identityScaleTransform;
550 606
551 // Non-anchor zoom-in 607 // Non-anchor zoom-in
552 { 608 {
553 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 609 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
554 scrollLayer->setPageScaleDelta(1); 610 scrollLayer->setImplTransform(identityScaleTransform);
555 scrollLayer->setScrollPosition(IntPoint(50, 50)); 611 scrollLayer->setScrollPosition(IntPoint(50, 50));
556 612
557 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); 613 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
558 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); 614 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation);
559 EXPECT_TRUE(m_didRequestRedraw); 615 EXPECT_TRUE(m_didRequestRedraw);
560 m_hostImpl->animate(endTime, endTime); 616 m_hostImpl->animate(endTime, endTime);
561 EXPECT_TRUE(m_didRequestCommit); 617 EXPECT_TRUE(m_didRequestCommit);
562 618
563 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 619 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
564 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); 620 EXPECT_EQ(scrollInfo->pageScaleDelta, 2);
565 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 621 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
566 } 622 }
567 623
568 // Anchor zoom-out 624 // Anchor zoom-out
569 { 625 {
570 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 626 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
571 scrollLayer->setPageScaleDelta(1); 627 scrollLayer->setImplTransform(identityScaleTransform);
572 scrollLayer->setScrollPosition(IntPoint(50, 50)); 628 scrollLayer->setScrollPosition(IntPoint(50, 50));
573 629
574 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); 630 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
575 m_hostImpl->animate(endTime, endTime); 631 m_hostImpl->animate(endTime, endTime);
576 EXPECT_TRUE(m_didRequestRedraw); 632 EXPECT_TRUE(m_didRequestRedraw);
577 EXPECT_TRUE(m_didRequestCommit); 633 EXPECT_TRUE(m_didRequestCommit);
578 634
579 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas (); 635 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas ();
580 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 636 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
581 // Pushed to (0,0) via clamping against contents layer size. 637 // Pushed to (0,0) via clamping against contents layer size.
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 1095
1040 // The scale should apply to the scroll delta. 1096 // The scale should apply to the scroll delta.
1041 expectedScrollDelta.scale(pageScale); 1097 expectedScrollDelta.scale(pageScale);
1042 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1098 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
1043 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1099 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1044 1100
1045 // The scroll range should also have been updated. 1101 // The scroll range should also have been updated.
1046 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1102 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1047 1103
1048 // The page scale delta remains constant because the impl thread did not sca le. 1104 // The page scale delta remains constant because the impl thread did not sca le.
1049 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1); 1105 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( ));
1050 } 1106 }
1051 1107
1052 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1108 TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1053 { 1109 {
1054 IntSize surfaceSize(10, 10); 1110 IntSize surfaceSize(10, 10);
1055 float pageScale = 2; 1111 float pageScale = 2;
1056 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); 1112 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize);
1057 m_hostImpl->setRootLayer(root.release()); 1113 m_hostImpl->setRootLayer(root.release());
1058 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1114 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1059 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1115 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1060 initializeRendererAndDrawFrame(); 1116 initializeRendererAndDrawFrame();
1061 1117
1062 IntSize scrollDelta(0, 10); 1118 IntSize scrollDelta(0, 10);
1063 IntSize expectedScrollDelta(scrollDelta); 1119 IntSize expectedScrollDelta(scrollDelta);
1064 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition()); 1120 IntSize expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollPosition());
1065 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1121 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1066 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1122 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1067 m_hostImpl->scrollEnd(); 1123 m_hostImpl->scrollEnd();
1068 1124
1069 // Set new page scale on impl thread by pinching. 1125 // Set new page scale on impl thread by pinching.
1070 m_hostImpl->pinchGestureBegin(); 1126 m_hostImpl->pinchGestureBegin();
1071 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint()); 1127 m_hostImpl->pinchGestureUpdate(pageScale, IntPoint());
1072 m_hostImpl->pinchGestureEnd(); 1128 m_hostImpl->pinchGestureEnd();
1129 m_hostImpl->updateRootScrollLayerImplTransform();
1073 1130
1074 // The scroll delta is not scaled because the main thread did not scale. 1131 // The scroll delta is not scaled because the main thread did not scale.
1075 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1132 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
1076 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1133 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1077 1134
1078 // The scroll range should also have been updated. 1135 // The scroll range should also have been updated.
1079 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll); 1136 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
1080 1137
1081 // The page scale delta should match the new scale on the impl side. 1138 // The page scale delta should match the new scale on the impl side.
1082 EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), pageScale); 1139 WebTransformationMatrix expectedScale;
1140 expectedScale.scale(pageScale);
1141 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
1083 } 1142 }
1084 1143
1085 TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) 1144 TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
1086 { 1145 {
1087 IntSize surfaceSize(10, 10); 1146 IntSize surfaceSize(10, 10);
1088 float defaultPageScale = 1; 1147 float defaultPageScale = 1;
1148 WebTransformationMatrix defaultPageScaleMatrix;
1149
1089 float newPageScale = 2; 1150 float newPageScale = 2;
1151 WebTransformationMatrix newPageScaleMatrix;
1152 newPageScaleMatrix.scale(newPageScale);
1090 1153
1091 // Create a normal scrollable root layer and another scrollable child layer. 1154 // Create a normal scrollable root layer and another scrollable child layer.
1092 setupScrollAndContentsLayers(surfaceSize); 1155 setupScrollAndContentsLayers(surfaceSize);
1093 CCLayerImpl* root = m_hostImpl->rootLayer(); 1156 CCLayerImpl* root = m_hostImpl->rootLayer();
1094 CCLayerImpl* child = root->children()[0]; 1157 CCLayerImpl* child = root->children()[0];
1095 1158
1096 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize); 1159 OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize);
1097 child->addChild(scrollableChild.release()); 1160 child->addChild(scrollableChild.release());
1098 CCLayerImpl* grandChild = child->children()[0]; 1161 CCLayerImpl* grandChild = child->children()[0];
1099 1162
1100 // Set new page scale on impl thread by pinching. 1163 // Set new page scale on impl thread by pinching.
1101 m_hostImpl->pinchGestureBegin(); 1164 m_hostImpl->pinchGestureBegin();
1102 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); 1165 m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint());
1103 m_hostImpl->pinchGestureEnd(); 1166 m_hostImpl->pinchGestureEnd();
1167 m_hostImpl->updateRootScrollLayerImplTransform();
1104 1168
1105 // The page scale delta should only be applied to the scrollable root layer. 1169 // The page scale delta should only be applied to the scrollable root layer.
1106 EXPECT_EQ(root->pageScaleDelta(), newPageScale); 1170 EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
1107 EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); 1171 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
1108 EXPECT_EQ(grandChild->pageScaleDelta(), defaultPageScale); 1172 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
1109 1173
1110 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale 1174 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale
1111 // delta on the root layer is applied hierarchically. 1175 // delta on the root layer is applied hierarchically.
1112 CCLayerTreeHostImpl::FrameData frame; 1176 CCLayerTreeHostImpl::FrameData frame;
1113 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1177 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1114 m_hostImpl->drawLayers(frame); 1178 m_hostImpl->drawLayers(frame);
1115 m_hostImpl->didDrawAllLayers(frame); 1179 m_hostImpl->didDrawAllLayers(frame);
1116 1180
1117 EXPECT_EQ(root->drawTransform().m11(), newPageScale); 1181 EXPECT_EQ(root->drawTransform().m11(), newPageScale);
1118 EXPECT_EQ(root->drawTransform().m22(), newPageScale); 1182 EXPECT_EQ(root->drawTransform().m22(), newPageScale);
(...skipping 22 matching lines...) Expand all
1141 IntSize scrollDelta(0, 10); 1205 IntSize scrollDelta(0, 10);
1142 IntSize expectedScrollDelta(scrollDelta); 1206 IntSize expectedScrollDelta(scrollDelta);
1143 IntSize expectedMaxScroll(child->maxScrollPosition()); 1207 IntSize expectedMaxScroll(child->maxScrollPosition());
1144 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted); 1208 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(5, 5), CCInputHandlerClient::Whee l), CCInputHandlerClient::ScrollStarted);
1145 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 1209 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
1146 m_hostImpl->scrollEnd(); 1210 m_hostImpl->scrollEnd();
1147 1211
1148 float pageScale = 2; 1212 float pageScale = 2;
1149 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); 1213 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
1150 1214
1215 m_hostImpl->updateRootScrollLayerImplTransform();
1216
1151 // The scale should apply to the scroll delta. 1217 // The scale should apply to the scroll delta.
1152 expectedScrollDelta.scale(pageScale); 1218 expectedScrollDelta.scale(pageScale);
1153 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); 1219 OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
1154 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1220 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1155 1221
1156 // The scroll range should not have changed. 1222 // The scroll range should not have changed.
1157 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll); 1223 EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll);
1158 1224
1159 // The page scale delta remains constant because the impl thread did not sca le. 1225 // The page scale delta remains constant because the impl thread did not sca le.
1160 EXPECT_EQ(child->pageScaleDelta(), 1); 1226 WebTransformationMatrix identityTransform;
1227 EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
1161 } 1228 }
1162 1229
1163 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit) 1230 TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit)
1164 { 1231 {
1165 // Scroll a child layer beyond its maximum scroll range and make sure the 1232 // Scroll a child layer beyond its maximum scroll range and make sure the
1166 // parent layer is scrolled on the axis on which the child was unable to 1233 // parent layer is scrolled on the axis on which the child was unable to
1167 // scroll. 1234 // scroll.
1168 IntSize surfaceSize(10, 10); 1235 IntSize surfaceSize(10, 10);
1169 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize); 1236 OwnPtr<CCLayerImpl> root = createScrollableLayer(1, surfaceSize);
1170 1237
(...skipping 3105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4276 while (removeRenderPassesCases[testCaseIndex].name) { 4343 while (removeRenderPassesCases[testCaseIndex].name) {
4277 RenderPassRemovalTestData testData; 4344 RenderPassRemovalTestData testData;
4278 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get()); 4345 configureRenderPassTestData(removeRenderPassesCases[testCaseIndex].initS cript, testData, renderer.get());
4279 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData); 4346 CCLayerTreeHostImpl::removeRenderPasses(CCLayerTreeHostImpl::CullRenderP assesWithCachedTextures(*renderer), testData);
4280 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4347 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
4281 testCaseIndex++; 4348 testCaseIndex++;
4282 } 4349 }
4283 } 4350 }
4284 4351
4285 } // namespace 4352 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698