Chromium Code Reviews| Index: cc/layer_tree_host_common_unittest.cc |
| diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc |
| index 15776469e6911b7405d9179195c8d3e60451b0b2..782bdd57a86fb687846689b3144aee35dd24ff50 100644 |
| --- a/cc/layer_tree_host_common_unittest.cc |
| +++ b/cc/layer_tree_host_common_unittest.cc |
| @@ -113,6 +113,22 @@ private: |
| } |
| }; |
| +class LayerCanClipSelf : public Layer { |
| +public: |
| + LayerCanClipSelf() |
| + : Layer() |
| + { |
| + } |
| + |
| + virtual bool drawsContent() const OVERRIDE { return true; } |
| + virtual bool canClipSelf() const OVERRIDE { return true; } |
| + |
| +private: |
| + virtual ~LayerCanClipSelf() |
| + { |
| + } |
| +}; |
| + |
| class MockContentLayerClient : public ContentLayerClient { |
| public: |
| MockContentLayerClient() { } |
| @@ -335,13 +351,18 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) |
| parentTranslationToAnchor.Translate(25, 30); |
| gfx::Transform parentSublayerMatrix; |
| parentSublayerMatrix.Scale3d(0.9, 1, 3.3); |
| + |
|
shawnsingh
2012/12/18 19:11:00
Did you add these empty lines here with the intent
whunt
2012/12/18 19:48:15
Just trying to read the code, I'll remove them.
O
|
| gfx::Transform parentTranslationToCenter; |
| parentTranslationToCenter.Translate(50, 60); |
| + |
| gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor) |
| * parentTranslationToCenter * parentSublayerMatrix * MathUtil::inverse(parentTranslationToCenter); |
| + |
| gfx::Vector2dF parentCompositeScale = MathUtil::computeTransform2dScaleComponents(parentCompositeTransform); |
| + |
| gfx::Transform surfaceSublayerTransform; |
| surfaceSublayerTransform.Scale(parentCompositeScale.x(), parentCompositeScale.y()); |
| + |
| gfx::Transform surfaceSublayerCompositeTransform = parentCompositeTransform * MathUtil::inverse(surfaceSublayerTransform); |
| // Child's render surface should not exist yet. |
| @@ -369,6 +390,90 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) |
| EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->renderTarget()->renderSurface()->screenSpaceTransform()); |
| } |
| +TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirement) |
| +{ |
| + { |
| + scoped_refptr<Layer> root = Layer::create(); |
| + scoped_refptr<Layer> parent = Layer::create(); |
| + scoped_refptr<Layer> child = Layer::create(); |
| + scoped_refptr<Layer> grandChild = make_scoped_refptr(new LayerCanClipSelf()); |
| + root->addChild(parent); |
| + parent->addChild(child); |
| + child->addChild(grandChild); |
| + parent->setMasksToBounds(true); |
| + child->setMasksToBounds(true); |
| + |
| + gfx::Transform identityMatrix; |
| + gfx::Transform parentLayerTransform; |
| + gfx::Transform parentSublayerMatrix; |
|
shawnsingh
2012/12/18 19:11:00
This is unmodified; how about we just use identity
|
| + gfx::Transform childLayerMatrix; |
| + |
| + // No render surface should exist yet. |
| + ASSERT_FALSE(root->renderSurface()); |
| + ASSERT_FALSE(parent->renderSurface()); |
| + ASSERT_FALSE(child->renderSurface()); |
| + ASSERT_FALSE(grandChild->renderSurface()); |
| + |
| + // One-time setup of root layer |
| + parentLayerTransform.Scale3d(1, 0.9, 1); |
| + childLayerMatrix.Scale3d(0.9, 1, 3.3); |
| + childLayerMatrix.Rotate(20); |
| + |
| + setLayerPropertiesForTesting(root .get(), identityMatrix , identityMatrix , gfx::PointF( 0, 0), gfx::PointF(0, 0), gfx::Size( 1, 2), false); |
| + setLayerPropertiesForTesting(parent .get(), parentLayerTransform, parentSublayerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), false); |
| + setLayerPropertiesForTesting(child .get(), childLayerMatrix , identityMatrix , gfx::PointF( 0, 0), gfx::PointF(0, 0), gfx::Size( 16, 18), false); |
| + setLayerPropertiesForTesting(grandChild.get(), identityMatrix , identityMatrix , gfx::PointF( 0, 0), gfx::PointF(0, 0), gfx::Size( 8, 10), false); |
| + |
| + executeCalculateDrawProperties(root.get()); |
| + |
| + // Render surface should have been created now. |
|
shawnsingh
2012/12/18 19:11:00
We probably want to update this comment, should pr
|
| + ASSERT_TRUE(root->renderSurface()); |
| + ASSERT_FALSE(parent->renderSurface()); |
| + ASSERT_FALSE(child->renderSurface()); |
| + ASSERT_FALSE(grandChild->renderSurface()); |
| + } |
| + { |
| + scoped_refptr<Layer> root = Layer::create(); |
| + scoped_refptr<Layer> parent = Layer::create(); |
| + scoped_refptr<Layer> child = Layer::create(); |
| + scoped_refptr<Layer> grandChild = make_scoped_refptr(new LayerWithForcedDrawsContent()); |
| + root->addChild(parent); |
| + parent->addChild(child); |
| + child->addChild(grandChild); |
| + parent->setMasksToBounds(true); |
| + child->setMasksToBounds(true); |
| + |
| + gfx::Transform identityMatrix; |
| + gfx::Transform parentLayerTransform; |
| + gfx::Transform parentSublayerMatrix; |
|
shawnsingh
2012/12/18 19:11:00
This is unmodified; how about we just use identity
|
| + gfx::Transform childLayerMatrix; |
| + |
| + // No render surface should exist yet. |
| + ASSERT_FALSE(root->renderSurface()); |
| + ASSERT_FALSE(parent->renderSurface()); |
| + ASSERT_FALSE(child->renderSurface()); |
| + ASSERT_FALSE(grandChild->renderSurface()); |
| + |
| + // One-time setup of root layer |
| + parentLayerTransform.Scale3d(1, 0.9, 1); |
| + childLayerMatrix.Scale3d(0.9, 1, 3.3); |
| + childLayerMatrix.Rotate(20); |
| + |
| + setLayerPropertiesForTesting(root .get(), identityMatrix , identityMatrix , gfx::PointF( 0, 0), gfx::PointF(0, 0), gfx::Size( 1, 2), false); |
| + setLayerPropertiesForTesting(parent .get(), parentLayerTransform, parentSublayerMatrix, gfx::PointF(0.25, 0.25), gfx::PointF(0, 0), gfx::Size(100, 120), false); |
| + setLayerPropertiesForTesting(child .get(), childLayerMatrix , identityMatrix , gfx::PointF( 0, 0), gfx::PointF(0, 0), gfx::Size( 16, 18), false); |
| + setLayerPropertiesForTesting(grandChild.get(), identityMatrix , identityMatrix , gfx::PointF( 0, 0), gfx::PointF(0, 0), gfx::Size( 8, 10), false); |
| + |
| + executeCalculateDrawProperties(root.get()); |
| + |
| + // Render surface should have been created now. |
|
shawnsingh
2012/12/18 19:11:00
We probably want to update this comment, something
|
| + ASSERT_TRUE(root->renderSurface()); |
| + ASSERT_FALSE(parent->renderSurface()); |
| + ASSERT_TRUE(child->renderSurface()); |
| + ASSERT_FALSE(grandChild->renderSurface()); |
| + } |
| +} |
| + |
| TEST(LayerTreeHostCommonTest, verifyTransformsForReplica) |
| { |
| scoped_refptr<Layer> root = Layer::create(); |
| @@ -872,6 +977,7 @@ TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD |
| grandChild->setPosition(gfx::PointF(8, 6)); |
| greatGrandChild->setFixedToContainerLayer(true); |
| + |
|
shawnsingh
2012/12/18 19:11:00
another empty line
|
| // Case 1: scrollDelta of 0, 0 |
| child->setScrollDelta(gfx::Vector2d(0, 0)); |
| executeCalculateDrawProperties(root.get()); |