| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/eviction_tile_priority_queue.h" | 5 #include "cc/resources/eviction_tile_priority_queue.h" |
| 6 | 6 |
| 7 namespace cc { | 7 namespace cc { |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 const TilingSetEvictionQueue* a_queue = | 26 const TilingSetEvictionQueue* a_queue = |
| 27 a_tree == ACTIVE_TREE ? a->active_queue.get() : a->pending_queue.get(); | 27 a_tree == ACTIVE_TREE ? a->active_queue.get() : a->pending_queue.get(); |
| 28 | 28 |
| 29 WhichTree b_tree = b->NextTileIteratorTree(); | 29 WhichTree b_tree = b->NextTileIteratorTree(); |
| 30 const TilingSetEvictionQueue* b_queue = | 30 const TilingSetEvictionQueue* b_queue = |
| 31 b_tree == ACTIVE_TREE ? b->active_queue.get() : b->pending_queue.get(); | 31 b_tree == ACTIVE_TREE ? b->active_queue.get() : b->pending_queue.get(); |
| 32 | 32 |
| 33 const Tile* a_tile = a_queue->Top(); | 33 const Tile* a_tile = a_queue->Top(); |
| 34 const Tile* b_tile = b_queue->Top(); | 34 const Tile* b_tile = b_queue->Top(); |
| 35 | 35 |
| 36 const TilePriority& a_priority = a_tile->priority(); | 36 const TilePriority& a_priority = a_tile->combined_priority(); |
| 37 const TilePriority& b_priority = b_tile->priority(); | 37 const TilePriority& b_priority = b_tile->combined_priority(); |
| 38 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; | 38 bool prioritize_low_res = tree_priority_ == SMOOTHNESS_TAKES_PRIORITY; |
| 39 | 39 |
| 40 // If the priority bin differs, b is lower priority if it has the higher | 40 // If the priority bin differs, b is lower priority if it has the higher |
| 41 // priority bin. | 41 // priority bin. |
| 42 if (a_priority.priority_bin != b_priority.priority_bin) | 42 if (a_priority.priority_bin != b_priority.priority_bin) |
| 43 return b_priority.priority_bin > a_priority.priority_bin; | 43 return b_priority.priority_bin > a_priority.priority_bin; |
| 44 | 44 |
| 45 // Otherwise if the resolution differs, then the order will be determined by | 45 // Otherwise if the resolution differs, then the order will be determined by |
| 46 // whether we prioritize low res or not. | 46 // whether we prioritize low res or not. |
| 47 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile | 47 // TODO(vmpstr): Remove this when TilePriority is no longer a member of Tile |
| 48 // class but instead produced by the iterators. | 48 // class but instead produced by the iterators. |
| 49 if (b_priority.resolution != a_priority.resolution) { | 49 if (b_priority.resolution != a_priority.resolution) { |
| 50 // Non ideal resolution should be sorted higher than other resolutions. | 50 // Non ideal resolution should be sorted higher than other resolutions. |
| 51 if (a_priority.resolution == NON_IDEAL_RESOLUTION) | 51 if (a_priority.resolution == NON_IDEAL_RESOLUTION) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 if (b_priority.resolution == NON_IDEAL_RESOLUTION) | 54 if (b_priority.resolution == NON_IDEAL_RESOLUTION) |
| 55 return true; | 55 return true; |
| 56 | 56 |
| 57 if (prioritize_low_res) | 57 if (prioritize_low_res) |
| 58 return a_priority.resolution == LOW_RESOLUTION; | 58 return a_priority.resolution == LOW_RESOLUTION; |
| 59 return a_priority.resolution == HIGH_RESOLUTION; | 59 return a_priority.resolution == HIGH_RESOLUTION; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Otherwise if the occlusion differs, b is lower priority if it is | 62 // Otherwise if the occlusion differs, b is lower priority if it is |
| 63 // occluded. | 63 // occluded. |
| 64 bool a_is_occluded = a_tile->is_occluded(); | 64 bool a_is_occluded = a_tile->is_occluded_combined(); |
| 65 bool b_is_occluded = b_tile->is_occluded(); | 65 bool b_is_occluded = b_tile->is_occluded_combined(); |
| 66 if (a_is_occluded != b_is_occluded) | 66 if (a_is_occluded != b_is_occluded) |
| 67 return b_is_occluded; | 67 return b_is_occluded; |
| 68 | 68 |
| 69 // b is lower priorty if it is farther from visible. | 69 // b is lower priorty if it is farther from visible. |
| 70 return b_priority.distance_to_visible > a_priority.distance_to_visible; | 70 return b_priority.distance_to_visible > a_priority.distance_to_visible; |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 TreePriority tree_priority_; | 74 TreePriority tree_priority_; |
| 75 }; | 75 }; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (!pending_queue || pending_queue->IsEmpty()) | 177 if (!pending_queue || pending_queue->IsEmpty()) |
| 178 return ACTIVE_TREE; | 178 return ACTIVE_TREE; |
| 179 | 179 |
| 180 const Tile* active_tile = active_queue->Top(); | 180 const Tile* active_tile = active_queue->Top(); |
| 181 const Tile* pending_tile = pending_queue->Top(); | 181 const Tile* pending_tile = pending_queue->Top(); |
| 182 | 182 |
| 183 // If tiles are the same, it doesn't matter which tree we return. | 183 // If tiles are the same, it doesn't matter which tree we return. |
| 184 if (active_tile == pending_tile) | 184 if (active_tile == pending_tile) |
| 185 return ACTIVE_TREE; | 185 return ACTIVE_TREE; |
| 186 | 186 |
| 187 const TilePriority& active_priority = active_tile->priority(); | 187 const TilePriority& active_priority = active_tile->combined_priority(); |
| 188 const TilePriority& pending_priority = pending_tile->priority(); | 188 const TilePriority& pending_priority = pending_tile->combined_priority(); |
| 189 | 189 |
| 190 // If the bins are the same and activation differs, then return the tree of | 190 // If the bins are the same and activation differs, then return the tree of |
| 191 // the tile not required for activation. | 191 // the tile not required for activation. |
| 192 if (active_priority.priority_bin == pending_priority.priority_bin && | 192 if (active_priority.priority_bin == pending_priority.priority_bin && |
| 193 active_tile->required_for_activation() != | 193 active_tile->required_for_activation() != |
| 194 pending_tile->required_for_activation()) { | 194 pending_tile->required_for_activation()) { |
| 195 return active_tile->required_for_activation() ? PENDING_TREE : ACTIVE_TREE; | 195 return active_tile->required_for_activation() ? PENDING_TREE : ACTIVE_TREE; |
| 196 } | 196 } |
| 197 | 197 |
| 198 // Return tile with a lower priority. | 198 // Return tile with a lower priority. |
| 199 if (pending_priority.IsHigherPriorityThan(active_priority)) | 199 if (pending_priority.IsHigherPriorityThan(active_priority)) |
| 200 return ACTIVE_TREE; | 200 return ACTIVE_TREE; |
| 201 return PENDING_TREE; | 201 return PENDING_TREE; |
| 202 } | 202 } |
| 203 | 203 |
| 204 } // namespace cc | 204 } // namespace cc |
| OLD | NEW |