summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 03:06:21 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-10 03:06:21 +0000
commit11ec9297f5fbaecd1b66b49da3cdf4dda1b04b3e (patch)
treec8e4f0b5507452b133c22fbdba36ae546841ac69 /cc
parent40bdb1263adac08afda5e35d4dd801a5d8b92a49 (diff)
downloadchromium_src-11ec9297f5fbaecd1b66b49da3cdf4dda1b04b3e.zip
chromium_src-11ec9297f5fbaecd1b66b49da3cdf4dda1b04b3e.tar.gz
chromium_src-11ec9297f5fbaecd1b66b49da3cdf4dda1b04b3e.tar.bz2
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
Diffstat (limited to 'cc')
-rw-r--r--cc/layer_tree_host_common.cc6
-rw-r--r--cc/layer_tree_host_common_unittest.cc55
2 files changed, 60 insertions, 1 deletions
diff --git a/cc/layer_tree_host_common.cc b/cc/layer_tree_host_common.cc
index e64a339..a7dd4c8 100644
--- a/cc/layer_tree_host_common.cc
+++ b/cc/layer_tree_host_common.cc
@@ -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);
}
}
diff --git a/cc/layer_tree_host_common_unittest.cc b/cc/layer_tree_host_common_unittest.cc
index 29d25b3..a9cc3e3 100644
--- a/cc/layer_tree_host_common_unittest.cc
+++ b/cc/layer_tree_host_common_unittest.cc
@@ -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;