| 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_TILE_PRIORITY_H_ | 5 #ifndef CC_TILE_PRIORITY_H_ |
| 6 #define CC_TILE_PRIORITY_H_ | 6 #define CC_TILE_PRIORITY_H_ |
| 7 | 7 |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 distance_to_visible_in_pixels = | 54 distance_to_visible_in_pixels = |
| 55 std::min(active.distance_to_visible_in_pixels, | 55 std::min(active.distance_to_visible_in_pixels, |
| 56 pending.distance_to_visible_in_pixels); | 56 pending.distance_to_visible_in_pixels); |
| 57 } | 57 } |
| 58 | 58 |
| 59 float time_to_needed_in_seconds() const { | 59 float time_to_needed_in_seconds() const { |
| 60 return std::min(time_to_visible_in_seconds, | 60 return std::min(time_to_visible_in_seconds, |
| 61 time_to_ideal_resolution_in_seconds); | 61 time_to_ideal_resolution_in_seconds); |
| 62 } | 62 } |
| 63 | 63 |
| 64 static const double kMaxTimeToVisibleInSeconds; | 64 static const float kMaxTimeToVisibleInSeconds; |
| 65 | 65 |
| 66 static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b); | 66 static inline float manhattanDistance(const gfx::RectF& a, const gfx::RectF& b
) { |
| 67 // Compute the union explicitly. |
| 68 gfx::RectF c = gfx::RectF( |
| 69 std::min(a.x(), b.x()), |
| 70 std::min(a.y(), b.y()), |
| 71 std::max(a.right(), b.right() - std::min(a.x(), b.x())), |
| 72 std::max(a.bottom(), b.bottom() - std::min(a.y(), b.y()))); |
| 73 |
| 74 // Rects touching the edge of the screen should not be considered visible. |
| 75 // So we add 1 pixel here to avoid that situation. |
| 76 float x = std::max(0.0f, c.width() - a.width() - b.width() + 1.0f); |
| 77 float y = std::max(0.0f, c.height() - a.height() - b.height() + 1.0f); |
| 78 return (x + y); |
| 79 } |
| 67 | 80 |
| 68 // Calculate the time for the |current_bounds| to intersect with the | 81 // Calculate the time for the |current_bounds| to intersect with the |
| 69 // |target_bounds| given its previous location and time delta. | 82 // |target_bounds| given its previous location and time delta. |
| 70 // This function should work for both scaling and scrolling case. | 83 // This function should work for both scaling and scrolling case. |
| 71 static double TimeForBoundsToIntersect(gfx::RectF previous_bounds, | 84 static float TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, |
| 72 gfx::RectF current_bounds, | 85 const gfx::RectF& current_bounds, |
| 73 double time_delta, | 86 float time_delta, |
| 74 gfx::RectF target_bounds); | 87 const gfx::RectF& target_bounds); |
| 75 | 88 |
| 76 TileResolution resolution; | 89 TileResolution resolution; |
| 77 float time_to_visible_in_seconds; | 90 float time_to_visible_in_seconds; |
| 78 float time_to_ideal_resolution_in_seconds; | 91 float time_to_ideal_resolution_in_seconds; |
| 79 float distance_to_visible_in_pixels; | 92 float distance_to_visible_in_pixels; |
| 80 }; | 93 }; |
| 81 | 94 |
| 82 enum TileMemoryLimitPolicy { | 95 enum TileMemoryLimitPolicy { |
| 83 // Nothing. | 96 // Nothing. |
| 84 ALLOW_NOTHING, | 97 ALLOW_NOTHING, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 110 TileMemoryLimitPolicy memory_limit_policy; | 123 TileMemoryLimitPolicy memory_limit_policy; |
| 111 | 124 |
| 112 size_t memory_limit_in_bytes; | 125 size_t memory_limit_in_bytes; |
| 113 | 126 |
| 114 TreePriority tree_priority; | 127 TreePriority tree_priority; |
| 115 }; | 128 }; |
| 116 | 129 |
| 117 } // namespace cc | 130 } // namespace cc |
| 118 | 131 |
| 119 #endif // CC_TILE_PRIORITY_H_ | 132 #endif // CC_TILE_PRIORITY_H_ |
| OLD | NEW |