summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 17:42:25 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-12 17:42:25 +0000
commitb0a917c8d9e4a77fecb9fa2ffe570eb3e51f3f83 (patch)
tree4e9eb697887f7e7c121df32cc7cba1835318f322 /cc
parent7506d2ef2b909759f0bb1ee3938fff20f8bf5005 (diff)
downloadchromium_src-b0a917c8d9e4a77fecb9fa2ffe570eb3e51f3f83.zip
chromium_src-b0a917c8d9e4a77fecb9fa2ffe570eb3e51f3f83.tar.gz
chromium_src-b0a917c8d9e4a77fecb9fa2ffe570eb3e51f3f83.tar.bz2
cc: Walk layer tree to determine if pending tree can be activated.
Remove bin counts from tile manager and instead add a AreVisibleResourcesReady() function to LayerTreeImpl that can be used by LTHI to determine if pending tree can be activated. BUG=168119 Review URL: https://chromiumcodereview.appspot.com/11828027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176560 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layer_impl.cc5
-rw-r--r--cc/layer_impl.h2
-rw-r--r--cc/layer_tree_host_impl.cc13
-rw-r--r--cc/layer_tree_impl.cc17
-rw-r--r--cc/layer_tree_impl.h2
-rw-r--r--cc/picture_layer_impl.cc24
-rw-r--r--cc/picture_layer_impl.h2
-rw-r--r--cc/picture_layer_tiling.cc2
-rw-r--r--cc/picture_layer_tiling.h7
-rw-r--r--cc/picture_layer_tiling_set.h3
-rw-r--r--cc/tile_manager.cc55
-rw-r--r--cc/tile_manager.h11
12 files changed, 72 insertions, 71 deletions
diff --git a/cc/layer_impl.cc b/cc/layer_impl.cc
index 04d01aa..f9c3271 100644
--- a/cc/layer_impl.cc
+++ b/cc/layer_impl.cc
@@ -297,6 +297,11 @@ bool LayerImpl::canClipSelf() const
return false;
}
+bool LayerImpl::areVisibleResourcesReady() const
+{
+ return true;
+}
+
std::string LayerImpl::indentString(int indent)
{
std::string str;
diff --git a/cc/layer_impl.h b/cc/layer_impl.h
index 540d4e3..01c0b66 100644
--- a/cc/layer_impl.h
+++ b/cc/layer_impl.h
@@ -293,6 +293,8 @@ public:
virtual bool canClipSelf() const;
+ virtual bool areVisibleResourcesReady() const;
+
protected:
LayerImpl(LayerTreeImpl* layerImpl, int);
diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc
index 31f8ac9..0aa769b 100644
--- a/cc/layer_tree_host_impl.cc
+++ b/cc/layer_tree_host_impl.cc
@@ -929,14 +929,11 @@ void LayerTreeHostImpl::activatePendingTreeIfNeeded()
if (!pendingTree())
return;
- int total_pending = m_tileManager->GetTilesInBinCount(NOW_BIN, PENDING_TREE);
- int drawable_pending = m_tileManager->GetDrawableTilesInBinCount(NOW_BIN, PENDING_TREE);
- int total_active = m_tileManager->GetTilesInBinCount(NOW_BIN, ACTIVE_TREE);
-
- // It's always fine to activate to or from an empty tree. Otherwise, only
- // activate once all high res visible tiles are ready on the pending tree.
- if (total_pending && total_active && total_pending != drawable_pending)
- return;
+ // It's always fine to activate to an empty tree. Otherwise, only
+ // activate once all visible resources in pending tree are ready.
+ if (activeTree()->RootLayer() &&
+ !pendingTree()->AreVisibleResourcesReady())
+ return;
activatePendingTree();
}
diff --git a/cc/layer_tree_impl.cc b/cc/layer_tree_impl.cc
index d94d38f..55e6c13 100644
--- a/cc/layer_tree_impl.cc
+++ b/cc/layer_tree_impl.cc
@@ -152,6 +152,23 @@ void LayerTreeImpl::ClearRenderSurfaces() {
SetNeedsUpdateDrawProperties();
}
+bool LayerTreeImpl::AreVisibleResourcesReady() const {
+ TRACE_EVENT0("cc", "LayerTreeImpl::AreVisibleResourcesReady");
+
+ typedef LayerIterator<LayerImpl,
+ std::vector<LayerImpl*>,
+ RenderSurfaceImpl,
+ LayerIteratorActions::BackToFront> LayerIteratorType;
+ LayerIteratorType end = LayerIteratorType::end(&render_surface_layer_list_);
+ for (LayerIteratorType it = LayerIteratorType::begin(
+ &render_surface_layer_list_); it != end; ++it) {
+ if (it.representsItself() && !(*it)->areVisibleResourcesReady())
+ return false;
+ }
+
+ return true;
+}
+
const LayerTreeImpl::LayerList& LayerTreeImpl::RenderSurfaceLayerList() const {
// If this assert triggers, then the list is dirty.
DCHECK(!layer_tree_host_impl_->needsUpdateDrawProperties());
diff --git a/cc/layer_tree_impl.h b/cc/layer_tree_impl.h
index a858891..6ff31c1 100644
--- a/cc/layer_tree_impl.h
+++ b/cc/layer_tree_impl.h
@@ -119,6 +119,8 @@ class CC_EXPORT LayerTreeImpl {
void ClearRenderSurfaces();
+ bool AreVisibleResourcesReady() const;
+
const LayerList& RenderSurfaceLayerList() const;
gfx::Size ContentSize() const;
diff --git a/cc/picture_layer_impl.cc b/cc/picture_layer_impl.cc
index 8d33a64..8d7b3ea 100644
--- a/cc/picture_layer_impl.cc
+++ b/cc/picture_layer_impl.cc
@@ -280,6 +280,30 @@ ResourceProvider::ResourceId PictureLayerImpl::contentsResourceId() const {
return 0;
}
+bool PictureLayerImpl::areVisibleResourcesReady() const {
+ const gfx::Rect& rect = visibleContentRect();
+
+ for (size_t i = 0; i < tilings_.num_tilings(); ++i) {
+ const PictureLayerTiling* tiling = tilings_.tiling_at(i);
+
+ // Ignore non-high resolution tilings.
+ if (tiling->resolution() != HIGH_RESOLUTION)
+ continue;
+
+ for (PictureLayerTiling::Iterator iter(tiling,
+ tiling->contents_scale(),
+ rect);
+ iter;
+ ++iter) {
+ // Resource not ready yet.
+ if (!*iter || !iter->GetResourceId())
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) {
if (contents_scale < layerTreeImpl()->settings().minimumContentsScale)
return NULL;
diff --git a/cc/picture_layer_impl.h b/cc/picture_layer_impl.h
index 1712b44..c67664c 100644
--- a/cc/picture_layer_impl.h
+++ b/cc/picture_layer_impl.h
@@ -51,6 +51,8 @@ public:
void SetIsMask(bool is_mask);
virtual ResourceProvider::ResourceId contentsResourceId() const OVERRIDE;
+ virtual bool areVisibleResourcesReady() const OVERRIDE;
+
protected:
PictureLayerImpl(LayerTreeImpl* treeImpl, int id);
PictureLayerTiling* AddTiling(float contents_scale);
diff --git a/cc/picture_layer_tiling.cc b/cc/picture_layer_tiling.cc
index 43d52c7..4ad4917 100644
--- a/cc/picture_layer_tiling.cc
+++ b/cc/picture_layer_tiling.cc
@@ -144,7 +144,7 @@ PictureLayerTiling::Iterator::Iterator()
bottom_(0) {
}
-PictureLayerTiling::Iterator::Iterator(PictureLayerTiling* tiling,
+PictureLayerTiling::Iterator::Iterator(const PictureLayerTiling* tiling,
float dest_scale,
gfx::Rect dest_rect)
: tiling_(tiling),
diff --git a/cc/picture_layer_tiling.h b/cc/picture_layer_tiling.h
index 38ef4c6..b0f1b91 100644
--- a/cc/picture_layer_tiling.h
+++ b/cc/picture_layer_tiling.h
@@ -52,7 +52,10 @@ class CC_EXPORT PictureLayerTiling {
class CC_EXPORT Iterator {
public:
Iterator();
- Iterator(PictureLayerTiling* tiling, float dest_scale, gfx::Rect rect);
+ Iterator(
+ const PictureLayerTiling* tiling,
+ float dest_scale,
+ gfx::Rect rect);
~Iterator();
// Visible rect (no borders), always in the space of content_rect,
@@ -69,7 +72,7 @@ class CC_EXPORT PictureLayerTiling {
operator bool() const { return tile_j_ <= bottom_; }
private:
- PictureLayerTiling* tiling_;
+ const PictureLayerTiling* tiling_;
gfx::Rect dest_rect_;
float dest_to_content_scale_;
diff --git a/cc/picture_layer_tiling_set.h b/cc/picture_layer_tiling_set.h
index 72b583e..1994173 100644
--- a/cc/picture_layer_tiling_set.h
+++ b/cc/picture_layer_tiling_set.h
@@ -31,6 +31,9 @@ class CC_EXPORT PictureLayerTilingSet {
gfx::Size tile_size);
size_t num_tilings() const { return tilings_.size(); }
PictureLayerTiling* tiling_at(size_t idx) { return tilings_[idx]; }
+ const PictureLayerTiling* tiling_at(size_t idx) const {
+ return tilings_[idx];
+ }
// Remove all tilings.
void RemoveAllTilings();
diff --git a/cc/tile_manager.cc b/cc/tile_manager.cc
index a75b715..c0a4c94 100644
--- a/cc/tile_manager.cc
+++ b/cc/tile_manager.cc
@@ -80,7 +80,6 @@ TileManager::TileManager(
manage_tiles_pending_(false),
manage_tiles_call_count_(0),
check_for_completed_set_pixels_pending_(false) {
- ResetBinCounts();
}
TileManager::~TileManager() {
@@ -158,8 +157,8 @@ public:
bool operator() (const Tile* a, const Tile* b) const {
const ManagedTileState& ams = a->managed_state();
const ManagedTileState& bms = b->managed_state();
- if (ams.raster_bin != bms.raster_bin)
- return ams.raster_bin < bms.raster_bin;
+ if (ams.bin != bms.bin)
+ return ams.bin < bms.bin;
if (ams.resolution != bms.resolution)
return ams.resolution < bms.resolution;
@@ -182,8 +181,6 @@ void TileManager::ManageTiles() {
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
Tile* tile = *it;
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;
if (smoothness_takes_priority)
@@ -193,7 +190,7 @@ void TileManager::ManageTiles() {
mts.resolution = prio.resolution;
mts.time_to_needed_in_seconds = prio.time_to_needed_in_seconds();
- mts.raster_bin = BinFromTilePriority(prio);
+ mts.bin = BinFromTilePriority(prio);
mts.gpu_memmgr_stats_bin = BinFromTilePriority(tile->combined_priority());
}
@@ -223,24 +220,7 @@ void TileManager::ManageTiles() {
for (TileVector::iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
Tile* tile = *it;
ManagedTileState& mts = tile->managed_state();
- 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]++;
- }
+ mts.bin = bin_map[mts.bin];
}
// Sort by bin.
@@ -285,23 +265,6 @@ void TileManager::GetRenderingStats(RenderingStats* stats) {
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::GetMemoryStats(
size_t* memoryRequiredBytes,
size_t* memoryNiceToHaveBytes,
@@ -322,12 +285,6 @@ void TileManager::GetMemoryStats(
}
}
-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() {
TRACE_EVENT0("cc", "TileManager::AssignGpuMemoryToTiles");
// Some memory cannot be released. Figure out which.
@@ -356,7 +313,7 @@ void TileManager::AssignGpuMemoryToTiles() {
ManagedTileState& managed_tile_state = tile->managed_state();
if (!managed_tile_state.can_be_freed)
continue;
- if (managed_tile_state.raster_bin == NEVER_BIN) {
+ if (managed_tile_state.bin == NEVER_BIN) {
managed_tile_state.can_use_gpu_memory = false;
FreeResourcesForTile(tile);
continue;
@@ -574,8 +531,6 @@ void TileManager::DidFinishTileInitialization(Tile* tile) {
DCHECK(managed_tile_state.resource);
managed_tile_state.resource_is_being_initialized = false;
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]++;
}
} // namespace cc
diff --git a/cc/tile_manager.h b/cc/tile_manager.h
index 7496a15..f9a3601b 100644
--- a/cc/tile_manager.h
+++ b/cc/tile_manager.h
@@ -58,9 +58,7 @@ class CC_EXPORT ManagedTileState {
std::list<skia::LazyPixelRef*> pending_pixel_refs;
// Ephemeral state, valid only during Manage.
- TileManagerBin bin[NUM_TREES];
- // Bin used to determine raster priority.
- TileManagerBin raster_bin;
+ TileManagerBin bin;
// The bin that the tile would have if the GPU memory manager had a maximally permissive policy,
// send to the GPU memory manager to determine policy.
TileManagerBin gpu_memmgr_stats_bin;
@@ -92,9 +90,6 @@ class CC_EXPORT TileManager {
void GetRenderingStats(RenderingStats* stats);
- int GetTilesInBinCount(TileManagerBin bin, WhichTree tree);
- int GetDrawableTilesInBinCount(TileManagerBin bin, WhichTree tree);
-
protected:
// Methods called by Tile
friend class Tile;
@@ -104,7 +99,6 @@ class CC_EXPORT TileManager {
Tile* tile, WhichTree tree, const TilePriority& new_priority);
private:
- void ResetBinCounts();
void AssignGpuMemoryToTiles();
void FreeResourcesForTile(Tile* tile);
void ScheduleManageTiles();
@@ -132,9 +126,6 @@ class CC_EXPORT TileManager {
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;
TileVector tiles_;
TileVector tiles_that_need_to_be_rasterized_;