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

Side by Side Diff: cc/trees/layer_tree_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 RenderTreePriority bug 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
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_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/animation/keyframed_animation_curve.h" 8 #include "cc/animation/keyframed_animation_curve.h"
9 #include "cc/animation/scrollbar_animation_controller.h" 9 #include "cc/animation/scrollbar_animation_controller.h"
10 #include "cc/debug/traced_value.h" 10 #include "cc/debug/traced_value.h"
(...skipping 15 matching lines...) Expand all
26 currently_scrolling_layer_(NULL), 26 currently_scrolling_layer_(NULL),
27 root_layer_scroll_offset_delegate_(NULL), 27 root_layer_scroll_offset_delegate_(NULL),
28 background_color_(0), 28 background_color_(0),
29 has_transparent_background_(false), 29 has_transparent_background_(false),
30 page_scale_factor_(1), 30 page_scale_factor_(1),
31 page_scale_delta_(1), 31 page_scale_delta_(1),
32 sent_page_scale_delta_(1), 32 sent_page_scale_delta_(1),
33 min_page_scale_factor_(0), 33 min_page_scale_factor_(0),
34 max_page_scale_factor_(0), 34 max_page_scale_factor_(0),
35 scrolling_layer_id_from_previous_tree_(0), 35 scrolling_layer_id_from_previous_tree_(0),
36 ui_resource_eviction_count_recreated_(0),
36 contents_textures_purged_(false), 37 contents_textures_purged_(false),
37 viewport_size_invalid_(false), 38 viewport_size_invalid_(false),
38 needs_update_draw_properties_(true), 39 needs_update_draw_properties_(true),
39 needs_full_tree_sync_(true) { 40 needs_full_tree_sync_(true) {
40 } 41 }
41 42
42 LayerTreeImpl::~LayerTreeImpl() { 43 LayerTreeImpl::~LayerTreeImpl() {
43 // Need to explicitly clear the tree prior to destroying this so that 44 // Need to explicitly clear the tree prior to destroying this so that
44 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor. 45 // the LayerTreeImpl pointer is still valid in the LayerImpl dtor.
45 root_layer_.reset(); 46 root_layer_.reset();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // LayerTreeHost::finishCommitOnImplThread(). 120 // LayerTreeHost::finishCommitOnImplThread().
120 target_tree->set_source_frame_number(source_frame_number()); 121 target_tree->set_source_frame_number(source_frame_number());
121 target_tree->set_background_color(background_color()); 122 target_tree->set_background_color(background_color());
122 target_tree->set_has_transparent_background(has_transparent_background()); 123 target_tree->set_has_transparent_background(has_transparent_background());
123 124
124 if (ContentsTexturesPurged()) 125 if (ContentsTexturesPurged())
125 target_tree->SetContentsTexturesPurged(); 126 target_tree->SetContentsTexturesPurged();
126 else 127 else
127 target_tree->ResetContentsTexturesPurged(); 128 target_tree->ResetContentsTexturesPurged();
128 129
130 target_tree->SetUIResourceEvictionCountRecreated(
131 ui_resource_eviction_count_recreated_);
132
129 if (ViewportSizeInvalid()) 133 if (ViewportSizeInvalid())
130 target_tree->SetViewportSizeInvalid(); 134 target_tree->SetViewportSizeInvalid();
131 else 135 else
132 target_tree->ResetViewportSizeInvalid(); 136 target_tree->ResetViewportSizeInvalid();
133 137
134 if (hud_layer()) 138 if (hud_layer())
135 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>( 139 target_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(
136 LayerTreeHostCommon::FindLayerInSubtree( 140 LayerTreeHostCommon::FindLayerInSubtree(
137 target_tree->root_layer(), hud_layer()->id()))); 141 target_tree->root_layer(), hud_layer()->id())));
138 else 142 else
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 380 }
377 381
378 void LayerTreeImpl::DidBecomeActive() { 382 void LayerTreeImpl::DidBecomeActive() {
379 if (!root_layer()) 383 if (!root_layer())
380 return; 384 return;
381 385
382 DidBecomeActiveRecursive(root_layer()); 386 DidBecomeActiveRecursive(root_layer());
383 FindRootScrollLayer(); 387 FindRootScrollLayer();
384 } 388 }
385 389
390 void LayerTreeImpl::SetUIResourceEvictionCountRecreated(
391 uint64 ui_resource_eviction_count_recreated) {
392 if (ui_resource_eviction_count_recreated ==
393 ui_resource_eviction_count_recreated_)
394 return;
395
396 ui_resource_eviction_count_recreated_ = ui_resource_eviction_count_recreated;
397 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
398 }
399
400 bool LayerTreeImpl::UIResourcesEvictedHaveNotBeenRecreated() const {
401 return layer_tree_host_impl_->ui_resource_eviction_count() !=
402 ui_resource_eviction_count_recreated_;
403 }
404
386 bool LayerTreeImpl::ContentsTexturesPurged() const { 405 bool LayerTreeImpl::ContentsTexturesPurged() const {
387 return contents_textures_purged_; 406 return contents_textures_purged_;
388 } 407 }
389 408
390 void LayerTreeImpl::SetContentsTexturesPurged() { 409 void LayerTreeImpl::SetContentsTexturesPurged() {
391 if (contents_textures_purged_) 410 if (contents_textures_purged_)
392 return; 411 return;
393 contents_textures_purged_ = true; 412 contents_textures_purged_ = true;
394 layer_tree_host_impl_->OnCanDrawStateChangedForTree(); 413 layer_tree_host_impl_->OnCanDrawStateChangedForTree();
395 } 414 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 UIResourceRequest req = ui_resource_request_queue_.front(); 636 UIResourceRequest req = ui_resource_request_queue_.front();
618 ui_resource_request_queue_.pop_front(); 637 ui_resource_request_queue_.pop_front();
619 638
620 switch (req.type) { 639 switch (req.type) {
621 case UIResourceRequest::UIResourceCreate: 640 case UIResourceRequest::UIResourceCreate:
622 layer_tree_host_impl_->CreateUIResource(req.id, req.bitmap); 641 layer_tree_host_impl_->CreateUIResource(req.id, req.bitmap);
623 break; 642 break;
624 case UIResourceRequest::UIResourceDelete: 643 case UIResourceRequest::UIResourceDelete:
625 layer_tree_host_impl_->DeleteUIResource(req.id); 644 layer_tree_host_impl_->DeleteUIResource(req.id);
626 break; 645 break;
646 case UIResourceRequest::UIResourceEvictionRecreated:
647 SetUIResourceEvictionCountRecreated(req.eviction_count_recreated);
648 break;
627 case UIResourceRequest::UIResourceInvalidRequest: 649 case UIResourceRequest::UIResourceInvalidRequest:
628 NOTREACHED(); 650 NOTREACHED();
629 break; 651 break;
630 } 652 }
631 } 653 }
632 } 654 }
633 655
634 void LayerTreeImpl::AddLayerWithCopyOutputRequest(LayerImpl* layer) { 656 void LayerTreeImpl::AddLayerWithCopyOutputRequest(LayerImpl* layer) {
635 // Only the active tree needs to know about layers with copy requests, as 657 // Only the active tree needs to know about layers with copy requests, as
636 // they are aborted if not serviced during draw. 658 // they are aborted if not serviced during draw.
(...skipping 21 matching lines...) Expand all
658 const std::vector<LayerImpl*> LayerTreeImpl::LayersWithCopyOutputRequest() 680 const std::vector<LayerImpl*> LayerTreeImpl::LayersWithCopyOutputRequest()
659 const { 681 const {
660 // Only the active tree needs to know about layers with copy requests, as 682 // Only the active tree needs to know about layers with copy requests, as
661 // they are aborted if not serviced during draw. 683 // they are aborted if not serviced during draw.
662 DCHECK(IsActiveTree()); 684 DCHECK(IsActiveTree());
663 685
664 return layers_with_copy_output_request_; 686 return layers_with_copy_output_request_;
665 } 687 }
666 688
667 } // namespace cc 689 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698