cc: Add TileManager interface that allows LTHI to determine when to activate pending tree.
BUG=166072 Review URL: https://chromiumcodereview.appspot.com/11568027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173385 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -1692,7 +1692,7 @@ void LayerTreeHostImpl::renderingStats(RenderingStats* stats) const
|
|||||||
stats->numMissingTiles = m_cumulativeNumMissingTiles;
|
stats->numMissingTiles = m_cumulativeNumMissingTiles;
|
||||||
|
|
||||||
if (m_tileManager)
|
if (m_tileManager)
|
||||||
m_tileManager->renderingStats(stats);
|
m_tileManager->GetRenderingStats(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerTreeHostImpl::sendManagedMemoryStats(
|
void LayerTreeHostImpl::sendManagedMemoryStats(
|
||||||
|
@@ -31,6 +31,30 @@ const int kDefaultNumberOfRasterThreads = 1;
|
|||||||
// low while making sure raster threads aren't unnecessarily idle.
|
// low while making sure raster threads aren't unnecessarily idle.
|
||||||
const int kNumPendingRasterTasksPerThread = 2;
|
const int kNumPendingRasterTasksPerThread = 2;
|
||||||
|
|
||||||
|
// Determine bin based on three categories of tiles: things we need now,
|
||||||
|
// things we need soon, and eventually.
|
||||||
|
cc::TileManagerBin BinFromTilePriority(const cc::TilePriority& prio) {
|
||||||
|
|
||||||
|
// The amount of time for which we want to have prepainting coverage.
|
||||||
|
const double prepainting_window_time_seconds = 1.0;
|
||||||
|
const double backfling_guard_distance_pixels = 314.0;
|
||||||
|
|
||||||
|
if (prio.time_to_needed_in_seconds() == std::numeric_limits<float>::max())
|
||||||
|
return cc::NEVER_BIN;
|
||||||
|
|
||||||
|
if (prio.resolution == cc::NON_IDEAL_RESOLUTION)
|
||||||
|
return cc::EVENTUALLY_BIN;
|
||||||
|
|
||||||
|
if (prio.time_to_needed_in_seconds() == 0 ||
|
||||||
|
prio.distance_to_visible_in_pixels < backfling_guard_distance_pixels)
|
||||||
|
return cc::NOW_BIN;
|
||||||
|
|
||||||
|
if (prio.time_to_needed_in_seconds() < prepainting_window_time_seconds)
|
||||||
|
return cc::SOON_BIN;
|
||||||
|
|
||||||
|
return cc::EVENTUALLY_BIN;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace cc {
|
namespace cc {
|
||||||
@@ -149,6 +173,8 @@ TileManager::TileManager(
|
|||||||
StringPrintf("Worker%d", thread_number).c_str()));
|
StringPrintf("Worker%d", thread_number).c_str()));
|
||||||
raster_threads_.append(thread.Pass());
|
raster_threads_.append(thread.Pass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResetBinCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
TileManager::~TileManager() {
|
TileManager::~TileManager() {
|
||||||
@@ -224,8 +250,8 @@ public:
|
|||||||
bool operator() (const Tile* a, const Tile* b) const {
|
bool operator() (const Tile* a, const Tile* b) const {
|
||||||
const ManagedTileState& ams = a->managed_state();
|
const ManagedTileState& ams = a->managed_state();
|
||||||
const ManagedTileState& bms = b->managed_state();
|
const ManagedTileState& bms = b->managed_state();
|
||||||
if (ams.bin != bms.bin)
|
if (ams.raster_bin != bms.raster_bin)
|
||||||
return ams.bin < bms.bin;
|
return ams.raster_bin < bms.raster_bin;
|
||||||
|
|
||||||
if (ams.resolution != bms.resolution)
|
if (ams.resolution != bms.resolution)
|
||||||
return ams.resolution < ams.resolution;
|
return ams.resolution < ams.resolution;
|
||||||
@@ -241,16 +267,16 @@ void TileManager::ManageTiles() {
|
|||||||
manage_tiles_pending_ = false;
|
manage_tiles_pending_ = false;
|
||||||
++manage_tiles_call_count_;
|
++manage_tiles_call_count_;
|
||||||
|
|
||||||
// The amount of time for which we want to have prepainting coverage.
|
const bool smoothness_takes_priority =
|
||||||
const double prepainting_window_time_seconds = 1.0;
|
global_state_.smoothness_takes_priority;
|
||||||
const double backfling_guard_distance_pixels = 314.0;
|
|
||||||
|
|
||||||
const bool smoothness_takes_priority = global_state_.smoothness_takes_priority;
|
// For each tree, bin into different categories of tiles.
|
||||||
|
|
||||||
// Bin into three categories of tiles: things we need now, things we need soon, and eventually
|
|
||||||
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
|
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
|
||||||
Tile* tile = *it;
|
Tile* tile = *it;
|
||||||
ManagedTileState& mts = tile->managed_state();
|
ManagedTileState& mts = tile->managed_state();
|
||||||
|
mts.bin[ACTIVE_TREE] = BinFromTilePriority(tile->priority(ACTIVE_TREE));
|
||||||
|
mts.bin[PENDING_TREE] = BinFromTilePriority(tile->priority(PENDING_TREE));
|
||||||
|
|
||||||
TilePriority prio;
|
TilePriority prio;
|
||||||
if (smoothness_takes_priority)
|
if (smoothness_takes_priority)
|
||||||
prio = tile->priority(ACTIVE_TREE);
|
prio = tile->priority(ACTIVE_TREE);
|
||||||
@@ -259,30 +285,7 @@ void TileManager::ManageTiles() {
|
|||||||
|
|
||||||
mts.resolution = prio.resolution;
|
mts.resolution = prio.resolution;
|
||||||
mts.time_to_needed_in_seconds = prio.time_to_needed_in_seconds();
|
mts.time_to_needed_in_seconds = prio.time_to_needed_in_seconds();
|
||||||
|
mts.raster_bin = BinFromTilePriority(prio);
|
||||||
if (mts.time_to_needed_in_seconds ==
|
|
||||||
std::numeric_limits<float>::max()) {
|
|
||||||
mts.bin = NEVER_BIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mts.resolution == NON_IDEAL_RESOLUTION) {
|
|
||||||
mts.bin = EVENTUALLY_BIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mts.time_to_needed_in_seconds == 0 ||
|
|
||||||
prio.distance_to_visible_in_pixels < backfling_guard_distance_pixels) {
|
|
||||||
mts.bin = NOW_BIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prio.time_to_needed_in_seconds() < prepainting_window_time_seconds) {
|
|
||||||
mts.bin = SOON_BIN;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
mts.bin = EVENTUALLY_BIN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memory limit policy works by mapping some bin states to the NEVER bin.
|
// Memory limit policy works by mapping some bin states to the NEVER bin.
|
||||||
@@ -310,8 +313,25 @@ void TileManager::ManageTiles() {
|
|||||||
}
|
}
|
||||||
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
|
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
|
||||||
Tile* tile = *it;
|
Tile* tile = *it;
|
||||||
TileManagerBin bin = bin_map[tile->managed_state().bin];
|
ManagedTileState& mts = tile->managed_state();
|
||||||
tile->managed_state().bin = bin;
|
mts.bin[ACTIVE_TREE] = bin_map[mts.bin[ACTIVE_TREE]];
|
||||||
|
mts.bin[PENDING_TREE] = bin_map[mts.bin[PENDING_TREE]];
|
||||||
|
mts.raster_bin = bin_map[mts.raster_bin];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update bin counts.
|
||||||
|
ResetBinCounts();
|
||||||
|
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
|
||||||
|
Tile* tile = *it;
|
||||||
|
ManagedTileState& mts = tile->managed_state();
|
||||||
|
for (int i = 0; i < NUM_TREES; ++i)
|
||||||
|
tiles_in_bin_count_[mts.bin[i]][i]++;
|
||||||
|
|
||||||
|
// Increment drawable count if GetResourceId() doesn't return 0.
|
||||||
|
if (tile->GetResourceId()) {
|
||||||
|
for (int i = 0; i < NUM_TREES; ++i)
|
||||||
|
drawable_tiles_in_bin_count_[mts.bin[i]][i]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by bin.
|
// Sort by bin.
|
||||||
@@ -347,7 +367,7 @@ void TileManager::CheckForCompletedSetPixels() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileManager::renderingStats(RenderingStats* stats) {
|
void TileManager::GetRenderingStats(RenderingStats* stats) {
|
||||||
stats->totalRasterizeTimeInSeconds =
|
stats->totalRasterizeTimeInSeconds =
|
||||||
rendering_stats_.totalRasterizeTimeInSeconds;
|
rendering_stats_.totalRasterizeTimeInSeconds;
|
||||||
stats->totalPixelsRasterized = rendering_stats_.totalPixelsRasterized;
|
stats->totalPixelsRasterized = rendering_stats_.totalPixelsRasterized;
|
||||||
@@ -362,6 +382,29 @@ void TileManager::renderingStats(RenderingStats* stats) {
|
|||||||
rendering_stats_.totalImageGatheringTimeInSeconds;
|
rendering_stats_.totalImageGatheringTimeInSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TileManager::GetTilesInBinCount(TileManagerBin bin, WhichTree tree) {
|
||||||
|
DCHECK(bin >= 0);
|
||||||
|
DCHECK(bin < NUM_BINS);
|
||||||
|
DCHECK(tree >= 0);
|
||||||
|
DCHECK(tree < NUM_TREES);
|
||||||
|
return tiles_in_bin_count_[bin][tree];
|
||||||
|
}
|
||||||
|
|
||||||
|
int TileManager::GetDrawableTilesInBinCount(
|
||||||
|
TileManagerBin bin, WhichTree tree) {
|
||||||
|
DCHECK(bin >= 0);
|
||||||
|
DCHECK(bin < NUM_BINS);
|
||||||
|
DCHECK(tree >= 0);
|
||||||
|
DCHECK(tree < NUM_TREES);
|
||||||
|
return drawable_tiles_in_bin_count_[bin][tree];
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileManager::ResetBinCounts() {
|
||||||
|
for (int i = 0; i < NUM_BINS; ++i)
|
||||||
|
for (int j = 0; j < NUM_TREES; ++j)
|
||||||
|
tiles_in_bin_count_[i][j] = drawable_tiles_in_bin_count_[i][j] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void TileManager::AssignGpuMemoryToTiles() {
|
void TileManager::AssignGpuMemoryToTiles() {
|
||||||
TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
|
TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
|
||||||
// Some memory cannot be released. Figure out which.
|
// Some memory cannot be released. Figure out which.
|
||||||
@@ -390,7 +433,7 @@ void TileManager::AssignGpuMemoryToTiles() {
|
|||||||
ManagedTileState& managed_tile_state = tile->managed_state();
|
ManagedTileState& managed_tile_state = tile->managed_state();
|
||||||
if (!managed_tile_state.can_be_freed)
|
if (!managed_tile_state.can_be_freed)
|
||||||
continue;
|
continue;
|
||||||
if (managed_tile_state.bin == NEVER_BIN) {
|
if (managed_tile_state.raster_bin == NEVER_BIN) {
|
||||||
managed_tile_state.can_use_gpu_memory = false;
|
managed_tile_state.can_use_gpu_memory = false;
|
||||||
FreeResourcesForTile(tile);
|
FreeResourcesForTile(tile);
|
||||||
continue;
|
continue;
|
||||||
@@ -644,6 +687,8 @@ void TileManager::DidFinishTileInitialization(Tile* tile) {
|
|||||||
DCHECK(managed_tile_state.resource);
|
DCHECK(managed_tile_state.resource);
|
||||||
managed_tile_state.resource_is_being_initialized = false;
|
managed_tile_state.resource_is_being_initialized = false;
|
||||||
managed_tile_state.can_be_freed = true;
|
managed_tile_state.can_be_freed = true;
|
||||||
|
for (int i = 0; i < NUM_TREES; ++i)
|
||||||
|
drawable_tiles_in_bin_count_[managed_tile_state.bin[i]][i]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -59,7 +59,9 @@ class CC_EXPORT ManagedTileState {
|
|||||||
std::list<skia::LazyPixelRef*> pending_pixel_refs;
|
std::list<skia::LazyPixelRef*> pending_pixel_refs;
|
||||||
|
|
||||||
// Ephemeral state, valid only during Manage.
|
// Ephemeral state, valid only during Manage.
|
||||||
TileManagerBin bin;
|
TileManagerBin bin[NUM_TREES];
|
||||||
|
// Bin used to determine raster priority.
|
||||||
|
TileManagerBin raster_bin;
|
||||||
TileResolution resolution;
|
TileResolution resolution;
|
||||||
float time_to_needed_in_seconds;
|
float time_to_needed_in_seconds;
|
||||||
};
|
};
|
||||||
@@ -81,7 +83,10 @@ class CC_EXPORT TileManager {
|
|||||||
void ManageTiles();
|
void ManageTiles();
|
||||||
void CheckForCompletedSetPixels();
|
void CheckForCompletedSetPixels();
|
||||||
|
|
||||||
void renderingStats(RenderingStats* stats);
|
void GetRenderingStats(RenderingStats* stats);
|
||||||
|
|
||||||
|
int GetTilesInBinCount(TileManagerBin bin, WhichTree tree);
|
||||||
|
int GetDrawableTilesInBinCount(TileManagerBin bin, WhichTree tree);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Methods called by Tile
|
// Methods called by Tile
|
||||||
@@ -91,6 +96,7 @@ class CC_EXPORT TileManager {
|
|||||||
void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority);
|
void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void ResetBinCounts();
|
||||||
void AssignGpuMemoryToTiles();
|
void AssignGpuMemoryToTiles();
|
||||||
void FreeResourcesForTile(Tile*);
|
void FreeResourcesForTile(Tile*);
|
||||||
void ScheduleManageTiles();
|
void ScheduleManageTiles();
|
||||||
@@ -121,6 +127,9 @@ class CC_EXPORT TileManager {
|
|||||||
|
|
||||||
GlobalStateThatImpactsTilePriority global_state_;
|
GlobalStateThatImpactsTilePriority global_state_;
|
||||||
|
|
||||||
|
int tiles_in_bin_count_[NUM_BINS][NUM_TREES];
|
||||||
|
int drawable_tiles_in_bin_count_[NUM_BINS][NUM_TREES];
|
||||||
|
|
||||||
typedef std::vector<Tile*> TileVector;
|
typedef std::vector<Tile*> TileVector;
|
||||||
TileVector tiles_;
|
TileVector tiles_;
|
||||||
TileVector tiles_that_need_to_be_rasterized_;
|
TileVector tiles_that_need_to_be_rasterized_;
|
||||||
|
@@ -18,7 +18,8 @@ enum WhichTree {
|
|||||||
// Note: these must be 0 and 1 because we index with them in various places,
|
// Note: these must be 0 and 1 because we index with them in various places,
|
||||||
// e.g. in Tile::priority_.
|
// e.g. in Tile::priority_.
|
||||||
ACTIVE_TREE = 0,
|
ACTIVE_TREE = 0,
|
||||||
PENDING_TREE = 1
|
PENDING_TREE = 1,
|
||||||
|
NUM_TREES = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TileResolution {
|
enum TileResolution {
|
||||||
|
Reference in New Issue
Block a user