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/resources/picture_layer_tiling.h" | 5 #include "cc/resources/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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 802 | 802 |
| 803 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); | 803 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); |
| 804 if (!tile_is_visible) | 804 if (!tile_is_visible) |
| 805 return false; | 805 return false; |
| 806 | 806 |
| 807 if (IsTileOccludedOnCurrentTree(tile)) | 807 if (IsTileOccludedOnCurrentTree(tile)) |
| 808 return false; | 808 return false; |
| 809 return true; | 809 return true; |
| 810 } | 810 } |
| 811 | 811 |
| 812 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { | 812 void PictureLayerTiling::UpdateTilePriority(Tile* tile, |
| 813 tile->set_priority(ComputePriorityForTile(tile)); | 813 PriorityRect priority_rect) const { |
| 814 tile->set_priority(ComputePriorityForTile(tile, priority_rect)); | |
| 814 tile->set_is_occluded(IsTileOccluded(tile)); | 815 tile->set_is_occluded(IsTileOccluded(tile)); |
| 815 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); | 816 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
| 816 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); | 817 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
| 817 } | 818 } |
| 818 | 819 |
| 819 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { | 820 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { |
| 820 #if DCHECK_IS_ON() | 821 #if DCHECK_IS_ON() |
| 821 for (const auto& tile_pair : tiles_) | 822 for (const auto& tile_pair : tiles_) |
| 822 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); | 823 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); |
| 823 #endif | 824 #endif |
| 824 } | 825 } |
| 825 | 826 |
| 826 TilePriority PictureLayerTiling::ComputePriorityForTile( | 827 TilePriority PictureLayerTiling::ComputePriorityForTile( |
| 827 const Tile* tile) const { | 828 const Tile* tile, |
| 829 PriorityRect priority_rect) const { | |
| 828 // TODO(vmpstr): See if this can be moved to iterators. | 830 // TODO(vmpstr): See if this can be moved to iterators. |
| 829 TilePriority::PriorityBin max_tile_priority_bin = | 831 TilePriority::PriorityBin max_tile_priority_bin = |
| 830 client_->GetMaxTilePriorityBin(); | 832 client_->GetMaxTilePriorityBin(); |
| 831 | 833 |
| 834 DCHECK_EQ(ComputePriorityRectForTile(tile), priority_rect); | |
| 832 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); | 835 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); |
| 836 | |
| 837 TilePriority::PriorityBin priority_bin = max_tile_priority_bin; | |
| 838 | |
| 839 switch (priority_rect) { | |
| 840 case VISIBLE_RECT: | |
| 841 return TilePriority(resolution_, tile_priority_bin, 0); | |
| 842 case PENDING_VISIBLE_RECT: | |
| 843 if (max_tile_priority_bin <= TilePriority::SOON) | |
| 844 return TilePriority(resolution_, TilePriority::SOON, 0); | |
| 845 priority_bin = TilePriority::EVENTUALLY; | |
| 846 break; | |
| 847 case SKEWPORT_RECT: | |
| 848 case SOON_BORDER_RECT: | |
| 849 if (max_tile_priority_bin <= TilePriority::SOON) | |
| 850 priority_bin = TilePriority::SOON; | |
| 851 break; | |
| 852 case EVENTUALLY_RECT: | |
| 853 priority_bin = TilePriority::EVENTUALLY; | |
| 854 break; | |
| 855 } | |
| 856 | |
| 833 gfx::Rect tile_bounds = | 857 gfx::Rect tile_bounds = |
| 834 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 858 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
| 835 | |
| 836 if (max_tile_priority_bin <= TilePriority::NOW && | |
| 837 current_visible_rect_.Intersects(tile_bounds)) { | |
| 838 return TilePriority(resolution_, TilePriority::NOW, 0); | |
| 839 } | |
| 840 | |
| 841 if (max_tile_priority_bin <= TilePriority::SOON && | |
| 842 pending_visible_rect().Intersects(tile_bounds)) { | |
| 843 return TilePriority(resolution_, TilePriority::SOON, 0); | |
| 844 } | |
| 845 | |
| 846 DCHECK_GT(current_content_to_screen_scale_, 0.f); | 859 DCHECK_GT(current_content_to_screen_scale_, 0.f); |
| 847 float distance_to_visible = | 860 float distance_to_visible = |
| 848 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * | 861 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * |
| 849 current_content_to_screen_scale_; | 862 current_content_to_screen_scale_; |
| 850 | 863 |
| 851 if (max_tile_priority_bin <= TilePriority::SOON && | 864 return TilePriority(resolution_, priority_bin, distance_to_visible); |
| 852 (current_soon_border_rect_.Intersects(tile_bounds) || | 865 } |
| 853 current_skewport_rect_.Intersects(tile_bounds))) { | |
| 854 return TilePriority(resolution_, TilePriority::SOON, distance_to_visible); | |
| 855 } | |
| 856 | 866 |
| 857 return TilePriority(resolution_, TilePriority::EVENTUALLY, | 867 PictureLayerTiling::PriorityRect PictureLayerTiling::ComputePriorityRectForTile( |
|
vmpstr
2015/05/05 18:04:01
Is this function only used in DCHECKs and tracing?
USE eero AT chromium.org
2015/05/06 12:05:20
It is used also by TilingSetRasterQueueRequired.
| |
| 858 distance_to_visible); | 868 const Tile* tile) const { |
| 869 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); | |
| 870 gfx::Rect tile_bounds = | |
| 871 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | |
| 872 | |
| 873 if (current_visible_rect_.Intersects(tile_bounds)) | |
| 874 return VISIBLE_RECT; | |
| 875 | |
| 876 if (pending_visible_rect().Intersects(tile_bounds)) | |
| 877 return PENDING_VISIBLE_RECT; | |
| 878 | |
| 879 if (current_skewport_rect_.Intersects(tile_bounds)) | |
| 880 return SKEWPORT_RECT; | |
| 881 | |
| 882 if (current_soon_border_rect_.Intersects(tile_bounds)) | |
| 883 return SOON_BORDER_RECT; | |
| 884 | |
| 885 DCHECK(current_eventually_rect_.Intersects(tile_bounds)); | |
| 886 return EVENTUALLY_RECT; | |
| 859 } | 887 } |
| 860 | 888 |
| 861 void PictureLayerTiling::GetAllTilesAndPrioritiesForTracing( | 889 void PictureLayerTiling::GetAllTilesAndPrioritiesForTracing( |
| 862 std::map<const Tile*, TilePriority>* tile_map) const { | 890 std::map<const Tile*, TilePriority>* tile_map) const { |
| 863 for (const auto& tile_pair : tiles_) { | 891 for (const auto& tile_pair : tiles_) { |
| 864 const Tile* tile = tile_pair.second.get(); | 892 const Tile* tile = tile_pair.second.get(); |
| 865 const TilePriority& priority = ComputePriorityForTile(tile); | 893 const TilePriority& priority = |
| 894 ComputePriorityForTile(tile, ComputePriorityRectForTile(tile)); | |
| 866 // Store combined priority. | 895 // Store combined priority. |
| 867 (*tile_map)[tile] = priority; | 896 (*tile_map)[tile] = priority; |
| 868 } | 897 } |
| 869 } | 898 } |
| 870 | 899 |
| 871 void PictureLayerTiling::AsValueInto( | 900 void PictureLayerTiling::AsValueInto( |
| 872 base::trace_event::TracedValue* state) const { | 901 base::trace_event::TracedValue* state) const { |
| 873 state->SetInteger("num_tiles", tiles_.size()); | 902 state->SetInteger("num_tiles", tiles_.size()); |
| 874 state->SetDouble("content_scale", contents_scale_); | 903 state->SetDouble("content_scale", contents_scale_); |
| 875 MathUtil::AddToTracedValue("visible_rect", current_visible_rect_, state); | 904 MathUtil::AddToTracedValue("visible_rect", current_visible_rect_, state); |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 break; | 1063 break; |
| 1035 } | 1064 } |
| 1036 | 1065 |
| 1037 gfx::Rect result(origin_x, origin_y, width, height); | 1066 gfx::Rect result(origin_x, origin_y, width, height); |
| 1038 if (cache) | 1067 if (cache) |
| 1039 cache->previous_result = result; | 1068 cache->previous_result = result; |
| 1040 return result; | 1069 return result; |
| 1041 } | 1070 } |
| 1042 | 1071 |
| 1043 } // namespace cc | 1072 } // namespace cc |
| OLD | NEW |