summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-11 22:26:57 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-11 22:26:57 +0000
commit0e61d29bb341dd98acd158ba5d785a2ab95af8ee (patch)
tree3d992c78fac9fac394655f1d9b9316a3778af79b
parente4fffd1094d779da7e005b9801ed5a276015c352 (diff)
downloadchromium_src-0e61d29bb341dd98acd158ba5d785a2ab95af8ee.zip
chromium_src-0e61d29bb341dd98acd158ba5d785a2ab95af8ee.tar.gz
chromium_src-0e61d29bb341dd98acd158ba5d785a2ab95af8ee.tar.bz2
cc: Don't add low res tilings for small layers
R=danakj@chromium.org BUG=247465 Review URL: https://chromiumcodereview.appspot.com/16671003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@205657 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/layers/picture_layer_impl.cc12
-rw-r--r--cc/layers/picture_layer_impl.h2
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc47
-rw-r--r--cc/resources/picture_layer_tiling.h2
-rw-r--r--cc/test/fake_picture_layer_impl.cc3
-rw-r--r--cc/test/fake_picture_layer_impl.h2
-rw-r--r--cc/test/fake_picture_layer_tiling_client.cc2
-rw-r--r--cc/test/fake_picture_layer_tiling_client.h2
8 files changed, 62 insertions, 10 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index f2eb6da..9488b4e 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -477,7 +477,7 @@ const PictureLayerTiling* PictureLayerImpl::GetTwinTiling(
}
gfx::Size PictureLayerImpl::CalculateTileSize(
- gfx::Size content_bounds) {
+ gfx::Size content_bounds) const {
if (is_mask_) {
int max_size = layer_tree_impl()->MaxTextureSize();
return gfx::Size(
@@ -880,6 +880,16 @@ void PictureLayerImpl::CalculateRasterContentsScale(
*raster_contents_scale, 1.f * ideal_page_scale_ * ideal_device_scale_);
}
+ // If this layer would only create one tile at this content scale,
+ // don't create a low res tiling.
+ gfx::Size content_bounds =
+ gfx::ToCeiledSize(gfx::ScaleSize(bounds(), *raster_contents_scale));
+ gfx::Size tile_size = CalculateTileSize(content_bounds);
+ if (tile_size == content_bounds) {
+ *low_res_raster_contents_scale = *raster_contents_scale;
+ return;
+ }
+
float low_res_factor =
layer_tree_impl()->settings().low_res_contents_scale_factor;
*low_res_raster_contents_scale = std::max(
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index b9697a7..ad96c6f 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -57,7 +57,7 @@ class CC_EXPORT PictureLayerImpl
gfx::Rect content_rect) OVERRIDE;
virtual void UpdatePile(Tile* tile) OVERRIDE;
virtual gfx::Size CalculateTileSize(
- gfx::Size content_bounds) OVERRIDE;
+ gfx::Size content_bounds) const OVERRIDE;
virtual const Region* GetInvalidation() OVERRIDE;
virtual const PictureLayerTiling* GetTwinTiling(
const PictureLayerTiling* tiling) OVERRIDE;
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 30bccaf..855fa56 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -48,9 +48,8 @@ class PictureLayerImplTest : public testing::Test {
virtual ~PictureLayerImplTest() {
}
- void SetupDefaultTrees() {
+ void SetupDefaultTrees(gfx::Size layer_bounds) {
gfx::Size tile_size(100, 100);
- gfx::Size layer_bounds(100, 100);
scoped_refptr<FakePicturePileImpl> pending_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
@@ -137,6 +136,11 @@ class PictureLayerImplTest : public testing::Test {
&result_bounds);
}
+ void ResetTilingsAndRasterScales() {
+ pending_layer_->DidLoseOutputSurface();
+ active_layer_->DidLoseOutputSurface();
+ }
+
protected:
void TestTileGridAlignmentCommon() {
// Layer to span 4 raster tiles in x and in y
@@ -645,7 +649,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) {
} while (false)
TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) {
- SetupDefaultTrees();
+ SetupDefaultTrees(gfx::Size(300, 100));
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
float contents_scale = 1.f;
@@ -686,6 +690,43 @@ TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) {
EXPECT_BOTH_EQ(num_tilings(), 4u);
}
+TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
+ gfx::Size tile_size(host_impl_.settings().default_tile_size);
+ 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;
+ SetContentsScaleOnBothLayers(
+ contents_scale, device_scale, page_scale, animating_transform);
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
+ EXPECT_BOTH_EQ(num_tilings(), 1u);
+
+ ResetTilingsAndRasterScales();
+
+ // Any content bounds that would create more than one tile will
+ // generate a low res tiling.
+ contents_scale = 1.2f;
+ SetContentsScaleOnBothLayers(
+ contents_scale, device_scale, page_scale, animating_transform);
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
+ EXPECT_BOTH_EQ(LowResTiling()->contents_scale(),
+ contents_scale * low_res_factor);
+ EXPECT_BOTH_EQ(num_tilings(), 2u);
+
+ ResetTilingsAndRasterScales();
+
+ // Mask layers dont create low res since they always fit on one tile.
+ pending_layer_->SetIsMask(true);
+ active_layer_->SetIsMask(true);
+ SetContentsScaleOnBothLayers(
+ contents_scale, device_scale, page_scale, animating_transform);
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale);
+ EXPECT_BOTH_EQ(num_tilings(), 1u);
+}
+
TEST_F(PictureLayerImplTest, DidLoseOutputSurface) {
gfx::Size tile_size(400, 400);
gfx::Size layer_bounds(1300, 1900);
diff --git a/cc/resources/picture_layer_tiling.h b/cc/resources/picture_layer_tiling.h
index 3f4a5daa..390b849 100644
--- a/cc/resources/picture_layer_tiling.h
+++ b/cc/resources/picture_layer_tiling.h
@@ -32,7 +32,7 @@ class CC_EXPORT PictureLayerTilingClient {
gfx::Rect content_rect) = 0;
virtual void UpdatePile(Tile* tile) = 0;
virtual gfx::Size CalculateTileSize(
- gfx::Size content_bounds) = 0;
+ gfx::Size content_bounds) const = 0;
virtual const Region* GetInvalidation() = 0;
virtual const PictureLayerTiling* GetTwinTiling(
const PictureLayerTiling* tiling) = 0;
diff --git a/cc/test/fake_picture_layer_impl.cc b/cc/test/fake_picture_layer_impl.cc
index 0bd16c6..d55d680 100644
--- a/cc/test/fake_picture_layer_impl.cc
+++ b/cc/test/fake_picture_layer_impl.cc
@@ -32,7 +32,8 @@ void FakePictureLayerImpl::AppendQuads(QuadSink* quad_sink,
++append_quads_count_;
}
-gfx::Size FakePictureLayerImpl::CalculateTileSize(gfx::Size content_bounds) {
+gfx::Size FakePictureLayerImpl::CalculateTileSize(
+ gfx::Size content_bounds) const {
if (fixed_tile_size_.IsEmpty()) {
return PictureLayerImpl::CalculateTileSize(content_bounds);
}
diff --git a/cc/test/fake_picture_layer_impl.h b/cc/test/fake_picture_layer_impl.h
index 6ac1126..a0c7829 100644
--- a/cc/test/fake_picture_layer_impl.h
+++ b/cc/test/fake_picture_layer_impl.h
@@ -26,7 +26,7 @@ class FakePictureLayerImpl : public PictureLayerImpl {
OVERRIDE;
virtual void AppendQuads(QuadSink* quad_sink,
AppendQuadsData* append_quads_data) OVERRIDE;
- virtual gfx::Size CalculateTileSize(gfx::Size content_bounds) OVERRIDE;
+ virtual gfx::Size CalculateTileSize(gfx::Size content_bounds) const OVERRIDE;
using PictureLayerImpl::AddTiling;
using PictureLayerImpl::CleanUpTilingsOnActiveLayer;
diff --git a/cc/test/fake_picture_layer_tiling_client.cc b/cc/test/fake_picture_layer_tiling_client.cc
index ebd530a7..39f1190 100644
--- a/cc/test/fake_picture_layer_tiling_client.cc
+++ b/cc/test/fake_picture_layer_tiling_client.cc
@@ -56,7 +56,7 @@ void FakePictureLayerTilingClient::SetTileSize(gfx::Size tile_size) {
}
gfx::Size FakePictureLayerTilingClient::CalculateTileSize(
- gfx::Size /* content_bounds */) {
+ gfx::Size /* content_bounds */) const {
return tile_size_;
}
diff --git a/cc/test/fake_picture_layer_tiling_client.h b/cc/test/fake_picture_layer_tiling_client.h
index 1050705..9b2aa52 100644
--- a/cc/test/fake_picture_layer_tiling_client.h
+++ b/cc/test/fake_picture_layer_tiling_client.h
@@ -25,7 +25,7 @@ class FakePictureLayerTilingClient : public PictureLayerTilingClient {
PictureLayerTiling* tiling, gfx::Rect rect) OVERRIDE;
virtual void UpdatePile(Tile* tile) OVERRIDE {}
virtual gfx::Size CalculateTileSize(
- gfx::Size content_bounds) OVERRIDE;
+ gfx::Size content_bounds) const OVERRIDE;
void SetTileSize(gfx::Size tile_size);
gfx::Size TileSize() const { return tile_size_; }