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

Unified Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/layer_tree_host_impl_unittest.cc
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index 56b251956f39add7810a127c50b0d2366154db3f..62fae15b478352e49dbc810d3f10684906e031ef 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -48,6 +48,7 @@ using namespace LayerTestCommon;
using namespace WebKit;
using namespace WebKitTests;
+using gfx::Transform;
using media::VideoFrame;
using ::testing::Mock;
using ::testing::Return;
@@ -534,7 +535,7 @@ TEST_P(LayerTreeHostImplTest, implPinchZoom)
DCHECK(scrollLayer);
const float minPageScale = 1, maxPageScale = 4;
- const WebTransformationMatrix identityScaleTransform;
+ const Transform identityScaleTransform;
// The impl-based pinch zoome should not adjust the max scroll position.
{
@@ -588,7 +589,7 @@ TEST_P(LayerTreeHostImplTest, pinchGesture)
const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
const float maxPageScale = 4;
- const WebTransformationMatrix identityScaleTransform;
+ const Transform identityScaleTransform;
// Basic pinch zoom in gesture
{
@@ -700,7 +701,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleAnimation)
const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
const base::TimeTicks endTime = startTime + duration;
- const WebTransformationMatrix identityScaleTransform;
+ const Transform identityScaleTransform;
// Non-anchor zoom-in
{
@@ -1162,8 +1163,8 @@ TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
- WebTransformationMatrix matrix;
- matrix.rotate3d(180, 0, 0);
+ Transform matrix;
+ MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
child->setTransform(matrix);
child->setDoubleSided(false);
@@ -1226,7 +1227,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix());
+ EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), Transform());
}
TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
@@ -1260,8 +1261,8 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
// The page scale delta should match the new scale on the impl side.
- WebTransformationMatrix expectedScale;
- expectedScale.scale(pageScale);
+ Transform expectedScale;
+ expectedScale.PreconcatScale(pageScale, pageScale);
EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
}
@@ -1269,11 +1270,11 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
{
gfx::Size surfaceSize(10, 10);
float defaultPageScale = 1;
- WebTransformationMatrix defaultPageScaleMatrix;
+ Transform defaultPageScaleMatrix;
float newPageScale = 2;
- WebTransformationMatrix newPageScaleMatrix;
- newPageScaleMatrix.scale(newPageScale);
+ Transform newPageScaleMatrix;
+ newPageScaleMatrix.PreconcatScale(newPageScale, newPageScale);
// Create a normal scrollable root layer and another scrollable child layer.
setupScrollAndContentsLayers(surfaceSize);
@@ -1302,12 +1303,12 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
m_hostImpl->drawLayers(frame);
m_hostImpl->didDrawAllLayers(frame);
- EXPECT_EQ(root->drawTransform().m11(), newPageScale);
- EXPECT_EQ(root->drawTransform().m22(), newPageScale);
- EXPECT_EQ(child->drawTransform().m11(), newPageScale);
- EXPECT_EQ(child->drawTransform().m22(), newPageScale);
- EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale);
- EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale);
+ EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale);
+ EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale);
+ EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale);
+ EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale);
+ EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale);
+ EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale);
}
TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
@@ -1349,8 +1350,8 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
// The page scale delta remains constant because the impl thread did not scale.
- WebTransformationMatrix identityTransform;
- EXPECT_EQ(child->implTransform(), WebTransformationMatrix());
+ Transform identityTransform;
+ EXPECT_EQ(child->implTransform(), Transform());
}
TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
@@ -1438,8 +1439,8 @@ TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
setupScrollAndContentsLayers(gfx::Size(100, 100));
// Rotate the root layer 90 degrees counter-clockwise about its center.
- WebTransformationMatrix rotateTransform;
- rotateTransform.rotate(-90);
+ Transform rotateTransform;
+ rotateTransform.PreconcatRotate(-90);
m_hostImpl->rootLayer()->setTransform(rotateTransform);
gfx::Size surfaceSize(50, 50);
@@ -1476,10 +1477,10 @@ TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
// Create a child layer that is rotated to a non-axis-aligned angle.
scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl->rootLayer()->contentBounds());
- WebTransformationMatrix rotateTransform;
- rotateTransform.translate(-50, -50);
- rotateTransform.rotate(childLayerAngle);
- rotateTransform.translate(50, 50);
+ Transform rotateTransform;
+ rotateTransform.PreconcatTranslate(-50, -50);
+ rotateTransform.PreconcatRotate(childLayerAngle);
+ rotateTransform.PreconcatTranslate(50, 50);
child->setTransform(rotateTransform);
// Only allow vertical scrolling.
@@ -1535,8 +1536,8 @@ TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
// Scale the layer to twice its normal size.
int scale = 2;
- WebTransformationMatrix scaleTransform;
- scaleTransform.scale(scale);
+ Transform scaleTransform;
+ scaleTransform.PreconcatScale(scale, scale);
m_hostImpl->rootLayer()->setTransform(scaleTransform);
gfx::Size surfaceSize(50, 50);
@@ -2715,9 +2716,9 @@ static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid
ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::Size(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), WebTransformationMatrix());
+ pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), Transform());
scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create();
- sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 1);
+ sharedState->SetAll(Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), 1);
scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), resourceId, false, gfx::RectF(0, 0, 1, 1), false);
@@ -3137,10 +3138,10 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
// Rotation will put part of the child ouside the bounds of the root layer.
// Nevertheless, the child layers should be drawn.
- WebTransformationMatrix transform = surfaceLayerPtr->transform();
- transform.translate(50, 50);
- transform.rotate(35);
- transform.translate(-50, -50);
+ Transform transform = surfaceLayerPtr->transform();
+ transform.PreconcatTranslate(50, 50);
+ transform.PreconcatRotate(35);
+ transform.PreconcatTranslate(-50, -50);
surfaceLayerPtr->setTransform(transform);
{
@@ -3171,9 +3172,9 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithClipping)
}
transform = surfaceLayerPtr->transform();
- transform.translate(50, 50);
- transform.rotate(-35);
- transform.translate(-50, -50);
+ transform.PreconcatTranslate(50, 50);
+ transform.PreconcatRotate(-35);
+ transform.PreconcatTranslate(-50, -50);
surfaceLayerPtr->setTransform(transform);
// The surface is now aligned again, and the clipped parts are exposed.
@@ -3266,8 +3267,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(150, 150);
+ Transform transform = layerS2Ptr->transform();
+ transform.PreconcatTranslate(150, 150);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3290,7 +3291,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusion)
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
transform = layerS2Ptr->transform();
- transform.translate(-15, -15);
+ transform.PreconcatTranslate(-15, -15);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3381,8 +3382,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(100, 100);
+ Transform transform = layerS2Ptr->transform();
+ transform.PreconcatTranslate(100, 100);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3405,7 +3406,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionEarlyOut)
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
transform = layerS2Ptr->transform();
- transform.translate(-15, -15);
+ transform.PreconcatTranslate(-15, -15);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3487,8 +3488,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalOverInternal)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(300, 0);
+ Transform transform = layerS2Ptr->transform();
+ transform.PreconcatTranslate(300, 0);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3541,10 +3542,10 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionExternalNotAligned)
addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
layerS1Ptr->setForceRenderSurface(true);
- WebTransformationMatrix transform = layerS1Ptr->transform();
- transform.translate(200, 200);
- transform.rotate(45);
- transform.translate(-200, -200);
+ Transform transform = layerS1Ptr->transform();
+ transform.PreconcatTranslate(200, 200);
+ transform.PreconcatRotate(45);
+ transform.PreconcatTranslate(-200, -200);
layerS1Ptr->setTransform(transform);
addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
@@ -3654,8 +3655,8 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
// "Unocclude" surface S1 and repeat draw.
// Must remove S2's render pass since it's cached;
// Must keep S1 quads because texture contained external occlusion.
- WebTransformationMatrix transform = layerS2Ptr->transform();
- transform.translate(150, 150);
+ Transform transform = layerS2Ptr->transform();
+ transform.PreconcatTranslate(150, 150);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3678,7 +3679,7 @@ TEST_P(LayerTreeHostImplTest, textureCachingWithOcclusionPartialSwap)
// Must remove S1's render pass since it is now available in full.
// S2 has no change so must also be removed.
transform = layerS2Ptr->transform();
- transform.translate(-15, -15);
+ transform.PreconcatTranslate(-15, -15);
layerS2Ptr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -3936,8 +3937,8 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCaching)
}
// Change location of the intermediate layer
- WebTransformationMatrix transform = intermediateLayerPtr->transform();
- transform.setM41(1.0001);
+ Transform transform = intermediateLayerPtr->transform();
+ transform.matrix().setDouble(0, 3, 1.0001);
intermediateLayerPtr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -4097,8 +4098,8 @@ TEST_P(LayerTreeHostImplTest, surfaceTextureCachingNoPartialSwap)
}
// Change location of the intermediate layer
- WebTransformationMatrix transform = intermediateLayerPtr->transform();
- transform.setM41(1.0001);
+ Transform transform = intermediateLayerPtr->transform();
+ transform.matrix().setDouble(0, 3, 1.0001);
intermediateLayerPtr->setTransform(transform);
{
LayerTreeHostImpl::FrameData frame;
@@ -4192,14 +4193,14 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova
// One shared state for all quads - we don't need the correct details
testData.sharedQuadState = SharedQuadState::Create();
- testData.sharedQuadState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx::Rect(), 1.0);
+ testData.sharedQuadState->SetAll(Transform(), gfx::Rect(), gfx::Rect(), 1.0);
const char* currentChar = testScript;
// Pre-create root pass
RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1]);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMatrix());
+ pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), Transform());
testData.renderPassCache.add(rootRenderPassId, pass.Pass());
while (*currentChar) {
int layerId = *currentChar;
@@ -4259,7 +4260,7 @@ static void configureRenderPassTestData(const char* testScript, RenderPassRemova
renderer->setHaveCachedResourcesForRenderPassId(newRenderPassId);
scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
- pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMatrix());
+ pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), Transform());
testData.renderPassCache.add(newRenderPassId, pass.Pass());
}

Powered by Google App Engine
This is Rietveld 408576698