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

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: nits updated. Created 6 years, 4 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/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.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/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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (a_is_occluded != b_is_occluded) 50 if (a_is_occluded != b_is_occluded)
51 return a_is_occluded; 51 return a_is_occluded;
52 52
53 // Or if a is farther away from visible. 53 // Or if a is farther away from visible.
54 return a_priority.distance_to_visible > b_priority.distance_to_visible; 54 return a_priority.distance_to_visible > b_priority.distance_to_visible;
55 } 55 }
56 56
57 private: 57 private:
58 TreePriority tree_priority_; 58 TreePriority tree_priority_;
59 }; 59 };
60
61 void ReleaseTile(Tile* tile, WhichTree tree) {
62 // Reset priority as tile is ref-counted and might still be used
63 // even though we no longer hold a reference to it here anymore.
64 tile->SetPriority(tree, TilePriority());
65 }
66
60 } // namespace 67 } // namespace
61 68
62 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( 69 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create(
63 float contents_scale, 70 float contents_scale,
64 const gfx::Size& layer_bounds, 71 const gfx::Size& layer_bounds,
65 PictureLayerTilingClient* client) { 72 PictureLayerTilingClient* client) {
66 return make_scoped_ptr(new PictureLayerTiling(contents_scale, 73 return make_scoped_ptr(new PictureLayerTiling(contents_scale,
67 layer_bounds, 74 layer_bounds,
68 client)); 75 client));
69 } 76 }
(...skipping 21 matching lines...) Expand all
91 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << 98 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) <<
92 "Tiling created with scale too small as contents become empty." << 99 "Tiling created with scale too small as contents become empty." <<
93 " Layer bounds: " << layer_bounds.ToString() << 100 " Layer bounds: " << layer_bounds.ToString() <<
94 " Contents scale: " << contents_scale; 101 " Contents scale: " << contents_scale;
95 102
96 tiling_data_.SetTilingSize(content_bounds); 103 tiling_data_.SetTilingSize(content_bounds);
97 tiling_data_.SetMaxTextureSize(tile_size); 104 tiling_data_.SetMaxTextureSize(tile_size);
98 } 105 }
99 106
100 PictureLayerTiling::~PictureLayerTiling() { 107 PictureLayerTiling::~PictureLayerTiling() {
108 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
109 ReleaseTile(it->second.get(), client_->GetTree());
101 } 110 }
102 111
103 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) { 112 void PictureLayerTiling::SetClient(PictureLayerTilingClient* client) {
104 client_ = client; 113 client_ = client;
105 } 114 }
106 115
107 Tile* PictureLayerTiling::CreateTile(int i, 116 Tile* PictureLayerTiling::CreateTile(int i,
108 int j, 117 int j,
109 const PictureLayerTiling* twin_tiling) { 118 const PictureLayerTiling* twin_tiling) {
110 TileMapKey key(i, j); 119 TileMapKey key(i, j);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 continue; 220 continue;
212 bool include_borders = true; 221 bool include_borders = true;
213 for (TilingData::Iterator iter( 222 for (TilingData::Iterator iter(
214 &tiling_data_, content_rect, include_borders); 223 &tiling_data_, content_rect, include_borders);
215 iter; 224 iter;
216 ++iter) { 225 ++iter) {
217 TileMapKey key(iter.index()); 226 TileMapKey key(iter.index());
218 TileMap::iterator find = tiles_.find(key); 227 TileMap::iterator find = tiles_.find(key);
219 if (find == tiles_.end()) 228 if (find == tiles_.end())
220 continue; 229 continue;
230
231 ReleaseTile(find->second.get(), client_->GetTree());
232
221 tiles_.erase(find); 233 tiles_.erase(find);
222 new_tile_keys.push_back(key); 234 new_tile_keys.push_back(key);
223 } 235 }
224 } 236 }
225 237
226 if (recreate_invalidated_tiles && !new_tile_keys.empty()) { 238 if (recreate_invalidated_tiles && !new_tile_keys.empty()) {
227 for (size_t i = 0; i < new_tile_keys.size(); ++i) { 239 for (size_t i = 0; i < new_tile_keys.size(); ++i) {
228 // Don't try to share a tile with the twin layer, it's been invalidated so 240 // Don't try to share a tile with the twin layer, it's been invalidated so
229 // we have to make our own tile here. 241 // we have to make our own tile here.
230 const PictureLayerTiling* twin_tiling = NULL; 242 const PictureLayerTiling* twin_tiling = NULL;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 // Iterate to delete all tiles outside of our new live_tiles rect. 618 // Iterate to delete all tiles outside of our new live_tiles rect.
607 for (TilingData::DifferenceIterator iter(&tiling_data_, 619 for (TilingData::DifferenceIterator iter(&tiling_data_,
608 live_tiles_rect_, 620 live_tiles_rect_,
609 new_live_tiles_rect); 621 new_live_tiles_rect);
610 iter; 622 iter;
611 ++iter) { 623 ++iter) {
612 TileMapKey key(iter.index()); 624 TileMapKey key(iter.index());
613 TileMap::iterator found = tiles_.find(key); 625 TileMap::iterator found = tiles_.find(key);
614 // If the tile was outside of the recorded region, it won't exist even 626 // If the tile was outside of the recorded region, it won't exist even
615 // though it was in the live rect. 627 // though it was in the live rect.
616 if (found != tiles_.end()) 628 if (found != tiles_.end()) {
629 ReleaseTile(found->second.get(), client_->GetTree());
617 tiles_.erase(found); 630 tiles_.erase(found);
631 }
618 } 632 }
619 633
620 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); 634 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this);
621 635
622 // Iterate to allocate new tiles for all regions with newly exposed area. 636 // Iterate to allocate new tiles for all regions with newly exposed area.
623 for (TilingData::DifferenceIterator iter(&tiling_data_, 637 for (TilingData::DifferenceIterator iter(&tiling_data_,
624 new_live_tiles_rect, 638 new_live_tiles_rect,
625 live_tiles_rect_); 639 live_tiles_rect_);
626 iter; 640 iter;
627 ++iter) { 641 ++iter) {
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 DCHECK(*this); 1021 DCHECK(*this);
1008 do { 1022 do {
1009 ++tile_iterator_; 1023 ++tile_iterator_;
1010 } while (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && 1024 } while (tile_iterator_ != tiling_->eviction_tiles_cache_.end() &&
1011 (!(*tile_iterator_)->HasResources())); 1025 (!(*tile_iterator_)->HasResources()));
1012 1026
1013 return *this; 1027 return *this;
1014 } 1028 }
1015 1029
1016 } // namespace cc 1030 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/picture_layer_tiling.h ('k') | cc/resources/picture_layer_tiling_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698