summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorvmpstr <vmpstr@chromium.org>2015-08-12 12:23:39 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-12 19:24:13 +0000
commit01df53b467f65bd3cdd2761d15d731269cec550a (patch)
tree4ee8ee0c25c94c69fb1777c9b8836cf75febd7e6 /cc
parent88d7709e7b708e6bb58cc920bd9e13c5102b2d22 (diff)
downloadchromium_src-01df53b467f65bd3cdd2761d15d731269cec550a.zip
chromium_src-01df53b467f65bd3cdd2761d15d731269cec550a.tar.gz
chromium_src-01df53b467f65bd3cdd2761d15d731269cec550a.tar.bz2
cc: Don't create low resolution tilings on the pending tree.
Since activation requires us to have high resolution tiles (unless we're out of memory), the low resolution tilings on the pending tree are very likely to be wasted. The only time they are not is if we activate and scroll into an area that was invalidated and neither new high res or new low res was rasterized yet, but the prepaint on the pending tree did rasterize it. This case seems very unlikely and rare. R=danakj, enne, weiliangc BUG=517227 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1275243003 Cr-Commit-Position: refs/heads/master@{#343068}
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/picture_layer_impl.cc52
-rw-r--r--cc/layers/picture_layer_impl.h1
-rw-r--r--cc/layers/picture_layer_impl_unittest.cc161
-rw-r--r--cc/tiles/tile_manager_unittest.cc66
4 files changed, 103 insertions, 177 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc
index 53a6a0a..4966180 100644
--- a/cc/layers/picture_layer_impl.cc
+++ b/cc/layers/picture_layer_impl.cc
@@ -405,6 +405,9 @@ bool PictureLayerImpl::UpdateTiles(bool resourceless_software_draw) {
AddTilingsForRasterScale();
}
+ if (layer_tree_impl()->IsActiveTree())
+ AddLowResolutionTilingIfNeeded();
+
DCHECK(raster_page_scale_);
DCHECK(raster_device_scale_);
DCHECK(raster_source_scale_);
@@ -823,27 +826,6 @@ void PictureLayerImpl::AddTilingsForRasterScale() {
}
high_res->set_resolution(HIGH_RESOLUTION);
- // If the low res scale is the same as the high res scale, that tiling
- // will be treated as high res.
- if (layer_tree_impl()->create_low_res_tiling() &&
- raster_contents_scale_ != low_res_raster_contents_scale_) {
- PictureLayerTiling* low_res =
- tilings_->FindTilingWithScale(low_res_raster_contents_scale_);
-
- // Only create new low res tilings when the transform is static. This
- // prevents wastefully creating a paired low res tiling for every new high
- // res tiling during a pinch or a CSS animation.
- bool is_pinching = layer_tree_impl()->PinchGestureActive();
- bool is_animating = draw_properties().screen_space_transform_is_animating;
- if (!low_res && !is_pinching && !is_animating)
- low_res = AddTiling(low_res_raster_contents_scale_);
-
- if (low_res) {
- DCHECK_NE(low_res, high_res);
- low_res->set_resolution(LOW_RESOLUTION);
- }
- }
-
if (layer_tree_impl()->IsPendingTree()) {
// On the pending tree, drop any tilings that are non-ideal since we don't
// need them to activate anyway.
@@ -899,6 +881,34 @@ bool PictureLayerImpl::ShouldAdjustRasterScale() const {
return false;
}
+void PictureLayerImpl::AddLowResolutionTilingIfNeeded() {
+ DCHECK(layer_tree_impl()->IsActiveTree());
+
+ if (!layer_tree_impl()->create_low_res_tiling())
+ return;
+
+ // We should have a high resolution tiling at raster_contents_scale, so if the
+ // low res one is the same then we shouldn't try to override this tiling by
+ // marking it as a low res.
+ if (raster_contents_scale_ == low_res_raster_contents_scale_)
+ return;
+
+ PictureLayerTiling* low_res =
+ tilings_->FindTilingWithScale(low_res_raster_contents_scale_);
+ DCHECK_IMPLIES(low_res, low_res->resolution() != HIGH_RESOLUTION);
+
+ // Only create new low res tilings when the transform is static. This
+ // prevents wastefully creating a paired low res tiling for every new high
+ // res tiling during a pinch or a CSS animation.
+ bool is_pinching = layer_tree_impl()->PinchGestureActive();
+ bool is_animating = draw_properties().screen_space_transform_is_animating;
+ if (!low_res && !is_pinching && !is_animating)
+ low_res = AddTiling(low_res_raster_contents_scale_);
+
+ if (low_res)
+ low_res->set_resolution(LOW_RESOLUTION);
+}
+
void PictureLayerImpl::RecalculateRasterScales() {
float old_raster_contents_scale = raster_contents_scale_;
float old_raster_page_scale = raster_page_scale_;
diff --git a/cc/layers/picture_layer_impl.h b/cc/layers/picture_layer_impl.h
index a23dbba..b56ca3f 100644
--- a/cc/layers/picture_layer_impl.h
+++ b/cc/layers/picture_layer_impl.h
@@ -108,6 +108,7 @@ class CC_EXPORT PictureLayerImpl
PictureLayerTiling* AddTiling(float contents_scale);
void RemoveAllTilings();
void AddTilingsForRasterScale();
+ void AddLowResolutionTilingIfNeeded();
virtual bool ShouldAdjustRasterScale() const;
virtual void RecalculateRasterScales();
void CleanUpTilingsOnActiveLayer(
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 73a495c..8ed5e6d 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -691,7 +691,7 @@ TEST_F(PictureLayerImplTest, ClonePartialInvalidation) {
SetupTreesWithFixedTileSize(pending_pile, active_pile, gfx::Size(50, 50),
layer_invalidation);
- EXPECT_EQ(2u, pending_layer_->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->num_tilings());
EXPECT_EQ(3u, active_layer_->num_tilings());
const PictureLayerTilingSet* tilings = pending_layer_->tilings();
@@ -842,7 +842,7 @@ TEST_F(PictureLayerImplTest, UpdateTilesCreatesTilings) {
active_layer_->tilings()->tiling_at(3)->contents_scale());
}
-TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) {
+TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighResTiling) {
gfx::Size tile_size(400, 400);
gfx::Size layer_bounds(1300, 1900);
@@ -868,11 +868,9 @@ TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) {
1.f, // maximum animation scale
0.f, // starting animation scale
false);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
EXPECT_FLOAT_EQ(6.f,
pending_layer_->tilings()->tiling_at(0)->contents_scale());
- EXPECT_FLOAT_EQ(6.f * low_res_factor,
- pending_layer_->tilings()->tiling_at(1)->contents_scale());
// If we change the page scale factor, then we should get new tilings.
SetupDrawPropertiesAndUpdateTiles(pending_layer_,
@@ -882,11 +880,9 @@ TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) {
1.f, // maximum animation scale
0.f, // starting animation scale
false);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
EXPECT_FLOAT_EQ(6.6f,
pending_layer_->tilings()->tiling_at(0)->contents_scale());
- EXPECT_FLOAT_EQ(6.6f * low_res_factor,
- pending_layer_->tilings()->tiling_at(1)->contents_scale());
// If we change the device scale factor, then we should get new tilings.
SetupDrawPropertiesAndUpdateTiles(pending_layer_,
@@ -896,11 +892,9 @@ TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) {
1.f, // maximum animation scale
0.f, // starting animation scale
false);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
EXPECT_FLOAT_EQ(7.26f,
pending_layer_->tilings()->tiling_at(0)->contents_scale());
- EXPECT_FLOAT_EQ(7.26f * low_res_factor,
- pending_layer_->tilings()->tiling_at(1)->contents_scale());
// If we change the device scale factor, but end up at the same total scale
// factor somehow, then we don't get new tilings.
@@ -911,11 +905,9 @@ TEST_F(PictureLayerImplTest, PendingLayerOnlyHasHighAndLowResTiling) {
1.f, // maximum animation scale
0.f, // starting animation scale
false);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
EXPECT_FLOAT_EQ(7.26f,
pending_layer_->tilings()->tiling_at(0)->contents_scale());
- EXPECT_FLOAT_EQ(7.26f * low_res_factor,
- pending_layer_->tilings()->tiling_at(1)->contents_scale());
}
TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
@@ -931,7 +923,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
SetupPendingTree(valid_pile);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
ActivateTree();
SetupPendingTree(empty_pile);
@@ -944,7 +936,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) {
ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
SetupPendingTree(valid_pile);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
}
@@ -985,10 +977,11 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) {
ResetTilingsAndRasterScales();
SetContentsScaleOnBothLayers(2.f, 1.0f, 2.f, 1.0f, 0.f, false);
- EXPECT_BOTH_EQ(num_tilings(), 2u);
- EXPECT_BOTH_EQ(tilings()->tiling_at(0)->contents_scale(), 2.f);
- EXPECT_BOTH_EQ(tilings()->tiling_at(1)->contents_scale(),
- 2.f * low_res_factor);
+ EXPECT_EQ(active_layer_->num_tilings(), 2u);
+ EXPECT_EQ(pending_layer_->num_tilings(), 1u);
+ EXPECT_EQ(active_layer_->tilings()->tiling_at(0)->contents_scale(), 2.f);
+ EXPECT_EQ(active_layer_->tilings()->tiling_at(1)->contents_scale(),
+ 2.f * low_res_factor);
// Ensure UpdateTiles won't remove any tilings.
active_layer_->MarkAllTilingsUsed();
@@ -1231,8 +1224,9 @@ TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) {
maximum_animation_scale,
starting_animation_scale, animating_transform);
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f);
- EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor);
- EXPECT_BOTH_EQ(num_tilings(), 2u);
+ EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(), low_res_factor);
+ EXPECT_EQ(active_layer_->num_tilings(), 2u);
+ EXPECT_EQ(pending_layer_->num_tilings(), 1u);
// Ensure UpdateTiles won't remove any tilings.
active_layer_->MarkAllTilingsUsed();
@@ -1259,9 +1253,10 @@ TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) {
maximum_animation_scale,
starting_animation_scale, animating_transform);
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f);
- EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor);
+ EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(),
+ 2.f * low_res_factor);
EXPECT_EQ(4u, active_layer_->num_tilings());
- EXPECT_EQ(2u, pending_layer_->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->num_tilings());
}
TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
@@ -1309,9 +1304,11 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) {
maximum_animation_scale,
starting_animation_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);
+ EXPECT_EQ(active_layer_->LowResTiling()->contents_scale(),
+ contents_scale * low_res_factor);
+ EXPECT_FALSE(pending_layer_->LowResTiling());
+ EXPECT_EQ(active_layer_->num_tilings(), 2u);
+ EXPECT_EQ(pending_layer_->num_tilings(), 1u);
// Mask layers dont create low res since they always fit on one tile.
scoped_ptr<FakePictureLayerImpl> mask =
@@ -1517,7 +1514,7 @@ TEST_F(PictureLayerImplTest, ReleaseResources) {
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
SetupTrees(pending_pile, active_pile);
- EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
// All tilings should be removed when losing output surface.
active_layer_->ReleaseResources();
@@ -1537,7 +1534,7 @@ TEST_F(PictureLayerImplTest, ReleaseResources) {
1.f, // maximum animation scale
0.f, // starting animation_scale
false);
- EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
}
TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
@@ -1573,7 +1570,7 @@ TEST_F(PictureLayerImplTest, ClampTilesToMaxTileSize) {
SetupDrawPropertiesAndUpdateTiles(pending_layer_, 1.f, 1.f, 1.f, 1.f, 0.f,
false);
- ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings());
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
@@ -2040,10 +2037,9 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveAllReady) {
// All active tiles ready, so pending can only activate with all high res
// tiles.
pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
- pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
+ EXPECT_FALSE(pending_layer_->LowResTiling());
AssertAllTilesRequired(pending_layer_->HighResTiling());
- AssertNoTilesRequired(pending_layer_->LowResTiling());
}
TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) {
@@ -2063,12 +2059,11 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenMissingHighResFlagOn) {
host_impl_.SetRequiresHighResToDraw();
pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
- pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
+ EXPECT_FALSE(pending_layer_->LowResTiling());
active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
- EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
AssertAllTilesRequired(active_layer_->HighResTiling());
AssertNoTilesRequired(active_layer_->LowResTiling());
}
@@ -2085,7 +2080,7 @@ TEST_F(PictureLayerImplTest, AllHighResRequiredEvenIfNotChanged) {
// Since there are no invalidations, pending tree should have no tiles.
EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
- EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
+ EXPECT_FALSE(pending_layer_->LowResTiling());
active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
@@ -2105,11 +2100,10 @@ TEST_F(PictureLayerImplTest, DisallowRequiredForActivation) {
EXPECT_FALSE(some_active_tile->draw_info().IsReadyToDraw());
EXPECT_TRUE(pending_layer_->HighResTiling()->AllTilesForTesting().empty());
- EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
+ EXPECT_FALSE(pending_layer_->LowResTiling());
active_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
active_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
pending_layer_->HighResTiling()->set_can_require_tiles_for_activation(false);
- pending_layer_->LowResTiling()->set_can_require_tiles_for_activation(false);
// If we disallow required for activation, no tiles can be required.
active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
@@ -2144,10 +2138,9 @@ TEST_F(PictureLayerImplTest, NothingRequiredIfActiveMissingTiles) {
// Since the active layer has no tiles at all, the pending layer doesn't
// need content in order to activate.
pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
- pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
+ EXPECT_FALSE(pending_layer_->LowResTiling());
AssertNoTilesRequired(pending_layer_->HighResTiling());
- AssertNoTilesRequired(pending_layer_->LowResTiling());
}
TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
@@ -2168,10 +2161,9 @@ TEST_F(PictureLayerImplTest, HighResRequiredIfActiveCantHaveTiles) {
// This can happen if a layer exists for a while and switches from
// not being able to have content to having content.
pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
- pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
+ EXPECT_FALSE(pending_layer_->LowResTiling());
AssertAllTilesRequired(pending_layer_->HighResTiling());
- AssertNoTilesRequired(pending_layer_->LowResTiling());
}
TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) {
@@ -2189,17 +2181,13 @@ TEST_F(PictureLayerImplTest, HighResRequiredWhenActiveHasDifferentBounds) {
// Since the active layer has different bounds, the pending layer needs all
// high res tiles in order to activate.
pending_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
- pending_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
+ EXPECT_FALSE(pending_layer_->LowResTiling());
active_layer_->HighResTiling()->UpdateAllRequiredStateForTesting();
active_layer_->LowResTiling()->UpdateAllRequiredStateForTesting();
AssertAllTilesRequired(pending_layer_->HighResTiling());
AssertAllTilesRequired(active_layer_->HighResTiling());
AssertNoTilesRequired(active_layer_->LowResTiling());
- // Since the test doesn't invalidate the resized region, we expect that the
- // same low res tile would exist (which means we don't create a new one of the
- // pending tree).
- EXPECT_TRUE(pending_layer_->LowResTiling()->AllTilesForTesting().empty());
}
TEST_F(PictureLayerImplTest, ActivateUninitializedLayer) {
@@ -2477,8 +2465,11 @@ TEST_F(PictureLayerImplTest, LowResTilingWithoutGpuRasterization) {
SetupDefaultTrees(layer_bounds);
EXPECT_FALSE(host_impl_.use_gpu_rasterization());
- // Should have a low-res and a high-res tiling.
- EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ // Should have only a high-res tiling.
+ EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
+ ActivateTree();
+ // Should add a high and a low res for active tree.
+ EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
}
TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) {
@@ -2493,6 +2484,9 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) {
EXPECT_TRUE(host_impl_.use_gpu_rasterization());
// Should only have the high-res tiling.
EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
+ ActivateTree();
+ // Should only have the high-res tiling.
+ EXPECT_EQ(1u, active_layer_->tilings()->num_tilings());
}
TEST_F(PictureLayerImplTest, RequiredTilesWithGpuRasterization) {
@@ -2868,7 +2862,7 @@ TEST_F(PictureLayerImplTest, TilingSetRasterQueue) {
FakePicturePileImpl::CreateFilledPile(recording_tile_size, layer_bounds);
SetupPendingTree(pending_pile);
- EXPECT_EQ(2u, pending_layer_->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->num_tilings());
std::set<Tile*> unique_tiles;
bool reached_prepaint = false;
@@ -2985,26 +2979,9 @@ TEST_F(PictureLayerImplTest, TilingSetRasterQueue) {
draw_info.SetSolidColorForTesting(SK_ColorRED);
}
- non_ideal_tile_count = 0;
- low_res_tile_count = 0;
- high_res_tile_count = 0;
queue.reset(new TilingSetRasterQueueAll(
pending_layer_->picture_layer_tiling_set(), true));
- while (!queue->IsEmpty()) {
- PrioritizedTile prioritized_tile = queue->Top();
- TilePriority priority = prioritized_tile.priority();
-
- EXPECT_TRUE(prioritized_tile.tile());
-
- non_ideal_tile_count += priority.resolution == NON_IDEAL_RESOLUTION;
- low_res_tile_count += priority.resolution == LOW_RESOLUTION;
- high_res_tile_count += priority.resolution == HIGH_RESOLUTION;
- queue->Pop();
- }
-
- EXPECT_EQ(0, non_ideal_tile_count);
- EXPECT_EQ(1, low_res_tile_count);
- EXPECT_EQ(0, high_res_tile_count);
+ EXPECT_TRUE(queue->IsEmpty());
}
TEST_F(PictureLayerImplTest, TilingSetRasterQueueActiveTree) {
@@ -3071,10 +3048,10 @@ TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) {
scoped_refptr<FakePicturePileImpl> pending_pile =
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
- // TODO(vmpstr): Add a test with tilings other than high/low res on the active
- // tree.
+ // TODO(vmpstr): Add a test with tilings other than high res on the active
+ // tree (crbug.com/519607).
SetupPendingTree(pending_pile);
- EXPECT_EQ(2u, pending_layer_->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->num_tilings());
std::vector<Tile*> all_tiles;
for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
@@ -3104,8 +3081,8 @@ TEST_F(PictureLayerImplTest, TilingSetEvictionQueue) {
}
// Sanity checks.
- EXPECT_EQ(17u, all_tiles.size());
- EXPECT_EQ(17u, all_tiles_set.size());
+ EXPECT_EQ(16u, all_tiles.size());
+ EXPECT_EQ(16u, all_tiles_set.size());
EXPECT_GT(number_of_marked_tiles, 1u);
EXPECT_GT(number_of_unmarked_tiles, 1u);
@@ -3304,7 +3281,7 @@ TEST_F(PictureLayerImplTest, LowResReadyToDrawNotEnoughToActivate) {
EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
// Initialize all low-res tiles.
- pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
+ EXPECT_FALSE(pending_layer_->LowResTiling());
pending_layer_->SetAllTilesReadyInTiling(active_layer_->LowResTiling());
// Low-res tiles should not be enough.
@@ -3336,28 +3313,6 @@ TEST_F(PictureLayerImplTest, HighResReadyToDrawEnoughToActivate) {
EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
}
-TEST_F(PictureLayerImplTest,
- ActiveHighResReadyAndPendingLowResReadyNotEnoughToActivate) {
- gfx::Size tile_size(100, 100);
- gfx::Size layer_bounds(1000, 1000);
-
- // Make sure pending tree has tiles.
- gfx::Rect invalidation(gfx::Point(50, 50), tile_size);
- SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, invalidation);
-
- // Initialize all high-res tiles in the active layer.
- active_layer_->SetAllTilesReadyInTiling(active_layer_->HighResTiling());
- // And all the low-res tiles in the pending layer.
- pending_layer_->SetAllTilesReadyInTiling(pending_layer_->LowResTiling());
-
- // The pending high-res tiles are not ready, so we cannot activate.
- EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
-
- // When the pending high-res tiles are ready, we can activate.
- pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
- EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
-}
-
TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) {
gfx::Size tile_size(100, 100);
gfx::Size layer_bounds(1000, 1000);
@@ -3372,7 +3327,7 @@ TEST_F(PictureLayerImplTest, ActiveHighResReadyNotEnoughToActivate) {
// The pending high-res tiles are not ready, so we cannot activate.
EXPECT_FALSE(host_impl_.tile_manager()->IsReadyToActivate());
- // When the pending pending high-res tiles are ready, we can activate.
+ // When the pending high-res tiles are ready, we can activate.
pending_layer_->SetAllTilesReadyInTiling(pending_layer_->HighResTiling());
EXPECT_TRUE(host_impl_.tile_manager()->IsReadyToActivate());
}
@@ -4295,10 +4250,16 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) {
if (!*iter)
continue;
const Tile* tile = *iter;
+ EXPECT_TRUE(tile);
// All tiles are unoccluded, because the pending tree has no occlusion.
EXPECT_FALSE(prioritized_tiles[tile].is_occluded());
+ if (tiling->resolution() == LOW_RESOLUTION) {
+ EXPECT_FALSE(active_layer_->GetPendingOrActiveTwinTiling(tiling));
+ continue;
+ }
+
Tile* twin_tile = active_layer_->GetPendingOrActiveTwinTiling(tiling)
->TileAt(iter.i(), iter.j());
gfx::Rect scaled_content_rect = ScaleToEnclosingRect(
@@ -4306,12 +4267,10 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, DifferentOcclusionOnTrees) {
if (scaled_content_rect.Intersects(invalidation_rect)) {
// Tiles inside the invalidation rect exist on both trees.
- EXPECT_TRUE(tile);
EXPECT_TRUE(twin_tile);
EXPECT_NE(tile, twin_tile);
} else {
// Tiles outside the invalidation rect only exist on the active tree.
- EXPECT_TRUE(tile);
EXPECT_FALSE(twin_tile);
}
}
@@ -4361,7 +4320,7 @@ TEST_F(OcclusionTrackingPictureLayerImplTest,
pending_occluding_layer->SetContentsOpaque(true);
pending_occluding_layer->SetPosition(pending_occluding_layer_position);
- EXPECT_EQ(2u, pending_layer_->num_tilings());
+ EXPECT_EQ(1u, pending_layer_->num_tilings());
EXPECT_EQ(2u, active_layer_->num_tilings());
host_impl_.AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1));
@@ -4372,8 +4331,8 @@ TEST_F(OcclusionTrackingPictureLayerImplTest,
// The expected number of occluded tiles on each of the 2 tilings for each of
// the 3 tree priorities.
size_t expected_occluded_tile_count_on_pending[] = {4u, 0u};
- size_t expected_occluded_tile_count_on_active[] = {12u, 1u};
- size_t total_expected_occluded_tile_count_on_trees[] = {13u, 4u};
+ size_t expected_occluded_tile_count_on_active[] = {12u, 3u};
+ size_t total_expected_occluded_tile_count_on_trees[] = {15u, 4u};
// Verify number of occluded tiles on the pending layer for each tiling.
for (size_t i = 0; i < pending_layer_->num_tilings(); ++i) {
diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc
index 8a71309..8312c08 100644
--- a/cc/tiles/tile_manager_unittest.cc
+++ b/cc/tiles/tile_manager_unittest.cc
@@ -88,12 +88,15 @@ class TileManagerTilePriorityQueueTest : public testing::Test {
SetupTrees(pending_pile, active_pile);
}
+ // This matches picture_layer_impl_unittest's ActivateTree.
void ActivateTree() {
host_impl_.ActivateSyncTree();
CHECK(!host_impl_.pending_tree());
pending_layer_ = NULL;
active_layer_ = static_cast<FakePictureLayerImpl*>(
host_impl_.active_tree()->LayerById(id_));
+ bool update_lcd_text = false;
+ host_impl_.active_tree()->UpdateDrawProperties(update_lcd_text);
}
void SetupDefaultTreesWithFixedTileSize(const gfx::Size& layer_bounds,
@@ -228,14 +231,11 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) {
// Invalidate the pending tree.
pending_layer_->set_invalidation(invalidation);
pending_layer_->HighResTiling()->Invalidate(invalidation);
- pending_layer_->LowResTiling()->Invalidate(invalidation);
// Renew all of the tile priorities.
gfx::Rect viewport(50, 50, 100, 100);
pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
- pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
- Occlusion());
active_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
active_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
@@ -251,11 +251,6 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueue) {
high_res_tiles.insert(pending_high_res_tiles[i]);
}
- std::vector<Tile*> pending_low_res_tiles =
- pending_layer_->LowResTiling()->AllTilesForTesting();
- for (size_t i = 0; i < pending_low_res_tiles.size(); ++i)
- all_tiles.insert(pending_low_res_tiles[i]);
-
std::vector<Tile*> active_high_res_tiles =
active_layer_->HighResTiling()->AllTilesForTesting();
for (size_t i = 0; i < active_high_res_tiles.size(); ++i) {
@@ -504,8 +499,6 @@ TEST_F(TileManagerTilePriorityQueueTest, RasterTilePriorityQueueInvalidation) {
pending_layer_->set_invalidation(invalidation);
pending_layer_->HighResTiling()->Invalidate(invalidation);
pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect();
- pending_layer_->LowResTiling()->Invalidate(invalidation);
- pending_layer_->LowResTiling()->CreateMissingTilesInLiveTilesRect();
// Sanity checks: Tile at 0, 0 not exist on the pending tree (it's not
// invalidated). Tile 1, 0 should exist on both.
@@ -649,6 +642,10 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
const gfx::Size layer_bounds(1000, 1000);
host_impl_.SetViewportSize(layer_bounds);
SetupDefaultTrees(layer_bounds);
+ ASSERT_TRUE(active_layer_->HighResTiling());
+ ASSERT_TRUE(active_layer_->LowResTiling());
+ ASSERT_TRUE(pending_layer_->HighResTiling());
+ EXPECT_FALSE(pending_layer_->LowResTiling());
scoped_ptr<EvictionTilePriorityQueue> empty_queue(
host_impl_.BuildEvictionQueue(SAME_PRIORITY_FOR_BOTH_TREES));
@@ -696,15 +693,12 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
pending_layer_->set_invalidation(invalidation);
pending_layer_->HighResTiling()->Invalidate(invalidation);
pending_layer_->HighResTiling()->CreateMissingTilesInLiveTilesRect();
- pending_layer_->LowResTiling()->Invalidate(invalidation);
- pending_layer_->LowResTiling()->CreateMissingTilesInLiveTilesRect();
+ EXPECT_FALSE(pending_layer_->LowResTiling());
// Renew all of the tile priorities.
gfx::Rect viewport(50, 50, 100, 100);
pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
- pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
- Occlusion());
active_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
active_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
@@ -717,11 +711,6 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
for (size_t i = 0; i < pending_high_res_tiles.size(); ++i)
all_tiles.insert(pending_high_res_tiles[i]);
- std::vector<Tile*> pending_low_res_tiles =
- pending_layer_->LowResTiling()->AllTilesForTesting();
- for (size_t i = 0; i < pending_low_res_tiles.size(); ++i)
- all_tiles.insert(pending_low_res_tiles[i]);
-
std::vector<Tile*> active_high_res_tiles =
active_layer_->HighResTiling()->AllTilesForTesting();
for (size_t i = 0; i < active_high_res_tiles.size(); ++i)
@@ -775,7 +764,7 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
// Ensure that the distance is decreasing many more times than increasing.
EXPECT_EQ(3, distance_increasing);
- EXPECT_EQ(17, distance_decreasing);
+ EXPECT_EQ(16, distance_decreasing);
EXPECT_EQ(tile_count, smoothness_tiles.size());
EXPECT_EQ(all_tiles, smoothness_tiles);
@@ -816,7 +805,7 @@ TEST_F(TileManagerTilePriorityQueueTest, EvictionTilePriorityQueue) {
// Ensure that the distance is decreasing many more times than increasing.
EXPECT_EQ(3, distance_increasing);
- EXPECT_EQ(17, distance_decreasing);
+ EXPECT_EQ(16, distance_decreasing);
EXPECT_EQ(tile_count, new_content_tiles.size());
EXPECT_EQ(all_tiles, new_content_tiles);
}
@@ -870,12 +859,8 @@ TEST_F(TileManagerTilePriorityQueueTest,
gfx::Rect viewport(layer_bounds);
pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
- pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
- Occlusion());
pending_child_layer->HighResTiling()->ComputeTilePriorityRects(
viewport, 1.0f, 1.0, Occlusion());
- pending_child_layer->LowResTiling()->ComputeTilePriorityRects(
- viewport, 1.0f, 1.0, Occlusion());
active_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
@@ -893,24 +878,12 @@ TEST_F(TileManagerTilePriorityQueueTest,
all_tiles.insert(pending_high_res_tiles.begin(),
pending_high_res_tiles.end());
- std::vector<Tile*> pending_low_res_tiles =
- pending_layer_->LowResTiling()->AllTilesForTesting();
- all_tiles.insert(pending_low_res_tiles.begin(), pending_low_res_tiles.end());
-
// Set all tiles on the pending_child_layer as occluded on the pending tree.
std::vector<Tile*> pending_child_high_res_tiles =
pending_child_layer->HighResTiling()->AllTilesForTesting();
pending_child_layer->HighResTiling()->SetAllTilesOccludedForTesting();
active_child_layer->HighResTiling()->SetAllTilesOccludedForTesting();
- all_tiles.insert(pending_child_high_res_tiles.begin(),
- pending_child_high_res_tiles.end());
-
- std::vector<Tile*> pending_child_low_res_tiles =
- pending_child_layer->LowResTiling()->AllTilesForTesting();
- pending_child_layer->LowResTiling()->SetAllTilesOccludedForTesting();
active_child_layer->LowResTiling()->SetAllTilesOccludedForTesting();
- all_tiles.insert(pending_child_low_res_tiles.begin(),
- pending_child_low_res_tiles.end());
tile_manager()->InitializeTilesWithResourcesForTesting(
std::vector<Tile*>(all_tiles.begin(), all_tiles.end()));
@@ -950,8 +923,7 @@ TEST_F(TileManagerTilePriorityQueueTest,
last_tile = prioritized_tile;
queue->Pop();
}
- size_t expected_occluded_count =
- pending_child_high_res_tiles.size() + pending_child_low_res_tiles.size();
+ size_t expected_occluded_count = pending_child_high_res_tiles.size();
EXPECT_EQ(expected_occluded_count, occluded_count);
}
@@ -989,12 +961,8 @@ TEST_F(TileManagerTilePriorityQueueTest,
gfx::Rect viewport(layer_bounds);
pending_layer_->HighResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
Occlusion());
- pending_layer_->LowResTiling()->ComputeTilePriorityRects(viewport, 1.0f, 1.0,
- Occlusion());
pending_child_layer->HighResTiling()->ComputeTilePriorityRects(
viewport, 1.0f, 1.0, Occlusion());
- pending_child_layer->LowResTiling()->ComputeTilePriorityRects(
- viewport, 1.0f, 1.0, Occlusion());
// Populate all tiles directly from the tilings.
std::set<Tile*> all_pending_tiles;
@@ -1004,12 +972,6 @@ TEST_F(TileManagerTilePriorityQueueTest,
pending_high_res_tiles.end());
EXPECT_EQ(16u, pending_high_res_tiles.size());
- std::vector<Tile*> pending_low_res_tiles =
- pending_layer_->LowResTiling()->AllTilesForTesting();
- all_pending_tiles.insert(pending_low_res_tiles.begin(),
- pending_low_res_tiles.end());
- EXPECT_EQ(1u, pending_low_res_tiles.size());
-
std::set<Tile*> all_pending_child_tiles;
std::vector<Tile*> pending_child_high_res_tiles =
pending_child_layer->HighResTiling()->AllTilesForTesting();
@@ -1017,12 +979,6 @@ TEST_F(TileManagerTilePriorityQueueTest,
pending_child_high_res_tiles.end());
EXPECT_EQ(16u, pending_child_high_res_tiles.size());
- std::vector<Tile*> pending_child_low_res_tiles =
- pending_child_layer->LowResTiling()->AllTilesForTesting();
- all_pending_child_tiles.insert(pending_child_low_res_tiles.begin(),
- pending_child_low_res_tiles.end());
- EXPECT_EQ(1u, pending_child_low_res_tiles.size());
-
std::set<Tile*> all_tiles = all_pending_tiles;
all_tiles.insert(all_pending_child_tiles.begin(),
all_pending_child_tiles.end());