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

Side by Side Diff: cc/resources/picture_layer_tiling.cc

Issue 366113002: cc: Do not cleanup tiles with raster tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use scopedvector for released tiles. Created 6 years, 5 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 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/resources/picture_layer_tiling.h" 5 #include "cc/resources/picture_layer_tiling.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << 87 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) <<
88 "Tiling created with scale too small as contents become empty." << 88 "Tiling created with scale too small as contents become empty." <<
89 " Layer bounds: " << layer_bounds.ToString() << 89 " Layer bounds: " << layer_bounds.ToString() <<
90 " Contents scale: " << contents_scale; 90 " Contents scale: " << contents_scale;
91 91
92 tiling_data_.SetTilingSize(content_bounds); 92 tiling_data_.SetTilingSize(content_bounds);
93 tiling_data_.SetMaxTextureSize(tile_size); 93 tiling_data_.SetMaxTextureSize(tile_size);
94 } 94 }
95 95
96 PictureLayerTiling::~PictureLayerTiling() { 96 PictureLayerTiling::~PictureLayerTiling() {
97 // Reset priority as tile is ref-counted and might still be used
98 // even though we no longer hold a reference to it here anymore.
99 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
100 it->second.get()->SetPriority(client_->GetTree(), TilePriority());
97 } 101 }
98 102
99 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { 103 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) {
100 client_ = client; 104 client_ = client;
101 } 105 }
102 106
103 Tile* PictureLayerTiling::CreateTile(int i, 107 Tile* PictureLayerTiling::CreateTile(int i,
104 int j, 108 int j,
105 const PictureLayerTiling* twin_tiling) { 109 const PictureLayerTiling* twin_tiling) {
106 TileMapKey key(i, j); 110 TileMapKey key(i, j);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 continue; 211 continue;
208 bool include_borders = true; 212 bool include_borders = true;
209 for (TilingData::Iterator iter( 213 for (TilingData::Iterator iter(
210 &tiling_data_, content_rect, include_borders); 214 &tiling_data_, content_rect, include_borders);
211 iter; 215 iter;
212 ++iter) { 216 ++iter) {
213 TileMapKey key(iter.index()); 217 TileMapKey key(iter.index());
214 TileMap::iterator find = tiles_.find(key); 218 TileMap::iterator find = tiles_.find(key);
215 if (find == tiles_.end()) 219 if (find == tiles_.end())
216 continue; 220 continue;
221
222 // Reset priority as tile is ref-counted and might still be used
223 // even though we no longer hold a reference to it here anymore.
224 find->second.get()->SetPriority(client_->GetTree(), TilePriority());
225
217 tiles_.erase(find); 226 tiles_.erase(find);
218 new_tile_keys.push_back(key); 227 new_tile_keys.push_back(key);
219 } 228 }
220 } 229 }
221 230
222 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { 231 if (recreate_invalidated_tiles && !new_tile_keys.empty()) {
223 for (size_t i = 0; i < new_tile_keys.size(); ++i) { 232 for (size_t i = 0; i < new_tile_keys.size(); ++i) {
224 // Don't try to share a tile with the twin layer, it's been invalidated so 233 // Don't try to share a tile with the twin layer, it's been invalidated so
225 // we have to make our own tile here. 234 // we have to make our own tile here.
226 const PictureLayerTiling* twin_tiling = NULL; 235 const PictureLayerTiling* twin_tiling = NULL;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 // Iterate to delete all tiles outside of our new live_tiles rect. 600 // Iterate to delete all tiles outside of our new live_tiles rect.
592 for (TilingData::DifferenceIterator iter(&tiling_data_, 601 for (TilingData::DifferenceIterator iter(&tiling_data_,
593 live_tiles_rect_, 602 live_tiles_rect_,
594 new_live_tiles_rect); 603 new_live_tiles_rect);
595 iter; 604 iter;
596 ++iter) { 605 ++iter) {
597 TileMapKey key(iter.index()); 606 TileMapKey key(iter.index());
598 TileMap::iterator found = tiles_.find(key); 607 TileMap::iterator found = tiles_.find(key);
599 // If the tile was outside of the recorded region, it won't exist even 608 // If the tile was outside of the recorded region, it won't exist even
600 // though it was in the live rect. 609 // though it was in the live rect.
601 if (found != tiles_.end()) 610 if (found != tiles_.end()) {
611 // Reset priority as tile is ref-counted and might still be used
612 // even though we no longer hold a reference to it here anymore.
613 found->second.get()->SetPriority(client_->GetTree(), TilePriority());
602 tiles_.erase(found); 614 tiles_.erase(found);
615 }
603 } 616 }
604 617
605 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 618 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
606 619
607 // Iterate to allocate new tiles for all regions with newly exposed area. 620 // Iterate to allocate new tiles for all regions with newly exposed area.
608 for (TilingData::DifferenceIterator iter(&tiling_data_, 621 for (TilingData::DifferenceIterator iter(&tiling_data_,
609 new_live_tiles_rect, 622 new_live_tiles_rect,
610 live_tiles_rect_); 623 live_tiles_rect_);
611 iter; 624 iter;
612 ++iter) { 625 ++iter) {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); 1000 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_);
988 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); 1001 tile_iterator_ = tiling_->eviction_tiles_cache_.begin();
989 is_valid_ = true; 1002 is_valid_ = true;
990 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && 1003 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() &&
991 !(*tile_iterator_)->HasResources()) { 1004 !(*tile_iterator_)->HasResources()) {
992 ++(*this); 1005 ++(*this);
993 } 1006 }
994 } 1007 }
995 1008
996 } // namespace cc 1009 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/tile.h » ('j') | cc/resources/tile.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698