| 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..e9501dcde7785edf06936fa63695e2fef8a69c7f 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,6 +351,7 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
|
| parentTranslationToAnchor.Translate(25, 30);
|
| gfx::Transform parentSublayerMatrix;
|
| parentSublayerMatrix.Scale3d(0.9, 1, 3.3);
|
| +
|
| gfx::Transform parentTranslationToCenter;
|
| parentTranslationToCenter.Translate(50, 60);
|
| gfx::Transform parentCompositeTransform = parentTranslationToAnchor * parentLayerTransform * MathUtil::inverse(parentTranslationToAnchor)
|
| @@ -369,6 +386,91 @@ TEST(LayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface)
|
| EXPECT_TRANSFORMATION_MATRIX_EQ(surfaceSublayerCompositeTransform, child->renderTarget()->renderSurface()->screenSpaceTransform());
|
| }
|
|
|
| +TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirementWithClipping)
|
| +{
|
| + 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;
|
| + gfx::Transform childLayerMatrix;
|
| +
|
| + // No render surface should exist yet.
|
| + EXPECT_FALSE(root->renderSurface());
|
| + EXPECT_FALSE(parent->renderSurface());
|
| + EXPECT_FALSE(child->renderSurface());
|
| + EXPECT_FALSE(grandChild->renderSurface());
|
| +
|
| + // One-time setup of root layer
|
| + parentLayerTransform.Scale3d(1, 0.9, 1);
|
| + parentSublayerMatrix.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 surfaces should have been created according to clipping rules now (grandchild can clip self).
|
| + EXPECT_TRUE(root->renderSurface());
|
| + EXPECT_FALSE(parent->renderSurface());
|
| + EXPECT_FALSE(child->renderSurface());
|
| + EXPECT_FALSE(grandChild->renderSurface());
|
| +}
|
| +
|
| +TEST(LayerTreeHostCommonTest, verifySeparateRenderTargetRequirementWithoutClipping)
|
| +{
|
| + scoped_refptr<Layer> root = Layer::create();
|
| + scoped_refptr<Layer> parent = Layer::create();
|
| + scoped_refptr<Layer> child = Layer::create();
|
| + // This layer cannot clip itself, a feature we are testing here.
|
| + 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;
|
| + gfx::Transform childLayerMatrix;
|
| +
|
| + // No render surface should exist yet.
|
| + EXPECT_FALSE(root->renderSurface());
|
| + EXPECT_FALSE(parent->renderSurface());
|
| + EXPECT_FALSE(child->renderSurface());
|
| + EXPECT_FALSE(grandChild->renderSurface());
|
| +
|
| + // One-time setup of root layer
|
| + parentLayerTransform.Scale3d(1, 0.9, 1);
|
| + parentSublayerMatrix.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 surfaces should have been created according to clipping rules now (grandchild can't clip self).
|
| + EXPECT_TRUE(root->renderSurface());
|
| + EXPECT_FALSE(parent->renderSurface());
|
| + EXPECT_TRUE(child->renderSurface());
|
| + EXPECT_FALSE(grandChild->renderSurface());
|
| +}
|
| +
|
| TEST(LayerTreeHostCommonTest, verifyTransformsForReplica)
|
| {
|
| scoped_refptr<Layer> root = Layer::create();
|
|
|