Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 23548022: [cc] Evict UIResources when the renderer is not visible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix names Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/trees/layer_tree_host_impl.cc
diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
index 08e4ac16366b7a4e3b1de129cd5b81d1c7a994d1..d6bebf57d3aee896ec46a59f346844b3e9d8bb47 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -201,7 +201,8 @@ LayerTreeHostImpl::LayerTreeHostImpl(
external_stencil_test_enabled_(false),
animation_registrar_(AnimationRegistrar::Create()),
rendering_stats_instrumentation_(rendering_stats_instrumentation),
- need_to_update_visible_tiles_before_draw_(false) {
+ need_to_update_visible_tiles_before_draw_(false),
+ ui_resource_eviction_count_(0) {
DCHECK(proxy_->IsImplThread());
DidVisibilityChange(this, visible_);
@@ -311,6 +312,13 @@ bool LayerTreeHostImpl::CanDraw() const {
TRACE_EVENT_SCOPE_THREAD);
return false;
}
+ if (active_tree_->ui_resource_eviction_count_recreated() !=
+ ui_resource_eviction_count()) {
+ TRACE_EVENT_INSTANT0(
+ "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
+ TRACE_EVENT_SCOPE_THREAD);
+ return false;
+ }
return true;
}
@@ -1558,6 +1566,9 @@ void LayerTreeHostImpl::SetVisible(bool visible) {
DidVisibilityChange(this, visible_);
EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
+ if (!visible_)
+ DeleteAllUIResources();
+
// Evict tiles immediately if invisible since this tab may never get another
// draw or timer tick.
if (!visible_)
@@ -2639,12 +2650,20 @@ void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
}
void LayerTreeHostImpl::DeleteAllUIResources() {
+ if (ui_resource_map_.empty())
+ return;
+
for (UIResourceMap::const_iterator iter = ui_resource_map_.begin();
iter != ui_resource_map_.end();
++iter) {
resource_provider_->DeleteResource(iter->second);
}
ui_resource_map_.clear();
+
+ ui_resource_eviction_count_ += 1;
+ client_->SetNeedsCommitOnImplThread();
+ client_->OnCanDrawStateChanged(CanDraw());
+ client_->RenewTreePriority();
powei 2013/09/09 20:34:25 Maybe a stupid question, but what's the purpose of
ccameron 2013/09/09 21:01:16 Oops! I needed to update RenewTreePriority to "pre
}
ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(

Powered by Google App Engine
This is Rietveld 408576698