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

Unified 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: Reduce number of prepared tiles and correct existing tests. Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: cc/CCLayerTreeHostImplTest.cpp
===================================================================
--- cc/CCLayerTreeHostImplTest.cpp (revision 157978)
+++ cc/CCLayerTreeHostImplTest.cpp (working copy)
@@ -462,11 +462,12 @@
ASSERT(scrollLayer);
const float minPageScale = 0.5, maxPageScale = 4;
+ const WebTransformationMatrix identityScaleTransform;
// Basic pinch zoom in gesture
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 2;
@@ -483,7 +484,7 @@
// Zoom-in clamping
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
float pageScaleDelta = 10;
@@ -498,7 +499,7 @@
// Zoom-out clamping
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
scrollLayer->setScrollPosition(IntPoint(50, 50));
@@ -517,7 +518,7 @@
// Two-finger panning
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollDelta(IntSize());
scrollLayer->setScrollPosition(IntPoint(20, 20));
@@ -547,11 +548,12 @@
const double duration = 0.1;
const double halfwayThroughAnimation = startTime + duration / 2;
const double endTime = startTime + duration;
+ const WebTransformationMatrix identityScaleTransform;
// Non-anchor zoom-in
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollPosition(IntPoint(50, 50));
m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
@@ -568,7 +570,7 @@
// Anchor zoom-out
{
m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
- scrollLayer->setPageScaleDelta(1);
+ scrollLayer->setImplTransform(identityScaleTransform);
scrollLayer->setScrollPosition(IntPoint(50, 50));
m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
@@ -1046,7 +1048,7 @@
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), 1);
+ EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
}
TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
@@ -1070,6 +1072,7 @@
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, IntPoint());
m_hostImpl->pinchGestureEnd();
+ m_hostImpl->updateRootScrollLayerImplTransform();
// The scroll delta is not scaled because the main thread did not scale.
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -1079,14 +1082,20 @@
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollPosition(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side.
- EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), pageScale);
+ WebTransformationMatrix expectedScale;
+ expectedScale.scale(pageScale);
+ EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
}
TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
{
IntSize surfaceSize(10, 10);
float defaultPageScale = 1;
+ WebTransformationMatrix defaultPageScaleMatrix;
+
float newPageScale = 2;
+ WebTransformationMatrix newPageScaleMatrix;
+ newPageScaleMatrix.scale(newPageScale);
// Create a normal scrollable root layer and another scrollable child layer.
setupScrollAndContentsLayers(surfaceSize);
@@ -1101,11 +1110,12 @@
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint());
m_hostImpl->pinchGestureEnd();
+ m_hostImpl->updateRootScrollLayerImplTransform();
// The page scale delta should only be applied to the scrollable root layer.
- EXPECT_EQ(root->pageScaleDelta(), newPageScale);
- EXPECT_EQ(child->pageScaleDelta(), defaultPageScale);
- EXPECT_EQ(grandChild->pageScaleDelta(), defaultPageScale);
+ EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
+ EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
+ EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
// Make sure all the layers are drawn with the page scale delta applied, i.e., the page scale
// delta on the root layer is applied hierarchically.
@@ -1148,6 +1158,8 @@
float pageScale = 2;
m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
+ m_hostImpl->updateRootScrollLayerImplTransform();
+
// The scale should apply to the scroll delta.
expectedScrollDelta.scale(pageScale);
OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -1157,7 +1169,8 @@
EXPECT_EQ(child->maxScrollPosition(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- EXPECT_EQ(child->pageScaleDelta(), 1);
+ WebTransformationMatrix identityTransform;
+ EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
}
TEST_F(CCLayerTreeHostImplTest, scrollChildBeyondLimit)
« no previous file with comments | « cc/CCLayerTreeHostImpl.cpp ('k') | cc/CCLayerTreeHostTest.cpp » ('j') | cc/CCSettings.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698