| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MANAGED_TILE_STATE_H_ | 5 #ifndef CC_RESOURCES_MANAGED_TILE_STATE_H_ |
| 6 #define CC_RESOURCES_MANAGED_TILE_STATE_H_ | 6 #define CC_RESOURCES_MANAGED_TILE_STATE_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/base/util.h" |
| 9 #include "cc/resources/platform_color.h" | 10 #include "cc/resources/platform_color.h" |
| 10 #include "cc/resources/raster_worker_pool.h" | 11 #include "cc/resources/raster_worker_pool.h" |
| 11 #include "cc/resources/resource_pool.h" | 12 #include "cc/resources/resource_pool.h" |
| 12 #include "cc/resources/resource_provider.h" | 13 #include "cc/resources/resource_provider.h" |
| 13 | 14 |
| 14 namespace cc { | 15 namespace cc { |
| 15 | 16 |
| 16 class TileManager; | 17 class TileManager; |
| 17 | 18 |
| 18 // Tile manager classifying tiles into a few basic bins: | 19 // Tile manager classifying tiles into a few basic bins: |
| 19 enum ManagedTileBin { | 20 // NOTE: Be sure to update kBinPolicyMap when adding fields. |
| 20 NOW_AND_READY_TO_DRAW_BIN = 0, // Ready to draw and within viewport. | 21 DEFINE_ENUM(ManagedTileBin, |
| 21 NOW_BIN = 1, // Needed ASAP. | 22 // Ready to draw and within viewport. |
| 22 SOON_BIN = 2, // Impl-side version of prepainting. | 23 NOW_AND_READY_TO_DRAW_BIN, |
| 23 EVENTUALLY_AND_ACTIVE_BIN = 3, // Nice to have, and has a task or resource. | |
| 24 EVENTUALLY_BIN = 4, // Nice to have, if we've got memory and time. | |
| 25 NEVER_AND_ACTIVE_BIN = 5, // Dont bother, but has a task or resource. | |
| 26 NEVER_BIN = 6, // Dont bother. | |
| 27 NUM_BINS = 7 | |
| 28 // NOTE: Be sure to update ManagedTileBinAsValue and kBinPolicyMap when adding | |
| 29 // or reordering fields. | |
| 30 }; | |
| 31 scoped_ptr<base::Value> ManagedTileBinAsValue( | |
| 32 ManagedTileBin bin); | |
| 33 | 24 |
| 34 enum ManagedTileBinPriority { | 25 // Needed ASAP. |
| 35 HIGH_PRIORITY_BIN = 0, | 26 NOW_BIN, |
| 36 LOW_PRIORITY_BIN = 1, | 27 |
| 37 NUM_BIN_PRIORITIES = 2 | 28 // Impl-side version of prepainting. |
| 38 }; | 29 SOON_BIN, |
| 30 |
| 31 // Nice to have, and has a task or resource. |
| 32 EVENTUALLY_AND_ACTIVE_BIN, |
| 33 |
| 34 // Nice to have, if we've got memory and time. |
| 35 EVENTUALLY_BIN, |
| 36 |
| 37 // Dont bother, but has a task or resource. |
| 38 NEVER_AND_ACTIVE_BIN, |
| 39 |
| 40 // Dont bother. |
| 41 NEVER_BIN); |
| 42 scoped_ptr<base::Value> ManagedTileBinAsValue(ManagedTileBin bin); |
| 43 |
| 44 DEFINE_ENUM(ManagedTileBinPriority, |
| 45 HIGH_PRIORITY_BIN, |
| 46 LOW_PRIORITY_BIN); |
| 39 scoped_ptr<base::Value> ManagedTileBinPriorityAsValue( | 47 scoped_ptr<base::Value> ManagedTileBinPriorityAsValue( |
| 40 ManagedTileBinPriority bin); | 48 ManagedTileBinPriority bin); |
| 41 | 49 |
| 42 // This is state that is specific to a tile that is | 50 // This is state that is specific to a tile that is |
| 43 // managed by the TileManager. | 51 // managed by the TileManager. |
| 44 class CC_EXPORT ManagedTileState { | 52 class CC_EXPORT ManagedTileState { |
| 45 public: | 53 public: |
| 46 class CC_EXPORT TileVersion { | 54 class CC_EXPORT TileVersion { |
| 47 public: | 55 public: |
| 48 enum Mode { | 56 enum Mode { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 scoped_ptr<ResourcePool::Resource> resource_; | 129 scoped_ptr<ResourcePool::Resource> resource_; |
| 122 RasterWorkerPool::RasterTask raster_task_; | 130 RasterWorkerPool::RasterTask raster_task_; |
| 123 }; | 131 }; |
| 124 | 132 |
| 125 ManagedTileState(); | 133 ManagedTileState(); |
| 126 ~ManagedTileState(); | 134 ~ManagedTileState(); |
| 127 | 135 |
| 128 scoped_ptr<base::Value> AsValue() const; | 136 scoped_ptr<base::Value> AsValue() const; |
| 129 | 137 |
| 130 // Persisted state: valid all the time. | 138 // Persisted state: valid all the time. |
| 131 TileVersion tile_versions[NUM_RASTER_MODES]; | 139 TileVersion tile_versions[RasterMode_ARRAYSIZE]; |
| 132 RasterMode raster_mode; | 140 RasterMode raster_mode; |
| 133 | 141 |
| 134 // Ephemeral state, valid only during TileManager::ManageTiles. | 142 // Ephemeral state, valid only during TileManager::ManageTiles. |
| 135 bool is_in_never_bin_on_both_trees() const { | 143 bool is_in_never_bin_on_both_trees() const { |
| 136 return (bin[HIGH_PRIORITY_BIN] == NEVER_BIN || | 144 return (bin[HIGH_PRIORITY_BIN] == NEVER_BIN || |
| 137 bin[HIGH_PRIORITY_BIN] == NEVER_AND_ACTIVE_BIN) && | 145 bin[HIGH_PRIORITY_BIN] == NEVER_AND_ACTIVE_BIN) && |
| 138 (bin[LOW_PRIORITY_BIN] == NEVER_BIN || | 146 (bin[LOW_PRIORITY_BIN] == NEVER_BIN || |
| 139 bin[LOW_PRIORITY_BIN] == NEVER_AND_ACTIVE_BIN); | 147 bin[LOW_PRIORITY_BIN] == NEVER_AND_ACTIVE_BIN); |
| 140 } | 148 } |
| 141 | 149 |
| 142 ManagedTileBin bin[NUM_BIN_PRIORITIES]; | 150 ManagedTileBin bin[ManagedTileBinPriority_ARRAYSIZE]; |
| 143 ManagedTileBin tree_bin[NUM_TREES]; | 151 ManagedTileBin tree_bin[WhichTree_ARRAYSIZE]; |
| 144 | 152 |
| 145 // The bin that the tile would have if the GPU memory manager had | 153 // The bin that the tile would have if the GPU memory manager had |
| 146 // a maximally permissive policy, send to the GPU memory manager | 154 // a maximally permissive policy, send to the GPU memory manager |
| 147 // to determine policy. | 155 // to determine policy. |
| 148 ManagedTileBin gpu_memmgr_stats_bin; | 156 ManagedTileBin gpu_memmgr_stats_bin; |
| 149 TileResolution resolution; | 157 TileResolution resolution; |
| 150 bool required_for_activation; | 158 bool required_for_activation; |
| 151 float time_to_needed_in_seconds; | 159 float time_to_needed_in_seconds; |
| 152 float distance_to_visible_in_pixels; | 160 float distance_to_visible_in_pixels; |
| 153 bool visible_and_ready_to_draw; | 161 bool visible_and_ready_to_draw; |
| 154 | 162 |
| 155 // Priority for this state from the last time we assigned memory. | 163 // Priority for this state from the last time we assigned memory. |
| 156 unsigned scheduled_priority; | 164 unsigned scheduled_priority; |
| 157 }; | 165 }; |
| 158 | 166 |
| 159 } // namespace cc | 167 } // namespace cc |
| 160 | 168 |
| 161 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ | 169 #endif // CC_RESOURCES_MANAGED_TILE_STATE_H_ |
| OLD | NEW |