| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/prioritized_tile_set.h" | 5 #include "cc/resources/prioritized_tile_set.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/resources/managed_tile_state.h" | 9 #include "cc/resources/managed_tile_state.h" |
| 10 #include "cc/resources/tile.h" | 10 #include "cc/resources/tile.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 typedef std::vector<Tile*> TileVector; | 49 typedef std::vector<Tile*> TileVector; |
| 50 | 50 |
| 51 void SortBinTiles(ManagedTileBin bin, TileVector* tiles) { | 51 void SortBinTiles(ManagedTileBin bin, TileVector* tiles) { |
| 52 switch (bin) { | 52 switch (bin) { |
| 53 case NOW_AND_READY_TO_DRAW_BIN: | 53 case NOW_AND_READY_TO_DRAW_BIN: |
| 54 break; | 54 return; |
| 55 case NOW_BIN: | 55 case NOW_BIN: |
| 56 case SOON_BIN: | 56 case SOON_BIN: |
| 57 case EVENTUALLY_AND_ACTIVE_BIN: | 57 case EVENTUALLY_AND_ACTIVE_BIN: |
| 58 case EVENTUALLY_BIN: | 58 case EVENTUALLY_BIN: |
| 59 case NEVER_AND_ACTIVE_BIN: | 59 case NEVER_AND_ACTIVE_BIN: |
| 60 case NEVER_BIN: | 60 case NEVER_BIN: |
| 61 std::sort(tiles->begin(), tiles->end(), BinComparator()); | 61 std::sort(tiles->begin(), tiles->end(), BinComparator()); |
| 62 break; | 62 return; |
| 63 default: | |
| 64 NOTREACHED(); | |
| 65 } | 63 } |
| 64 NOTREACHED(); |
| 66 } | 65 } |
| 67 | 66 |
| 68 } // namespace | 67 } // namespace |
| 69 | 68 |
| 70 PrioritizedTileSet::PrioritizedTileSet() { | 69 PrioritizedTileSet::PrioritizedTileSet() { |
| 71 for (int bin = 0; bin < NUM_BINS; ++bin) | 70 for (int bin = 0; bin < ManagedTileBin_ARRAYSIZE; ++bin) |
| 72 bin_sorted_[bin] = true; | 71 bin_sorted_[bin] = true; |
| 73 } | 72 } |
| 74 | 73 |
| 75 PrioritizedTileSet::~PrioritizedTileSet() {} | 74 PrioritizedTileSet::~PrioritizedTileSet() {} |
| 76 | 75 |
| 77 void PrioritizedTileSet::InsertTile(Tile* tile, ManagedTileBin bin) { | 76 void PrioritizedTileSet::InsertTile(Tile* tile, ManagedTileBin bin) { |
| 78 tiles_[bin].push_back(tile); | 77 tiles_[bin].push_back(tile); |
| 79 bin_sorted_[bin] = false; | 78 bin_sorted_[bin] = false; |
| 80 } | 79 } |
| 81 | 80 |
| 82 void PrioritizedTileSet::Clear() { | 81 void PrioritizedTileSet::Clear() { |
| 83 for (int bin = 0; bin < NUM_BINS; ++bin) { | 82 for (int bin = 0; bin < ManagedTileBin_ARRAYSIZE; ++bin) { |
| 84 tiles_[bin].clear(); | 83 tiles_[bin].clear(); |
| 85 bin_sorted_[bin] = true; | 84 bin_sorted_[bin] = true; |
| 86 } | 85 } |
| 87 } | 86 } |
| 88 | 87 |
| 89 void PrioritizedTileSet::SortBinIfNeeded(ManagedTileBin bin) { | 88 void PrioritizedTileSet::SortBinIfNeeded(ManagedTileBin bin) { |
| 90 if (!bin_sorted_[bin]) { | 89 if (!bin_sorted_[bin]) { |
| 91 SortBinTiles(bin, &tiles_[bin]); | 90 SortBinTiles(bin, &tiles_[bin]); |
| 92 bin_sorted_[bin] = true; | 91 bin_sorted_[bin] = true; |
| 93 } | 92 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 if (use_priority_ordering_) | 135 if (use_priority_ordering_) |
| 137 tile_set_->SortBinIfNeeded(current_bin_); | 136 tile_set_->SortBinIfNeeded(current_bin_); |
| 138 | 137 |
| 139 iterator_ = tile_set_->tiles_[current_bin_].begin(); | 138 iterator_ = tile_set_->tiles_[current_bin_].begin(); |
| 140 if (iterator_ != tile_set_->tiles_[current_bin_].end()) | 139 if (iterator_ != tile_set_->tiles_[current_bin_].end()) |
| 141 break; | 140 break; |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 | 143 |
| 145 } // namespace cc | 144 } // namespace cc |
| OLD | NEW |