Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2999)

Unified Diff: cc/layer_tree_host_common_unittest.cc

Issue 11360093: Mark layers that can use LCD text based on layer transform and opacity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed compile error Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 c37a9f422d2c1bac645e74f6deed32ab00502c28..02649fbffb5ada63614c38d39c6ac0f226e89c50 100644
--- a/cc/layer_tree_host_common_unittest.cc
+++ b/cc/layer_tree_host_common_unittest.cc
@@ -51,7 +51,7 @@ void setLayerPropertiesForTesting(LayerImpl* layer, const WebTransformationMatri
layer->setContentBounds(bounds);
}
-void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceScaleFactor = 1, float pageScaleFactor = 1)
+void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceScaleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false)
{
WebTransformationMatrix identityMatrix;
std::vector<scoped_refptr<Layer> > dummyRenderSurfaceLayerList;
@@ -60,10 +60,10 @@ void executeCalculateDrawTransformsAndVisibility(Layer* rootLayer, float deviceS
// We are probably not testing what is intended if the rootLayer bounds are empty.
DCHECK(!rootLayer->bounds().IsEmpty());
- LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, dummyRenderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, canUseLCDText, dummyRenderSurfaceLayerList);
}
-void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float deviceScaleFactor = 1, float pageScaleFactor = 1)
+void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float deviceScaleFactor = 1, float pageScaleFactor = 1, bool canUseLCDText = false)
{
// Note: this version skips layer sorting.
@@ -74,7 +74,7 @@ void executeCalculateDrawTransformsAndVisibility(LayerImpl* rootLayer, float dev
// We are probably not testing what is intended if the rootLayer bounds are empty.
DCHECK(!rootLayer->bounds().IsEmpty());
- LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, dummyRenderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(rootLayer, deviceViewportSize, deviceScaleFactor, pageScaleFactor, 0, dummyMaxTextureSize, canUseLCDText, dummyRenderSurfaceLayerList);
}
WebTransformationMatrix remove3DComponentOfMatrix(const WebTransformationMatrix& mat)
@@ -713,7 +713,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForRenderSurfaceWithClipped
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// The child layer's content is entirely outside the parent's clip rect, so the intermediate
// render surface should not be listed here, even if it was forced to be created. Render surfaces without children or visible
@@ -740,7 +740,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceListForTransparentChild)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Since the layer is transparent, renderSurface1->renderSurface() should not have gotten added anywhere.
// Also, the drawable content rect should not have been extended by the children.
@@ -772,7 +772,7 @@ TEST(LayerTreeHostCommonTest, verifyForceRenderSurface)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// The root layer always creates a renderSurface
EXPECT_TRUE(parent->renderSurface());
@@ -781,7 +781,7 @@ TEST(LayerTreeHostCommonTest, verifyForceRenderSurface)
renderSurfaceLayerList.clear();
renderSurface1->setForceRenderSurface(false);
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_TRUE(parent->renderSurface());
EXPECT_FALSE(renderSurface1->renderSurface());
EXPECT_EQ(1U, renderSurfaceLayerList.size());
@@ -1375,7 +1375,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
ASSERT_EQ(2U, renderSurfaceLayerList.size());
EXPECT_EQ(parent->id(), renderSurfaceLayerList[0]->id());
@@ -1420,7 +1420,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Without an animation, we should cull child and grandChild from the renderSurfaceLayerList.
ASSERT_EQ(1U, renderSurfaceLayerList.size());
@@ -1434,7 +1434,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectCullsSurfaceWithoutVisibleContent)
grandChild->clearRenderSurface();
renderSurfaceLayerList.clear();
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// With an animating transform, we should keep child and grandChild in the renderSurfaceLayerList.
ASSERT_EQ(3U, renderSurfaceLayerList.size());
@@ -1486,7 +1486,7 @@ TEST(LayerTreeHostCommonTest, verifyDrawableContentRectForLayers)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_RECT_EQ(gfx::Rect(gfx::Point(5, 5), gfx::Size(10, 10)), grandChild1->drawableContentRect());
EXPECT_RECT_EQ(gfx::Rect(gfx::Point(15, 15), gfx::Size(5, 5)), grandChild3->drawableContentRect());
@@ -1551,7 +1551,7 @@ TEST(LayerTreeHostCommonTest, verifyClipRectIsPropagatedCorrectlyToSurfaces)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
ASSERT_TRUE(grandChild1->renderSurface());
ASSERT_TRUE(grandChild2->renderSurface());
@@ -2393,7 +2393,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithoutPreserves3d)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Verify which renderSurfaces were created.
EXPECT_FALSE(frontFacingChild->renderSurface());
@@ -2492,7 +2492,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3d)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Verify which renderSurfaces were created.
EXPECT_FALSE(frontFacingChild->renderSurface());
@@ -2572,7 +2572,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithAnimatingTransforms)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_FALSE(child->renderSurface());
EXPECT_TRUE(animatingSurface->renderSurface());
@@ -2638,7 +2638,7 @@ TEST(LayerTreeHostCommonTest, verifyBackFaceCullingWithPreserves3dForFlatteningS
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Verify which renderSurfaces were created.
EXPECT_TRUE(frontFacingSurface->renderSurface());
@@ -2688,7 +2688,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2735,7 +2735,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForUninvertibleTransform)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2787,7 +2787,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePositionedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2832,7 +2832,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleRotatedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2886,7 +2886,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSinglePerspectiveLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -2949,7 +2949,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSingleLayerWithScaledContents)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
// The visibleContentRect for testLayer is actually 100x100, even though its layout size is 50x50, positioned at 25x25.
@@ -3011,7 +3011,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForSimpleClippedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3099,7 +3099,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultiClippedRotatedLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
// The grandChild is expected to create a renderSurface because it masksToBounds and is not axis aligned.
@@ -3179,7 +3179,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForNonClippingIntermediateLayer)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_EQ(1u, renderSurfaceLayerList.size());
@@ -3257,7 +3257,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayers)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -3363,7 +3363,7 @@ TEST(LayerTreeHostCommonTest, verifyHitTestingForMultipleLayerLists)
std::vector<LayerImpl*> renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(root.get(), root->bounds(), 1, 1, 0, dummyMaxTextureSize, false, renderSurfaceLayerList);
// Sanity check the scenario we just created.
ASSERT_TRUE(child1);
@@ -3464,7 +3464,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPI)
const double deviceScaleFactor = 2.5;
const double pageScaleFactor = 1;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child);
@@ -3539,7 +3539,7 @@ TEST(LayerTreeHostCommonTest, verifyLayerTransformsInHighDPIAccurateScaleZeroChi
const float deviceScaleFactor = 1.7f;
const float pageScaleFactor = 1;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, parent);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor, child);
@@ -3640,7 +3640,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
pageScaleMatrix.scale(pageScaleFactor);
parent->setSublayerTransform(pageScaleMatrix);
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childScale);
@@ -3663,7 +3663,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
childScale->setTransform(identityMatrix);
renderSurfaceLayerList.clear();
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childScale);
@@ -3679,7 +3679,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
parent->setSublayerTransform(pageScaleMatrix);
renderSurfaceLayerList.clear();
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, childScale);
@@ -3765,7 +3765,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces)
pageScaleMatrix.scale(pageScaleFactor);
parent->setSublayerTransform(pageScaleMatrix);
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * initialChildScale, surfaceScale);
@@ -3859,7 +3859,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer)
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
int dummyMaxTextureSize = 512;
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent);
// The layers with animating transforms should not compute a contentsScale other than 1 until they finish animating.
@@ -3868,7 +3868,7 @@ TEST(LayerTreeHostCommonTest, verifyContentsScaleForAnimatingLayer)
// Remove the animation, now it can save a raster scale.
childScale->layerAnimationController()->removeAnimation(animationId);
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), 1, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
EXPECT_CONTENTS_SCALE_EQ(initialParentScale, parent);
// The layers with animating transforms should not compute a contentsScale other than 1 until they finish animating.
@@ -3910,7 +3910,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPI)
duplicateChildNonOwner->setContentsScale(deviceScaleFactor);
replica->setContentsScale(deviceScaleFactor);
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// We should have two render surfaces. The root's render surface and child's
// render surface (it needs one because it has a replica layer).
@@ -3993,7 +3993,7 @@ TEST(LayerTreeHostCommonTest, verifyRenderSurfaceTransformsInHighDPIAccurateScal
duplicateChildNonOwner->setContentsScale(deviceScaleFactor);
replica->setContentsScale(deviceScaleFactor);
- LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, renderSurfaceLayerList);
+ LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, 1, dummyMaxTextureSize, false, renderSurfaceLayerList);
// We should have two render surfaces. The root's render surface and child's
// render surface (it needs one because it has a replica layer).
@@ -4045,4 +4045,141 @@ TEST(LayerTreeHostCommonTest, verifySubtreeSearch)
EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistentId));
}
+class LCDTextTest : public testing::TestWithParam<int> {
+public:
+ enum Param {
+ LAYER_REGULAR,
+ LAYER_PRESERVES_3D,
+ LAYER_FORCES_RENDER_SURFACE
+ };
+
+protected:
+ virtual void SetUp()
+ {
+ m_root = Layer::create();
+ m_child = Layer::create();
+ m_grandChild = Layer::create();
+ m_child->addChild(m_grandChild.get());
+ m_root->addChild(m_child.get());
+
+ WebTransformationMatrix identityMatrix;
+ setLayerPropertiesForTesting(m_root, identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false);
+ setLayerPropertiesForTesting(m_child, identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false);
+ setLayerPropertiesForTesting(m_grandChild, identityMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(1, 1), false);
+
+ switch (GetParam()) {
+ case LAYER_REGULAR:
+ break;
+ case LAYER_PRESERVES_3D:
+ m_child->setPreserves3D(true);
+ break;
+ case LAYER_FORCES_RENDER_SURFACE:
+ m_child->setForceRenderSurface(true);
+ break;
+ default:
+ ASSERT(false);
+ break;
+ }
+ }
+
+ scoped_refptr<Layer> m_root;
+ scoped_refptr<Layer> m_child;
+ scoped_refptr<Layer> m_grandChild;
+};
+
+TEST_P(LCDTextTest, verifyCanUseLCDText)
+{
+ bool canUseLCDText = true;
danakj 2012/11/10 01:12:35 Can you add a simple test or parameterize this to
alokp 2012/11/12 01:04:45 Done.
danakj 2012/11/12 01:25:47 Awesome, thanks.
+
+ // Case 1: Identity transform.
+ WebTransformationMatrix identityMatrix;
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(canUseLCDText, m_child->canUseLCDText());
+ EXPECT_EQ(canUseLCDText, m_grandChild->canUseLCDText());
+
+ // Case 2: Integral translation.
+ WebTransformationMatrix integralTranslation;
+ integralTranslation.translate(1, 2);
+ m_child->setTransform(integralTranslation);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(canUseLCDText, m_child->canUseLCDText());
+ EXPECT_EQ(canUseLCDText, m_grandChild->canUseLCDText());
+
+ // Case 3: Non-integral translation.
+ WebTransformationMatrix nonIntegralTranslation;
+ nonIntegralTranslation.translate(1.5, 2.5);
+ m_child->setTransform(nonIntegralTranslation);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(false, m_child->canUseLCDText());
+ EXPECT_EQ(false, m_grandChild->canUseLCDText());
+
+ // Case 4: Rotation.
+ WebTransformationMatrix rotation;
+ rotation.rotate(10);
+ m_child->setTransform(rotation);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(false, m_child->canUseLCDText());
+ EXPECT_EQ(false, m_grandChild->canUseLCDText());
+
+ // Case 5: Scale.
+ WebTransformationMatrix scale;
+ scale.scale(2);
+ m_child->setTransform(scale);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(false, m_child->canUseLCDText());
+ EXPECT_EQ(false, m_grandChild->canUseLCDText());
+
+ // Case 6: Skew.
+ WebTransformationMatrix skew;
+ skew.skewX(10);
+ m_child->setTransform(skew);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(false, m_child->canUseLCDText());
+ EXPECT_EQ(false, m_grandChild->canUseLCDText());
+
+ // Case 7: Translucent.
+ m_child->setTransform(identityMatrix);
+ m_child->setOpacity(0.5);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(false, m_child->canUseLCDText());
+ EXPECT_EQ(m_child->forceRenderSurface() || m_child->preserves3D() ? false : canUseLCDText, m_grandChild->canUseLCDText());
+
+ // Case 8: Sanity check: restore transform and opacity.
+ m_child->setTransform(identityMatrix);
+ m_child->setOpacity(1);
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, canUseLCDText);
+ EXPECT_EQ(canUseLCDText, m_root->canUseLCDText());
+ EXPECT_EQ(canUseLCDText, m_child->canUseLCDText());
+ EXPECT_EQ(canUseLCDText, m_grandChild->canUseLCDText());
+}
+
+TEST_P(LCDTextTest, verifyCanUseLCDTextWithAnimation)
+{
+ m_root->setCanUseLCDText(true);
+ m_child->setCanUseLCDText(true);
+ m_grandChild->setCanUseLCDText(true);
+
+ m_child->setOpacity(0.9f);
+ addOpacityTransitionToController(*(m_child->layerAnimationController()), 10, 0.9f, 0.1f, false);
+
+ executeCalculateDrawTransformsAndVisibility(m_root, 1, 1, true);
+ // Text AA should not be adjusted while animation is active.
+ // LCD text remains enabled even when it should not be.
+ EXPECT_EQ(true, m_root->canUseLCDText());
+ EXPECT_EQ(true, m_child->canUseLCDText());
+ EXPECT_EQ(true, m_grandChild->canUseLCDText());
+}
+
+INSTANTIATE_TEST_CASE_P(All, LCDTextTest,
+ testing::Values(LCDTextTest::LAYER_REGULAR,
+ LCDTextTest::LAYER_PRESERVES_3D,
+ LCDTextTest::LAYER_FORCES_RENDER_SURFACE));
+
} // anonymous namespace

Powered by Google App Engine
This is Rietveld 408576698