| 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 { NOW, SOON, EVENTUALLY }; |
| 45 |
| 44 TilePriority() | 46 TilePriority() |
| 45 : resolution(NON_IDEAL_RESOLUTION), | 47 : resolution(NON_IDEAL_RESOLUTION), |
| 46 required_for_activation(false), | 48 required_for_activation(false), |
| 47 time_to_visible_in_seconds(std::numeric_limits<float>::infinity()), | 49 priority_bin(EVENTUALLY), |
| 48 distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) {} | 50 distance_to_visible(std::numeric_limits<float>::infinity()) {} |
| 49 | 51 |
| 50 TilePriority(TileResolution resolution, | 52 TilePriority(TileResolution resolution, |
| 51 float time_to_visible_in_seconds, | 53 PriorityBin bin, |
| 52 float distance_to_visible_in_pixels) | 54 float distance_to_visible) |
| 53 : resolution(resolution), | 55 : resolution(resolution), |
| 54 required_for_activation(false), | 56 required_for_activation(false), |
| 55 time_to_visible_in_seconds(time_to_visible_in_seconds), | 57 priority_bin(bin), |
| 56 distance_to_visible_in_pixels(distance_to_visible_in_pixels) {} | 58 distance_to_visible(distance_to_visible) {} |
| 57 | 59 |
| 58 TilePriority(const TilePriority& active, const TilePriority& pending) { | 60 TilePriority(const TilePriority& active, const TilePriority& pending) { |
| 59 if (active.resolution == HIGH_RESOLUTION || | 61 if (active.resolution == HIGH_RESOLUTION || |
| 60 pending.resolution == HIGH_RESOLUTION) | 62 pending.resolution == HIGH_RESOLUTION) |
| 61 resolution = HIGH_RESOLUTION; | 63 resolution = HIGH_RESOLUTION; |
| 62 else if (active.resolution == LOW_RESOLUTION || | 64 else if (active.resolution == LOW_RESOLUTION || |
| 63 pending.resolution == LOW_RESOLUTION) | 65 pending.resolution == LOW_RESOLUTION) |
| 64 resolution = LOW_RESOLUTION; | 66 resolution = LOW_RESOLUTION; |
| 65 else | 67 else |
| 66 resolution = NON_IDEAL_RESOLUTION; | 68 resolution = NON_IDEAL_RESOLUTION; |
| 67 | 69 |
| 68 required_for_activation = | 70 required_for_activation = |
| 69 active.required_for_activation || pending.required_for_activation; | 71 active.required_for_activation || pending.required_for_activation; |
| 70 | 72 |
| 71 time_to_visible_in_seconds = | 73 if (active.priority_bin < pending.priority_bin) { |
| 72 std::min(active.time_to_visible_in_seconds, | 74 priority_bin = active.priority_bin; |
| 73 pending.time_to_visible_in_seconds); | 75 distance_to_visible = active.distance_to_visible; |
| 74 distance_to_visible_in_pixels = | 76 } else if (active.priority_bin > pending.priority_bin) { |
| 75 std::min(active.distance_to_visible_in_pixels, | 77 priority_bin = pending.priority_bin; |
| 76 pending.distance_to_visible_in_pixels); | 78 distance_to_visible = pending.distance_to_visible; |
| 79 } else { |
| 80 priority_bin = active.priority_bin; |
| 81 distance_to_visible = |
| 82 std::min(active.distance_to_visible, pending.distance_to_visible); |
| 83 } |
| 77 } | 84 } |
| 78 | 85 |
| 79 scoped_ptr<base::Value> AsValue() const; | 86 scoped_ptr<base::Value> AsValue() const; |
| 80 | 87 |
| 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 { | 88 bool operator ==(const TilePriority& other) const { |
| 90 return resolution == other.resolution && | 89 return resolution == other.resolution && |
| 91 time_to_visible_in_seconds == other.time_to_visible_in_seconds && | 90 priority_bin == other.priority_bin && |
| 92 distance_to_visible_in_pixels == other.distance_to_visible_in_pixels && | 91 distance_to_visible == other.distance_to_visible && |
| 93 required_for_activation == other.required_for_activation; | 92 required_for_activation == other.required_for_activation; |
| 94 } | 93 } |
| 95 | 94 |
| 96 bool operator !=(const TilePriority& other) const { | 95 bool operator !=(const TilePriority& other) const { |
| 97 return !(*this == other); | 96 return !(*this == other); |
| 98 } | 97 } |
| 99 | 98 |
| 100 TileResolution resolution; | 99 TileResolution resolution; |
| 101 bool required_for_activation; | 100 bool required_for_activation; |
| 102 float time_to_visible_in_seconds; | 101 PriorityBin priority_bin; |
| 103 float distance_to_visible_in_pixels; | 102 float distance_to_visible; |
| 104 }; | 103 }; |
| 105 | 104 |
| 105 scoped_ptr<base::Value> TilePriorityBinAsValue(TilePriority::PriorityBin bin); |
| 106 |
| 106 enum TileMemoryLimitPolicy { | 107 enum TileMemoryLimitPolicy { |
| 107 // Nothing. | 108 // Nothing. |
| 108 ALLOW_NOTHING = 0, | 109 ALLOW_NOTHING = 0, |
| 109 | 110 |
| 110 // You might be made visible, but you're not being interacted with. | 111 // You might be made visible, but you're not being interacted with. |
| 111 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall. | 112 ALLOW_ABSOLUTE_MINIMUM = 1, // Tall. |
| 112 | 113 |
| 113 // You're being interacted with, but we're low on memory. | 114 // You're being interacted with, but we're low on memory. |
| 114 ALLOW_PREPAINT_ONLY = 2, // Grande. | 115 ALLOW_PREPAINT_ONLY = 2, // Grande. |
| 115 | 116 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { | 161 bool operator!=(const GlobalStateThatImpactsTilePriority& other) const { |
| 161 return !(*this == other); | 162 return !(*this == other); |
| 162 } | 163 } |
| 163 | 164 |
| 164 scoped_ptr<base::Value> AsValue() const; | 165 scoped_ptr<base::Value> AsValue() const; |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 } // namespace cc | 168 } // namespace cc |
| 168 | 169 |
| 169 #endif // CC_RESOURCES_TILE_PRIORITY_H_ | 170 #endif // CC_RESOURCES_TILE_PRIORITY_H_ |
| OLD | NEW |