| 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 | 10 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 eviction_cache_tree_priority_ = tree_priority; | 833 eviction_cache_tree_priority_ = tree_priority; |
| 834 } | 834 } |
| 835 | 835 |
| 836 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator() | 836 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator() |
| 837 : tiling_(NULL), current_tile_(NULL) {} | 837 : tiling_(NULL), current_tile_(NULL) {} |
| 838 | 838 |
| 839 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator( | 839 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator( |
| 840 PictureLayerTiling* tiling, | 840 PictureLayerTiling* tiling, |
| 841 WhichTree tree) | 841 WhichTree tree) |
| 842 : tiling_(tiling), | 842 : tiling_(tiling), |
| 843 type_(TilePriority::NOW), | 843 phase_(VISIBLE_RECT), |
| 844 visible_rect_in_content_space_(tiling_->current_visible_rect_), | 844 visible_rect_in_content_space_(tiling_->current_visible_rect_), |
| 845 skewport_in_content_space_(tiling_->current_skewport_rect_), | 845 skewport_in_content_space_(tiling_->current_skewport_rect_), |
| 846 eventually_rect_in_content_space_(tiling_->current_eventually_rect_), | 846 eventually_rect_in_content_space_(tiling_->current_eventually_rect_), |
| 847 soon_border_rect_in_content_space_(tiling_->current_soon_border_rect_), | 847 soon_border_rect_in_content_space_(tiling_->current_soon_border_rect_), |
| 848 tree_(tree), | 848 tree_(tree), |
| 849 current_tile_(NULL), | 849 current_tile_(NULL), |
| 850 visible_iterator_(&tiling->tiling_data_, | 850 visible_iterator_(&tiling->tiling_data_, |
| 851 visible_rect_in_content_space_, | 851 visible_rect_in_content_space_, |
| 852 true /* include_borders */), | 852 true /* include_borders */), |
| 853 spiral_iterator_(&tiling->tiling_data_, | 853 spiral_iterator_(&tiling->tiling_data_, |
| 854 skewport_in_content_space_, | 854 skewport_in_content_space_, |
| 855 visible_rect_in_content_space_, | 855 visible_rect_in_content_space_, |
| 856 visible_rect_in_content_space_), | 856 visible_rect_in_content_space_) { |
| 857 skewport_processed_(false) { | |
| 858 if (!visible_iterator_) { | 857 if (!visible_iterator_) { |
| 859 AdvancePhase(); | 858 AdvancePhase(); |
| 860 return; | 859 return; |
| 861 } | 860 } |
| 862 | 861 |
| 863 current_tile_ = | 862 current_tile_ = |
| 864 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | 863 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); |
| 865 if (!current_tile_ || !TileNeedsRaster(current_tile_)) | 864 if (!current_tile_ || !TileNeedsRaster(current_tile_)) |
| 866 ++(*this); | 865 ++(*this); |
| 867 } | 866 } |
| 868 | 867 |
| 869 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} | 868 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} |
| 870 | 869 |
| 871 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { | 870 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { |
| 872 DCHECK_LT(type_, TilePriority::EVENTUALLY); | 871 DCHECK_LT(phase_, EVENTUALLY_RECT); |
| 873 | 872 |
| 874 do { | 873 do { |
| 875 type_ = static_cast<TilePriority::PriorityBin>(type_ + 1); | 874 phase_ = static_cast<Phase>(phase_ + 1); |
| 876 if (type_ == TilePriority::EVENTUALLY) { | 875 |
| 876 if (phase_ == SOON_BORDER_RECT) { |
| 877 spiral_iterator_ = TilingData::SpiralDifferenceIterator( |
| 878 &tiling_->tiling_data_, |
| 879 soon_border_rect_in_content_space_, |
| 880 skewport_in_content_space_, |
| 881 visible_rect_in_content_space_); |
| 882 } else if (phase_ == EVENTUALLY_RECT) { |
| 877 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | 883 spiral_iterator_ = TilingData::SpiralDifferenceIterator( |
| 878 &tiling_->tiling_data_, | 884 &tiling_->tiling_data_, |
| 879 eventually_rect_in_content_space_, | 885 eventually_rect_in_content_space_, |
| 880 skewport_in_content_space_, | 886 skewport_in_content_space_, |
| 881 visible_rect_in_content_space_); | 887 soon_border_rect_in_content_space_); |
| 882 } | 888 } |
| 883 | 889 |
| 884 while (spiral_iterator_) { | 890 while (spiral_iterator_) { |
| 885 current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(), | 891 current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(), |
| 886 spiral_iterator_.index_y()); | 892 spiral_iterator_.index_y()); |
| 887 if (current_tile_ && TileNeedsRaster(current_tile_)) | 893 if (current_tile_ && TileNeedsRaster(current_tile_)) |
| 888 break; | 894 break; |
| 889 ++spiral_iterator_; | 895 ++spiral_iterator_; |
| 890 } | 896 } |
| 891 | 897 |
| 892 if (!spiral_iterator_ && type_ == TilePriority::EVENTUALLY) { | 898 if (!spiral_iterator_ && phase_ == EVENTUALLY_RECT) { |
| 893 current_tile_ = NULL; | 899 current_tile_ = NULL; |
| 894 break; | 900 break; |
| 895 } | 901 } |
| 896 } while (!spiral_iterator_); | 902 } while (!spiral_iterator_); |
| 897 } | 903 } |
| 898 | 904 |
| 899 PictureLayerTiling::TilingRasterTileIterator& | 905 PictureLayerTiling::TilingRasterTileIterator& |
| 900 PictureLayerTiling::TilingRasterTileIterator:: | 906 PictureLayerTiling::TilingRasterTileIterator:: |
| 901 operator++() { | 907 operator++() { |
| 902 current_tile_ = NULL; | 908 current_tile_ = NULL; |
| 903 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { | 909 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { |
| 904 std::pair<int, int> next_index; | 910 std::pair<int, int> next_index; |
| 905 switch (type_) { | 911 switch (phase_) { |
| 906 case TilePriority::NOW: | 912 case VISIBLE_RECT: |
| 907 ++visible_iterator_; | 913 ++visible_iterator_; |
| 908 if (!visible_iterator_) { | 914 if (!visible_iterator_) { |
| 909 AdvancePhase(); | 915 AdvancePhase(); |
| 910 return *this; | 916 return *this; |
| 911 } | 917 } |
| 912 next_index = visible_iterator_.index(); | 918 next_index = visible_iterator_.index(); |
| 913 break; | 919 break; |
| 914 case TilePriority::SOON: | 920 case SKEWPORT_RECT: |
| 921 case SOON_BORDER_RECT: |
| 915 ++spiral_iterator_; | 922 ++spiral_iterator_; |
| 916 if (!spiral_iterator_) { | 923 if (!spiral_iterator_) { |
| 917 if (skewport_processed_) { | 924 AdvancePhase(); |
| 918 AdvancePhase(); | 925 return *this; |
| 919 return *this; | |
| 920 } | |
| 921 skewport_processed_ = true; | |
| 922 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
| 923 &tiling_->tiling_data_, | |
| 924 soon_border_rect_in_content_space_, | |
| 925 skewport_in_content_space_, | |
| 926 visible_rect_in_content_space_); | |
| 927 if (!spiral_iterator_) { | |
| 928 AdvancePhase(); | |
| 929 return *this; | |
| 930 } | |
| 931 } | 926 } |
| 932 next_index = spiral_iterator_.index(); | 927 next_index = spiral_iterator_.index(); |
| 933 break; | 928 break; |
| 934 case TilePriority::EVENTUALLY: | 929 case EVENTUALLY_RECT: |
| 935 ++spiral_iterator_; | 930 ++spiral_iterator_; |
| 936 if (!spiral_iterator_) { | 931 if (!spiral_iterator_) { |
| 937 current_tile_ = NULL; | 932 current_tile_ = NULL; |
| 938 return *this; | 933 return *this; |
| 939 } | 934 } |
| 940 next_index = spiral_iterator_.index(); | 935 next_index = spiral_iterator_.index(); |
| 941 break; | 936 break; |
| 942 } | 937 } |
| 943 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); | 938 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); |
| 944 } | 939 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 DCHECK(*this); | 978 DCHECK(*this); |
| 984 do { | 979 do { |
| 985 ++tile_iterator_; | 980 ++tile_iterator_; |
| 986 } while (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 981 } while (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
| 987 (!(*tile_iterator_)->HasResources())); | 982 (!(*tile_iterator_)->HasResources())); |
| 988 | 983 |
| 989 return *this; | 984 return *this; |
| 990 } | 985 } |
| 991 | 986 |
| 992 } // namespace cc | 987 } // namespace cc |
| OLD | NEW |