| 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_RESOURCES_TILE_PRIORITY_H_ | 5 #ifndef CC_RESOURCES_TILE_PRIORITY_H_ | 
| 6 #define CC_RESOURCES_TILE_PRIORITY_H_ | 6 #define CC_RESOURCES_TILE_PRIORITY_H_ | 
| 7 | 7 | 
| 8 #include <algorithm> | 8 #include <algorithm> | 
| 9 #include <limits> | 9 #include <limits> | 
| 10 | 10 | 
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" | 
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" | 
|  | 13 #include "cc/base/util.h" | 
| 13 #include "cc/resources/picture_pile.h" | 14 #include "cc/resources/picture_pile.h" | 
| 14 #include "ui/gfx/quad_f.h" | 15 #include "ui/gfx/quad_f.h" | 
| 15 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" | 
| 16 #include "ui/gfx/size.h" | 17 #include "ui/gfx/size.h" | 
| 17 | 18 | 
| 18 namespace base { | 19 namespace base { | 
| 19 class Value; | 20 class Value; | 
| 20 } | 21 } | 
| 21 | 22 | 
| 22 namespace cc { | 23 namespace cc { | 
| 23 | 24 | 
| 24 enum WhichTree { | 25 DEFINE_ENUM(WhichTree, | 
| 25   // Note: these must be 0 and 1 because we index with them in various places, | 26             ACTIVE_TREE, | 
| 26   // e.g. in Tile::priority_. | 27             PENDING_TREE); | 
| 27   ACTIVE_TREE = 0, | 28 scoped_ptr<base::Value> WhichTreeAsValue(WhichTree tree); | 
| 28   PENDING_TREE = 1, |  | 
| 29   NUM_TREES = 2 |  | 
| 30   // Be sure to update WhichTreeAsValue when adding new fields. |  | 
| 31 }; |  | 
| 32 scoped_ptr<base::Value> WhichTreeAsValue( |  | 
| 33     WhichTree tree); |  | 
| 34 | 29 | 
| 35 enum TileResolution { | 30 enum TileResolution { | 
| 36   LOW_RESOLUTION = 0 , | 31   LOW_RESOLUTION = 0, | 
| 37   HIGH_RESOLUTION = 1, | 32   HIGH_RESOLUTION = 1, | 
| 38   NON_IDEAL_RESOLUTION = 2, | 33   NON_IDEAL_RESOLUTION = 2 | 
| 39 }; | 34 }; | 
| 40 scoped_ptr<base::Value> TileResolutionAsValue( | 35 scoped_ptr<base::Value> TileResolutionAsValue(TileResolution resolution); | 
| 41     TileResolution resolution); |  | 
| 42 | 36 | 
| 43 struct CC_EXPORT TilePriority { | 37 struct CC_EXPORT TilePriority { | 
| 44   TilePriority() | 38   TilePriority() | 
| 45       : resolution(NON_IDEAL_RESOLUTION), | 39       : resolution(NON_IDEAL_RESOLUTION), | 
| 46         required_for_activation(false), | 40         required_for_activation(false), | 
| 47         time_to_visible_in_seconds(std::numeric_limits<float>::infinity()), | 41         time_to_visible_in_seconds(std::numeric_limits<float>::infinity()), | 
| 48         distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) {} | 42         distance_to_visible_in_pixels(std::numeric_limits<float>::infinity()) {} | 
| 49 | 43 | 
| 50   TilePriority(TileResolution resolution, | 44   TilePriority(TileResolution resolution, | 
| 51                float time_to_visible_in_seconds, | 45                float time_to_visible_in_seconds, | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 117 | 111 | 
| 118   TileResolution resolution; | 112   TileResolution resolution; | 
| 119   bool required_for_activation; | 113   bool required_for_activation; | 
| 120   float time_to_visible_in_seconds; | 114   float time_to_visible_in_seconds; | 
| 121   float distance_to_visible_in_pixels; | 115   float distance_to_visible_in_pixels; | 
| 122 | 116 | 
| 123  private: | 117  private: | 
| 124   gfx::QuadF current_screen_quad; | 118   gfx::QuadF current_screen_quad; | 
| 125 }; | 119 }; | 
| 126 | 120 | 
| 127 enum TileMemoryLimitPolicy { | 121 // NOTE: Be sure to update kBinPolicyMap when adding fields. | 
| 128   // Nothing. | 122 DEFINE_ENUM(TileMemoryLimitPolicy, | 
| 129   ALLOW_NOTHING = 0, | 123             // Nothing. | 
|  | 124             ALLOW_NOTHING, | 
| 130 | 125 | 
| 131   // You might be made visible, but you're not being interacted with. | 126             // You might be made visible, but you're not being interacted with. | 
| 132   ALLOW_ABSOLUTE_MINIMUM = 1,  // Tall. | 127             ALLOW_ABSOLUTE_MINIMUM,  // Tall. | 
| 133 | 128 | 
| 134   // You're being interacted with, but we're low on memory. | 129             // You're being interacted with, but we're low on memory. | 
| 135   ALLOW_PREPAINT_ONLY = 2,  // Grande. | 130             ALLOW_PREPAINT_ONLY,  // Grande. | 
| 136 | 131 | 
| 137   // You're the only thing in town. Go crazy. | 132             // You're the only thing in town. Go crazy. | 
| 138   ALLOW_ANYTHING = 3,  // Venti. | 133             ALLOW_ANYTHING);  // Venti. | 
| 139 |  | 
| 140   NUM_TILE_MEMORY_LIMIT_POLICIES = 4, |  | 
| 141 |  | 
| 142   // NOTE: Be sure to update TreePriorityAsValue and kBinPolicyMap when adding |  | 
| 143   // or reordering fields. |  | 
| 144 }; |  | 
| 145 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( | 134 scoped_ptr<base::Value> TileMemoryLimitPolicyAsValue( | 
| 146     TileMemoryLimitPolicy policy); | 135     TileMemoryLimitPolicy policy); | 
| 147 | 136 | 
| 148 enum TreePriority { | 137 enum TreePriority { | 
| 149   SAME_PRIORITY_FOR_BOTH_TREES, | 138   SAME_PRIORITY_FOR_BOTH_TREES, | 
| 150   SMOOTHNESS_TAKES_PRIORITY, | 139   SMOOTHNESS_TAKES_PRIORITY, | 
| 151   NEW_CONTENT_TAKES_PRIORITY | 140   NEW_CONTENT_TAKES_PRIORITY | 
| 152 |  | 
| 153   // Be sure to update TreePriorityAsValue when adding new fields. |  | 
| 154 }; | 141 }; | 
| 155 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio); | 142 scoped_ptr<base::Value> TreePriorityAsValue(TreePriority prio); | 
| 156 | 143 | 
| 157 class GlobalStateThatImpactsTilePriority { | 144 class GlobalStateThatImpactsTilePriority { | 
| 158  public: | 145  public: | 
| 159   GlobalStateThatImpactsTilePriority() | 146   GlobalStateThatImpactsTilePriority() | 
| 160       : memory_limit_policy(ALLOW_NOTHING), | 147       : memory_limit_policy(ALLOW_NOTHING), | 
| 161         memory_limit_in_bytes(0), | 148         memory_limit_in_bytes(0), | 
| 162         unused_memory_limit_in_bytes(0), | 149         unused_memory_limit_in_bytes(0), | 
| 163         num_resources_limit(0), | 150         num_resources_limit(0), | 
| 164         tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) {} | 151         tree_priority(SAME_PRIORITY_FOR_BOTH_TREES) {} | 
| 165 | 152 | 
| 166   TileMemoryLimitPolicy memory_limit_policy; | 153   TileMemoryLimitPolicy memory_limit_policy; | 
| 167 | 154 | 
| 168   size_t memory_limit_in_bytes; | 155   size_t memory_limit_in_bytes; | 
| 169   size_t unused_memory_limit_in_bytes; | 156   size_t unused_memory_limit_in_bytes; | 
| 170   size_t num_resources_limit; | 157   size_t num_resources_limit; | 
| 171 | 158 | 
| 172   TreePriority tree_priority; | 159   TreePriority tree_priority; | 
| 173 | 160 | 
| 174   scoped_ptr<base::Value> AsValue() const; | 161   scoped_ptr<base::Value> AsValue() const; | 
| 175 }; | 162 }; | 
| 176 | 163 | 
| 177 }  // namespace cc | 164 }  // namespace cc | 
| 178 | 165 | 
| 179 #endif  // CC_RESOURCES_TILE_PRIORITY_H_ | 166 #endif  // CC_RESOURCES_TILE_PRIORITY_H_ | 
| OLD | NEW | 
|---|