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

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: 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_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2763d33fbde49550b1dcc0cdb60f78e165ccbd13 100644
--- a/cc/trees/layer_tree_host_impl.cc
+++ b/cc/trees/layer_tree_host_impl.cc
@@ -200,7 +200,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_resources_evicted_(false) {
DCHECK(proxy_->IsImplThread());
DidVisibilityChange(this, visible_);
@@ -305,6 +306,14 @@ bool LayerTreeHostImpl::CanDraw() const {
TRACE_EVENT_SCOPE_THREAD);
return false;
}
+
+ if (ui_resources_evicted_) {
+ TRACE_EVENT_INSTANT0(
+ "cc", "LayerTreeHostImpl::CanDraw ui resources evicted",
+ TRACE_EVENT_SCOPE_THREAD);
+ return false;
+ }
+
return true;
}
@@ -1536,11 +1545,16 @@ 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
+ ui_resources_evicted_ = ui_resource_map_.size() > 0;
+ ReleaseUIResources();
+ }
+
if (!renderer_)
return;
@@ -1576,8 +1590,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(
@@ -2530,6 +2543,11 @@ void LayerTreeHostImpl::CreateUIResource(
gfx::Rect(bitmap->GetSize()),
gfx::Rect(bitmap->GetSize()),
gfx::Vector2d(0, 0));
+
+ // Once any UI resource creation has been completed, we can assume that the
+ // evicted UI resources will have been recovered by the time CanDraw is
+ // checked.
+ ui_resources_evicted_ = false;
}
void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
@@ -2548,4 +2566,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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698