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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 resolution = NON_IDEAL_RESOLUTION; | 82 resolution = NON_IDEAL_RESOLUTION; |
83 | 83 |
84 time_to_visible_in_seconds = | 84 time_to_visible_in_seconds = |
85 std::min(active.time_to_visible_in_seconds, | 85 std::min(active.time_to_visible_in_seconds, |
86 pending.time_to_visible_in_seconds); | 86 pending.time_to_visible_in_seconds); |
87 distance_to_visible_in_pixels = | 87 distance_to_visible_in_pixels = |
88 std::min(active.distance_to_visible_in_pixels, | 88 std::min(active.distance_to_visible_in_pixels, |
89 pending.distance_to_visible_in_pixels); | 89 pending.distance_to_visible_in_pixels); |
90 } | 90 } |
91 | 91 |
92 static const double kMaxTimeToVisibleInSeconds; | 92 static const float kMaxDistanceInContentSpace; |
93 static const double kMaxDistanceInContentSpace; | |
94 | 93 |
95 static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b); | 94 static inline float manhattanDistance(const gfx::RectF& a, const gfx::RectF& b
) { |
| 95 // Compute the union explicitly. |
| 96 gfx::RectF c = gfx::RectF( |
| 97 std::min(a.x(), b.x()), |
| 98 std::min(a.y(), b.y()), |
| 99 std::max(a.right(), b.right()) - std::min(a.x(), b.x()), |
| 100 std::max(a.bottom(), b.bottom()) - std::min(a.y(), b.y())); |
| 101 |
| 102 // Rects touching the edge of the screen should not be considered visible. |
| 103 // So we add 1 pixel here to avoid that situation. |
| 104 float x = std::max(0.0f, c.width() - a.width() - b.width() + 1.0f); |
| 105 float y = std::max(0.0f, c.height() - a.height() - b.height() + 1.0f); |
| 106 return (x + y); |
| 107 } |
96 | 108 |
97 // Calculate the time for the |current_bounds| to intersect with the | 109 // Calculate the time for the |current_bounds| to intersect with the |
98 // |target_bounds| given its previous location and time delta. | 110 // |target_bounds| given its previous location and time delta. |
99 // This function should work for both scaling and scrolling case. | 111 // This function should work for both scaling and scrolling case. |
100 static double TimeForBoundsToIntersect(gfx::RectF previous_bounds, | 112 static float TimeForBoundsToIntersect(const gfx::RectF& previous_bounds, |
101 gfx::RectF current_bounds, | 113 const gfx::RectF& current_bounds, |
102 double time_delta, | 114 float time_delta, |
103 gfx::RectF target_bounds); | 115 const gfx::RectF& target_bounds); |
104 | 116 |
105 // If a tile is not live, then all other fields are invalid. | 117 // If a tile is not live, then all other fields are invalid. |
106 bool is_live; | 118 bool is_live; |
107 TileResolution resolution; | 119 TileResolution resolution; |
108 float time_to_visible_in_seconds; | 120 float time_to_visible_in_seconds; |
109 float distance_to_visible_in_pixels; | 121 float distance_to_visible_in_pixels; |
110 }; | 122 }; |
111 | 123 |
112 enum TileMemoryLimitPolicy { | 124 enum TileMemoryLimitPolicy { |
113 // Nothing. | 125 // Nothing. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 size_t memory_limit_in_bytes; | 161 size_t memory_limit_in_bytes; |
150 | 162 |
151 TreePriority tree_priority; | 163 TreePriority tree_priority; |
152 | 164 |
153 scoped_ptr<base::Value> AsValue() const; | 165 scoped_ptr<base::Value> AsValue() const; |
154 }; | 166 }; |
155 | 167 |
156 } // namespace cc | 168 } // namespace cc |
157 | 169 |
158 #endif // CC_TILE_PRIORITY_H_ | 170 #endif // CC_TILE_PRIORITY_H_ |
OLD | NEW |