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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 261
262 client_->SendManagedMemoryStats(); 262 client_->SendManagedMemoryStats();
263 } 263 }
264 264
265 bool LayerTreeHostImpl::CanDraw() const { 265 bool LayerTreeHostImpl::CanDraw() const {
266 // Note: If you are changing this function or any other function that might 266 // Note: If you are changing this function or any other function that might
267 // affect the result of CanDraw, make sure to call 267 // affect the result of CanDraw, make sure to call
268 // client_->OnCanDrawStateChanged in the proper places and update the 268 // client_->OnCanDrawStateChanged in the proper places and update the
269 // NotifyIfCanDrawChanged test. 269 // NotifyIfCanDrawChanged test.
270 270
ccameron 2013/08/26 23:54:32 You probably need to make sure that this returns f
271 if (!renderer_) { 271 if (!renderer_) {
272 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no renderer", 272 TRACE_EVENT_INSTANT0("cc", "LayerTreeHostImpl::CanDraw no renderer",
273 TRACE_EVENT_SCOPE_THREAD); 273 TRACE_EVENT_SCOPE_THREAD);
274 return false; 274 return false;
275 } 275 }
276 276
277 // Must have an OutputSurface if |renderer_| is not NULL. 277 // Must have an OutputSurface if |renderer_| is not NULL.
278 DCHECK(output_surface_); 278 DCHECK(output_surface_);
279 279
280 // TODO(boliu): Make draws without root_layer work and move this below 280 // TODO(boliu): Make draws without root_layer work and move this below
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1529
1530 void LayerTreeHostImpl::SetVisible(bool visible) { 1530 void LayerTreeHostImpl::SetVisible(bool visible) {
1531 DCHECK(proxy_->IsImplThread()); 1531 DCHECK(proxy_->IsImplThread());
1532 1532
1533 if (visible_ == visible) 1533 if (visible_ == visible)
1534 return; 1534 return;
1535 visible_ = visible; 1535 visible_ = visible;
1536 DidVisibilityChange(this, visible_); 1536 DidVisibilityChange(this, visible_);
1537 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1537 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1538 1538
1539 // Evict tiles immediately if invisible since this tab may never get another 1539 if (!visible_) {
1540 // draw or timer tick. 1540 // Evict tiles immediately if invisible since this tab may never get another
1541 if (!visible_) 1541 // draw or timer tick.
1542 ManageTiles(); 1542 ManageTiles();
1543 1543
1544 // Evict UI resources
1545 ReleaseUIResources();
1546 }
1547
1544 if (!renderer_) 1548 if (!renderer_)
1545 return; 1549 return;
1546 1550
1547 renderer_->SetVisible(visible); 1551 renderer_->SetVisible(visible);
1548 } 1552 }
1549 1553
1550 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const { 1554 ManagedMemoryPolicy LayerTreeHostImpl::ActualManagedMemoryPolicy() const {
1551 ManagedMemoryPolicy actual = cached_managed_memory_policy_; 1555 ManagedMemoryPolicy actual = cached_managed_memory_policy_;
1552 if (debug_state_.rasterize_only_visible_content) { 1556 if (debug_state_.rasterize_only_visible_content) {
1553 actual.priority_cutoff_when_not_visible = 1557 actual.priority_cutoff_when_not_visible =
(...skipping 15 matching lines...) Expand all
1569 } 1573 }
1570 1574
1571 void LayerTreeHostImpl::ReleaseTreeResources() { 1575 void LayerTreeHostImpl::ReleaseTreeResources() {
1572 if (active_tree_->root_layer()) 1576 if (active_tree_->root_layer())
1573 SendReleaseResourcesRecursive(active_tree_->root_layer()); 1577 SendReleaseResourcesRecursive(active_tree_->root_layer());
1574 if (pending_tree_ && pending_tree_->root_layer()) 1578 if (pending_tree_ && pending_tree_->root_layer())
1575 SendReleaseResourcesRecursive(pending_tree_->root_layer()); 1579 SendReleaseResourcesRecursive(pending_tree_->root_layer());
1576 if (recycle_tree_ && recycle_tree_->root_layer()) 1580 if (recycle_tree_ && recycle_tree_->root_layer())
1577 SendReleaseResourcesRecursive(recycle_tree_->root_layer()); 1581 SendReleaseResourcesRecursive(recycle_tree_->root_layer());
1578 1582
1579 // Remove all existing maps from UIResourceId to ResourceId. 1583 ReleaseUIResources();
1580 ui_resource_map_.clear();
1581 } 1584 }
1582 1585
1583 void LayerTreeHostImpl::CreateAndSetRenderer( 1586 void LayerTreeHostImpl::CreateAndSetRenderer(
1584 OutputSurface* output_surface, 1587 OutputSurface* output_surface,
1585 ResourceProvider* resource_provider, 1588 ResourceProvider* resource_provider,
1586 bool skip_gl_renderer) { 1589 bool skip_gl_renderer) {
1587 DCHECK(!renderer_); 1590 DCHECK(!renderer_);
1588 if (output_surface->capabilities().delegated_rendering) { 1591 if (output_surface->capabilities().delegated_rendering) {
1589 renderer_ = 1592 renderer_ =
1590 DelegatingRenderer::Create(this, output_surface, resource_provider); 1593 DelegatingRenderer::Create(this, output_surface, resource_provider);
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 } 2544 }
2542 2545
2543 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2546 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2544 UIResourceId uid) const { 2547 UIResourceId uid) const {
2545 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2548 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2546 if (iter != ui_resource_map_.end()) 2549 if (iter != ui_resource_map_.end())
2547 return iter->second; 2550 return iter->second;
2548 return 0; 2551 return 0;
2549 } 2552 }
2550 2553
2554 void LayerTreeHostImpl::ReleaseUIResources() {
2555 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin();
2556 iter != ui_resource_map_.end();
2557 ++iter) {
2558 resource_provider_->DeleteResource(iter->second);
2559 }
2560 ui_resource_map_.clear();
2561 }
2562
2551 } // namespace cc 2563 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698