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 228ce2b6e5b7cf4cc4e8f5a6a7bf61e73cde12c3..9c4d72f9ad242b5634584e95d4427aef226ffb1c 100644 |
--- a/cc/layer_tree_host_common_unittest.cc |
+++ b/cc/layer_tree_host_common_unittest.cc |
@@ -4045,4 +4045,120 @@ TEST(LayerTreeHostCommonTest, verifySubtreeSearch) |
EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistentId)); |
} |
+TEST(LayerTreeHostCommonTest, verifyCanUseLCDTextForSingleLayer) |
+{ |
+ scoped_refptr<Layer> root = Layer::create(); |
+ |
+ // Case 1: Identity transform. |
+ WebTransformationMatrix identityMatrix; |
+ setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+ |
+ // Case 2: Integral translation. |
+ WebTransformationMatrix integralTranslation; |
+ integralTranslation.translate(1, 2); |
+ root->setTransform(integralTranslation); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+ |
+ // Case 3: Non-integral translation. |
+ WebTransformationMatrix nonIntegralTranslation; |
+ nonIntegralTranslation.translate(1.5, 2.5); |
+ root->setTransform(nonIntegralTranslation); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(false, root->canUseLCDText()); |
+ |
+ // Case 4: Rotation. |
+ WebTransformationMatrix rotation; |
+ rotation.rotate(10); |
+ root->setTransform(rotation); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(false, root->canUseLCDText()); |
+ |
+ // Case 5: Scale. |
+ WebTransformationMatrix scale; |
+ scale.scale(2); |
+ root->setTransform(scale); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(false, root->canUseLCDText()); |
+ |
+ // Case 6: Skew. |
+ WebTransformationMatrix skew; |
+ skew.skewX(10); |
+ root->setTransform(skew); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(false, root->canUseLCDText()); |
+ |
+ // Case 7: Translucent. |
+ root->setTransform(identityMatrix); |
+ 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.
|
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(false, root->canUseLCDText()); |
+ |
+ // Case 8: Restore transform and opacity. |
+ root->setTransform(identityMatrix); |
+ root->setOpacity(1); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+} |
+ |
+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.
|
+{ |
+ 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.
|
+ scoped_refptr<Layer> child = Layer::create(); |
+ root->addChild(child.get()); |
+ |
+ // Case 1: Identity transform. |
+ WebTransformationMatrix identityMatrix; |
+ setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
+ setLayerPropertiesForTesting(child.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), child->canUseLCDText()); |
+ |
+ // Case 2: Integral translation. |
+ WebTransformationMatrix integralTranslation; |
+ integralTranslation.translate(1, 2); |
+ root->setTransform(integralTranslation); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), child->canUseLCDText()); |
+ |
+ // Case 3: Render surface cannot use LCD text. |
+ root->setOpacity(0.5); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(false, root->canUseLCDText()); |
+ EXPECT_EQ(false, child->canUseLCDText()); |
+ |
+ // Case 4: Restore opacity. |
+ root->setOpacity(1); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), child->canUseLCDText()); |
+ |
+ // Case 5: Child layer cannot use LCD text. |
+ WebTransformationMatrix scale; |
+ scale.scale(2); |
+ child->setTransform(scale); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ EXPECT_EQ(LayerTreeHostCommon::canUseLCDText(), root->canUseLCDText()); |
+ EXPECT_EQ(false, child->canUseLCDText()); |
+} |
+ |
+TEST(LayerTreeHostCommonTest, verifyCanUseLCDTextWithAnimation) |
+{ |
+ 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.
|
+ |
+ WebTransformationMatrix identityMatrix; |
+ setLayerPropertiesForTesting(root.get(), identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false); |
+ root->setOpacity(0.9f); |
+ root->setCanUseLCDText(true); |
+ addOpacityTransitionToController(*(root->layerAnimationController()), 10, 0.9f, 0.1f, false); |
+ executeCalculateDrawTransformsAndVisibility(root.get()); |
+ // Text AA should not be adjusted while animation is active. |
+ // LCD text remains enabled even when it should not be. |
+ EXPECT_EQ(true, root->canUseLCDText()); |
+} |
+ |
} // anonymous namespace |