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

Side by Side Diff: cc/trees/layer_tree_host_impl.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 typo 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 "cc", "LayerTreeHostImpl::CanDraw viewport size recently changed", 328 "cc", "LayerTreeHostImpl::CanDraw viewport size recently changed",
329 TRACE_EVENT_SCOPE_THREAD); 329 TRACE_EVENT_SCOPE_THREAD);
330 return false; 330 return false;
331 } 331 }
332 if (active_tree_->ContentsTexturesPurged()) { 332 if (active_tree_->ContentsTexturesPurged()) {
333 TRACE_EVENT_INSTANT0( 333 TRACE_EVENT_INSTANT0(
334 "cc", "LayerTreeHostImpl::CanDraw contents textures purged", 334 "cc", "LayerTreeHostImpl::CanDraw contents textures purged",
335 TRACE_EVENT_SCOPE_THREAD); 335 TRACE_EVENT_SCOPE_THREAD);
336 return false; 336 return false;
337 } 337 }
338 if (EvictedUIResourcesExist()) {
339 TRACE_EVENT_INSTANT0(
340 "cc", "LayerTreeHostImpl::CanDraw UI resources evicted not recreated",
341 TRACE_EVENT_SCOPE_THREAD);
342 return false;
343 }
338 return true; 344 return true;
339 } 345 }
340 346
341 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time, 347 void LayerTreeHostImpl::Animate(base::TimeTicks monotonic_time,
342 base::Time wall_clock_time) { 348 base::Time wall_clock_time) {
343 if (input_handler_client_) 349 if (input_handler_client_)
344 input_handler_client_->Animate(monotonic_time); 350 input_handler_client_->Animate(monotonic_time);
345 AnimatePageScale(monotonic_time); 351 AnimatePageScale(monotonic_time);
346 AnimateLayers(monotonic_time, wall_clock_time); 352 AnimateLayers(monotonic_time, wall_clock_time);
347 AnimateScrollbars(monotonic_time); 353 AnimateScrollbars(monotonic_time);
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 1562
1557 void LayerTreeHostImpl::SetVisible(bool visible) { 1563 void LayerTreeHostImpl::SetVisible(bool visible) {
1558 DCHECK(proxy_->IsImplThread()); 1564 DCHECK(proxy_->IsImplThread());
1559 1565
1560 if (visible_ == visible) 1566 if (visible_ == visible)
1561 return; 1567 return;
1562 visible_ = visible; 1568 visible_ = visible;
1563 DidVisibilityChange(this, visible_); 1569 DidVisibilityChange(this, visible_);
1564 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1570 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
1565 1571
1572 if (!visible_)
1573 EvictAllUIResources();
1574
1566 // Evict tiles immediately if invisible since this tab may never get another 1575 // Evict tiles immediately if invisible since this tab may never get another
1567 // draw or timer tick. 1576 // draw or timer tick.
1568 if (!visible_) 1577 if (!visible_)
1569 ManageTiles(); 1578 ManageTiles();
1570 1579
1571 if (!renderer_) 1580 if (!renderer_)
1572 return; 1581 return;
1573 1582
1574 renderer_->SetVisible(visible); 1583 renderer_->SetVisible(visible);
1575 } 1584 }
(...skipping 20 matching lines...) Expand all
1596 } 1605 }
1597 1606
1598 void LayerTreeHostImpl::ReleaseTreeResources() { 1607 void LayerTreeHostImpl::ReleaseTreeResources() {
1599 if (active_tree_->root_layer()) 1608 if (active_tree_->root_layer())
1600 SendReleaseResourcesRecursive(active_tree_->root_layer()); 1609 SendReleaseResourcesRecursive(active_tree_->root_layer());
1601 if (pending_tree_ && pending_tree_->root_layer()) 1610 if (pending_tree_ && pending_tree_->root_layer())
1602 SendReleaseResourcesRecursive(pending_tree_->root_layer()); 1611 SendReleaseResourcesRecursive(pending_tree_->root_layer());
1603 if (recycle_tree_ && recycle_tree_->root_layer()) 1612 if (recycle_tree_ && recycle_tree_->root_layer())
1604 SendReleaseResourcesRecursive(recycle_tree_->root_layer()); 1613 SendReleaseResourcesRecursive(recycle_tree_->root_layer());
1605 1614
1606 DeleteAllUIResources(); 1615 EvictAllUIResources();
1607 } 1616 }
1608 1617
1609 void LayerTreeHostImpl::CreateAndSetRenderer( 1618 void LayerTreeHostImpl::CreateAndSetRenderer(
1610 OutputSurface* output_surface, 1619 OutputSurface* output_surface,
1611 ResourceProvider* resource_provider, 1620 ResourceProvider* resource_provider,
1612 bool skip_gl_renderer) { 1621 bool skip_gl_renderer) {
1613 DCHECK(!renderer_); 1622 DCHECK(!renderer_);
1614 if (output_surface->capabilities().delegated_rendering) { 1623 if (output_surface->capabilities().delegated_rendering) {
1615 renderer_ = DelegatingRenderer::Create( 1624 renderer_ = DelegatingRenderer::Create(
1616 this, &settings_, output_surface, resource_provider); 1625 this, &settings_, output_surface, resource_provider);
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 resource_provider_->best_texture_format(), 2643 resource_provider_->best_texture_format(),
2635 wrap_mode, 2644 wrap_mode,
2636 ResourceProvider::TextureUsageAny); 2645 ResourceProvider::TextureUsageAny);
2637 2646
2638 ui_resource_map_[uid] = id; 2647 ui_resource_map_[uid] = id;
2639 resource_provider_->SetPixels(id, 2648 resource_provider_->SetPixels(id,
2640 reinterpret_cast<uint8_t*>(bitmap->GetPixels()), 2649 reinterpret_cast<uint8_t*>(bitmap->GetPixels()),
2641 gfx::Rect(bitmap->GetSize()), 2650 gfx::Rect(bitmap->GetSize()),
2642 gfx::Rect(bitmap->GetSize()), 2651 gfx::Rect(bitmap->GetSize()),
2643 gfx::Vector2d(0, 0)); 2652 gfx::Vector2d(0, 0));
2653 MarkUIResourceNotEvicted(uid);
2644 } 2654 }
2645 2655
2646 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) { 2656 void LayerTreeHostImpl::DeleteUIResource(UIResourceId uid) {
2647 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid); 2657 ResourceProvider::ResourceId id = ResourceIdForUIResource(uid);
2648 if (id) { 2658 if (id) {
2649 resource_provider_->DeleteResource(id); 2659 resource_provider_->DeleteResource(id);
2650 ui_resource_map_.erase(uid); 2660 ui_resource_map_.erase(uid);
2651 } 2661 }
2662 MarkUIResourceNotEvicted(uid);
2652 } 2663 }
2653 2664
2654 void LayerTreeHostImpl::DeleteAllUIResources() { 2665 void LayerTreeHostImpl::EvictAllUIResources() {
2666 if (ui_resource_map_.empty())
2667 return;
2668
2655 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin(); 2669 for (UIResourceMap::const_iterator iter = ui_resource_map_.begin();
2656 iter != ui_resource_map_.end(); 2670 iter != ui_resource_map_.end();
2657 ++iter) { 2671 ++iter) {
2672 evicted_ui_resources_.insert(iter->first);
2658 resource_provider_->DeleteResource(iter->second); 2673 resource_provider_->DeleteResource(iter->second);
2659 } 2674 }
2660 ui_resource_map_.clear(); 2675 ui_resource_map_.clear();
2676
2677 client_->SetNeedsCommitOnImplThread();
2678 client_->OnCanDrawStateChanged(CanDraw());
2679 client_->RenewTreePriority();
2661 } 2680 }
2662 2681
2663 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource( 2682 ResourceProvider::ResourceId LayerTreeHostImpl::ResourceIdForUIResource(
2664 UIResourceId uid) const { 2683 UIResourceId uid) const {
2665 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid); 2684 UIResourceMap::const_iterator iter = ui_resource_map_.find(uid);
2666 if (iter != ui_resource_map_.end()) 2685 if (iter != ui_resource_map_.end())
2667 return iter->second; 2686 return iter->second;
2668 return 0; 2687 return 0;
2669 } 2688 }
2670 2689
2690 bool LayerTreeHostImpl::EvictedUIResourcesExist() const {
2691 return !evicted_ui_resources_.empty();
2692 }
2693
2694 void LayerTreeHostImpl::MarkUIResourceNotEvicted(UIResourceId uid) {
2695 std::set<UIResourceId>::iterator found_in_evicted =
2696 evicted_ui_resources_.find(uid);
2697 if (found_in_evicted == evicted_ui_resources_.end())
2698 return;
2699 evicted_ui_resources_.erase(found_in_evicted);
2700 if (evicted_ui_resources_.empty())
2701 client_->OnCanDrawStateChanged(CanDraw());
2702 }
2703
2671 } // namespace cc 2704 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698