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 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 explicit TileEvictionOrder(TreePriority tree_priority) | 28 explicit TileEvictionOrder(TreePriority tree_priority) |
| 29 : tree_priority_(tree_priority) {} | 29 : tree_priority_(tree_priority) {} |
| 30 ~TileEvictionOrder() {} | 30 ~TileEvictionOrder() {} |
| 31 | 31 |
| 32 bool operator()(const Tile* a, const Tile* b) { | 32 bool operator()(const Tile* a, const Tile* b) { |
| 33 const TilePriority& a_priority = | 33 const TilePriority& a_priority = |
| 34 a->priority_for_tree_priority(tree_priority_); | 34 a->priority_for_tree_priority(tree_priority_); |
| 35 const TilePriority& b_priority = | 35 const TilePriority& b_priority = |
| 36 b->priority_for_tree_priority(tree_priority_); | 36 b->priority_for_tree_priority(tree_priority_); |
| 37 | 37 |
| 38 if (a_priority.priority_bin == b_priority.priority_bin && | 38 // Evict a before b if their priority bins differ and a has the higher |
| 39 a->required_for_activation() != b->required_for_activation()) { | 39 // priority bin. |
| 40 if (a_priority.priority_bin != b_priority.priority_bin) | |
| 41 return a_priority.priority_bin > b_priority.priority_bin; | |
| 42 | |
| 43 // Or if a is not required and b is required. | |
| 44 if (a->required_for_activation() != b->required_for_activation()) | |
| 40 return b->required_for_activation(); | 45 return b->required_for_activation(); |
| 46 | |
| 47 // Or if a is occluded and b is unoccluded. | |
| 48 bool a_is_occluded; | |
|
danakj
2014/07/09 17:38:40
initialize these to false
| |
| 49 bool b_is_occluded; | |
| 50 | |
| 51 switch (tree_priority_) { | |
|
vmpstr
2014/07/09 23:23:06
Maybe it's worth having something like is_occluded
jbedley
2014/07/11 00:19:38
Done.
| |
| 52 case SMOOTHNESS_TAKES_PRIORITY: | |
| 53 a_is_occluded = a->is_occluded(ACTIVE_TREE); | |
| 54 b_is_occluded = b->is_occluded(ACTIVE_TREE); | |
| 55 break; | |
| 56 case NEW_CONTENT_TAKES_PRIORITY: | |
| 57 a_is_occluded = a->is_occluded(PENDING_TREE); | |
| 58 b_is_occluded = b->is_occluded(PENDING_TREE); | |
| 59 break; | |
| 60 case SAME_PRIORITY_FOR_BOTH_TREES: | |
| 61 a_is_occluded = | |
| 62 a->is_occluded(ACTIVE_TREE) && a->is_occluded(PENDING_TREE); | |
| 63 b_is_occluded = | |
| 64 b->is_occluded(ACTIVE_TREE) && a->is_occluded(PENDING_TREE); | |
| 65 break; | |
| 41 } | 66 } |
| 42 return b_priority.IsHigherPriorityThan(a_priority); | 67 |
| 68 if (a_is_occluded != b_is_occluded) | |
| 69 return a_is_occluded; | |
| 70 | |
| 71 // Or if a is farther away from visible. | |
| 72 return a_priority.distance_to_visible > b_priority.distance_to_visible; | |
| 43 } | 73 } |
| 44 | 74 |
| 45 private: | 75 private: |
| 46 TreePriority tree_priority_; | 76 TreePriority tree_priority_; |
| 47 }; | 77 }; |
| 48 } // namespace | 78 } // namespace |
| 49 | 79 |
| 50 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 80 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
| 51 float contents_scale, | 81 float contents_scale, |
| 52 const gfx::Size& layer_bounds, | 82 const gfx::Size& layer_bounds, |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 973 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 1003 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
| 974 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 1004 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
| 975 is_valid_ = true; | 1005 is_valid_ = true; |
| 976 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 1006 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
| 977 !(*tile_iterator_)->HasResources()) { | 1007 !(*tile_iterator_)->HasResources()) { |
| 978 ++(*this); | 1008 ++(*this); |
| 979 } | 1009 } |
| 980 } | 1010 } |
| 981 | 1011 |
| 982 } // namespace cc | 1012 } // namespace cc |
| OLD | NEW |