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

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 502453003: cc: Remove tiles from recycle tree that were deleted on active. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: don't maintain recycled twin Created 6 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
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layers/picture_layer_impl.h" 5 #include "cc/layers/picture_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/debug/trace_event_argument.h" 10 #include "base/debug/trace_event_argument.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // there are now tiles in this layer's tilings that were unref'd and replaced 102 // there are now tiles in this layer's tilings that were unref'd and replaced
103 // with new tiles (due to invalidation). This resets all active priorities on 103 // with new tiles (due to invalidation). This resets all active priorities on
104 // the to-be-recycled tiling to ensure replaced tiles don't linger and take 104 // the to-be-recycled tiling to ensure replaced tiles don't linger and take
105 // memory (due to a stale 'active' priority). 105 // memory (due to a stale 'active' priority).
106 if (layer_impl->tilings_) 106 if (layer_impl->tilings_)
107 layer_impl->tilings_->DidBecomeRecycled(); 107 layer_impl->tilings_->DidBecomeRecycled();
108 108
109 LayerImpl::PushPropertiesTo(base_layer); 109 LayerImpl::PushPropertiesTo(base_layer);
110 110
111 // When the pending tree pushes to the active tree, the pending twin 111 // When the pending tree pushes to the active tree, the pending twin
112 // disappears. 112 // becomes recycled.
113 layer_impl->twin_layer_ = NULL; 113 layer_impl->twin_layer_ = NULL;
114 twin_layer_ = NULL; 114 twin_layer_ = NULL;
115 115
116 layer_impl->SetIsMask(is_mask_); 116 layer_impl->SetIsMask(is_mask_);
117 layer_impl->pile_ = pile_; 117 layer_impl->pile_ = pile_;
118 118
119 // Tilings would be expensive to push, so we swap. 119 // Tilings would be expensive to push, so we swap.
120 layer_impl->tilings_.swap(tilings_); 120 layer_impl->tilings_.swap(tilings_);
121 121
122 // Remove invalidated tiles from what will become a recycle tree. 122 // Remove invalidated tiles from what will become a recycle tree.
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( 534 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect(
535 view_to_layer, viewport_rect_for_tile_priority_)); 535 view_to_layer, viewport_rect_for_tile_priority_));
536 536
537 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds())); 537 visible_rect_in_content_space.Intersect(gfx::Rect(content_bounds()));
538 } 538 }
539 } 539 }
540 540
541 return visible_rect_in_content_space; 541 return visible_rect_in_content_space;
542 } 542 }
543 543
544 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() {
545 // TODO(vmpstr): Maintain recycled twin as a member. crbug.com/407418
546 return static_cast<PictureLayerImpl*>(
547 layer_tree_impl()->FindRecycleTreeLayerById(id()));
548 }
549
544 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { 550 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) {
545 if (layer_tree_impl()->IsActiveTree()) { 551 if (layer_tree_impl()->IsActiveTree()) {
546 gfx::RectF layer_damage_rect = 552 gfx::RectF layer_damage_rect =
547 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); 553 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale());
548 AddDamageRect(layer_damage_rect); 554 AddDamageRect(layer_damage_rect);
549 } 555 }
550 } 556 }
551 557
552 void PictureLayerImpl::DidBecomeActive() { 558 void PictureLayerImpl::DidBecomeActive() {
553 LayerImpl::DidBecomeActive(); 559 LayerImpl::DidBecomeActive();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 return &invalidation_; 612 return &invalidation_;
607 } 613 }
608 614
609 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling( 615 const PictureLayerTiling* PictureLayerImpl::GetTwinTiling(
610 const PictureLayerTiling* tiling) const { 616 const PictureLayerTiling* tiling) const {
611 if (!twin_layer_) 617 if (!twin_layer_)
612 return NULL; 618 return NULL;
613 return twin_layer_->tilings_->TilingAtScale(tiling->contents_scale()); 619 return twin_layer_->tilings_->TilingAtScale(tiling->contents_scale());
614 } 620 }
615 621
622 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling(
623 const PictureLayerTiling* tiling) {
624 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
625 if (!recycled_twin || !recycled_twin->tilings_)
626 return NULL;
627 return recycled_twin->tilings_->TilingAtScale(tiling->contents_scale());
628 }
629
616 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const { 630 size_t PictureLayerImpl::GetMaxTilesForInterestArea() const {
617 return layer_tree_impl()->settings().max_tiles_for_interest_area; 631 return layer_tree_impl()->settings().max_tiles_for_interest_area;
618 } 632 }
619 633
620 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const { 634 float PictureLayerImpl::GetSkewportTargetTimeInSeconds() const {
621 float skewport_target_time_in_frames = 635 float skewport_target_time_in_frames =
622 layer_tree_impl()->use_gpu_rasterization() 636 layer_tree_impl()->use_gpu_rasterization()
623 ? kGpuSkewportTargetTimeInFrames 637 ? kGpuSkewportTargetTimeInFrames
624 : kCpuSkewportTargetTimeInFrames; 638 : kCpuSkewportTargetTimeInFrames;
625 return skewport_target_time_in_frames * 639 return skewport_target_time_in_frames *
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) != 1260 if (std::find(used_tilings.begin(), used_tilings.end(), tiling) !=
1247 used_tilings.end()) 1261 used_tilings.end())
1248 continue; 1262 continue;
1249 1263
1250 to_remove.push_back(tiling); 1264 to_remove.push_back(tiling);
1251 } 1265 }
1252 1266
1253 if (to_remove.empty()) 1267 if (to_remove.empty())
1254 return; 1268 return;
1255 1269
1256 PictureLayerImpl* recycled_twin = static_cast<PictureLayerImpl*>( 1270 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer();
1257 layer_tree_impl()->FindRecycleTreeLayerById(id()));
1258 // Remove tilings on this tree and the twin tree. 1271 // Remove tilings on this tree and the twin tree.
1259 for (size_t i = 0; i < to_remove.size(); ++i) { 1272 for (size_t i = 0; i < to_remove.size(); ++i) {
1260 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]); 1273 const PictureLayerTiling* twin_tiling = GetTwinTiling(to_remove[i]);
1261 // Only remove tilings from the twin layer if they have 1274 // Only remove tilings from the twin layer if they have
1262 // NON_IDEAL_RESOLUTION. 1275 // NON_IDEAL_RESOLUTION.
1263 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION) 1276 if (twin_tiling && twin_tiling->resolution() == NON_IDEAL_RESOLUTION)
1264 twin->RemoveTiling(to_remove[i]->contents_scale()); 1277 twin->RemoveTiling(to_remove[i]->contents_scale());
1265 // Remove the tiling from the recycle tree. Note that we ignore resolution, 1278 // Remove the tiling from the recycle tree. Note that we ignore resolution,
1266 // since we don't need to maintain high/low res on the recycle tree. 1279 // since we don't need to maintain high/low res on the recycle tree.
1267 if (recycled_twin) 1280 if (recycled_twin)
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1764 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1752 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1765 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1753 return tiling_range.end - 1 - current_tiling_range_offset; 1766 return tiling_range.end - 1 - current_tiling_range_offset;
1754 } 1767 }
1755 } 1768 }
1756 NOTREACHED(); 1769 NOTREACHED();
1757 return 0; 1770 return 0;
1758 } 1771 }
1759 1772
1760 } // namespace cc 1773 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl.h ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698