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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 DCHECK_EQ(after_bottom, before_bottom + 1); | 277 DCHECK_EQ(after_bottom, before_bottom + 1); |
278 for (int i = before_left; i <= before_right; ++i) { | 278 for (int i = before_left; i <= before_right; ++i) { |
279 Tile::CreateInfo info = CreateInfoForTile(i, after_bottom); | 279 Tile::CreateInfo info = CreateInfoForTile(i, after_bottom); |
280 if (ShouldCreateTileAt(info)) | 280 if (ShouldCreateTileAt(info)) |
281 CreateTile(info); | 281 CreateTile(info); |
282 } | 282 } |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { | 286 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { |
287 DCHECK(tree_ != ACTIVE_TREE || !client_->GetPendingOrActiveTwinTiling(this)); | 287 DCHECK_IMPLIES(tree_ == ACTIVE_TREE, |
| 288 !client_->GetPendingOrActiveTwinTiling(this)); |
288 RemoveTilesInRegion(layer_invalidation, true /* recreate tiles */); | 289 RemoveTilesInRegion(layer_invalidation, true /* recreate tiles */); |
289 } | 290 } |
290 | 291 |
291 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, | 292 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_invalidation, |
292 bool recreate_tiles) { | 293 bool recreate_tiles) { |
293 // We only invalidate the active tiling when it's orphaned: it has no pending | 294 // We only invalidate the active tiling when it's orphaned: it has no pending |
294 // twin, so it's slated for removal in the future. | 295 // twin, so it's slated for removal in the future. |
295 if (live_tiles_rect_.IsEmpty()) | 296 if (live_tiles_rect_.IsEmpty()) |
296 return; | 297 return; |
297 // Pick 16 for the size of the SmallMap before it promotes to a hash_map. | 298 // Pick 16 for the size of the SmallMap before it promotes to a hash_map. |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 } | 679 } |
679 } | 680 } |
680 } | 681 } |
681 DCHECK_EQ(visible_rect_in_content_space.IsEmpty(), eventually_rect.IsEmpty()); | 682 DCHECK_EQ(visible_rect_in_content_space.IsEmpty(), eventually_rect.IsEmpty()); |
682 | 683 |
683 // Now we have an empty visible/eventually rect if it's not useful and a | 684 // Now we have an empty visible/eventually rect if it's not useful and a |
684 // non-empty one if it is. We can compute the final eventually rect. | 685 // non-empty one if it is. We can compute the final eventually rect. |
685 eventually_rect = | 686 eventually_rect = |
686 tiling_data_.ExpandRectIgnoringBordersToTileBounds(eventually_rect); | 687 tiling_data_.ExpandRectIgnoringBordersToTileBounds(eventually_rect); |
687 | 688 |
688 DCHECK(eventually_rect.IsEmpty() || | 689 DCHECK_IMPLIES(!eventually_rect.IsEmpty(), |
689 gfx::Rect(tiling_size()).Contains(eventually_rect)) | 690 gfx::Rect(tiling_size()).Contains(eventually_rect)) |
690 << "tiling_size: " << tiling_size().ToString() | 691 << "tiling_size: " << tiling_size().ToString() |
691 << " eventually_rect: " << eventually_rect.ToString(); | 692 << " eventually_rect: " << eventually_rect.ToString(); |
692 | 693 |
693 if (tiling_size().IsEmpty()) { | 694 if (tiling_size().IsEmpty()) { |
694 UpdateVisibleRectHistory(current_frame_time_in_seconds, | 695 UpdateVisibleRectHistory(current_frame_time_in_seconds, |
695 visible_rect_in_content_space); | 696 visible_rect_in_content_space); |
696 last_viewport_in_layer_space_ = viewport_in_layer_space; | 697 last_viewport_in_layer_space_ = viewport_in_layer_space; |
697 return false; | 698 return false; |
698 } | 699 } |
699 | 700 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 1030 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
1030 size_t amount = 0; | 1031 size_t amount = 0; |
1031 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 1032 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
1032 const Tile* tile = it->second; | 1033 const Tile* tile = it->second; |
1033 amount += tile->GPUMemoryUsageInBytes(); | 1034 amount += tile->GPUMemoryUsageInBytes(); |
1034 } | 1035 } |
1035 return amount; | 1036 return amount; |
1036 } | 1037 } |
1037 | 1038 |
1038 } // namespace cc | 1039 } // namespace cc |
OLD | NEW |