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