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 #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 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 enum TileResolution { | 35 enum TileResolution { |
| 36 LOW_RESOLUTION = 0 , | 36 LOW_RESOLUTION = 0 , |
| 37 HIGH_RESOLUTION = 1, | 37 HIGH_RESOLUTION = 1, |
| 38 NON_IDEAL_RESOLUTION = 2, | 38 NON_IDEAL_RESOLUTION = 2, |
| 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 { | |
| 45 NOW = 0, | |
|
enne (OOO)
2014/01/31 23:07:46
No need to assign these values.
vmpstr
2014/02/03 20:27:24
Done.
| |
| 46 SOON = 1, | |
| 47 EVENTUALLY = 2 | |
| 48 }; | |
| 49 | |
| 44 TilePriority() | 50 TilePriority() |
| 45 : resolution(NON_IDEAL_RESOLUTION), | 51 : resolution(NON_IDEAL_RESOLUTION), |
| 46 required_for_activation(false), | 52 required_for_activation(false), |
| 47 time_to_visible_in_seconds(std::numeric_limits<float>::infinity()), | 53 priority_bin(EVENTUALLY), |
| 48 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) {} | 54 distance_to_visible(std::numeric_limits<float>::infinity()) {} |
| 49 | 55 |
| 50 TilePriority(TileResolution resolution, | 56 TilePriority(TileResolution resolution, |
| 51 float time_to_visible_in_seconds, | 57 PriorityBin bin, |
| 52 float distance_to_visible_in_pixels) | 58 float distance_to_visible) |
| 53 : resolution(resolution), | 59 : resolution(resolution), |
| 54 required_for_activation(false), | 60 required_for_activation(false), |
| 55 time_to_visible_in_seconds(time_to_visible_in_seconds), | 61 priority_bin(bin), |
| 56 distance_to_visible_in_pixels(distance_to_visible_in_pixels) {} | 62 distance_to_visible(distance_to_visible) {} |
| 57 | 63 |
| 58 TilePriority(const TilePriority& active, const TilePriority& pending) { | 64 TilePriority(const TilePriority& active, const TilePriority& pending) { |
| 59 if (active.resolution == HIGH_RESOLUTION || | 65 if (active.resolution == HIGH_RESOLUTION || |
| 60 pending.resolution == HIGH_RESOLUTION) | 66 pending.resolution == HIGH_RESOLUTION) |
| 61 resolution = HIGH_RESOLUTION; | 67 resolution = HIGH_RESOLUTION; |
| 62 else if (active.resolution == LOW_RESOLUTION || | 68 else if (active.resolution == LOW_RESOLUTION || |
| 63 pending.resolution == LOW_RESOLUTION) | 69 pending.resolution == LOW_RESOLUTION) |
| 64 resolution = LOW_RESOLUTION; | 70 resolution = LOW_RESOLUTION; |
| 65 else | 71 else |
| 66 resolution = NON_IDEAL_RESOLUTION; | 72 resolution = NON_IDEAL_RESOLUTION; |
| 67 | 73 |
| 68 required_for_activation = | 74 required_for_activation = |
| 69 active.required_for_activation || pending.required_for_activation; | 75 active.required_for_activation || pending.required_for_activation; |
| 70 | 76 |
| 71 time_to_visible_in_seconds = | 77 if (active.priority_bin < pending.priority_bin) { |
| 72 std::min(active.time_to_visible_in_seconds, | 78 priority_bin = active.priority_bin; |
| 73 pending.time_to_visible_in_seconds); | 79 distance_to_visible = active.distance_to_visible; |
| 74 distance_to_visible_in_pixels = | 80 } else if (active.priority_bin > pending.priority_bin) { |
| 75 std::min(active.distance_to_visible_in_pixels, | 81 priority_bin = pending.priority_bin; |
| 76 pending.distance_to_visible_in_pixels); | 82 distance_to_visible = pending.distance_to_visible; |
| 83 } else { | |
| 84 priority_bin = active.priority_bin; | |
| 85 distance_to_visible = | |
| 86 std::min(active.distance_to_visible, pending.distance_to_visible); | |
| 87 } | |
| 77 } | 88 } |
| 78 | 89 |
| 79 scoped_ptr<base::Value> AsValue() const; | 90 scoped_ptr<base::Value> AsValue() const; |
| 80 | 91 |
| 81 // Calculate the time for the |current_bounds| to intersect with the | |
| 82 // |target_bounds| given its previous location and time delta. | |
| 83 // This function should work for both scaling and scrolling case. | |
| 84 static float TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, | |
| 85 const gfx::RectF& current_bounds, | |
| 86 float time_delta, | |
| 87 const gfx::RectF& target_bounds); | |
| 88 | |
| 89 bool operator ==(const TilePriority& other) const { | 92 bool operator ==(const TilePriority& other) const { |
| 90 return resolution == other.resolution && | 93 return resolution == other.resolution && |
| 91 time_to_visible_in_seconds == other.time_to_visible_in_seconds && | 94 priority_bin == other.priority_bin && |
| 92 distance_to_visible_in_pixels == other.distance_to_visible_in_pixels && | 95 distance_to_visible == other.distance_to_visible && |
| 93 required_for_activation == other.required_for_activation; | 96 required_for_activation == other.required_for_activation; |
| 94 } | 97 } |
| 95 | 98 |
| 96 bool operator !=(const TilePriority& other) const { | 99 bool operator !=(const TilePriority& other) const { |
| 97 return !(*this == other); | 100 return !(*this == other); |
| 98 } | 101 } |
| 99 | 102 |
| 100 TileResolution resolution; | 103 TileResolution resolution; |
| 101 bool required_for_activation; | 104 bool required_for_activation; |
| 102 float time_to_visible_in_seconds; | 105 PriorityBin priority_bin; |
| 103 float distance_to_visible_in_pixels; | 106 float distance_to_visible; |
| 104 }; | 107 }; |
| 105 | 108 |
| 109 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin); | |
| 110 | |
| 106 enum TileMemoryLimitPolicy { | 111 enum TileMemoryLimitPolicy { |
| 107 // Nothing. | 112 // Nothing. |
| 108 ALLOW_NOTHING = 0, | 113 ALLOW_NOTHING = 0, |
| 109 | 114 |
| 110 // You might be made visible, but you're not being interacted with. | 115 // You might be made visible, but you're not being interacted with. |
| 111 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall. | 116 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall. |
| 112 | 117 |
| 113 // You're being interacted with, but we're low on memory. | 118 // You're being interacted with, but we're low on memory. |
| 114 ALLOW_PREPAINT_ONLY = 2, // Grande. | 119 ALLOW_PREPAINT_ONLY = 2, // Grande. |
| 115 | 120 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { | 165 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { |
| 161 return !(*this == other); | 166 return !(*this == other); |
| 162 } | 167 } |
| 163 | 168 |
| 164 scoped_ptr<base::Value> AsValue() const; | 169 scoped_ptr<base::Value> AsValue() const; |
| 165 }; | 170 }; |
| 166 | 171 |
| 167 } // namespace cc | 172 } // namespace cc |
| 168 | 173 |
| 169 #endif // CC_RESOURCES_TILE_PRIORITY_H_ | 174 #endif // CC_RESOURCES_TILE_PRIORITY_H_ |
| OLD | NEW |