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

Unified Diff: cc/trees/layer_tree_host.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.cc
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 773a689ac03749590685580a88dafb9cb92fcf0b..3b9da9006ce597344079868c5d94788b7bdb78d7 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -62,7 +62,10 @@ RendererCapabilities::RendererCapabilities()
RendererCapabilities::~RendererCapabilities() {}
UIResourceRequest::UIResourceRequest()
- : type(UIResourceInvalidRequest), id(0), bitmap(NULL) {}
+ : type(UIResourceInvalidRequest),
+ id(0),
+ bitmap(NULL),
+ eviction_count_recreated(0) {}
UIResourceRequest::~UIResourceRequest() {}
@@ -86,6 +89,7 @@ static int s_next_tree_id = 1;
LayerTreeHost::LayerTreeHost(LayerTreeHostClient* client,
const LayerTreeSettings& settings)
: next_ui_resource_id_(1),
+ ui_resource_eviction_count_recreated_(0),
animating_(false),
needs_full_tree_sync_(true),
needs_filter_context_(false),
@@ -379,6 +383,13 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
overhang_ui_resource_->GetSize());
}
+ // If all UI resource evictions will not be recreated by this commit, then
+ // another commit is required.
+ if (ui_resource_eviction_count_recreated_ !=
+ host_impl->ui_resource_eviction_count()) {
+ host_impl->SetNeedsCommit();
+ }
+
DCHECK(!sync_tree->ViewportSizeInvalid());
if (new_impl_tree_has_no_evicted_resources) {
@@ -444,9 +455,6 @@ void LayerTreeHost::DidLoseOutputSurface() {
if (output_surface_lost_)
return;
- bool resource_lost = true;
- RecreateUIResources(resource_lost);
-
num_failed_recreate_attempts_ = 0;
output_surface_lost_ = true;
SetNeedsCommit();
@@ -1176,7 +1184,11 @@ void LayerTreeHost::DeleteUIResource(UIResourceId uid) {
ui_resource_client_map_.erase(uid);
}
-void LayerTreeHost::RecreateUIResources(bool resource_lost) {
+bool LayerTreeHost::SetUIResourceEvictionCount(
+ uint64 ui_resource_eviction_count) {
+ if (ui_resource_eviction_count_recreated_ == ui_resource_eviction_count)
+ return false;
+
for (UIResourceClientMap::iterator iter = ui_resource_client_map_.begin();
iter != ui_resource_client_map_.end();
++iter) {
@@ -1184,10 +1196,18 @@ void LayerTreeHost::RecreateUIResources(bool resource_lost) {
UIResourceRequest request;
request.type = UIResourceRequest::UIResourceCreate;
request.id = uid;
+ bool resource_lost = true;
request.bitmap = iter->second->GetBitmap(uid, resource_lost);
DCHECK(request.bitmap.get());
ui_resource_request_queue_.push_back(request);
}
+ UIResourceRequest request;
+ request.type = UIResourceRequest::UIResourceEvictionRecreated;
+ request.eviction_count_recreated = ui_resource_eviction_count;
+ ui_resource_request_queue_.push_back(request);
+ ui_resource_eviction_count_recreated_ = ui_resource_eviction_count;
+
+ return true;
}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698