OLD | NEW |
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 "cc/layer_tree_host_common.h" | 7 #include "cc/layer_tree_host_common.h" |
8 | 8 |
9 #include "cc/content_layer.h" | 9 #include "cc/content_layer.h" |
10 #include "cc/content_layer_client.h" | 10 #include "cc/content_layer_client.h" |
(...skipping 3669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3680 | 3680 |
3681 renderSurfaceLayerList.clear(); | 3681 renderSurfaceLayerList.clear(); |
3682 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); | 3682 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
3683 | 3683 |
3684 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); | 3684 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
3685 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); | 3685 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * initialChildScale, childScale); |
3686 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); | 3686 EXPECT_CONTENTS_SCALE_EQ(1, childNoScale); |
3687 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); | 3687 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterSc
ale, childNoAutoScale); |
3688 } | 3688 } |
3689 | 3689 |
| 3690 TEST(LayerTreeHostCommonTest, verifySmallContentsScale) |
| 3691 { |
| 3692 MockContentLayerClient delegate; |
| 3693 WebTransformationMatrix identityMatrix; |
| 3694 |
| 3695 WebTransformationMatrix parentScaleMatrix; |
| 3696 const double initialParentScale = 1.75; |
| 3697 parentScaleMatrix.scale(initialParentScale); |
| 3698 |
| 3699 WebTransformationMatrix childScaleMatrix; |
| 3700 const double initialChildScale = 0.25; |
| 3701 childScaleMatrix.scale(initialChildScale); |
| 3702 |
| 3703 scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate); |
| 3704 setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix
, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true); |
| 3705 |
| 3706 scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegat
e); |
| 3707 setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMat
rix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true); |
| 3708 |
| 3709 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3710 // Page scale should not apply to the parent. |
| 3711 parent->setBoundsContainPageScale(true); |
| 3712 |
| 3713 parent->addChild(childScale); |
| 3714 |
| 3715 std::vector<scoped_refptr<Layer> > renderSurfaceLayerList; |
| 3716 int dummyMaxTextureSize = 512; |
| 3717 |
| 3718 double deviceScaleFactor = 2.5; |
| 3719 double pageScaleFactor = 0.01; |
| 3720 |
| 3721 // FIXME: Remove this when pageScaleFactor is applied in the compositor. |
| 3722 WebTransformationMatrix pageScaleMatrix; |
| 3723 pageScaleMatrix.scale(pageScaleFactor); |
| 3724 parent->setSublayerTransform(pageScaleMatrix); |
| 3725 |
| 3726 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 3727 |
| 3728 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 3729 // The child's scale is < 1, so we should not save and use that scale factor
. |
| 3730 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale
); |
| 3731 |
| 3732 // When chilld's total scale becomes >= 1, we should save and use that scale
factor. |
| 3733 childScaleMatrix.makeIdentity(); |
| 3734 const double finalChildScale = 0.75; |
| 3735 childScaleMatrix.scale(finalChildScale); |
| 3736 childScale->setTransform(childScaleMatrix); |
| 3737 |
| 3738 renderSurfaceLayerList.clear(); |
| 3739 LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(),
deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList
); |
| 3740 |
| 3741 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent); |
| 3742 EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParent
Scale * finalChildScale, childScale); |
| 3743 } |
| 3744 |
3690 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) | 3745 TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces) |
3691 { | 3746 { |
3692 MockContentLayerClient delegate; | 3747 MockContentLayerClient delegate; |
3693 WebTransformationMatrix identityMatrix; | 3748 WebTransformationMatrix identityMatrix; |
3694 | 3749 |
3695 WebTransformationMatrix parentScaleMatrix; | 3750 WebTransformationMatrix parentScaleMatrix; |
3696 const double initialParentScale = 2; | 3751 const double initialParentScale = 2; |
3697 parentScaleMatrix.scale(initialParentScale); | 3752 parentScaleMatrix.scale(initialParentScale); |
3698 | 3753 |
3699 WebTransformationMatrix childScaleMatrix; | 3754 WebTransformationMatrix childScaleMatrix; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4039 int nonexistentId = -1; | 4094 int nonexistentId = -1; |
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); | 4095 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id
())); |
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); | 4096 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child->
id())); |
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); | 4097 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr
andChild->id())); |
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); | 4098 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas
kLayer->id())); |
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); | 4099 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(),
replicaLayer->id())); |
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); | 4100 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent
Id)); |
4046 } | 4101 } |
4047 | 4102 |
4048 } // anonymous namespace | 4103 } // anonymous namespace |
OLD | NEW |