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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 801 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 801 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
| 802 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds); | 802 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds); |
| 803 if (!tile_is_visible) | 803 if (!tile_is_visible) |
| 804 return false; | 804 return false; |
| 805 | 805 |
| 806 if (IsTileOccludedOnCurrentTree(tile)) | 806 if (IsTileOccludedOnCurrentTree(tile)) |
| 807 return false; | 807 return false; |
| 808 return true; | 808 return true; |
| 809 } | 809 } |
| 810 | 810 |
| 811 bool PictureLayerTiling::ShouldDecodeCheckeredImagesForTile( | |
|
vmpstr
2017/04/20 20:59:32
If we did end up having images on a tile earlier t
Khushal
2017/04/20 21:54:22
May we could store an enum on Tile indicating whet
| |
| 812 const Tile* tile) const { | |
| 813 // If this is the pending tree and the tile is not occluded, any checkered | |
| 814 // images on this tile should be decoded. | |
| 815 if (tree_ == PENDING_TREE) | |
| 816 return !IsTileOccludedOnCurrentTree(tile); | |
| 817 | |
| 818 DCHECK_EQ(tree_, ACTIVE_TREE); | |
| 819 const PictureLayerTiling* pending_twin = | |
| 820 client_->GetPendingOrActiveTwinTiling(this); | |
| 821 | |
| 822 // If we don't have a pending twin, then 2 cases are possible. Either we don't | |
| 823 // have a pending tree, in which case we should be decoding images for tiles | |
| 824 // which are unoccluded. | |
| 825 // If we do have a pending tree, then not having a twin implies that this | |
| 826 // tiling will be evicted upon activation. TODO(khushalsagar): Plumb this | |
| 827 // information here and return false for this case. | |
| 828 if (!pending_twin) | |
| 829 return !IsTileOccludedOnCurrentTree(tile); | |
| 830 | |
| 831 // If the tile will be replaced upon activation, then we don't need to process | |
| 832 // it for checkered images. Since once the pending tree is activated, it is | |
| 833 // the new active tree's content that we will invalidate and replace once the | |
| 834 // decode finishes. | |
| 835 if (!TilingMatchesTileIndices(pending_twin) || | |
| 836 pending_twin->TileAt(tile->tiling_i_index(), tile->tiling_j_index())) { | |
| 837 return false; | |
| 838 } | |
| 839 | |
| 840 // Ask the pending twin if this tile will become occluded upon activation. | |
| 841 return !pending_twin->IsTileOccludedOnCurrentTree(tile); | |
| 842 } | |
| 843 | |
| 811 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { | 844 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { |
| 812 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 845 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
| 813 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | 846 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
| 814 } | 847 } |
| 815 | 848 |
| 816 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( | 849 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( |
| 817 Tile* tile, | 850 Tile* tile, |
| 818 PriorityRectType priority_rect_type) const { | 851 PriorityRectType priority_rect_type) const { |
| 819 DCHECK(tile); | 852 DCHECK(tile); |
| 820 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) | 853 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) |
| 821 << "Recording rect: " | 854 << "Recording rect: " |
| 822 << EnclosingLayerRectFromContentsRect(tile->content_rect()).ToString(); | 855 << EnclosingLayerRectFromContentsRect(tile->content_rect()).ToString(); |
| 823 | 856 |
| 824 UpdateRequiredStatesOnTile(tile); | 857 UpdateRequiredStatesOnTile(tile); |
| 825 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); | 858 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); |
| 826 DCHECK((!tile->required_for_activation() && !tile->required_for_draw()) || | 859 DCHECK((!tile->required_for_activation() && !tile->required_for_draw()) || |
| 827 tile_priority.priority_bin == TilePriority::NOW || | 860 tile_priority.priority_bin == TilePriority::NOW || |
| 828 !client_->HasValidTilePriorities()); | 861 !client_->HasValidTilePriorities()); |
| 829 | 862 |
| 830 // Note that TileManager will consider this flag but may rasterize the tile | 863 // Note that TileManager will consider this flag but may rasterize the tile |
| 831 // anyway (if tile is required for activation for example). We should process | 864 // anyway (if tile is required for activation for example). We should process |
| 832 // the tile for images only if it's further than half of the skewport extent. | 865 // the tile for images only if it's further than half of the skewport extent. |
| 833 bool process_for_images_only = | 866 bool process_for_images_only = |
| 834 tile_priority.distance_to_visible > min_preraster_distance_ && | 867 tile_priority.distance_to_visible > min_preraster_distance_ && |
| 835 (tile_priority.distance_to_visible > max_preraster_distance_ || | 868 (tile_priority.distance_to_visible > max_preraster_distance_ || |
| 836 tile_priority.distance_to_visible > | 869 tile_priority.distance_to_visible > |
| 837 0.5f * max_skewport_extent_in_screen_space_); | 870 0.5f * max_skewport_extent_in_screen_space_); |
| 838 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), | 871 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), |
| 839 process_for_images_only); | 872 process_for_images_only, |
| 873 ShouldDecodeCheckeredImagesForTile(tile)); | |
| 840 } | 874 } |
| 841 | 875 |
| 842 std::map<const Tile*, PrioritizedTile> | 876 std::map<const Tile*, PrioritizedTile> |
| 843 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { | 877 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { |
| 844 std::map<const Tile*, PrioritizedTile> result; | 878 std::map<const Tile*, PrioritizedTile> result; |
| 845 for (const auto& key_tile_pair : tiles_) { | 879 for (const auto& key_tile_pair : tiles_) { |
| 846 Tile* tile = key_tile_pair.second.get(); | 880 Tile* tile = key_tile_pair.second.get(); |
| 847 PrioritizedTile prioritized_tile = | 881 PrioritizedTile prioritized_tile = |
| 848 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); | 882 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); |
| 849 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); | 883 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 949 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect))); | 983 return ToEnclosingRect(raster_transform_.MapRect(gfx::RectF(layer_rect))); |
| 950 } | 984 } |
| 951 | 985 |
| 952 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect( | 986 gfx::Rect PictureLayerTiling::EnclosingLayerRectFromContentsRect( |
| 953 const gfx::Rect& contents_rect) const { | 987 const gfx::Rect& contents_rect) const { |
| 954 return ToEnclosingRect( | 988 return ToEnclosingRect( |
| 955 raster_transform_.InverseMapRect(gfx::RectF(contents_rect))); | 989 raster_transform_.InverseMapRect(gfx::RectF(contents_rect))); |
| 956 } | 990 } |
| 957 | 991 |
| 958 } // namespace cc | 992 } // namespace cc |
| OLD | NEW |