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 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 return true; | 715 return true; |
| 716 } | 716 } |
| 717 return pending_twin->IsTileOccludedOnCurrentTree(tile); | 717 return pending_twin->IsTileOccludedOnCurrentTree(tile); |
| 718 } | 718 } |
| 719 return true; | 719 return true; |
| 720 } | 720 } |
| 721 | 721 |
| 722 bool PictureLayerTiling::IsTileOccludedOnCurrentTree(const Tile* tile) const { | 722 bool PictureLayerTiling::IsTileOccludedOnCurrentTree(const Tile* tile) const { |
| 723 if (!current_occlusion_in_layer_space_.HasOcclusion()) | 723 if (!current_occlusion_in_layer_space_.HasOcclusion()) |
| 724 return false; | 724 return false; |
| 725 gfx::Rect tile_bounds = | |
| 726 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | |
| 725 gfx::Rect tile_query_rect = | 727 gfx::Rect tile_query_rect = |
| 726 gfx::IntersectRects(tile->content_rect(), current_visible_rect_); | 728 gfx::IntersectRects(tile_bounds, current_visible_rect_); |
| 727 // Explicitly check if the tile is outside the viewport. If so, we need to | 729 // Explicitly check if the tile is outside the viewport. If so, we need to |
| 728 // return false, since occlusion for this tile is unknown. | 730 // return false, since occlusion for this tile is unknown. |
| 729 if (tile_query_rect.IsEmpty()) | 731 if (tile_query_rect.IsEmpty()) |
| 730 return false; | 732 return false; |
| 731 | 733 |
| 732 if (contents_scale_ != 1.f) { | 734 if (contents_scale_ != 1.f) { |
| 733 tile_query_rect = | 735 tile_query_rect = |
| 734 gfx::ScaleToEnclosingRect(tile_query_rect, 1.f / contents_scale_); | 736 gfx::ScaleToEnclosingRect(tile_query_rect, 1.f / contents_scale_); |
| 735 } | 737 } |
| 736 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); | 738 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); |
| 737 } | 739 } |
| 738 | 740 |
| 739 bool PictureLayerTiling::IsTileRequiredForActivation(const Tile* tile) const { | 741 bool PictureLayerTiling::IsTileRequiredForActivation(const Tile* tile) const { |
| 740 if (tree_ == PENDING_TREE) { | 742 if (tree_ == PENDING_TREE) { |
| 741 if (!can_require_tiles_for_activation_) | 743 if (!can_require_tiles_for_activation_) |
| 742 return false; | 744 return false; |
| 743 | 745 |
| 744 if (resolution_ != HIGH_RESOLUTION) | 746 if (resolution_ != HIGH_RESOLUTION) |
| 745 return false; | 747 return false; |
| 746 | 748 |
| 747 if (IsTileOccluded(tile)) | 749 if (IsTileOccluded(tile)) |
| 748 return false; | 750 return false; |
| 749 | 751 |
| 750 bool tile_is_visible = | 752 gfx::Rect tile_bounds = |
| 751 tile->content_rect().Intersects(current_visible_rect_); | 753 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
| 754 bool tile_is_visible = tile_bounds.Intersects(current_visible_rect_); | |
| 752 if (!tile_is_visible) | 755 if (!tile_is_visible) |
| 753 return false; | 756 return false; |
| 754 | 757 |
| 755 if (client_->RequiresHighResToDraw()) | 758 if (client_->RequiresHighResToDraw()) |
| 756 return true; | 759 return true; |
| 757 | 760 |
| 758 const PictureLayerTiling* active_twin = | 761 const PictureLayerTiling* active_twin = |
| 759 client_->GetPendingOrActiveTwinTiling(this); | 762 client_->GetPendingOrActiveTwinTiling(this); |
| 760 if (!active_twin || !TilingMatchesTileIndices(active_twin)) | 763 if (!active_twin || !TilingMatchesTileIndices(active_twin)) |
| 761 return true; | 764 return true; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 786 return pending_twin->IsTileRequiredForActivation(tile); | 789 return pending_twin->IsTileRequiredForActivation(tile); |
| 787 } | 790 } |
| 788 | 791 |
| 789 bool PictureLayerTiling::IsTileRequiredForDraw(const Tile* tile) const { | 792 bool PictureLayerTiling::IsTileRequiredForDraw(const Tile* tile) const { |
| 790 if (tree_ == PENDING_TREE) | 793 if (tree_ == PENDING_TREE) |
| 791 return false; | 794 return false; |
| 792 | 795 |
| 793 if (resolution_ != HIGH_RESOLUTION) | 796 if (resolution_ != HIGH_RESOLUTION) |
| 794 return false; | 797 return false; |
| 795 | 798 |
| 796 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); | 799 gfx::Rect tile_bounds = |
| 800 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | |
| 801 bool tile_is_visible = current_visible_rect_.Intersects(tile_bounds); | |
| 797 if (!tile_is_visible) | 802 if (!tile_is_visible) |
| 798 return false; | 803 return false; |
| 799 | 804 |
| 800 if (IsTileOccludedOnCurrentTree(tile)) | 805 if (IsTileOccludedOnCurrentTree(tile)) |
| 801 return false; | 806 return false; |
| 802 return true; | 807 return true; |
| 803 } | 808 } |
| 804 | 809 |
| 805 void PictureLayerTiling::UpdateRequiredStatesOnTile(Tile* tile) const { | |
| 806 DCHECK(tile); | |
| 807 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | |
| 808 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | |
| 809 } | |
| 810 | |
| 811 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( | 810 PrioritizedTile PictureLayerTiling::MakePrioritizedTile( |
| 812 Tile* tile, | 811 Tile* tile, |
| 813 PriorityRectType priority_rect_type) const { | 812 PriorityRectType priority_rect_type) const { |
| 814 DCHECK(tile); | 813 DCHECK(tile); |
| 815 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) | 814 DCHECK(raster_source()->CoversRect(tile->enclosing_layer_rect())) |
| 816 << "Tile layer rect: " << tile->enclosing_layer_rect().ToString(); | 815 << "Tile layer rect: " << tile->enclosing_layer_rect().ToString(); |
| 817 | 816 |
| 818 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); | 817 const auto& tile_priority = ComputePriorityForTile(tile, priority_rect_type); |
| 818 bool is_now_bin = tile_priority.priority_bin == TilePriority::NOW; | |
| 819 tile->set_required_for_activation(is_now_bin && | |
|
danakj
2017/01/30 16:55:18
I don't see a test checking this code, which appea
vmpstr
2017/01/30 19:38:20
This was just a safeguard that we never have requi
| |
| 820 IsTileRequiredForActivation(tile)); | |
| 821 tile->set_required_for_draw(is_now_bin && IsTileRequiredForDraw(tile)); | |
| 822 | |
| 819 // Note that TileManager will consider this flag but may rasterize the tile | 823 // Note that TileManager will consider this flag but may rasterize the tile |
| 820 // anyway (if tile is required for activation for example). We should process | 824 // anyway (if tile is required for activation for example). We should process |
| 821 // the tile for images only if it's further than half of the skewport extent. | 825 // the tile for images only if it's further than half of the skewport extent. |
| 822 bool process_for_images_only = | 826 bool process_for_images_only = |
| 823 tile_priority.distance_to_visible > min_preraster_distance_ && | 827 tile_priority.distance_to_visible > min_preraster_distance_ && |
| 824 (tile_priority.distance_to_visible > max_preraster_distance_ || | 828 (tile_priority.distance_to_visible > max_preraster_distance_ || |
| 825 tile_priority.distance_to_visible > | 829 tile_priority.distance_to_visible > |
| 826 0.5f * max_skewport_extent_in_screen_space_); | 830 0.5f * max_skewport_extent_in_screen_space_); |
| 827 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), | 831 return PrioritizedTile(tile, this, tile_priority, IsTileOccluded(tile), |
| 828 process_for_images_only); | 832 process_for_images_only); |
| 829 } | 833 } |
| 830 | 834 |
| 831 std::map<const Tile*, PrioritizedTile> | 835 std::map<const Tile*, PrioritizedTile> |
| 832 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { | 836 PictureLayerTiling::UpdateAndGetAllPrioritizedTilesForTesting() const { |
| 833 std::map<const Tile*, PrioritizedTile> result; | 837 std::map<const Tile*, PrioritizedTile> result; |
| 834 for (const auto& key_tile_pair : tiles_) { | 838 for (const auto& key_tile_pair : tiles_) { |
| 835 Tile* tile = key_tile_pair.second.get(); | 839 Tile* tile = key_tile_pair.second.get(); |
| 836 UpdateRequiredStatesOnTile(tile); | |
| 837 PrioritizedTile prioritized_tile = | 840 PrioritizedTile prioritized_tile = |
| 838 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); | 841 MakePrioritizedTile(tile, ComputePriorityRectTypeForTile(tile)); |
| 839 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); | 842 result.insert(std::make_pair(prioritized_tile.tile(), prioritized_tile)); |
| 840 } | 843 } |
| 841 return result; | 844 return result; |
| 842 } | 845 } |
| 843 | 846 |
| 844 TilePriority PictureLayerTiling::ComputePriorityForTile( | 847 TilePriority PictureLayerTiling::ComputePriorityForTile( |
| 845 const Tile* tile, | 848 const Tile* tile, |
| 846 PriorityRectType priority_rect_type) const { | 849 PriorityRectType priority_rect_type) const { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { | 925 size_t PictureLayerTiling::GPUMemoryUsageInBytes() const { |
| 923 size_t amount = 0; | 926 size_t amount = 0; |
| 924 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 927 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
| 925 const Tile* tile = it->second.get(); | 928 const Tile* tile = it->second.get(); |
| 926 amount += tile->GPUMemoryUsageInBytes(); | 929 amount += tile->GPUMemoryUsageInBytes(); |
| 927 } | 930 } |
| 928 return amount; | 931 return amount; |
| 929 } | 932 } |
| 930 | 933 |
| 931 } // namespace cc | 934 } // namespace cc |
| OLD | NEW |