| 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_MANAGER_H_ | 5 #ifndef CC_TILE_MANAGER_H_ |
| 6 #define CC_TILE_MANAGER_H_ | 6 #define CC_TILE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "cc/memory_history.h" | 16 #include "cc/memory_history.h" |
| 17 #include "cc/picture_pile_impl.h" |
| 17 #include "cc/rendering_stats.h" | 18 #include "cc/rendering_stats.h" |
| 18 #include "cc/resource_pool.h" | 19 #include "cc/resource_pool.h" |
| 19 #include "cc/tile_priority.h" | 20 #include "cc/tile_priority.h" |
| 20 #include "cc/worker_pool.h" | 21 #include "cc/worker_pool.h" |
| 21 | 22 |
| 22 namespace cc { | 23 namespace cc { |
| 23 class RasterWorkerPool; | 24 class RasterWorkerPool; |
| 24 class ResourceProvider; | 25 class ResourceProvider; |
| 25 class Tile; | 26 class Tile; |
| 26 class TileVersion; | 27 class TileVersion; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 // Ephemeral state, valid only during Manage. | 87 // Ephemeral state, valid only during Manage. |
| 87 TileManagerBin bin[NUM_BIN_PRIORITIES]; | 88 TileManagerBin bin[NUM_BIN_PRIORITIES]; |
| 88 TileManagerBin tree_bin[NUM_TREES]; | 89 TileManagerBin tree_bin[NUM_TREES]; |
| 89 // The bin that the tile would have if the GPU memory manager had a maximally
permissive policy, | 90 // The bin that the tile would have if the GPU memory manager had a maximally
permissive policy, |
| 90 // send to the GPU memory manager to determine policy. | 91 // send to the GPU memory manager to determine policy. |
| 91 TileManagerBin gpu_memmgr_stats_bin; | 92 TileManagerBin gpu_memmgr_stats_bin; |
| 92 TileResolution resolution; | 93 TileResolution resolution; |
| 93 float time_to_needed_in_seconds; | 94 float time_to_needed_in_seconds; |
| 94 float distance_to_visible_in_pixels; | 95 float distance_to_visible_in_pixels; |
| 96 PicturePileImpl::Analysis picture_pile_analysis; |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 // This class manages tiles, deciding which should get rasterized and which | 99 // This class manages tiles, deciding which should get rasterized and which |
| 98 // should no longer have any memory assigned to them. Tile objects are "owned" | 100 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 99 // by layers; they automatically register with the manager when they are | 101 // by layers; they automatically register with the manager when they are |
| 100 // created, and unregister from the manager when they are deleted. | 102 // created, and unregister from the manager when they are deleted. |
| 101 class CC_EXPORT TileManager : public WorkerPoolClient { | 103 class CC_EXPORT TileManager : public WorkerPoolClient { |
| 102 public: | 104 public: |
| 103 TileManager(TileManagerClient* client, | 105 TileManager(TileManagerClient* client, |
| 104 ResourceProvider *resource_provider, | 106 ResourceProvider *resource_provider, |
| 105 size_t num_raster_threads, | 107 size_t num_raster_threads, |
| 106 bool use_cheapess_estimator); | 108 bool use_cheapess_estimator, |
| 109 bool use_color_estimator, |
| 110 bool prediction_benchmarking); |
| 107 virtual ~TileManager(); | 111 virtual ~TileManager(); |
| 108 | 112 |
| 109 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 113 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
| 110 return global_state_; | 114 return global_state_; |
| 111 } | 115 } |
| 112 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 116 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
| 113 | 117 |
| 114 void ManageTiles(); | 118 void ManageTiles(); |
| 115 void CheckForCompletedTileUploads(); | 119 void CheckForCompletedTileUploads(); |
| 116 void AbortPendingTileUploads(); | 120 void AbortPendingTileUploads(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | 145 Tile* tile, WhichTree tree, const TilePriority& new_priority) { |
| 142 // TODO(nduca): Do something smarter if reprioritization turns out to be | 146 // TODO(nduca): Do something smarter if reprioritization turns out to be |
| 143 // costly. | 147 // costly. |
| 144 ScheduleManageTiles(); | 148 ScheduleManageTiles(); |
| 145 } | 149 } |
| 146 | 150 |
| 147 private: | 151 private: |
| 148 | 152 |
| 149 // Data that is passed to raster tasks. | 153 // Data that is passed to raster tasks. |
| 150 struct RasterTaskMetadata { | 154 struct RasterTaskMetadata { |
| 151 bool use_cheapness_estimator; | 155 bool prediction_benchmarking; |
| 152 bool is_tile_in_pending_tree_now_bin; | 156 bool is_tile_in_pending_tree_now_bin; |
| 153 TileResolution tile_resolution; | 157 TileResolution tile_resolution; |
| 154 int layer_id; | 158 int layer_id; |
| 155 }; | 159 }; |
| 156 | 160 |
| 157 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; | 161 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const; |
| 162 |
| 158 void SortTiles(); | 163 void SortTiles(); |
| 159 void AssignGpuMemoryToTiles(); | 164 void AssignGpuMemoryToTiles(); |
| 160 void FreeResourcesForTile(Tile* tile); | 165 void FreeResourcesForTile(Tile* tile); |
| 161 void ScheduleManageTiles() { | 166 void ScheduleManageTiles() { |
| 162 if (manage_tiles_pending_) | 167 if (manage_tiles_pending_) |
| 163 return; | 168 return; |
| 164 client_->ScheduleManageTiles(); | 169 client_->ScheduleManageTiles(); |
| 165 manage_tiles_pending_ = true; | 170 manage_tiles_pending_ = true; |
| 166 } | 171 } |
| 167 void DispatchMoreTasks(); | 172 void DispatchMoreTasks(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 190 const gfx::Rect& rect, | 195 const gfx::Rect& rect, |
| 191 float contents_scale, | 196 float contents_scale, |
| 192 const RasterTaskMetadata& metadata, | 197 const RasterTaskMetadata& metadata, |
| 193 PicturePileImpl* picture_pile, | 198 PicturePileImpl* picture_pile, |
| 194 RenderingStats* stats); | 199 RenderingStats* stats); |
| 195 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 200 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
| 196 RenderingStats* stats); | 201 RenderingStats* stats); |
| 197 | 202 |
| 198 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, | 203 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, |
| 199 bool is_actually_cheap); | 204 bool is_actually_cheap); |
| 205 static void RecordSolidColorPredictorResults(const SkColor* actual_colors, |
| 206 size_t color_count, |
| 207 bool is_predicted_solid, |
| 208 SkColor predicted_color, |
| 209 bool is_predicted_transparent); |
| 200 | 210 |
| 201 TileManagerClient* client_; | 211 TileManagerClient* client_; |
| 202 scoped_ptr<ResourcePool> resource_pool_; | 212 scoped_ptr<ResourcePool> resource_pool_; |
| 203 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 213 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
| 204 bool manage_tiles_pending_; | 214 bool manage_tiles_pending_; |
| 205 int manage_tiles_call_count_; | 215 int manage_tiles_call_count_; |
| 206 | 216 |
| 207 GlobalStateThatImpactsTilePriority global_state_; | 217 GlobalStateThatImpactsTilePriority global_state_; |
| 208 | 218 |
| 209 typedef std::vector<Tile*> TileVector; | 219 typedef std::vector<Tile*> TileVector; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 224 TileQueue tiles_with_pending_upload_; | 234 TileQueue tiles_with_pending_upload_; |
| 225 size_t bytes_pending_upload_; | 235 size_t bytes_pending_upload_; |
| 226 bool has_performed_uploads_since_last_flush_; | 236 bool has_performed_uploads_since_last_flush_; |
| 227 bool ever_exceeded_memory_budget_; | 237 bool ever_exceeded_memory_budget_; |
| 228 MemoryHistory::Entry memory_stats_from_last_assign_; | 238 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 229 | 239 |
| 230 bool record_rendering_stats_; | 240 bool record_rendering_stats_; |
| 231 RenderingStats rendering_stats_; | 241 RenderingStats rendering_stats_; |
| 232 | 242 |
| 233 bool use_cheapness_estimator_; | 243 bool use_cheapness_estimator_; |
| 244 bool use_color_estimator_; |
| 234 bool did_schedule_cheap_tasks_; | 245 bool did_schedule_cheap_tasks_; |
| 235 bool allow_cheap_tasks_; | 246 bool allow_cheap_tasks_; |
| 236 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 247 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
| 248 bool prediction_benchmarking_; |
| 237 | 249 |
| 238 DISALLOW_COPY_AND_ASSIGN(TileManager); | 250 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 239 }; | 251 }; |
| 240 | 252 |
| 241 } // namespace cc | 253 } // namespace cc |
| 242 | 254 |
| 243 #endif // CC_TILE_MANAGER_H_ | 255 #endif // CC_TILE_MANAGER_H_ |
| OLD | NEW |