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 #ifndef CC_RESOURCES_TILE_PRIORITY_H_ | 5 #ifndef CC_RESOURCES_TILE_PRIORITY_H_ |
6 #define CC_RESOURCES_TILE_PRIORITY_H_ | 6 #define CC_RESOURCES_TILE_PRIORITY_H_ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 }; | 39 }; |
40 scoped_ptr<base::Value> TileResolutionAsValue( | 40 scoped_ptr<base::Value> TileResolutionAsValue( |
41 TileResolution resolution); | 41 TileResolution resolution); |
42 | 42 |
43 struct CC_EXPORT TilePriority { | 43 struct CC_EXPORT TilePriority { |
44 enum PriorityBin { NOW, SOON, EVENTUALLY }; | 44 enum PriorityBin { NOW, SOON, EVENTUALLY }; |
45 | 45 |
46 TilePriority() | 46 TilePriority() |
47 : resolution(NON_IDEAL_RESOLUTION), | 47 : resolution(NON_IDEAL_RESOLUTION), |
48 required_for_activation(false), | 48 required_for_activation(false), |
| 49 is_occluded(false), |
49 priority_bin(EVENTUALLY), | 50 priority_bin(EVENTUALLY), |
50 distance_to_visible(std::numeric_limits<float>::infinity()) {} | 51 distance_to_visible(std::numeric_limits<float>::infinity()) {} |
51 | 52 |
52 TilePriority(TileResolution resolution, | 53 TilePriority(TileResolution resolution, |
| 54 bool is_occluded, |
53 PriorityBin bin, | 55 PriorityBin bin, |
54 float distance_to_visible) | 56 float distance_to_visible) |
55 : resolution(resolution), | 57 : resolution(resolution), |
56 required_for_activation(false), | 58 required_for_activation(false), |
| 59 is_occluded(is_occluded), |
57 priority_bin(bin), | 60 priority_bin(bin), |
58 distance_to_visible(distance_to_visible) {} | 61 distance_to_visible(distance_to_visible) {} |
59 | 62 |
60 TilePriority(const TilePriority& active, const TilePriority& pending) { | 63 TilePriority(const TilePriority& active, const TilePriority& pending) { |
61 if (active.resolution == HIGH_RESOLUTION || | 64 if (active.resolution == HIGH_RESOLUTION || |
62 pending.resolution == HIGH_RESOLUTION) | 65 pending.resolution == HIGH_RESOLUTION) |
63 resolution = HIGH_RESOLUTION; | 66 resolution = HIGH_RESOLUTION; |
64 else if (active.resolution == LOW_RESOLUTION || | 67 else if (active.resolution == LOW_RESOLUTION || |
65 pending.resolution == LOW_RESOLUTION) | 68 pending.resolution == LOW_RESOLUTION) |
66 resolution = LOW_RESOLUTION; | 69 resolution = LOW_RESOLUTION; |
67 else | 70 else |
68 resolution = NON_IDEAL_RESOLUTION; | 71 resolution = NON_IDEAL_RESOLUTION; |
69 | 72 |
70 required_for_activation = | 73 required_for_activation = |
71 active.required_for_activation || pending.required_for_activation; | 74 active.required_for_activation || pending.required_for_activation; |
72 | 75 |
| 76 is_occluded = active.is_occluded && pending.is_occluded; |
| 77 |
73 if (active.priority_bin < pending.priority_bin) { | 78 if (active.priority_bin < pending.priority_bin) { |
74 priority_bin = active.priority_bin; | 79 priority_bin = active.priority_bin; |
75 distance_to_visible = active.distance_to_visible; | 80 distance_to_visible = active.distance_to_visible; |
76 } else if (active.priority_bin > pending.priority_bin) { | 81 } else if (active.priority_bin > pending.priority_bin) { |
77 priority_bin = pending.priority_bin; | 82 priority_bin = pending.priority_bin; |
78 distance_to_visible = pending.distance_to_visible; | 83 distance_to_visible = pending.distance_to_visible; |
79 } else { | 84 } else { |
80 priority_bin = active.priority_bin; | 85 priority_bin = active.priority_bin; |
81 distance_to_visible = | 86 distance_to_visible = |
82 std::min(active.distance_to_visible, pending.distance_to_visible); | 87 std::min(active.distance_to_visible, pending.distance_to_visible); |
83 } | 88 } |
84 } | 89 } |
85 | 90 |
86 scoped_ptr<base::Value> AsValue() const; | 91 scoped_ptr<base::Value> AsValue() const; |
87 | 92 |
88 bool operator ==(const TilePriority& other) const { | 93 bool operator ==(const TilePriority& other) const { |
89 return resolution == other.resolution && | 94 return resolution == other.resolution && |
90 priority_bin == other.priority_bin && | 95 priority_bin == other.priority_bin && |
91 distance_to_visible == other.distance_to_visible && | 96 distance_to_visible == other.distance_to_visible && |
92 required_for_activation == other.required_for_activation; | 97 required_for_activation == other.required_for_activation && |
| 98 is_occluded == other.is_occluded; |
93 } | 99 } |
94 | 100 |
95 bool operator !=(const TilePriority& other) const { | 101 bool operator !=(const TilePriority& other) const { |
96 return !(*this == other); | 102 return !(*this == other); |
97 } | 103 } |
98 | 104 |
99 bool IsHigherPriorityThan(const TilePriority& other) const { | 105 bool IsHigherPriorityThan(const TilePriority& other) const { |
100 return priority_bin < other.priority_bin || | 106 return priority_bin < other.priority_bin || |
101 (priority_bin == other.priority_bin && | 107 (priority_bin == other.priority_bin && |
102 distance_to_visible < other.distance_to_visible); | 108 distance_to_visible < other.distance_to_visible); |
103 } | 109 } |
104 | 110 |
105 TileResolution resolution; | 111 TileResolution resolution; |
106 bool required_for_activation; | 112 bool required_for_activation; |
| 113 bool is_occluded; |
107 PriorityBin priority_bin; | 114 PriorityBin priority_bin; |
108 float distance_to_visible; | 115 float distance_to_visible; |
109 }; | 116 }; |
110 | 117 |
111 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin); | 118 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin); |
112 | 119 |
113 enum TileMemoryLimitPolicy { | 120 enum TileMemoryLimitPolicy { |
114 // Nothing. | 121 // Nothing. |
115 ALLOW_NOTHING = 0, | 122 ALLOW_NOTHING = 0, |
116 | 123 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { | 174 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { |
168 return !(*this == other); | 175 return !(*this == other); |
169 } | 176 } |
170 | 177 |
171 scoped_ptr<base::Value> AsValue() const; | 178 scoped_ptr<base::Value> AsValue() const; |
172 }; | 179 }; |
173 | 180 |
174 } // namespace cc | 181 } // namespace cc |
175 | 182 |
176 #endif // CC_RESOURCES_TILE_PRIORITY_H_ | 183 #endif // CC_RESOURCES_TILE_PRIORITY_H_ |
OLD | NEW |