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> | |
danakj
2012/12/01 02:37:37
seems unused
qinmin
2012/12/01 02:45:24
this is for the std::numeric_limits in TilePriorit
| |
9 | |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
9 #include "cc/picture_pile.h" | 11 #include "cc/picture_pile.h" |
10 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
11 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
12 | 14 |
13 namespace cc { | 15 namespace cc { |
14 | 16 |
15 enum WhichTree { | 17 enum WhichTree { |
16 // Note: these must be 0 and 1 because we index with them in various places, | 18 // Note: these must be 0 and 1 because we index with them in various places, |
17 // e.g. in Tile::priority_. | 19 // e.g. in Tile::priority_. |
18 ACTIVE_TREE = 0, | 20 ACTIVE_TREE = 0, |
19 PENDING_TREE = 1 | 21 PENDING_TREE = 1 |
20 }; | 22 }; |
21 | 23 |
22 enum TileResolution { | 24 enum TileResolution { |
23 LOW_RESOLUTION = 0 , | 25 LOW_RESOLUTION = 0 , |
24 HIGH_RESOLUTION = 1, | 26 HIGH_RESOLUTION = 1, |
25 NON_IDEAL_RESOLUTION = 2 | 27 NON_IDEAL_RESOLUTION = 2 |
26 }; | 28 }; |
27 | 29 |
28 struct TilePriority { | 30 struct CC_EXPORT TilePriority { |
29 TilePriority() | 31 TilePriority() |
30 : resolution(NON_IDEAL_RESOLUTION), | 32 : resolution(NON_IDEAL_RESOLUTION), |
31 time_to_visible_in_seconds(std::numeric_limits<float>::max()), | 33 time_to_visible_in_seconds(std::numeric_limits<float>::max()), |
32 time_to_ideal_resolution_in_seconds(std::numeric_limits<float>::max()), | 34 time_to_ideal_resolution_in_seconds(std::numeric_limits<float>::max()), |
33 distance_to_visible_in_pixels(std::numeric_limits<float>::max()) {} | 35 distance_to_visible_in_pixels(std::numeric_limits<float>::max()) {} |
34 | 36 |
35 TilePriority(const TilePriority& active, const TilePriority& pending) { | 37 TilePriority(const TilePriority& active, const TilePriority& pending) { |
36 if (active.resolution == HIGH_RESOLUTION || | 38 if (active.resolution == HIGH_RESOLUTION || |
37 pending.resolution == HIGH_RESOLUTION) | 39 pending.resolution == HIGH_RESOLUTION) |
38 resolution = HIGH_RESOLUTION; | 40 resolution = HIGH_RESOLUTION; |
(...skipping 12 matching lines...) Expand all Loading... | |
51 distance_to_visible_in_pixels = | 53 distance_to_visible_in_pixels = |
52 std::min(active.distance_to_visible_in_pixels, | 54 std::min(active.distance_to_visible_in_pixels, |
53 pending.distance_to_visible_in_pixels); | 55 pending.distance_to_visible_in_pixels); |
54 } | 56 } |
55 | 57 |
56 float time_to_needed_in_seconds() const { | 58 float time_to_needed_in_seconds() const { |
57 return std::min(time_to_visible_in_seconds, | 59 return std::min(time_to_visible_in_seconds, |
58 time_to_ideal_resolution_in_seconds); | 60 time_to_ideal_resolution_in_seconds); |
59 } | 61 } |
60 | 62 |
63 static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b); | |
64 | |
65 // Calculate the time for the |current_bounds| to intersect with the | |
66 // |target_bounds| given its previous location and time delta. | |
67 // This function should work for both scaling and scrolling case. | |
68 static double TimeForBoundsToIntersect(gfx::RectF previous_bounds, | |
69 gfx::RectF current_bounds, | |
70 double time_delta, | |
71 gfx::RectF target_bounds); | |
72 | |
61 TileResolution resolution; | 73 TileResolution resolution; |
62 float time_to_visible_in_seconds; | 74 float time_to_visible_in_seconds; |
63 float time_to_ideal_resolution_in_seconds; | 75 float time_to_ideal_resolution_in_seconds; |
64 float distance_to_visible_in_pixels; | 76 float distance_to_visible_in_pixels; |
65 }; | 77 }; |
66 | 78 |
67 enum TileMemoryLimitPolicy { | 79 enum TileMemoryLimitPolicy { |
68 // Nothing. | 80 // Nothing. |
69 ALLOW_NOTHING, | 81 ALLOW_NOTHING, |
70 | 82 |
(...skipping 19 matching lines...) Expand all Loading... | |
90 | 102 |
91 size_t memory_limit_in_bytes; | 103 size_t memory_limit_in_bytes; |
92 | 104 |
93 // Set when scrolling. | 105 // Set when scrolling. |
94 bool smoothness_takes_priority; | 106 bool smoothness_takes_priority; |
95 }; | 107 }; |
96 | 108 |
97 } // namespace cc | 109 } // namespace cc |
98 | 110 |
99 #endif // CC_TILE_PRIORITY_H_ | 111 #endif // CC_TILE_PRIORITY_H_ |
OLD | NEW |