OLD | NEW |
---|---|
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 <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 if (find != tiles_.end()) | 134 if (find != tiles_.end()) |
135 continue; | 135 continue; |
136 | 136 |
137 Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); | 137 Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); |
138 if (ShouldCreateTileAt(info)) { | 138 if (ShouldCreateTileAt(info)) { |
139 Tile* tile = CreateTile(info); | 139 Tile* tile = CreateTile(info); |
140 | 140 |
141 // If this is the pending tree, then the active twin tiling may contain | 141 // If this is the pending tree, then the active twin tiling may contain |
142 // the previous content ID of these tiles. In that case, we need only | 142 // the previous content ID of these tiles. In that case, we need only |
143 // partially raster the tile content. | 143 // partially raster the tile content. |
144 if (tile && invalidation && TilingMatchesTileIndices(active_twin)) { | 144 if (client_->EnablePartialRaster() && tile && invalidation && |
145 TilingMatchesTileIndices(active_twin)) { | |
145 if (const Tile* old_tile = | 146 if (const Tile* old_tile = |
146 active_twin->TileAt(key.index_x, key.index_y)) { | 147 active_twin->TileAt(key.index_x, key.index_y)) { |
147 gfx::Rect tile_rect = tile->content_rect(); | 148 gfx::Rect tile_rect = tile->content_rect(); |
148 gfx::Rect invalidated; | 149 gfx::Rect invalidated; |
149 for (Region::Iterator iter(*invalidation); iter.has_rect(); | 150 for (Region::Iterator iter(*invalidation); iter.has_rect(); |
150 iter.next()) { | 151 iter.next()) { |
151 gfx::Rect invalid_content_rect = | 152 gfx::Rect invalid_content_rect = |
152 gfx::ScaleToEnclosingRect(iter.rect(), contents_scale_); | 153 gfx::ScaleToEnclosingRect(iter.rect(), contents_scale_); |
153 invalid_content_rect.Intersect(tile_rect); | 154 invalid_content_rect.Intersect(tile_rect); |
154 invalidated.Union(invalid_content_rect); | 155 invalidated.Union(invalid_content_rect); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
332 for (const auto& pair : remove_tiles) { | 333 for (const auto& pair : remove_tiles) { |
333 const TileMapKey& key = pair.first; | 334 const TileMapKey& key = pair.first; |
334 const gfx::Rect& invalid_content_rect = pair.second; | 335 const gfx::Rect& invalid_content_rect = pair.second; |
335 // TODO(danakj): This old_tile will not exist if we are committing to a | 336 // TODO(danakj): This old_tile will not exist if we are committing to a |
336 // pending tree since there is no tile there to remove, which prevents | 337 // pending tree since there is no tile there to remove, which prevents |
337 // tiles from knowing the invalidation rect and content id. crbug.com/490847 | 338 // tiles from knowing the invalidation rect and content id. crbug.com/490847 |
338 ScopedTilePtr old_tile = TakeTileAt(key.index_x, key.index_y); | 339 ScopedTilePtr old_tile = TakeTileAt(key.index_x, key.index_y); |
339 if (recreate_tiles && old_tile) { | 340 if (recreate_tiles && old_tile) { |
340 Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); | 341 Tile::CreateInfo info = CreateInfoForTile(key.index_x, key.index_y); |
341 if (Tile* tile = CreateTile(info)) | 342 if (Tile* tile = CreateTile(info)) |
342 tile->SetInvalidated(invalid_content_rect, old_tile->id()); | 343 tile->SetInvalidated(invalid_content_rect, old_tile->id()); |
vmpstr
2015/10/06 18:35:48
You probably need a similar check here. (with test
ericrk
2015/10/07 17:59:08
Yup - missed this and had a unit test bug =/... I'
| |
343 } | 344 } |
344 } | 345 } |
345 } | 346 } |
346 | 347 |
347 Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const { | 348 Tile::CreateInfo PictureLayerTiling::CreateInfoForTile(int i, int j) const { |
348 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); | 349 gfx::Rect tile_rect = tiling_data_.TileBoundsWithBorder(i, j); |
349 tile_rect.set_size(tiling_data_.max_texture_size()); | 350 tile_rect.set_size(tiling_data_.max_texture_size()); |
350 gfx::Rect enclosing_layer_rect = | 351 gfx::Rect enclosing_layer_rect = |
351 gfx::ScaleToEnclosingRect(tile_rect, 1.f / contents_scale_); | 352 gfx::ScaleToEnclosingRect(tile_rect, 1.f / contents_scale_); |
352 return Tile::CreateInfo(i, j, enclosing_layer_rect, tile_rect, | 353 return Tile::CreateInfo(i, j, enclosing_layer_rect, tile_rect, |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1005 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 1006 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
1006 size_t amount = 0; | 1007 size_t amount = 0; |
1007 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 1008 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
1008 const Tile* tile = it->second; | 1009 const Tile* tile = it->second; |
1009 amount += tile->GPUMemoryUsageInBytes(); | 1010 amount += tile->GPUMemoryUsageInBytes(); |
1010 } | 1011 } |
1011 return amount; | 1012 return amount; |
1012 } | 1013 } |
1013 | 1014 |
1014 } // namespace cc | 1015 } // namespace cc |
OLD | NEW |