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

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

Issue 2612413003: Clean up tile deletion (Closed)
Patch Set: "Fix Tile* comparison in tests" Created 3 years, 11 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/tiles/picture_layer_tiling.h ('k') | cc/tiles/tile.h » ('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/tiles/picture_layer_tiling.h" 5 #include "cc/tiles/picture_layer_tiling.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 Tile* PictureLayerTiling::CreateTile(const Tile::CreateInfo& info) { 83 Tile* PictureLayerTiling::CreateTile(const Tile::CreateInfo& info) {
84 const int i = info.tiling_i_index; 84 const int i = info.tiling_i_index;
85 const int j = info.tiling_j_index; 85 const int j = info.tiling_j_index;
86 TileMapKey key(i, j); 86 TileMapKey key(i, j);
87 DCHECK(tiles_.find(key) == tiles_.end()); 87 DCHECK(tiles_.find(key) == tiles_.end());
88 88
89 if (!raster_source_->CoversRect(info.enclosing_layer_rect)) 89 if (!raster_source_->CoversRect(info.enclosing_layer_rect))
90 return nullptr; 90 return nullptr;
91 91
92 all_tiles_done_ = false; 92 all_tiles_done_ = false;
93 ScopedTilePtr tile = client_->CreateTile(info); 93 std::unique_ptr<Tile> tile = client_->CreateTile(info);
94 Tile* raw_ptr = tile.get(); 94 Tile* raw_ptr = tile.get();
95 tiles_[key] = std::move(tile); 95 tiles_[key] = std::move(tile);
96 return raw_ptr; 96 return raw_ptr;
97 } 97 }
98 98
99 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { 99 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() {
100 const PictureLayerTiling* active_twin = 100 const PictureLayerTiling* active_twin =
101 tree_ == PENDING_TREE ? client_->GetPendingOrActiveTwinTiling(this) 101 tree_ == PENDING_TREE ? client_->GetPendingOrActiveTwinTiling(this)
102 : nullptr; 102 : nullptr;
103 const Region* invalidation = 103 const Region* invalidation =
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 remove_tiles[TileMapKey(iter.index())].Union(invalid_content_rect); 299 remove_tiles[TileMapKey(iter.index())].Union(invalid_content_rect);
300 } 300 }
301 } 301 }
302 302
303 for (const auto& pair : remove_tiles) { 303 for (const auto& pair : remove_tiles) {
304 const TileMapKey& key = pair.first; 304 const TileMapKey& key = pair.first;
305 const gfx::Rect& invalid_content_rect = pair.second; 305 const gfx::Rect& invalid_content_rect = pair.second;
306 // TODO(danakj): This old_tile will not exist if we are committing to a 306 // TODO(danakj): This old_tile will not exist if we are committing to a
307 // pending tree since there is no tile there to remove, which prevents 307 // pending tree since there is no tile there to remove, which prevents
308 // tiles from knowing the invalidation rect and content id. crbug.com/490847 308 // tiles from knowing the invalidation rect and content id. crbug.com/490847
309 ScopedTilePtr old_tile = TakeTileAt(key.index_x, key.index_y); 309 std::unique_ptr<Tile> old_tile = TakeTileAt(key.index_x, key.index_y);
310 if (recreate_tiles && old_tile) { 310 if (recreate_tiles && old_tile) {
311 Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); 311 Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y);
312 if (Tile* tile = CreateTile(info)) 312 if (Tile* tile = CreateTile(info))
313 tile->SetInvalidated(invalid_content_rect, old_tile->id()); 313 tile->SetInvalidated(invalid_content_rect, old_tile->id());
314 } 314 }
315 } 315 }
316 } 316 }
317 317
318 Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const { 318 Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const {
319 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); 319 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j);
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 texture_rect.Scale(coverage_to_content_scale_.width(), 558 texture_rect.Scale(coverage_to_content_scale_.width(),
559 coverage_to_content_scale_.height()); 559 coverage_to_content_scale_.height());
560 texture_rect.Intersect(gfx::RectF(gfx::SizeF(tiling_->tiling_size()))); 560 texture_rect.Intersect(gfx::RectF(gfx::SizeF(tiling_->tiling_size())));
561 if (texture_rect.IsEmpty()) 561 if (texture_rect.IsEmpty())
562 return texture_rect; 562 return texture_rect;
563 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); 563 texture_rect.Offset(-tex_origin.OffsetFromOrigin());
564 564
565 return texture_rect; 565 return texture_rect;
566 } 566 }
567 567
568 ScopedTilePtr PictureLayerTiling::TakeTileAt(int i, int j) { 568 std::unique_ptr<Tile> PictureLayerTiling::TakeTileAt(int i, int j) {
569 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); 569 TileMap::iterator found = tiles_.find(TileMapKey(i, j));
570 if (found == tiles_.end()) 570 if (found == tiles_.end())
571 return nullptr; 571 return nullptr;
572 ScopedTilePtr result = std::move(found->second); 572 std::unique_ptr<Tile> result = std::move(found->second);
573 tiles_.erase(found); 573 tiles_.erase(found);
574 return result; 574 return result;
575 } 575 }
576 576
577 bool PictureLayerTiling::RemoveTileAt(int i, int j) { 577 bool PictureLayerTiling::RemoveTileAt(int i, int j) {
578 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); 578 TileMap::iterator found = tiles_.find(TileMapKey(i, j));
579 if (found == tiles_.end()) 579 if (found == tiles_.end())
580 return false; 580 return false;
581 tiles_.erase(found); 581 tiles_.erase(found);
582 return true; 582 return true;
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { 962 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const {
963 size_t amount = 0; 963 size_t amount = 0;
964 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { 964 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) {
965 const Tile* tile = it->second.get(); 965 const Tile* tile = it->second.get();
966 amount += tile->GPUMemoryUsageInBytes(); 966 amount += tile->GPUMemoryUsageInBytes();
967 } 967 }
968 return amount; 968 return amount;
969 } 969 }
970 970
971 } // namespace cc 971 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/picture_layer_tiling.h ('k') | cc/tiles/tile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698