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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 resolution = NON_IDEAL_RESOLUTION; | 53 resolution = NON_IDEAL_RESOLUTION; |
54 | 54 |
55 time_to_visible_in_seconds = | 55 time_to_visible_in_seconds = |
56 std::min(active.time_to_visible_in_seconds, | 56 std::min(active.time_to_visible_in_seconds, |
57 pending.time_to_visible_in_seconds); | 57 pending.time_to_visible_in_seconds); |
58 distance_to_visible_in_pixels = | 58 distance_to_visible_in_pixels = |
59 std::min(active.distance_to_visible_in_pixels, | 59 std::min(active.distance_to_visible_in_pixels, |
60 pending.distance_to_visible_in_pixels); | 60 pending.distance_to_visible_in_pixels); |
61 } | 61 } |
62 | 62 |
63 static const double kMaxTimeToVisibleInSeconds; | 63 static const float kMaxTimeToVisibleInSeconds; |
64 | 64 |
65 static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b); | 65 static inline float manhattanDistance(const gfx::RectF& a, const gfx::RectF& b
) { |
| 66 // Compute the union explicitly. |
| 67 gfx::RectF c = gfx::RectF( |
| 68 std::min(a.x(), b.x()), |
| 69 std::min(a.y(), b.y()), |
| 70 std::max(a.right(), b.right()) - std::min(a.x(), b.x()), |
| 71 std::max(a.bottom(), b.bottom()) - std::min(a.y(), b.y())); |
| 72 |
| 73 // Rects touching the edge of the screen should not be considered visible. |
| 74 // So we add 1 pixel here to avoid that situation. |
| 75 float x = std::max(0.0f, c.width() - a.width() - b.width() + 1.0f); |
| 76 float y = std::max(0.0f, c.height() - a.height() - b.height() + 1.0f); |
| 77 return (x + y); |
| 78 } |
66 | 79 |
67 // Calculate the time for the |current_bounds| to intersect with the | 80 // Calculate the time for the |current_bounds| to intersect with the |
68 // |target_bounds| given its previous location and time delta. | 81 // |target_bounds| given its previous location and time delta. |
69 // This function should work for both scaling and scrolling case. | 82 // This function should work for both scaling and scrolling case. |
70 static double TimeForBoundsToIntersect(gfx::RectF previous_bounds, | 83 static float TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, |
71 gfx::RectF current_bounds, | 84 const gfx::RectF& current_bounds, |
72 double time_delta, | 85 float time_delta, |
73 gfx::RectF target_bounds); | 86 const gfx::RectF& target_bounds); |
74 | 87 |
75 TileResolution resolution; | 88 TileResolution resolution; |
76 float time_to_visible_in_seconds; | 89 float time_to_visible_in_seconds; |
77 float distance_to_visible_in_pixels; | 90 float distance_to_visible_in_pixels; |
78 }; | 91 }; |
79 | 92 |
80 enum TileMemoryLimitPolicy { | 93 enum TileMemoryLimitPolicy { |
81 // Nothing. | 94 // Nothing. |
82 ALLOW_NOTHING, | 95 ALLOW_NOTHING, |
83 | 96 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 size_t memory_limit_in_bytes; | 130 size_t memory_limit_in_bytes; |
118 | 131 |
119 TreePriority tree_priority; | 132 TreePriority tree_priority; |
120 | 133 |
121 scoped_ptr<base::Value> AsValue() const; | 134 scoped_ptr<base::Value> AsValue() const; |
122 }; | 135 }; |
123 | 136 |
124 } // namespace cc | 137 } // namespace cc |
125 | 138 |
126 #endif // CC_TILE_PRIORITY_H_ | 139 #endif // CC_TILE_PRIORITY_H_ |
OLD | NEW |