summaryrefslogtreecommitdiffstats
path: root/cc/layers
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 07:50:00 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-22 07:50:00 +0000
commit9d03b1a3dc2ada552c39c68a9c8faf07287f9a86 (patch)
tree642964c477c3be098df77fcc39202bc6876f0ba3 /cc/layers
parent852185659ee97b95d751e6523d994f168aa84c3b (diff)
downloadchromium_src-9d03b1a3dc2ada552c39c68a9c8faf07287f9a86.zip
chromium_src-9d03b1a3dc2ada552c39c68a9c8faf07287f9a86.tar.gz
chromium_src-9d03b1a3dc2ada552c39c68a9c8faf07287f9a86.tar.bz2
cc: Allow layers to have tilings even if twin doesn't
This fixes a bug where an active layer has a valid raster scale but can't have tilings. When a pending layer that could have tilings syncs to it, it picks up these raster scales and so doesn't think it needs to change tilings, even though it doesn't have any. Worse, this state would continue to persist for every future pending layer that can have tilings because they would also pick up these raster scales without tilings and think they were in an acceptable state. This patch addresses this problem by always making sure that raster scales are reset whenever a layer can't have tilings. This causes PictureLayerImpl::ManageTilings to not early out and to create new tilings as soon as it is possible. R=danakj@chromium.org BUG=313598 Review URL: https://codereview.chromium.org/78853006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layers')
-rw-r--r--cc/layers/picture_layer_impl.cc23
-rw-r--r--cc/layers/picture_layer_impl.h1
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc88
3 files changed, 103 insertions, 9 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 9aaad29..29f5110 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -383,7 +383,7 @@ void PictureLayerImpl::DidBeginTracing() {
void PictureLayerImpl::DidLoseOutputSurface() {
if (tilings_)
- tilings_->RemoveAllTilings();
+ RemoveAllTilings();
ResetRasterScale();
}
@@ -553,8 +553,7 @@ void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
UpdateLCDTextStatus(other->is_using_lcd_text_);
if (!DrawsContent()) {
- ResetRasterScale();
- tilings_->RemoveAllTilings();
+ RemoveAllTilings();
return;
}
@@ -597,7 +596,7 @@ void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) {
tiling_invalidation,
MinimumContentsScale());
} else {
- tilings_->RemoveAllTilings();
+ RemoveAllTilings();
}
SanityCheckTilingState();
@@ -778,9 +777,17 @@ void PictureLayerImpl::RemoveTiling(float contents_scale) {
break;
}
}
+ if (tilings_->num_tilings() == 0)
+ ResetRasterScale();
SanityCheckTilingState();
}
+void PictureLayerImpl::RemoveAllTilings() {
+ tilings_->RemoveAllTilings();
+ // If there are no tilings, then raster scales are no longer meaningful.
+ ResetRasterScale();
+}
+
namespace {
inline float PositiveRatio(float float1, float float2) {
@@ -807,6 +814,11 @@ void PictureLayerImpl::ManageTilings(bool animating_transform_to_screen) {
low_res_raster_contents_scale_ == 0.f ||
ShouldAdjustRasterScale(animating_transform_to_screen);
+ if (tilings_->num_tilings() == 0) {
+ DCHECK(change_target_tiling)
+ << "A layer with no tilings shouldn't have valid raster scales";
+ }
+
// Store the value for the next time ShouldAdjustRasterScale is called.
raster_source_scale_was_animating_ = animating_transform_to_screen;
@@ -931,6 +943,8 @@ void PictureLayerImpl::CalculateRasterContentsScale(
void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
std::vector<PictureLayerTiling*> used_tilings) {
DCHECK(layer_tree_impl()->IsActiveTree());
+ if (tilings_->num_tilings() == 0)
+ return;
float min_acceptable_high_res_scale = std::min(
raster_contents_scale_, ideal_contents_scale_);
@@ -974,6 +988,7 @@ void PictureLayerImpl::CleanUpTilingsOnActiveLayer(
twin->RemoveTiling(to_remove[i]->contents_scale());
tilings_->Remove(to_remove[i]);
}
+ DCHECK_GT(tilings_->num_tilings(), 0u);
SanityCheckTilingState();
}
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index de322ea..45f2c7d 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -77,6 +77,7 @@ class CC_EXPORT PictureLayerImpl
PictureLayerImpl(LayerTreeImpl* tree_impl, int id);
PictureLayerTiling* AddTiling(float contents_scale);
void RemoveTiling(float contents_scale);
+ void RemoveAllTilings();
void SyncFromActiveLayer(const PictureLayerImpl* other);
void ManageTilings(bool animating_transform_to_screen);
virtual bool ShouldAdjustRasterScale(
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 716d50d..d54a907 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -68,15 +68,19 @@ class PictureLayerImplTest : public testing::Test {
SetupTrees(pending_pile, active_pile);
}
- void SetupTrees(
- scoped_refptr<PicturePileImpl> pending_pile,
- scoped_refptr<PicturePileImpl> active_pile) {
- SetupPendingTree(active_pile);
+ void ActivateTree() {
host_impl_.ActivatePendingTree();
-
+ CHECK(!host_impl_.pending_tree());
+ pending_layer_ = NULL;
active_layer_ = static_cast<FakePictureLayerImpl*>(
host_impl_.active_tree()->LayerById(id_));
+ }
+ void SetupTrees(
+ scoped_refptr<PicturePileImpl> pending_pile,
+ scoped_refptr<PicturePileImpl> active_pile) {
+ SetupPendingTree(active_pile);
+ ActivateTree();
SetupPendingTree(pending_pile);
}
@@ -591,6 +595,80 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) {
pending_layer_->tilings()->tiling_at(3)->contents_scale());
}
+TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
+ // This test makes sure that if a layer can have tilings, then a commit makes
+ // it not able to have tilings (empty size), and then a future commit that
+ // makes it valid again should be able to create tilings.
+ gfx::Size tile_size(400, 400);
+ gfx::Size layer_bounds(1300, 1900);
+
+ scoped_refptr<FakePicturePileImpl> empty_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, gfx::Size(1000, 0));
+ scoped_refptr<FakePicturePileImpl> valid_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
+ EXPECT_LT(low_res_factor, 1.f);
+
+ float high_res_scale = 1.3f;
+ float low_res_scale = high_res_scale * low_res_factor;
+ float device_scale = 1.7f;
+ float page_scale = 3.2f;
+ float result_scale_x, result_scale_y;
+ gfx::Size result_bounds;
+
+ SetupPendingTree(valid_pile);
+ pending_layer_->CalculateContentsScale(high_res_scale,
+ device_scale,
+ page_scale,
+ false,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
+ ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ EXPECT_FLOAT_EQ(high_res_scale,
+ pending_layer_->HighResTiling()->contents_scale());
+ EXPECT_FLOAT_EQ(low_res_scale,
+ pending_layer_->LowResTiling()->contents_scale());
+
+ ActivateTree();
+ SetupPendingTree(empty_pile);
+ pending_layer_->CalculateContentsScale(high_res_scale,
+ device_scale,
+ page_scale,
+ false,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
+ ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
+ ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings());
+
+ ActivateTree();
+ active_layer_->CalculateContentsScale(high_res_scale,
+ device_scale,
+ page_scale,
+ false,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
+ ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
+
+ SetupPendingTree(valid_pile);
+ pending_layer_->CalculateContentsScale(high_res_scale,
+ device_scale,
+ page_scale,
+ false,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
+ ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
+ EXPECT_FLOAT_EQ(high_res_scale,
+ pending_layer_->HighResTiling()->contents_scale());
+ EXPECT_FLOAT_EQ(low_res_scale,
+ pending_layer_->LowResTiling()->contents_scale());
+}
+
TEST_F(PictureLayerImplTest, CleanUpTilings) {
gfx::Size tile_size(400, 400);
gfx::Size layer_bounds(1300, 1900);