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

Unified Diff: cc/trees/layer_tree_host.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: CanDraw returns false when UI resources are evicted 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
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index cb76b46769dc7bb82f0c7cedf9e4fe06a326d402..5c3a0572c119786dbe5c2da0f2670556dfd4f5e5 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -435,7 +435,8 @@ void LayerTreeHost::DidLoseOutputSurface() {
if (output_surface_lost_)
return;
- DidLoseUIResources();
+ bool resource_lost = true;
+ RecreateUIResources(resource_lost);
num_failed_recreate_attempts_ = 0;
output_surface_lost_ = true;
@@ -626,8 +627,13 @@ void LayerTreeHost::SetVisible(bool visible) {
if (visible_ == visible)
return;
visible_ = visible;
- if (!visible)
+ if (!visible) {
ReduceMemoryUsage();
+ } else {
+ // Recreate the UI resources since they were evicted when SetVisible(false).
+ bool resource_lost = false;
+ RecreateUIResources(resource_lost);
+ }
proxy_->SetVisible(visible);
}
@@ -1155,26 +1161,18 @@ void LayerTreeHost::DeleteUIResource(UIResourceId uid) {
ui_resource_client_map_.erase(uid);
}
-void LayerTreeHost::UIResourceLost(UIResourceId uid) {
- UIResourceClientMap::iterator iter = ui_resource_client_map_.find(uid);
- if (iter == ui_resource_client_map_.end())
- return;
-
- UIResourceRequest request;
- bool resource_lost = true;
- request.type = UIResourceRequest::UIResourceCreate;
- request.id = uid;
- request.bitmap = iter->second->GetBitmap(uid, resource_lost);
- DCHECK(request.bitmap.get());
- ui_resource_request_queue_.push_back(request);
-}
-
-void LayerTreeHost::DidLoseUIResources() {
+void LayerTreeHost::RecreateUIResources(bool resource_lost) {
// When output surface is lost, we need to recreate the resource.
for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin();
iter != ui_resource_client_map_.end();
++iter) {
- UIResourceLost(iter->first);
+ UIResourceId uid = iter->first;
+ UIResourceRequest request;
+ request.type = UIResourceRequest::UIResourceCreate;
+ request.id = uid;
+ request.bitmap = iter->second->GetBitmap(uid, resource_lost);
+ DCHECK(request.bitmap.get());
+ ui_resource_request_queue_.push_back(request);
}
}
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698