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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 | 782 |
| 783 if (resolution_ != HIGH_RESOLUTION) | 783 if (resolution_ != HIGH_RESOLUTION) |
| 784 return false; | 784 return false; |
| 785 | 785 |
| 786 if (IsTileOccluded(tile)) | 786 if (IsTileOccluded(tile)) |
| 787 return false; | 787 return false; |
| 788 | 788 |
| 789 return true; | 789 return true; |
| 790 } | 790 } |
| 791 | 791 |
| 792 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { | 792 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { |
|
danakj
2015/01/07 20:05:31
I liked the old function name, how come it changed
vmpstr
2015/01/08 00:23:59
I thought it would make more sense, but I think yo
| |
| 793 UpdateTilePriority(tile); | 793 WhichTree tree = client_->GetTree(); |
| 794 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | |
| 795 | |
| 796 UpdateTilePriorityForTree(tile, tree); | |
| 794 | 797 |
| 795 const PictureLayerTiling* twin_tiling = | 798 const PictureLayerTiling* twin_tiling = |
| 796 client_->GetPendingOrActiveTwinTiling(this); | 799 client_->GetPendingOrActiveTwinTiling(this); |
| 797 if (!tile->is_shared() || !twin_tiling) { | 800 if (!tile->is_shared() || !twin_tiling) { |
| 798 WhichTree tree = client_->GetTree(); | |
| 799 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | |
| 800 tile->SetPriority(twin_tree, TilePriority()); | 801 tile->SetPriority(twin_tree, TilePriority()); |
| 801 tile->set_is_occluded(twin_tree, false); | 802 tile->set_is_occluded(twin_tree, false); |
| 802 if (twin_tree == PENDING_TREE) | 803 if (twin_tree == PENDING_TREE) |
| 803 tile->set_required_for_activation(false); | 804 tile->set_required_for_activation(false); |
| 804 else | 805 else |
| 805 tile->set_required_for_draw(false); | 806 tile->set_required_for_draw(false); |
| 806 return; | 807 return; |
| 807 } | 808 } |
| 808 | 809 |
| 809 twin_tiling->UpdateTilePriority(tile); | 810 twin_tiling->UpdateTilePriorityForTree(tile, twin_tree); |
| 810 } | 811 } |
| 811 | 812 |
| 812 void PictureLayerTiling::UpdateTilePriority(Tile* tile) const { | 813 void PictureLayerTiling::UpdateTilePriorityForTree(Tile* tile, |
| 814 WhichTree tree) const { | |
| 813 // TODO(vmpstr): This code should return the priority instead of setting it on | 815 // TODO(vmpstr): This code should return the priority instead of setting it on |
| 814 // the tile. This should be a part of the change to move tile priority from | 816 // the tile. This should be a part of the change to move tile priority from |
| 815 // tiles into iterators. | 817 // tiles into iterators. |
| 816 TilePriority::PriorityBin max_tile_priority_bin = | 818 TilePriority::PriorityBin max_tile_priority_bin = |
| 817 client_->GetMaxTilePriorityBin(); | 819 client_->GetMaxTilePriorityBin(); |
| 818 WhichTree tree = client_->GetTree(); | |
| 819 | 820 |
| 820 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); | 821 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); |
| 821 gfx::Rect tile_bounds = | 822 gfx::Rect tile_bounds = |
| 822 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 823 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
| 823 | 824 |
| 824 if (max_tile_priority_bin <= TilePriority::NOW && | 825 if (max_tile_priority_bin <= TilePriority::NOW && |
| 825 current_visible_rect_.Intersects(tile_bounds)) { | 826 current_visible_rect_.Intersects(tile_bounds)) { |
| 826 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); | 827 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); |
| 827 if (tree == PENDING_TREE) { | 828 if (tree == PENDING_TREE) { |
| 828 tile->set_required_for_activation( | 829 tile->set_required_for_activation( |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 if (delta < event.distance) | 1027 if (delta < event.distance) |
| 1027 break; | 1028 break; |
| 1028 } | 1029 } |
| 1029 | 1030 |
| 1030 gfx::Rect result(origin_x, origin_y, width, height); | 1031 gfx::Rect result(origin_x, origin_y, width, height); |
| 1031 if (cache) | 1032 if (cache) |
| 1032 cache->previous_result = result; | 1033 cache->previous_result = result; |
| 1033 return result; | 1034 return result; |
| 1034 } | 1035 } |
| 1035 | 1036 |
| 1036 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator() | |
| 1037 : tiling_(NULL), current_tile_(NULL) {} | |
| 1038 | |
| 1039 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator( | |
| 1040 PictureLayerTiling* tiling) | |
| 1041 : tiling_(tiling), phase_(VISIBLE_RECT), current_tile_(NULL) { | |
| 1042 if (!tiling_->has_visible_rect_tiles_) { | |
| 1043 AdvancePhase(); | |
| 1044 return; | |
| 1045 } | |
| 1046 | |
| 1047 visible_iterator_ = TilingData::Iterator(&tiling_->tiling_data_, | |
| 1048 tiling_->current_visible_rect_, | |
| 1049 false /* include_borders */); | |
| 1050 if (!visible_iterator_) { | |
| 1051 AdvancePhase(); | |
| 1052 return; | |
| 1053 } | |
| 1054 | |
| 1055 current_tile_ = | |
| 1056 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | |
| 1057 if (!current_tile_ || !TileNeedsRaster(current_tile_)) { | |
| 1058 ++(*this); | |
| 1059 return; | |
| 1060 } | |
| 1061 tiling_->UpdateTileAndTwinPriority(current_tile_); | |
| 1062 } | |
| 1063 | |
| 1064 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} | |
| 1065 | |
| 1066 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { | |
| 1067 DCHECK_LT(phase_, EVENTUALLY_RECT); | |
| 1068 | |
| 1069 do { | |
| 1070 phase_ = static_cast<Phase>(phase_ + 1); | |
| 1071 switch (phase_) { | |
| 1072 case VISIBLE_RECT: | |
| 1073 NOTREACHED(); | |
| 1074 return; | |
| 1075 case SKEWPORT_RECT: | |
| 1076 if (!tiling_->has_skewport_rect_tiles_) | |
| 1077 continue; | |
| 1078 | |
| 1079 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
| 1080 &tiling_->tiling_data_, | |
| 1081 tiling_->current_skewport_rect_, | |
| 1082 tiling_->current_visible_rect_, | |
| 1083 tiling_->current_visible_rect_); | |
| 1084 break; | |
| 1085 case SOON_BORDER_RECT: | |
| 1086 if (!tiling_->has_soon_border_rect_tiles_) | |
| 1087 continue; | |
| 1088 | |
| 1089 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
| 1090 &tiling_->tiling_data_, | |
| 1091 tiling_->current_soon_border_rect_, | |
| 1092 tiling_->current_skewport_rect_, | |
| 1093 tiling_->current_visible_rect_); | |
| 1094 break; | |
| 1095 case EVENTUALLY_RECT: | |
| 1096 if (!tiling_->has_eventually_rect_tiles_) { | |
| 1097 current_tile_ = NULL; | |
| 1098 return; | |
| 1099 } | |
| 1100 | |
| 1101 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | |
| 1102 &tiling_->tiling_data_, | |
| 1103 tiling_->current_eventually_rect_, | |
| 1104 tiling_->current_skewport_rect_, | |
| 1105 tiling_->current_soon_border_rect_); | |
| 1106 break; | |
| 1107 } | |
| 1108 | |
| 1109 while (spiral_iterator_) { | |
| 1110 current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(), | |
| 1111 spiral_iterator_.index_y()); | |
| 1112 if (current_tile_ && TileNeedsRaster(current_tile_)) | |
| 1113 break; | |
| 1114 ++spiral_iterator_; | |
| 1115 } | |
| 1116 | |
| 1117 if (!spiral_iterator_ && phase_ == EVENTUALLY_RECT) { | |
| 1118 current_tile_ = NULL; | |
| 1119 break; | |
| 1120 } | |
| 1121 } while (!spiral_iterator_); | |
| 1122 | |
| 1123 if (current_tile_) | |
| 1124 tiling_->UpdateTileAndTwinPriority(current_tile_); | |
| 1125 } | |
| 1126 | |
| 1127 PictureLayerTiling::TilingRasterTileIterator& | |
| 1128 PictureLayerTiling::TilingRasterTileIterator:: | |
| 1129 operator++() { | |
| 1130 current_tile_ = NULL; | |
| 1131 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { | |
| 1132 std::pair<int, int> next_index; | |
| 1133 switch (phase_) { | |
| 1134 case VISIBLE_RECT: | |
| 1135 ++visible_iterator_; | |
| 1136 if (!visible_iterator_) { | |
| 1137 AdvancePhase(); | |
| 1138 return *this; | |
| 1139 } | |
| 1140 next_index = visible_iterator_.index(); | |
| 1141 break; | |
| 1142 case SKEWPORT_RECT: | |
| 1143 case SOON_BORDER_RECT: | |
| 1144 ++spiral_iterator_; | |
| 1145 if (!spiral_iterator_) { | |
| 1146 AdvancePhase(); | |
| 1147 return *this; | |
| 1148 } | |
| 1149 next_index = spiral_iterator_.index(); | |
| 1150 break; | |
| 1151 case EVENTUALLY_RECT: | |
| 1152 ++spiral_iterator_; | |
| 1153 if (!spiral_iterator_) { | |
| 1154 current_tile_ = NULL; | |
| 1155 return *this; | |
| 1156 } | |
| 1157 next_index = spiral_iterator_.index(); | |
| 1158 break; | |
| 1159 } | |
| 1160 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); | |
| 1161 } | |
| 1162 | |
| 1163 if (current_tile_) | |
| 1164 tiling_->UpdateTileAndTwinPriority(current_tile_); | |
| 1165 return *this; | |
| 1166 } | |
| 1167 | |
| 1168 } // namespace cc | 1037 } // namespace cc |
| OLD | NEW |