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

Unified Diff: cc/trees/layer_tree_host_impl.cc

Issue 23478004: UI resource are evicted when LTH is set to not visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 1131050dc695a131dfee529af78852843b05ae7e..cc72e84bb27ec308b0c20c70da47b62ee285d90e 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -1536,11 +1536,15 @@ void LayerTreeHostImpl::SetVisible(bool visible) {
DidVisibilityChange(this, visible_);
EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
- // Evict tiles immediately if invisible since this tab may never get another
- // draw or timer tick.
- if (!visible_)
+ if (!visible_) {
+ // Evict tiles immediately if invisible since this tab may never get another
+ // draw or timer tick.
ManageTiles();
+ // Evict UI resources
+ ReleaseUIResources();
+ }
+
if (!renderer_)
return;
@@ -1576,8 +1580,7 @@ void LayerTreeHostImpl::ReleaseTreeResources() {
if (recycle_tree_ && recycle_tree_->root_layer())
SendReleaseResourcesRecursive(recycle_tree_->root_layer());
- // Remove all existing maps from UIResourceId to ResourceId.
- ui_resource_map_.clear();
+ ReleaseUIResources();
}
void LayerTreeHostImpl::CreateAndSetRenderer(
@@ -2548,4 +2551,13 @@ ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
return 0;
}
+void LayerTreeHostImpl::ReleaseUIResources() {
+ for (UIResourceMap::const_iterator iter = ui_resource_map_.begin();
+ iter != ui_resource_map_.end();
+ ++iter) {
+ resource_provider_->DeleteResource(iter->second);
+ }
+ ui_resource_map_.clear();
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698