cc: Prevent small scale factors (below 1) from being used or saved as the layer's rasterScale.
When the scale is < 1, then we don't save anything. The first time we see a scale >= 1, we will save it. Tests: cc_unittests:LayerTreeHostCommonTest.verifySmallContentsScale BUG=159655 R=enne,jamesr Review URL: https://chromiumcodereview.appspot.com/11377088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167040 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -363,7 +363,11 @@ static inline void updateLayerContentsScale(Layer* layer, const WebTransformatio
|
||||
rasterScale = combinedScale / deviceScaleFactor;
|
||||
if (!layer->boundsContainPageScale())
|
||||
rasterScale /= pageScaleFactor;
|
||||
layer->setRasterScale(rasterScale);
|
||||
// Prevent scale factors below 1 from being used or saved.
|
||||
if (rasterScale < 1)
|
||||
rasterScale = 1;
|
||||
else
|
||||
layer->setRasterScale(rasterScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3686,6 +3686,61 @@ TEST(LayerTreeHostCommonTest, verifyContentsScale)
|
||||
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * fixedRasterScale, childNoAutoScale);
|
||||
}
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifySmallContentsScale)
|
||||
{
|
||||
MockContentLayerClient delegate;
|
||||
WebTransformationMatrix identityMatrix;
|
||||
|
||||
WebTransformationMatrix parentScaleMatrix;
|
||||
const double initialParentScale = 1.75;
|
||||
parentScaleMatrix.scale(initialParentScale);
|
||||
|
||||
WebTransformationMatrix childScaleMatrix;
|
||||
const double initialChildScale = 0.25;
|
||||
childScaleMatrix.scale(initialChildScale);
|
||||
|
||||
scoped_refptr<ContentLayer> parent = createDrawableContentLayer(&delegate);
|
||||
setLayerPropertiesForTesting(parent.get(), parentScaleMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(100, 100), true);
|
||||
|
||||
scoped_refptr<ContentLayer> childScale = createDrawableContentLayer(&delegate);
|
||||
setLayerPropertiesForTesting(childScale.get(), childScaleMatrix, identityMatrix, gfx::PointF(0, 0), gfx::PointF(2, 2), gfx::Size(10, 10), true);
|
||||
|
||||
// FIXME: Remove this when pageScaleFactor is applied in the compositor.
|
||||
// Page scale should not apply to the parent.
|
||||
parent->setBoundsContainPageScale(true);
|
||||
|
||||
parent->addChild(childScale);
|
||||
|
||||
std::vector<scoped_refptr<Layer> > renderSurfaceLayerList;
|
||||
int dummyMaxTextureSize = 512;
|
||||
|
||||
double deviceScaleFactor = 2.5;
|
||||
double pageScaleFactor = 0.01;
|
||||
|
||||
// FIXME: Remove this when pageScaleFactor is applied in the compositor.
|
||||
WebTransformationMatrix pageScaleMatrix;
|
||||
pageScaleMatrix.scale(pageScaleFactor);
|
||||
parent->setSublayerTransform(pageScaleMatrix);
|
||||
|
||||
LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
|
||||
|
||||
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
|
||||
// The child's scale is < 1, so we should not save and use that scale factor.
|
||||
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * 1, childScale);
|
||||
|
||||
// When chilld's total scale becomes >= 1, we should save and use that scale factor.
|
||||
childScaleMatrix.makeIdentity();
|
||||
const double finalChildScale = 0.75;
|
||||
childScaleMatrix.scale(finalChildScale);
|
||||
childScale->setTransform(childScaleMatrix);
|
||||
|
||||
renderSurfaceLayerList.clear();
|
||||
LayerTreeHostCommon::calculateDrawTransforms(parent.get(), parent->bounds(), deviceScaleFactor, pageScaleFactor, dummyMaxTextureSize, renderSurfaceLayerList);
|
||||
|
||||
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * initialParentScale, parent);
|
||||
EXPECT_CONTENTS_SCALE_EQ(deviceScaleFactor * pageScaleFactor * initialParentScale * finalChildScale, childScale);
|
||||
}
|
||||
|
||||
TEST(LayerTreeHostCommonTest, verifyContentsScaleForSurfaces)
|
||||
{
|
||||
MockContentLayerClient delegate;
|
||||
|
Reference in New Issue
Block a user