From 2809aed15ca0d666a2ae24f1f170a8e516e84d68 Mon Sep 17 00:00:00 2001 From: "vmpstr@chromium.org" Date: Wed, 28 Aug 2013 03:44:19 +0000 Subject: cc: Removed low priority bin from tile management. This patch removes low priority bin from tile management, increasing the perftests by about 5% (since the bin comparator doesn't have to check this anymore). TileManager unittests, and all of cc_unittests pass. R=reveman@chromium.org BUG=268887 Review URL: https://chromiumcodereview.appspot.com/22831041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219897 0039d316-1c4b-4281-b951-d872f2087c98 --- cc/resources/managed_tile_state.cc | 84 +++++++++++------------- cc/resources/managed_tile_state.h | 17 ++--- cc/resources/prioritized_tile_set.cc | 8 +-- cc/resources/prioritized_tile_set_unittest.cc | 92 +++++++++++++-------------- cc/resources/tile_manager.cc | 37 +++++++---- cc/resources/tile_manager_perftest.cc | 10 +-- 6 files changed, 119 insertions(+), 129 deletions(-) (limited to 'cc') diff --git a/cc/resources/managed_tile_state.cc b/cc/resources/managed_tile_state.cc index cf4a7a7..4583e53 100644 --- a/cc/resources/managed_tile_state.cc +++ b/cc/resources/managed_tile_state.cc @@ -12,52 +12,42 @@ namespace cc { scoped_ptr ManagedTileBinAsValue(ManagedTileBin bin) { switch (bin) { - case NOW_AND_READY_TO_DRAW_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "NOW_AND_READY_TO_DRAW_BIN")); - case NOW_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "NOW_BIN")); - case SOON_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "SOON_BIN")); - case EVENTUALLY_AND_ACTIVE_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "EVENTUALLY_AND_ACTIVE_BIN")); - case EVENTUALLY_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "EVENTUALLY_BIN")); - case NEVER_AND_ACTIVE_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "NEVER_AND_ACTIVE_BIN")); - case NEVER_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "NEVER_BIN")); - default: - DCHECK(false) << "Unrecognized ManagedTileBin value " << bin; - return scoped_ptr(base::Value::CreateStringValue( - "")); - } -} - -scoped_ptr ManagedTileBinPriorityAsValue( - ManagedTileBinPriority bin_priority) { - switch (bin_priority) { - case HIGH_PRIORITY_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "HIGH_PRIORITY_BIN")); - case LOW_PRIORITY_BIN: - return scoped_ptr(base::Value::CreateStringValue( - "LOW_PRIORITY_BIN")); - default: - DCHECK(false) << "Unrecognized ManagedTileBinPriority value"; - return scoped_ptr(base::Value::CreateStringValue( - "")); + case NOW_AND_READY_TO_DRAW_BIN: + return scoped_ptr( + base::Value::CreateStringValue("NOW_AND_READY_TO_DRAW_BIN")); + case NOW_BIN: + return scoped_ptr( + base::Value::CreateStringValue("NOW_BIN")); + case SOON_BIN: + return scoped_ptr( + base::Value::CreateStringValue("SOON_BIN")); + case EVENTUALLY_AND_ACTIVE_BIN: + return scoped_ptr( + base::Value::CreateStringValue("EVENTUALLY_AND_ACTIVE_BIN")); + case EVENTUALLY_BIN: + return scoped_ptr( + base::Value::CreateStringValue("EVENTUALLY_BIN")); + case AT_LAST_AND_ACTIVE_BIN: + return scoped_ptr( + base::Value::CreateStringValue("AT_LAST_AND_ACTIVE_BIN")); + case AT_LAST_BIN: + return scoped_ptr( + base::Value::CreateStringValue("AT_LAST_BIN")); + case NEVER_BIN: + return scoped_ptr( + base::Value::CreateStringValue("NEVER_BIN")); + case NUM_BINS: + NOTREACHED(); + return scoped_ptr( + base::Value::CreateStringValue("Invalid Bin (NUM_BINS)")); } + return scoped_ptr( + base::Value::CreateStringValue("Invalid Bin (UNKNOWN)")); } ManagedTileState::ManagedTileState() : raster_mode(LOW_QUALITY_RASTER_MODE), + bin(NEVER_BIN), gpu_memmgr_stats_bin(NEVER_BIN), resolution(NON_IDEAL_RESOLUTION), required_for_activation(false), @@ -65,10 +55,8 @@ ManagedTileState::ManagedTileState() distance_to_visible_in_pixels(std::numeric_limits::infinity()), visible_and_ready_to_draw(false), scheduled_priority(0) { - for (int i = 0; i < NUM_TREES; ++i) { + for (int i = 0; i < NUM_TREES; ++i) tree_bin[i] = NEVER_BIN; - bin[i] = NEVER_BIN; - } } ManagedTileState::TileVersion::TileVersion() @@ -105,10 +93,12 @@ scoped_ptr ManagedTileState::AsValue() const { scoped_ptr state(new base::DictionaryValue()); state->SetBoolean("has_resource", tile_versions[raster_mode].resource_.get() != 0); - state->Set("bin.0", ManagedTileBinAsValue(bin[ACTIVE_TREE]).release()); - state->Set("bin.1", ManagedTileBinAsValue(bin[PENDING_TREE]).release()); + state->Set("tree_bin.0", + ManagedTileBinAsValue(tree_bin[ACTIVE_TREE]).release()); + state->Set("tree_bin.1", + ManagedTileBinAsValue(tree_bin[PENDING_TREE]).release()); state->Set("gpu_memmgr_stats_bin", - ManagedTileBinAsValue(bin[ACTIVE_TREE]).release()); + ManagedTileBinAsValue(gpu_memmgr_stats_bin).release()); state->Set("resolution", TileResolutionAsValue(resolution).release()); state->Set("time_to_needed_in_seconds", MathUtil::AsValueSafely(time_to_needed_in_seconds).release()); diff --git a/cc/resources/managed_tile_state.h b/cc/resources/managed_tile_state.h index 3220add..8b72917 100644 --- a/cc/resources/managed_tile_state.h +++ b/cc/resources/managed_tile_state.h @@ -22,9 +22,10 @@ enum ManagedTileBin { SOON_BIN = 2, // Impl-side version of prepainting. EVENTUALLY_AND_ACTIVE_BIN = 3, // Nice to have, and has a task or resource. EVENTUALLY_BIN = 4, // Nice to have, if we've got memory and time. - NEVER_AND_ACTIVE_BIN = 5, // Dont bother, but has a task or resource. - NEVER_BIN = 6, // Dont bother. - NUM_BINS = 7 + AT_LAST_AND_ACTIVE_BIN = 5, // Only do this after all other bins. + AT_LAST_BIN = 6, // Only do this after all other bins. + NEVER_BIN = 7, // Dont bother. + NUM_BINS = 8 // NOTE: Be sure to update ManagedTileBinAsValue and kBinPolicyMap when adding // or reordering fields. }; @@ -131,15 +132,7 @@ class CC_EXPORT ManagedTileState { TileVersion tile_versions[NUM_RASTER_MODES]; RasterMode raster_mode; - // Ephemeral state, valid only during TileManager::ManageTiles. - bool is_in_never_bin_on_both_trees() const { - return (bin[HIGH_PRIORITY_BIN] == NEVER_BIN || - bin[HIGH_PRIORITY_BIN] == NEVER_AND_ACTIVE_BIN) && - (bin[LOW_PRIORITY_BIN] == NEVER_BIN || - bin[LOW_PRIORITY_BIN] == NEVER_AND_ACTIVE_BIN); - } - - ManagedTileBin bin[NUM_BIN_PRIORITIES]; + ManagedTileBin bin; ManagedTileBin tree_bin[NUM_TREES]; // The bin that the tile would have if the GPU memory manager had diff --git a/cc/resources/prioritized_tile_set.cc b/cc/resources/prioritized_tile_set.cc index d1cc5b7..6c5c472 100644 --- a/cc/resources/prioritized_tile_set.cc +++ b/cc/resources/prioritized_tile_set.cc @@ -18,9 +18,6 @@ class BinComparator { const ManagedTileState& ams = a->managed_state(); const ManagedTileState& bms = b->managed_state(); - if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) - return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; - if (ams.required_for_activation != bms.required_for_activation) return ams.required_for_activation; @@ -51,13 +48,14 @@ typedef std::vector TileVector; void SortBinTiles(ManagedTileBin bin, TileVector* tiles) { switch (bin) { case NOW_AND_READY_TO_DRAW_BIN: + case NEVER_BIN: break; case NOW_BIN: case SOON_BIN: case EVENTUALLY_AND_ACTIVE_BIN: case EVENTUALLY_BIN: - case NEVER_AND_ACTIVE_BIN: - case NEVER_BIN: + case AT_LAST_AND_ACTIVE_BIN: + case AT_LAST_BIN: std::sort(tiles->begin(), tiles->end(), BinComparator()); break; default: diff --git a/cc/resources/prioritized_tile_set_unittest.cc b/cc/resources/prioritized_tile_set_unittest.cc index 9325691..45c714f 100644 --- a/cc/resources/prioritized_tile_set_unittest.cc +++ b/cc/resources/prioritized_tile_set_unittest.cc @@ -25,9 +25,6 @@ class BinComparator { const ManagedTileState& ams = a->managed_state(); const ManagedTileState& bms = b->managed_state(); - if (ams.bin[LOW_PRIORITY_BIN] != bms.bin[LOW_PRIORITY_BIN]) - return ams.bin[LOW_PRIORITY_BIN] < bms.bin[LOW_PRIORITY_BIN]; - if (ams.required_for_activation != bms.required_for_activation) return ams.required_for_activation; @@ -310,8 +307,8 @@ TEST_F(PrioritizedTileSetTest, EventuallyBin) { EXPECT_EQ(20, i); } -TEST_F(PrioritizedTileSetTest, NeverAndActiveBin) { - // Ensure that NEVER_AND_ACTIVE_BIN tiles are sorted. +TEST_F(PrioritizedTileSetTest, AtLastAndActiveBin) { + // Ensure that AT_LAST_AND_ACTIVE_BIN tiles are sorted. PrioritizedTileSet set; TilePriority priorities[4] = { @@ -327,7 +324,7 @@ TEST_F(PrioritizedTileSetTest, NeverAndActiveBin) { tile->SetPriority(ACTIVE_TREE, priorities[priority]); tile->SetPriority(PENDING_TREE, priorities[priority]); tiles.push_back(tile); - set.InsertTile(tile, NEVER_AND_ACTIVE_BIN); + set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); } } @@ -344,9 +341,8 @@ TEST_F(PrioritizedTileSetTest, NeverAndActiveBin) { EXPECT_EQ(20, i); } -TEST_F(PrioritizedTileSetTest, NeverBin) { - // Ensure that NEVER_BIN tiles are sorted, since they might not - // be NEVER_BIN on a LOW_PRIORITY tree. +TEST_F(PrioritizedTileSetTest, AtLastBin) { + // Ensure that AT_LAST_BIN tiles are sorted. PrioritizedTileSet set; TilePriority priorities[4] = { @@ -362,7 +358,7 @@ TEST_F(PrioritizedTileSetTest, NeverBin) { tile->SetPriority(ACTIVE_TREE, priorities[priority]); tile->SetPriority(PENDING_TREE, priorities[priority]); tiles.push_back(tile); - set.InsertTile(tile, NEVER_BIN); + set.InsertTile(tile, AT_LAST_BIN); } } @@ -388,16 +384,16 @@ TEST_F(PrioritizedTileSetTest, TilesForEachBin) { scoped_refptr soon_bin = CreateTile(); scoped_refptr eventually_and_active_bin = CreateTile(); scoped_refptr eventually_bin = CreateTile(); - scoped_refptr never_bin = CreateTile(); - scoped_refptr never_and_active_bin = CreateTile(); + scoped_refptr at_last_bin = CreateTile(); + scoped_refptr at_last_and_active_bin = CreateTile(); PrioritizedTileSet set; set.InsertTile(soon_bin, SOON_BIN); - set.InsertTile(never_and_active_bin, NEVER_AND_ACTIVE_BIN); + set.InsertTile(at_last_and_active_bin, AT_LAST_AND_ACTIVE_BIN); set.InsertTile(eventually_bin, EVENTUALLY_BIN); set.InsertTile(now_bin, NOW_BIN); set.InsertTile(eventually_and_active_bin, EVENTUALLY_AND_ACTIVE_BIN); - set.InsertTile(never_bin, NEVER_BIN); + set.InsertTile(at_last_bin, AT_LAST_BIN); set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); // Tiles should appear in order. @@ -412,9 +408,9 @@ TEST_F(PrioritizedTileSetTest, TilesForEachBin) { ++it; EXPECT_TRUE(*it == eventually_bin.get()); ++it; - EXPECT_TRUE(*it == never_and_active_bin.get()); + EXPECT_TRUE(*it == at_last_and_active_bin.get()); ++it; - EXPECT_TRUE(*it == never_bin.get()); + EXPECT_TRUE(*it == at_last_bin.get()); ++it; EXPECT_FALSE(it); } @@ -428,8 +424,8 @@ TEST_F(PrioritizedTileSetTest, ManyTilesForEachBin) { std::vector > soon_bins; std::vector > eventually_and_active_bins; std::vector > eventually_bins; - std::vector > never_bins; - std::vector > never_and_active_bins; + std::vector > at_last_bins; + std::vector > at_last_and_active_bins; TilePriority priorities[4] = { TilePriorityForEventualBin(), @@ -449,16 +445,16 @@ TEST_F(PrioritizedTileSetTest, ManyTilesForEachBin) { soon_bins.push_back(tile); eventually_and_active_bins.push_back(tile); eventually_bins.push_back(tile); - never_bins.push_back(tile); - never_and_active_bins.push_back(tile); + at_last_bins.push_back(tile); + at_last_and_active_bins.push_back(tile); set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); set.InsertTile(tile, NOW_BIN); set.InsertTile(tile, SOON_BIN); set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); set.InsertTile(tile, EVENTUALLY_BIN); - set.InsertTile(tile, NEVER_BIN); - set.InsertTile(tile, NEVER_AND_ACTIVE_BIN); + set.InsertTile(tile, AT_LAST_BIN); + set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); } } @@ -507,20 +503,20 @@ TEST_F(PrioritizedTileSetTest, ManyTilesForEachBin) { ++it; } - // Never and active bins are sorted. - std::sort(never_and_active_bins.begin(), - never_and_active_bins.end(), + // At last and active bins are sorted. + std::sort(at_last_and_active_bins.begin(), + at_last_and_active_bins.end(), BinComparator()); - for (vector_it = never_and_active_bins.begin(); - vector_it != never_and_active_bins.end(); + for (vector_it = at_last_and_active_bins.begin(); + vector_it != at_last_and_active_bins.end(); ++vector_it) { EXPECT_TRUE(*vector_it == *it); ++it; } - // Never bins are sorted. - std::sort(never_bins.begin(), never_bins.end(), BinComparator()); - for (vector_it = never_bins.begin(); vector_it != never_bins.end(); + // At last bins are sorted. + std::sort(at_last_bins.begin(), at_last_bins.end(), BinComparator()); + for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); ++vector_it) { EXPECT_TRUE(*vector_it == *it); ++it; @@ -539,8 +535,8 @@ TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { std::vector > soon_bins; std::vector > eventually_and_active_bins; std::vector > eventually_bins; - std::vector > never_bins; - std::vector > never_and_active_bins; + std::vector > at_last_bins; + std::vector > at_last_and_active_bins; TilePriority priorities[4] = { TilePriorityForEventualBin(), @@ -560,16 +556,16 @@ TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { soon_bins.push_back(tile); eventually_and_active_bins.push_back(tile); eventually_bins.push_back(tile); - never_bins.push_back(tile); - never_and_active_bins.push_back(tile); + at_last_bins.push_back(tile); + at_last_and_active_bins.push_back(tile); set.InsertTile(tile, NOW_AND_READY_TO_DRAW_BIN); set.InsertTile(tile, NOW_BIN); set.InsertTile(tile, SOON_BIN); set.InsertTile(tile, EVENTUALLY_AND_ACTIVE_BIN); set.InsertTile(tile, EVENTUALLY_BIN); - set.InsertTile(tile, NEVER_BIN); - set.InsertTile(tile, NEVER_AND_ACTIVE_BIN); + set.InsertTile(tile, AT_LAST_BIN); + set.InsertTile(tile, AT_LAST_AND_ACTIVE_BIN); } } @@ -620,16 +616,16 @@ TEST_F(PrioritizedTileSetTest, ManyTilesForEachBinDisablePriority) { ++it; } - // Never and active bins are not sorted. - for (vector_it = never_and_active_bins.begin(); - vector_it != never_and_active_bins.end(); + // At last and active bins are not sorted. + for (vector_it = at_last_and_active_bins.begin(); + vector_it != at_last_and_active_bins.end(); ++vector_it) { EXPECT_TRUE(*vector_it == *it); ++it; } - // Never bins are not sorted. - for (vector_it = never_bins.begin(); vector_it != never_bins.end(); + // At last bins are not sorted. + for (vector_it = at_last_bins.begin(); vector_it != at_last_bins.end(); ++vector_it) { EXPECT_TRUE(*vector_it == *it); ++it; @@ -643,17 +639,17 @@ TEST_F(PrioritizedTileSetTest, TilesForFirstAndLastBins) { // we just get two tiles from the iterator. scoped_refptr now_and_ready_to_draw_bin = CreateTile(); - scoped_refptr never_bin = CreateTile(); + scoped_refptr at_last_bin = CreateTile(); PrioritizedTileSet set; - set.InsertTile(never_bin, NEVER_BIN); + set.InsertTile(at_last_bin, AT_LAST_BIN); set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); // Only two tiles should appear and they should appear in order. PrioritizedTileSet::Iterator it(&set, true); EXPECT_TRUE(*it == now_and_ready_to_draw_bin.get()); ++it; - EXPECT_TRUE(*it == never_bin.get()); + EXPECT_TRUE(*it == at_last_bin.get()); ++it; EXPECT_FALSE(it); } @@ -665,13 +661,13 @@ TEST_F(PrioritizedTileSetTest, MultipleIterators) { scoped_refptr now_bin = CreateTile(); scoped_refptr soon_bin = CreateTile(); scoped_refptr eventually_bin = CreateTile(); - scoped_refptr never_bin = CreateTile(); + scoped_refptr at_last_bin = CreateTile(); PrioritizedTileSet set; set.InsertTile(soon_bin, SOON_BIN); set.InsertTile(eventually_bin, EVENTUALLY_BIN); set.InsertTile(now_bin, NOW_BIN); - set.InsertTile(never_bin, NEVER_BIN); + set.InsertTile(at_last_bin, AT_LAST_BIN); set.InsertTile(now_and_ready_to_draw_bin, NOW_AND_READY_TO_DRAW_BIN); // Tiles should appear in order. @@ -684,7 +680,7 @@ TEST_F(PrioritizedTileSetTest, MultipleIterators) { ++it; EXPECT_TRUE(*it == eventually_bin.get()); ++it; - EXPECT_TRUE(*it == never_bin.get()); + EXPECT_TRUE(*it == at_last_bin.get()); ++it; EXPECT_FALSE(it); @@ -712,7 +708,7 @@ TEST_F(PrioritizedTileSetTest, MultipleIterators) { EXPECT_TRUE(third_it); EXPECT_TRUE(*third_it == soon_bin.get()); EXPECT_TRUE(second_it); - EXPECT_TRUE(*second_it == never_bin.get()); + EXPECT_TRUE(*second_it == at_last_bin.get()); EXPECT_FALSE(it); ++second_it; diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index 6b108d8..3e91167 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -32,7 +32,8 @@ const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { NEVER_BIN, // [SOON_BIN] NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] NEVER_BIN, // [EVENTUALLY_BIN] - NEVER_BIN, // [NEVER_AND_ACTIVE_BIN] + NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] + NEVER_BIN, // [AT_LAST_BIN] NEVER_BIN // [NEVER_BIN] }, { // [ALLOW_ABSOLUTE_MINIMUM] NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] @@ -40,7 +41,8 @@ const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { NEVER_BIN, // [SOON_BIN] NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] NEVER_BIN, // [EVENTUALLY_BIN] - NEVER_BIN, // [NEVER_AND_ACTIVE_BIN] + NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] + NEVER_BIN, // [AT_LAST_BIN] NEVER_BIN // [NEVER_BIN] }, { // [ALLOW_PREPAINT_ONLY] NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] @@ -48,7 +50,8 @@ const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { SOON_BIN, // [SOON_BIN] NEVER_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] NEVER_BIN, // [EVENTUALLY_BIN] - NEVER_BIN, // [NEVER_AND_ACTIVE_BIN] + NEVER_BIN, // [AT_LAST_AND_ACTIVE_BIN] + NEVER_BIN, // [AT_LAST_BIN] NEVER_BIN // [NEVER_BIN] }, { // [ALLOW_ANYTHING] NOW_AND_READY_TO_DRAW_BIN, // [NOW_AND_READY_TO_DRAW_BIN] @@ -56,7 +59,8 @@ const ManagedTileBin kBinPolicyMap[NUM_TILE_MEMORY_LIMIT_POLICIES][NUM_BINS] = { SOON_BIN, // [SOON_BIN] EVENTUALLY_AND_ACTIVE_BIN, // [EVENTUALLY_AND_ACTIVE_BIN] EVENTUALLY_BIN, // [EVENTUALLY_BIN] - NEVER_AND_ACTIVE_BIN, // [NEVER_AND_ACTIVE_BIN] + AT_LAST_AND_ACTIVE_BIN, // [AT_LAST_AND_ACTIVE_BIN] + AT_LAST_BIN, // [AT_LAST_BIN] NEVER_BIN // [NEVER_BIN] } }; @@ -78,7 +82,7 @@ inline ManagedTileBin BinFromTilePriority(const TilePriority& prio, if (prio.distance_to_visible_in_pixels == std::numeric_limits::infinity()) - return is_active ? NEVER_AND_ACTIVE_BIN : NEVER_BIN; + return NEVER_BIN; if (can_be_in_now_bin && prio.time_to_visible_in_seconds == 0) return is_ready_to_draw ? NOW_AND_READY_TO_DRAW_BIN : NOW_BIN; @@ -308,21 +312,28 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { TilePriority* high_priority = NULL; switch (tree_priority) { case SAME_PRIORITY_FOR_BOTH_TREES: - mts.bin[HIGH_PRIORITY_BIN] = mts.bin[LOW_PRIORITY_BIN] = combined_bin; + mts.bin = combined_bin; high_priority = &combined_priority; break; case SMOOTHNESS_TAKES_PRIORITY: - mts.bin[HIGH_PRIORITY_BIN] = mts.tree_bin[ACTIVE_TREE]; - mts.bin[LOW_PRIORITY_BIN] = mts.tree_bin[PENDING_TREE]; + mts.bin = mts.tree_bin[ACTIVE_TREE]; high_priority = &active_priority; break; case NEW_CONTENT_TAKES_PRIORITY: - mts.bin[HIGH_PRIORITY_BIN] = mts.tree_bin[PENDING_TREE]; - mts.bin[LOW_PRIORITY_BIN] = mts.tree_bin[ACTIVE_TREE]; + mts.bin = mts.tree_bin[PENDING_TREE]; high_priority = &pending_priority; break; } + // Bump up the priority if we determined it's NEVER_BIN on one tree, + // but is still required on the other tree. + bool is_in_never_bin_on_both_trees = + mts.tree_bin[ACTIVE_TREE] == NEVER_BIN && + mts.tree_bin[PENDING_TREE] == NEVER_BIN; + + if (mts.bin == NEVER_BIN && !is_in_never_bin_on_both_trees) + mts.bin = tile_is_active ? AT_LAST_AND_ACTIVE_BIN : AT_LAST_BIN; + DCHECK(high_priority != NULL); mts.resolution = high_priority->resolution; @@ -334,7 +345,7 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { mts.visible_and_ready_to_draw = mts.tree_bin[ACTIVE_TREE] == NOW_AND_READY_TO_DRAW_BIN; - if (mts.is_in_never_bin_on_both_trees()) { + if (mts.bin == NEVER_BIN) { FreeResourcesForTile(tile); continue; } @@ -346,7 +357,7 @@ void TileManager::GetTilesWithAssignedBins(PrioritizedTileSet* tiles) { // priority. ManagedTileBin priority_bin = mts.visible_and_ready_to_draw ? NOW_AND_READY_TO_DRAW_BIN - : mts.bin[HIGH_PRIORITY_BIN]; + : mts.bin; // Insert the tile into a priority set. tiles->InsertTile(tile, priority_bin); @@ -526,7 +537,7 @@ void TileManager::AssignGpuMemoryToTiles( continue; // If the tile is not needed, free it up. - if (mts.is_in_never_bin_on_both_trees()) { + if (mts.bin == NEVER_BIN) { FreeResourcesForTile(tile); continue; } diff --git a/cc/resources/tile_manager_perftest.cc b/cc/resources/tile_manager_perftest.cc index 336fa57..1a60601 100644 --- a/cc/resources/tile_manager_perftest.cc +++ b/cc/resources/tile_manager_perftest.cc @@ -91,7 +91,8 @@ class TileManagerPerfTest : public testing::Test { case EVENTUALLY_AND_ACTIVE_BIN: case EVENTUALLY_BIN: return TilePriorityForEventualBin(); - case NEVER_AND_ACTIVE_BIN: + case AT_LAST_BIN: + case AT_LAST_AND_ACTIVE_BIN: case NEVER_BIN: return TilePriority(); default: @@ -110,7 +111,8 @@ class TileManagerPerfTest : public testing::Test { case EVENTUALLY_AND_ACTIVE_BIN: case EVENTUALLY_BIN: return NEVER_BIN; - case NEVER_AND_ACTIVE_BIN: + case AT_LAST_BIN: + case AT_LAST_AND_ACTIVE_BIN: case NEVER_BIN: return NOW_BIN; default: @@ -149,8 +151,8 @@ class TileManagerPerfTest : public testing::Test { void RunManageTilesTest(const std::string test_name, unsigned tile_count, unsigned priority_change_percent) { - DCHECK_GE(100u, tile_count); - DCHECK_LE(100u, priority_change_percent); + DCHECK_GE(tile_count, 100u); + DCHECK_LE(priority_change_percent, 100u); num_runs_ = 0; TileBinVector tiles; CreateTiles(tile_count, &tiles); -- cgit v1.1