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(); |
41 } | 46 |
42 return b_priority.IsHigherPriorityThan(a_priority); | 47 // Or if a is occluded and b is unoccluded. |
| 48 bool a_is_occluded = a->is_occluded_for_tree_priority(tree_priority_); |
| 49 bool b_is_occluded = b->is_occluded_for_tree_priority(tree_priority_); |
| 50 |
| 51 if (a_is_occluded != b_is_occluded) |
| 52 return a_is_occluded; |
| 53 |
| 54 // Or if a is farther away from visible. |
| 55 return a_priority.distance_to_visible > b_priority.distance_to_visible; |
43 } | 56 } |
44 | 57 |
45 private: | 58 private: |
46 TreePriority tree_priority_; | 59 TreePriority tree_priority_; |
47 }; | 60 }; |
48 } // namespace | 61 } // namespace |
49 | 62 |
50 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( | 63 scoped_ptr<PictureLayerTiling> PictureLayerTiling::Create( |
51 float contents_scale, | 64 float contents_scale, |
52 const gfx::Size& layer_bounds, | 65 const gfx::Size& layer_bounds, |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 986 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
974 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 987 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
975 is_valid_ = true; | 988 is_valid_ = true; |
976 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 989 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
977 !(*tile_iterator_)->HasResources()) { | 990 !(*tile_iterator_)->HasResources()) { |
978 ++(*this); | 991 ++(*this); |
979 } | 992 } |
980 } | 993 } |
981 | 994 |
982 } // namespace cc | 995 } // namespace cc |
OLD | NEW |