Index: cc/resources/tile_manager.cc |
diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc |
index c9fab0fc06034c14f840772b76aadcf7972a9fad..e03fe3f938d20891d4e4248a9ce2d2f385c663a9 100644 |
--- a/cc/resources/tile_manager.cc |
+++ b/cc/resources/tile_manager.cc |
@@ -512,21 +512,41 @@ bool TileManager::FreeTileResourcesWithLowerPriorityUntilUsageIsWithinLimit( |
return true; |
} |
-bool TileManager::TilePriorityViolatesMemoryPolicy( |
- const TilePriority& priority) { |
+bool TileManager::TileViolatesMemoryPolicy(const Tile* tile) { |
+ bool memory_policy_violated = true; |
+ const TilePriority& priority = |
+ tile->priority_for_tree_priority(global_state_.tree_priority); |
switch (global_state_.memory_limit_policy) { |
case ALLOW_NOTHING: |
+ // In the case of ALLOW_NOTHING, there are no special cases. A tile always |
+ // violated memory policy. |
return true; |
case ALLOW_ABSOLUTE_MINIMUM: |
- return priority.priority_bin > TilePriority::NOW; |
+ memory_policy_violated = priority.priority_bin > TilePriority::NOW; |
+ break; |
case ALLOW_PREPAINT_ONLY: |
- return priority.priority_bin > TilePriority::SOON; |
+ memory_policy_violated = priority.priority_bin > TilePriority::SOON; |
+ break; |
case ALLOW_ANYTHING: |
- return priority.distance_to_visible == |
- std::numeric_limits<float>::infinity(); |
+ memory_policy_violated = priority.distance_to_visible == |
+ std::numeric_limits<float>::infinity(); |
+ break; |
} |
- NOTREACHED(); |
- return true; |
reveman
2014/10/13 19:45:11
can we keep this NOTREACHED statement?
vmpstr
2014/10/13 20:20:14
Done.
|
+ |
+ // If memory policy was violated, we need to check whether this tile is coming |
+ // from the NOW bin on the pending tree. The reason for this is that there is |
+ // a possibility that a pending tree tile could be required for activation and |
+ // we don't want to starve activation in any of the above cases. |
+ // TODO(vmpstr): Note that it is insufficient to check whether tile is |
+ // required for activation, since pending tree iterator can return NOW bin |
+ // tiles not required for activation before NOW bin tiles that are required. |
+ // The todo here is to fix this, so that we can check only the activation |
+ // requirement. |
+ if (memory_policy_violated) { |
+ const TilePriority& pending_priority = tile->priority(PENDING_TREE); |
+ memory_policy_violated = pending_priority.priority_bin != TilePriority::NOW; |
+ } |
reveman
2014/10/13 19:45:11
Looks like this is just being tacked on as a quick
vmpstr
2014/10/13 20:20:14
Reworked this a bit.
|
+ return memory_policy_violated; |
} |
void TileManager::AssignGpuMemoryToTiles( |
@@ -560,10 +580,7 @@ void TileManager::AssignGpuMemoryToTiles( |
while (!raster_priority_queue_.IsEmpty()) { |
Tile* tile = raster_priority_queue_.Top(); |
- TilePriority priority = |
- tile->priority_for_tree_priority(global_state_.tree_priority); |
- |
- if (TilePriorityViolatesMemoryPolicy(priority)) |
+ if (TileViolatesMemoryPolicy(tile)) |
break; |
// We won't be able to schedule this tile, so break out early. |
@@ -589,6 +606,8 @@ void TileManager::AssignGpuMemoryToTiles( |
tile->size(), resource_pool_->resource_format()); |
} |
+ const TilePriority& priority = |
+ tile->priority_for_tree_priority(global_state_.tree_priority); |
bool tile_is_needed_now = priority.priority_bin == TilePriority::NOW; |
// This is the memory limit that will be used by this tile. Depending on |