| 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/picture_pile_impl.h" |
| 18 #include "cc/rendering_stats.h" | 18 #include "cc/rendering_stats_recorder.h" |
| 19 #include "cc/resource_pool.h" | 19 #include "cc/resource_pool.h" |
| 20 #include "cc/tile_priority.h" | 20 #include "cc/tile_priority.h" |
| 21 #include "cc/worker_pool.h" | 21 #include "cc/worker_pool.h" |
| 22 | 22 |
| 23 namespace cc { | 23 namespace cc { |
| 24 class RasterWorkerPool; | 24 class RasterWorkerPool; |
| 25 class ResourceProvider; | 25 class ResourceProvider; |
| 26 class Tile; | 26 class Tile; |
| 27 class TileVersion; | 27 class TileVersion; |
| 28 | 28 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 // This class manages tiles, deciding which should get rasterized and which | 100 // This class manages tiles, deciding which should get rasterized and which |
| 101 // should no longer have any memory assigned to them. Tile objects are "owned" | 101 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 102 // by layers; they automatically register with the manager when they are | 102 // by layers; they automatically register with the manager when they are |
| 103 // created, and unregister from the manager when they are deleted. | 103 // created, and unregister from the manager when they are deleted. |
| 104 class CC_EXPORT TileManager : public WorkerPoolClient { | 104 class CC_EXPORT TileManager : public WorkerPoolClient { |
| 105 public: | 105 public: |
| 106 TileManager(TileManagerClient* client, | 106 TileManager(TileManagerClient* client, |
| 107 ResourceProvider *resource_provider, | 107 ResourceProvider *resource_provider, |
| 108 size_t num_raster_threads, | 108 size_t num_raster_threads, |
| 109 RenderingStatsRecorder* rendering_stats_recorder, |
| 109 bool use_cheapess_estimator, | 110 bool use_cheapess_estimator, |
| 110 bool use_color_estimator, | 111 bool use_color_estimator, |
| 111 bool prediction_benchmarking); | 112 bool prediction_benchmarking); |
| 112 virtual ~TileManager(); | 113 virtual ~TileManager(); |
| 113 | 114 |
| 114 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 115 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
| 115 return global_state_; | 116 return global_state_; |
| 116 } | 117 } |
| 117 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 118 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
| 118 | 119 |
| 119 void ManageTiles(); | 120 void ManageTiles(); |
| 120 void CheckForCompletedTileUploads(); | 121 void CheckForCompletedTileUploads(); |
| 121 void AbortPendingTileUploads(); | 122 void AbortPendingTileUploads(); |
| 122 void DidCompleteFrame(); | 123 void DidCompleteFrame(); |
| 123 | 124 |
| 124 scoped_ptr<base::Value> BasicStateAsValue() const; | 125 scoped_ptr<base::Value> BasicStateAsValue() const; |
| 125 scoped_ptr<base::Value> AllTilesAsValue() const; | 126 scoped_ptr<base::Value> AllTilesAsValue() const; |
| 126 void GetMemoryStats(size_t* memoryRequiredBytes, | 127 void GetMemoryStats(size_t* memoryRequiredBytes, |
| 127 size_t* memoryNiceToHaveBytes, | 128 size_t* memoryNiceToHaveBytes, |
| 128 size_t* memoryUsedBytes) const; | 129 size_t* memoryUsedBytes) const; |
| 129 void SetRecordRenderingStats(bool record_rendering_stats); | |
| 130 void GetRenderingStats(RenderingStats* stats); | |
| 131 bool HasPendingWorkScheduled(WhichTree tree) const; | 130 bool HasPendingWorkScheduled(WhichTree tree) const; |
| 132 | 131 |
| 133 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 132 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 134 return memory_stats_from_last_assign_; | 133 return memory_stats_from_last_assign_; |
| 135 } | 134 } |
| 136 | 135 |
| 137 // Overridden from WorkerPoolClient: | 136 // Overridden from WorkerPoolClient: |
| 138 virtual void DidFinishDispatchingWorkerPoolCompletionCallbacks() OVERRIDE; | 137 virtual void DidFinishDispatchingWorkerPoolCompletionCallbacks() OVERRIDE; |
| 139 | 138 |
| 140 protected: | 139 protected: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 scoped_refptr<Tile> tile, | 185 scoped_refptr<Tile> tile, |
| 187 scoped_ptr<ResourcePool::Resource> resource, | 186 scoped_ptr<ResourcePool::Resource> resource, |
| 188 int manage_tiles_call_count_when_dispatched); | 187 int manage_tiles_call_count_when_dispatched); |
| 189 void DidFinishTileInitialization(Tile* tile); | 188 void DidFinishTileInitialization(Tile* tile); |
| 190 void DidTileRasterStateChange(Tile* tile, TileRasterState state); | 189 void DidTileRasterStateChange(Tile* tile, TileRasterState state); |
| 191 void DidTileTreeBinChange(Tile* tile, | 190 void DidTileTreeBinChange(Tile* tile, |
| 192 TileManagerBin new_tree_bin, | 191 TileManagerBin new_tree_bin, |
| 193 WhichTree tree); | 192 WhichTree tree); |
| 194 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; | 193 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; |
| 195 | 194 |
| 196 static void RunRasterTask(uint8* buffer, | 195 static void RunRasterTask( |
| 197 const gfx::Rect& rect, | 196 uint8* buffer, |
| 198 float contents_scale, | 197 const gfx::Rect& rect, |
| 199 const RasterTaskMetadata& metadata, | 198 float contents_scale, |
| 200 PicturePileImpl* picture_pile, | 199 const RasterTaskMetadata& metadata, |
| 201 RenderingStats* stats); | 200 RenderingStatsRecorder* stats_recorder, |
| 202 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 201 PicturePileImpl* picture_pile); |
| 203 RenderingStats* stats); | 202 static void RunImageDecodeTask( |
| 203 skia::LazyPixelRef* pixel_ref, |
| 204 RenderingStatsRecorder* stats_recorder); |
| 204 | 205 |
| 205 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, | 206 static void RecordCheapnessPredictorResults(bool is_predicted_cheap, |
| 206 bool is_actually_cheap); | 207 bool is_actually_cheap); |
| 207 static void RecordSolidColorPredictorResults(const SkColor* actual_colors, | 208 static void RecordSolidColorPredictorResults(const SkColor* actual_colors, |
| 208 size_t color_count, | 209 size_t color_count, |
| 209 bool is_predicted_solid, | 210 bool is_predicted_solid, |
| 210 SkColor predicted_color, | 211 SkColor predicted_color, |
| 211 bool is_predicted_transparent); | 212 bool is_predicted_transparent); |
| 212 | 213 |
| 213 TileManagerClient* client_; | 214 TileManagerClient* client_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 232 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; | 233 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; |
| 233 PixelRefMap pending_decode_tasks_; | 234 PixelRefMap pending_decode_tasks_; |
| 234 | 235 |
| 235 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 236 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
| 236 TileQueue tiles_with_pending_upload_; | 237 TileQueue tiles_with_pending_upload_; |
| 237 size_t bytes_pending_upload_; | 238 size_t bytes_pending_upload_; |
| 238 bool has_performed_uploads_since_last_flush_; | 239 bool has_performed_uploads_since_last_flush_; |
| 239 bool ever_exceeded_memory_budget_; | 240 bool ever_exceeded_memory_budget_; |
| 240 MemoryHistory::Entry memory_stats_from_last_assign_; | 241 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 241 | 242 |
| 242 bool record_rendering_stats_; | 243 RenderingStatsRecorder* rendering_stats_recorder_; |
| 243 RenderingStats rendering_stats_; | |
| 244 | 244 |
| 245 bool use_cheapness_estimator_; | 245 bool use_cheapness_estimator_; |
| 246 bool use_color_estimator_; | 246 bool use_color_estimator_; |
| 247 bool did_schedule_cheap_tasks_; | 247 bool did_schedule_cheap_tasks_; |
| 248 bool allow_cheap_tasks_; | 248 bool allow_cheap_tasks_; |
| 249 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 249 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
| 250 bool prediction_benchmarking_; | 250 bool prediction_benchmarking_; |
| 251 | 251 |
| 252 size_t pending_tasks_; | 252 size_t pending_tasks_; |
| 253 size_t max_pending_tasks_; | 253 size_t max_pending_tasks_; |
| 254 | 254 |
| 255 DISALLOW_COPY_AND_ASSIGN(TileManager); | 255 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 256 }; | 256 }; |
| 257 | 257 |
| 258 } // namespace cc | 258 } // namespace cc |
| 259 | 259 |
| 260 #endif // CC_TILE_MANAGER_H_ | 260 #endif // CC_TILE_MANAGER_H_ |
| OLD | NEW |