summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 01:27:26 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-01 01:27:26 +0000
commit8ebc8d3da2cbbd98c125295d2f33dfe1456e0d33 (patch)
tree2569c4dbff200c243f6185b68fbc77afff03bcf8 /cc
parentfb60421a953eb737dfa385a6ee2da1ad0196c724 (diff)
downloadchromium_src-8ebc8d3da2cbbd98c125295d2f33dfe1456e0d33.zip
chromium_src-8ebc8d3da2cbbd98c125295d2f33dfe1456e0d33.tar.gz
chromium_src-8ebc8d3da2cbbd98c125295d2f33dfe1456e0d33.tar.bz2
cc: Don't create low res for small layers, redux
The previous check was supposed to see that if a layer fit on one tile at some ideal res, don't create a corresponding low res. However, this check verified that the content bounds at that scale exactly equalled the tile size. The tile size gets rounded to 64, so hilariously this only worked for layers of very particular sizes, like the one in the test case. This adds an additional test that would have caught this. R=vmpstr@chromium.org BUG=none Review URL: https://chromiumcodereview.appspot.com/21355005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/picture_layer_impl.cc3
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc27
2 files changed, 24 insertions, 6 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 6b4bc58..1e2b5c2 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -893,7 +893,8 @@ void PictureLayerImpl::CalculateRasterContentsScale(
gfx::Size content_bounds =
gfx::ToCeiledSize(gfx::ScaleSize(bounds(), *raster_contents_scale));
gfx::Size tile_size = CalculateTileSize(content_bounds);
- if (tile_size == content_bounds) {
+ if (tile_size.width() >= content_bounds.width() &&
+ tile_size.height() >= content_bounds.height()) {
*low_res_raster_contents_scale = *raster_contents_scale;
return;
}
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 88d179f..d800123 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -648,7 +648,13 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) {
} while (false)
TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) {
- SetupDefaultTrees(gfx::Size(300, 100));
+ // Make sure this layer covers multiple tiles, since otherwise low
+ // res won't get created because it is too small.
+ gfx::Size tile_size(host_impl_.settings().default_tile_size);
+ SetupDefaultTrees(gfx::Size(tile_size.width() + 1, tile_size.height() + 1));
+ // Avoid max untiled layer size heuristics via fixed tile size.
+ pending_layer_->set_fixed_tile_size(tile_size);
+ active_layer_->set_fixed_tile_size(tile_size);
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
float contents_scale = 1.f;
@@ -694,10 +700,21 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
SetupDefaultTrees(tile_size);
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
- float contents_scale = 1.f;
float device_scale = 1.f;
float page_scale = 1.f;
bool animating_transform = false;
+
+ // Contents exactly fit on one tile at scale 1, no low res.
+ float contents_scale = 1.f;
+ SetContentsScaleOnBothLayers(
+ contents_scale, device_scale, page_scale, animating_transform);
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
+ EXPECT_BOTH_EQ(num_tilings(), 1u);
+
+ ResetTilingsAndRasterScales();
+
+ // Contents that are smaller than one tile, no low res.
+ contents_scale = 0.123f;
SetContentsScaleOnBothLayers(
contents_scale, device_scale, page_scale, animating_transform);
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
@@ -707,7 +724,7 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
// Any content bounds that would create more than one tile will
// generate a low res tiling.
- contents_scale = 1.2f;
+ contents_scale = 2.5f;
SetContentsScaleOnBothLayers(
contents_scale, device_scale, page_scale, animating_transform);
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
@@ -836,7 +853,7 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) {
pending_layer_->CalculateContentsScale(
1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_LE(1u, pending_layer_->tilings()->num_tilings());
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
@@ -859,7 +876,7 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) {
pending_layer_->CalculateContentsScale(
1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_LE(1u, pending_layer_->tilings()->num_tilings());
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();