| 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> |
| 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 const double kMaxTimeToVisibleInSeconds; |
| 64 |
| 65 static int manhattanDistance(const gfx::RectF& a, const gfx::RectF& b); |
| 66 |
| 67 // Calculate the time for the |current_bounds| to intersect with the |
| 68 // |target_bounds| given its previous location and time delta. |
| 69 // This function should work for both scaling and scrolling case. |
| 70 static double TimeForBoundsToIntersect(gfx::RectF previous_bounds, |
| 71 gfx::RectF current_bounds, |
| 72 double time_delta, |
| 73 gfx::RectF target_bounds); |
| 74 |
| 61 TileResolution resolution; | 75 TileResolution resolution; |
| 62 float time_to_visible_in_seconds; | 76 float time_to_visible_in_seconds; |
| 63 float time_to_ideal_resolution_in_seconds; | 77 float time_to_ideal_resolution_in_seconds; |
| 64 float distance_to_visible_in_pixels; | 78 float distance_to_visible_in_pixels; |
| 65 }; | 79 }; |
| 66 | 80 |
| 67 enum TileMemoryLimitPolicy { | 81 enum TileMemoryLimitPolicy { |
| 68 // Nothing. | 82 // Nothing. |
| 69 ALLOW_NOTHING, | 83 ALLOW_NOTHING, |
| 70 | 84 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 90 | 104 |
| 91 size_t memory_limit_in_bytes; | 105 size_t memory_limit_in_bytes; |
| 92 | 106 |
| 93 // Set when scrolling. | 107 // Set when scrolling. |
| 94 bool smoothness_takes_priority; | 108 bool smoothness_takes_priority; |
| 95 }; | 109 }; |
| 96 | 110 |
| 97 } // namespace cc | 111 } // namespace cc |
| 98 | 112 |
| 99 #endif // CC_TILE_PRIORITY_H_ | 113 #endif // CC_TILE_PRIORITY_H_ |
| OLD | NEW |