Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 808 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
| 809 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds); | 809 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds); |
| 810 if (!tile_is_visible) | 810 if (!tile_is_visible) |
| 811 return false; | 811 return false; |
| 812 | 812 |
| 813 if (IsTileOccludedOnCurrentTree(tile)) | 813 if (IsTileOccludedOnCurrentTree(tile)) |
| 814 return false; | 814 return false; |
| 815 return true; | 815 return true; |
| 816 } | 816 } |
| 817 | 817 |
| 818 bool PictureLayerTiling::ShouldProcessTileForCheckerImages( | |
|
Khushal
2017/04/11 22:45:22
This one was to skip tiles on the active tree if t
| |
| 819 const Tile* tile) const { | |
| 820 // If this is the pending tree and the tile is not occluded, it needs to be | |
| 821 // processed for checker-images. | |
| 822 if (tree_ == PENDING_TREE) | |
| 823 return !IsTileOccludedOnCurrentTree(tile); | |
| 824 | |
| 825 DCHECK_EQ(tree_, ACTIVE_TREE); | |
| 826 const PictureLayerTiling* pending_twin = | |
| 827 client_->GetPendingOrActiveTwinTiling(this); | |
| 828 | |
| 829 // If we don't have a pending twin, the tiling may be evicted upon activation, | |
| 830 // or we may not have a pending tree. So use the occlusion on the current | |
| 831 // tree. | |
| 832 if (!pending_twin) | |
| 833 return !IsTileOccludedOnCurrentTree(tile); | |
| 834 | |
| 835 // If the tile will be replaced upon activation, then we don't need to process | |
| 836 // it for checkered images. Since it is the active tree's content that we will | |
| 837 // invalidate and replace once the decode finishes. | |
| 838 if (!TilingMatchesTileIndices(pending_twin) || | |
| 839 pending_twin->TileAt(tile->tiling_i_index(), tile->tiling_j_index())) { | |
| 840 return false; | |
| 841 } | |
| 842 | |
| 843 // Ask the pending twin if this tile will become occluded upon activation. | |
| 844 return !pending_twin->IsTileOccludedOnCurrentTree(tile); | |
| 845 } | |
| 846 | |
| 818 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { | 847 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { |
| 819 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 848 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
| 820 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | 849 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
| 821 } | 850 } |
| 822 | 851 |
| 823 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( | 852 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( |
| 824 Tile* tile, | 853 Tile* tile, |
| 825 PriorityRectType priority_rect_type) const { | 854 PriorityRectType priority_rect_type) const { |
| 826 DCHECK(tile); | 855 DCHECK(tile); |
| 827 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) | 856 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) |
| 828 << "Tile layer rect: " << tile->enclosing_layer_rect().ToString(); | 857 << "Tile layer rect: " << tile->enclosing_layer_rect().ToString(); |
| 829 | 858 |
| 830 UpdateRequiredStatesOnTile(tile); | 859 UpdateRequiredStatesOnTile(tile); |
| 831 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); | 860 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); |
| 832 DCHECK((!tile->required_for_activation() && !tile->required_for_draw()) || | 861 DCHECK((!tile->required_for_activation() && !tile->required_for_draw()) || |
| 833 tile_priority.priority_bin == TilePriority::NOW || | 862 tile_priority.priority_bin == TilePriority::NOW || |
| 834 !client_->HasValidTilePriorities()); | 863 !client_->HasValidTilePriorities()); |
| 835 | 864 |
| 836 // Note that TileManager will consider this flag but may rasterize the tile | 865 // Note that TileManager will consider this flag but may rasterize the tile |
| 837 // anyway (if tile is required for activation for example). We should process | 866 // anyway (if tile is required for activation for example). We should process |
| 838 // the tile for images only if it's further than half of the skewport extent. | 867 // the tile for images only if it's further than half of the skewport extent. |
| 839 bool process_for_images_only = | 868 bool process_for_images_only = |
| 840 tile_priority.distance_to_visible > min_preraster_distance_ && | 869 tile_priority.distance_to_visible > min_preraster_distance_ && |
| 841 (tile_priority.distance_to_visible > max_preraster_distance_ || | 870 (tile_priority.distance_to_visible > max_preraster_distance_ || |
| 842 tile_priority.distance_to_visible > | 871 tile_priority.distance_to_visible > |
| 843 0.5f * max_skewport_extent_in_screen_space_); | 872 0.5f * max_skewport_extent_in_screen_space_); |
| 844 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), | 873 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), |
| 845 process_for_images_only); | 874 process_for_images_only, |
| 875 ShouldProcessTileForCheckerImages(tile)); | |
| 846 } | 876 } |
| 847 | 877 |
| 848 std::map<const Tile*, PrioritizedTile> | 878 std::map<const Tile*, PrioritizedTile> |
| 849 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { | 879 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { |
| 850 std::map<const Tile*, PrioritizedTile> result; | 880 std::map<const Tile*, PrioritizedTile> result; |
| 851 for (const auto& key_tile_pair : tiles_) { | 881 for (const auto& key_tile_pair : tiles_) { |
| 852 Tile* tile = key_tile_pair.second.get(); | 882 Tile* tile = key_tile_pair.second.get(); |
| 853 PrioritizedTile prioritized_tile = | 883 PrioritizedTile prioritized_tile = |
| 854 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); | 884 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); |
| 855 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); | 885 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 968 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
| 939 size_t amount = 0; | 969 size_t amount = 0; |
| 940 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 970 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 941 const Tile* tile = it->second.get(); | 971 const Tile* tile = it->second.get(); |
| 942 amount += tile->GPUMemoryUsageInBytes(); | 972 amount += tile->GPUMemoryUsageInBytes(); |
| 943 } | 973 } |
| 944 return amount; | 974 return amount; |
| 945 } | 975 } |
| 946 | 976 |
| 947 } // namespace cc | 977 } // namespace cc |
| OLD | NEW |