Chromium Code Reviews| Index: cc/tile_priority.h |
| diff --git a/cc/tile_priority.h b/cc/tile_priority.h |
| index fd257f090ed40b1a0ca5a22c5daf91fe475b4a1f..cf61af6d7f779d146dec438141294aba26f8b291 100644 |
| --- a/cc/tile_priority.h |
| +++ b/cc/tile_priority.h |
| @@ -12,37 +12,63 @@ |
| namespace cc { |
| -struct TilePriority { |
| - // Set to true for tiles that should be favored during, for example, |
| - // scrolls. |
| - bool on_primary_tree; |
| - |
| - // A given layer may have multiple tilings, of differing quality. |
| - // would_be_drawn is set for the tiles that are visible that would be |
| - // drawn if they were chosen. |
| - bool would_be_drawn; |
| +enum TileCrispness { |
| + NOT_VERY_CRISP = 0 , |
| + IDEALY_CRISP = 1, |
| + MIGHT_EVENTUALLY_BE_CRISP = 2 // Not perfectly matched, but hey, keep it around if you've got free space. |
|
enne (OOO)
2012/11/15 19:03:24
It's interesting to me that you said that this mad
|
| +}; |
| - // We expect it to be useful soon. |
| - bool nice_to_have; |
| +struct TilePriority { |
| + TilePriority() |
| + : crispness(MIGHT_EVENTUALLY_BE_CRISP), |
| + time_to_visible_in_seconds(std::numeric_limits<float>::max()), |
| + time_to_crisp_in_seconds(std::numeric_limits<float>::max()), |
| + distance_to_visible_in_pixels(std::numeric_limits<float>::max()) {} |
| + |
| + TilePriority(const TilePriority& active, const TilePriority& pending) { |
| + if (active.crispness == IDEALY_CRISP || |
| + pending.crispness == IDEALY_CRISP) |
| + crispness = IDEALY_CRISP; |
| + else if (active.crispness == NOT_VERY_CRISP || |
| + pending.crispness == NOT_VERY_CRISP) |
| + crispness = IDEALY_CRISP; |
| + else |
| + crispness = MIGHT_EVENTUALLY_BE_CRISP; |
| + |
| + time_to_visible_in_seconds = |
| + std::min(active.time_to_visible_in_seconds, |
| + pending.time_to_visible_in_seconds); |
| + time_to_crisp_in_seconds = |
| + std::min(active.time_to_crisp_in_seconds, |
| + pending.time_to_crisp_in_seconds); |
| + distance_to_visible_in_pixels = |
| + std::min(active.distance_to_visible_in_pixels, |
| + pending.distance_to_visible_in_pixels); |
| + } |
| - // Used to prefer tiles near to the viewport. |
| - float distance_to_viewport; |
| + float time_to_needed_in_seconds() const { |
| + return std::min(time_to_visible_in_seconds, |
| + time_to_crisp_in_seconds); |
| + } |
| - // TODO(enne): some metric that penalizes blurriness. |
| + TileCrispness crispness; |
| + float time_to_visible_in_seconds; |
| + float time_to_crisp_in_seconds; |
| + float distance_to_visible_in_pixels; |
| }; |
| enum TileMemoryLimitPolicy { |
| // Nothing. |
| ALLOW_NOTHING, |
| - // Use as little as possible. |
| - ALLOW_ONLY_REQUIRED, // On primary tree, would be drawn. |
| + // You might be made visible, but you're not being interacted with. |
| + ALLOW_ABSOLUTE_MINIMUM, // Tall. |
| - // Use as little as possible. |
| - ALLOW_NICE_TO_HAVE, // On either tree, nice to have |
| + // You're being interacted with, but we're low on memory. |
| + ALLOW_PREPAINT_ONLY, // Grande. |
| - // Use as much memory, up to memory size. |
| - ALLOW_ANYTHING, |
| + // You're the only thing in town. Go crazy. |
| + ALLOW_ANYTHING, // Venti. |
| }; |
| class GlobalStateThatImpactsTilePriority { |
| @@ -50,9 +76,7 @@ class GlobalStateThatImpactsTilePriority { |
| GlobalStateThatImpactsTilePriority() |
| : memory_limit_policy(ALLOW_NOTHING) |
| , memory_limit_in_bytes(0) |
| - , smoothness_takes_priority(false) |
| - , pending_tree_frame_number(-1) |
| - , active_tree_frame_number(-1) { |
| + , smoothness_takes_priority(false) { |
| } |
| TileMemoryLimitPolicy memory_limit_policy; |
| @@ -61,24 +85,6 @@ class GlobalStateThatImpactsTilePriority { |
| // Set when scrolling. |
| bool smoothness_takes_priority; |
| - |
| - // Use -1 if no tree. |
| - int pending_tree_frame_number; |
| - int active_tree_frame_number; |
| -}; |
| - |
| -class TilePriorityComparator { |
| - public: |
| - TilePriorityComparator(GlobalStateThatImpactsTilePriority& global_state) |
| - : global_state_(global_state) {} |
| - |
| - int compare(const TilePriority& a, const TilePriority& b) { |
| - // TODO(nduca,enne): Implement a comparator using the attributes here. |
| - return 0; |
| - } |
| - |
| - private: |
| - GlobalStateThatImpactsTilePriority global_state_; |
| }; |
| } // namespace cc |