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 4027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4038 | 4038 |
4039 int nonexistentId = -1; | 4039 int nonexistentId = -1; |
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); | 4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); |
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); | 4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); |
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); | 4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); |
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); | 4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); |
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); | 4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); |
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); | 4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); |
4046 } | 4046 } |
4047 | 4047 |
4048 TEST(LayerTreeHostCommonTest, verifyCanUseLCDTextForSingleLayer) | |
4049 { | |
4050 scoped_refptr<Layer> root = Layer::create(); | |
4051 | |
4052 // Case 1: Identity transform. | |
4053 WebTransformationMatrix identityMatrix; | |
4054 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4055 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4056 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4057 | |
4058 // Case 2: Integral translation. | |
4059 WebTransformationMatrix integralTranslation; | |
4060 integralTranslation.translate(1, 2); | |
4061 root->setTransform(integralTranslation); | |
4062 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4063 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4064 | |
4065 // Case 3: Non-integral translation. | |
4066 WebTransformationMatrix nonIntegralTranslation; | |
4067 nonIntegralTranslation.translate(1.5, 2.5); | |
4068 root->setTransform(nonIntegralTranslation); | |
4069 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4070 EXPECT_EQ(false, root->canUseLCDText()); | |
4071 | |
4072 // Case 4: Rotation. | |
4073 WebTransformationMatrix rotation; | |
4074 rotation.rotate(10); | |
4075 root->setTransform(rotation); | |
4076 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4077 EXPECT_EQ(false, root->canUseLCDText()); | |
4078 | |
4079 // Case 5: Scale. | |
4080 WebTransformationMatrix scale; | |
4081 scale.scale(2); | |
4082 root->setTransform(scale); | |
4083 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4084 EXPECT_EQ(false, root->canUseLCDText()); | |
4085 | |
4086 // Case 6: Skew. | |
4087 WebTransformationMatrix skew; | |
4088 skew.skewX(10); | |
4089 root->setTransform(skew); | |
4090 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4091 EXPECT_EQ(false, root->canUseLCDText()); | |
4092 | |
4093 // Case 7: Translucent. | |
4094 root->setTransform(identityMatrix); | |
4095 root->setOpacity(0.5); | |
danakj
2012/11/07 18:15:00
The root layer owns a render surface, so this isn'
alokp
2012/11/08 22:34:07
Done.
| |
4096 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4097 EXPECT_EQ(false, root->canUseLCDText()); | |
4098 | |
4099 // Case 8: Restore transform and opacity. | |
4100 root->setTransform(identityMatrix); | |
4101 root->setOpacity(1); | |
4102 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4103 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4104 } | |
4105 | |
4106 TEST(LayerTreeHostCommonTest, verifyCanUseLCDTextForLayerTree) | |
danakj
2012/11/07 18:15:00
Seems like this is testing "...ForRenderSurface" m
alokp
2012/11/08 22:34:07
Done.
| |
4107 { | |
4108 scoped_refptr<Layer> root = Layer::create(); | |
danakj
2012/11/07 18:15:00
Can you make a child of the root, that owns a rend
alokp
2012/11/08 22:34:07
Done.
| |
4109 scoped_refptr<Layer> child = Layer::create(); | |
4110 root->addChild(child.get()); | |
4111 | |
4112 // Case 1: Identity transform. | |
4113 WebTransformationMatrix identityMatrix; | |
4114 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4115 setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gf x::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4116 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4117 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4118 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), child->canUseLCDText()); | |
4119 | |
4120 // Case 2: Integral translation. | |
4121 WebTransformationMatrix integralTranslation; | |
4122 integralTranslation.translate(1, 2); | |
4123 root->setTransform(integralTranslation); | |
4124 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4125 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4126 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), child->canUseLCDText()); | |
4127 | |
4128 // Case 3: Render surface cannot use LCD text. | |
4129 root->setOpacity(0.5); | |
4130 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4131 EXPECT_EQ(false, root->canUseLCDText()); | |
4132 EXPECT_EQ(false, child->canUseLCDText()); | |
4133 | |
4134 // Case 4: Restore opacity. | |
4135 root->setOpacity(1); | |
4136 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4137 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4138 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), child->canUseLCDText()); | |
4139 | |
4140 // Case 5: Child layer cannot use LCD text. | |
4141 WebTransformationMatrix scale; | |
4142 scale.scale(2); | |
4143 child->setTransform(scale); | |
4144 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4145 EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); | |
4146 EXPECT_EQ(false, child->canUseLCDText()); | |
4147 } | |
4148 | |
4149 TEST(LayerTreeHostCommonTest, verifyCanUseLCDTextWithAnimation) | |
4150 { | |
4151 scoped_refptr<Layer> root = Layer::create(); | |
danakj
2012/11/07 18:15:00
Again, please use a child of the root to be more r
alokp
2012/11/08 22:34:07
Done.
| |
4152 | |
4153 WebTransformationMatrix identityMatrix; | |
4154 setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); | |
4155 root->setOpacity(0.9f); | |
4156 root->setCanUseLCDText(true); | |
4157 addOpacityTransitionToController(*(root->layerAnimationController()), 10, 0. 9f, 0.1f, false); | |
4158 executeCalculateDrawTransformsAndVisibility(root.get()); | |
4159 // Text AA should not be adjusted while animation is active. | |
4160 // LCD text remains enabled even when it should not be. | |
4161 EXPECT_EQ(true, root->canUseLCDText()); | |
4162 } | |
4163 | |
4048 } // anonymous namespace | 4164 } // anonymous namespace |
OLD | NEW |