Chromium Code Reviews| 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 <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "cc/memory_history.h" | 15 #include "cc/memory_history.h" |
| 16 #include "cc/rendering_stats.h" | 16 #include "cc/rendering_stats.h" |
| 17 #include "cc/resource_pool.h" | 17 #include "cc/resource_pool.h" |
| 18 #include "cc/tile_priority.h" | 18 #include "cc/tile_priority.h" |
| 19 #include "cc/worker_pool.h" | |
| 19 | 20 |
| 20 namespace cc { | 21 namespace cc { |
| 21 class RasterWorkerPool; | 22 class RasterWorkerPool; |
| 22 class ResourceProvider; | 23 class ResourceProvider; |
| 23 class Tile; | 24 class Tile; |
| 24 class TileVersion; | 25 class TileVersion; |
| 25 | 26 |
| 26 class CC_EXPORT TileManagerClient { | 27 class CC_EXPORT TileManagerClient { |
| 27 public: | 28 public: |
| 28 virtual void ScheduleManageTiles() = 0; | 29 virtual void ScheduleManageTiles() = 0; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 // send to the GPU memory manager to determine policy. | 89 // send to the GPU memory manager to determine policy. |
| 89 TileManagerBin gpu_memmgr_stats_bin; | 90 TileManagerBin gpu_memmgr_stats_bin; |
| 90 TileResolution resolution; | 91 TileResolution resolution; |
| 91 float time_to_needed_in_seconds; | 92 float time_to_needed_in_seconds; |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 // This class manages tiles, deciding which should get rasterized and which | 95 // This class manages tiles, deciding which should get rasterized and which |
| 95 // should no longer have any memory assigned to them. Tile objects are "owned" | 96 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 96 // by layers; they automatically register with the manager when they are | 97 // by layers; they automatically register with the manager when they are |
| 97 // created, and unregister from the manager when they are deleted. | 98 // created, and unregister from the manager when they are deleted. |
| 98 class CC_EXPORT TileManager { | 99 class CC_EXPORT TileManager : public WorkerPoolClient { |
| 99 public: | 100 public: |
| 100 TileManager(TileManagerClient* client, | 101 TileManager(TileManagerClient* client, |
| 101 ResourceProvider *resource_provider, | 102 ResourceProvider *resource_provider, |
| 102 size_t num_raster_threads, | 103 size_t num_raster_threads, |
| 103 bool use_cheapess_estimator); | 104 bool use_cheapess_estimator); |
| 104 virtual ~TileManager(); | 105 virtual ~TileManager(); |
| 105 | 106 |
| 106 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 107 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
| 107 return global_state_; | 108 return global_state_; |
| 108 } | 109 } |
| 109 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 110 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
| 110 | 111 |
| 111 void ManageTiles(); | 112 void ManageTiles(); |
| 112 void CheckForCompletedTileUploads(); | 113 void CheckForCompletedTileUploads(); |
| 113 void AbortPendingTileUploads(); | 114 void AbortPendingTileUploads(); |
| 114 | 115 |
| 115 scoped_ptr<base::Value> BasicStateAsValue() const; | 116 scoped_ptr<base::Value> BasicStateAsValue() const; |
| 116 scoped_ptr<base::Value> AllTilesAsValue() const; | 117 scoped_ptr<base::Value> AllTilesAsValue() const; |
| 117 void GetMemoryStats(size_t* memoryRequiredBytes, | 118 void GetMemoryStats(size_t* memoryRequiredBytes, |
| 118 size_t* memoryNiceToHaveBytes, | 119 size_t* memoryNiceToHaveBytes, |
| 119 size_t* memoryUsedBytes) const; | 120 size_t* memoryUsedBytes) const; |
| 120 void SetRecordRenderingStats(bool record_rendering_stats); | 121 void SetRecordRenderingStats(bool record_rendering_stats); |
| 121 void GetRenderingStats(RenderingStats* stats); | 122 void GetRenderingStats(RenderingStats* stats); |
| 122 bool HasPendingWorkScheduled(WhichTree tree) const; | 123 bool HasPendingWorkScheduled(WhichTree tree) const; |
| 123 | 124 |
| 124 const MemoryHistory::Entry& memory_stats_from_last_assign() const { return mem ory_stats_from_last_assign_; } | 125 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 126 return memory_stats_from_last_assign_; | |
| 127 } | |
| 128 | |
| 129 // Overridden from WorkerPoolClient: | |
| 130 virtual void DidFinishDispatchingCompletionCallbacks() OVERRIDE; | |
|
nduca
2013/02/13 10:53:37
Might tweak the name so it has Worker in it so its
reveman
2013/02/13 15:32:58
Now DidFinishDispatchingWorkerPoolCompletionCallba
| |
| 125 | 131 |
| 126 protected: | 132 protected: |
| 127 // Methods called by Tile | 133 // Methods called by Tile |
| 128 friend class Tile; | 134 friend class Tile; |
| 129 void RegisterTile(Tile* tile); | 135 void RegisterTile(Tile* tile); |
| 130 void UnregisterTile(Tile* tile); | 136 void UnregisterTile(Tile* tile); |
| 131 void WillModifyTilePriority( | 137 void WillModifyTilePriority( |
| 132 Tile* tile, WhichTree tree, const TilePriority& new_priority) { | 138 Tile* tile, WhichTree tree, const TilePriority& new_priority) { |
| 133 // TODO(nduca): Do something smarter if reprioritization turns out to be | 139 // TODO(nduca): Do something smarter if reprioritization turns out to be |
| 134 // costly. | 140 // costly. |
| 135 ScheduleManageTiles(); | 141 ScheduleManageTiles(); |
| 136 } | 142 } |
| 137 | 143 |
| 138 private: | 144 private: |
| 139 void SortTiles(); | 145 void SortTiles(); |
| 140 void AssignGpuMemoryToTiles(); | 146 void AssignGpuMemoryToTiles(); |
| 141 void FreeResourcesForTile(Tile* tile); | 147 void FreeResourcesForTile(Tile* tile); |
| 142 void ScheduleManageTiles() { | 148 void ScheduleManageTiles() { |
| 143 if (manage_tiles_pending_) | 149 if (manage_tiles_pending_) |
| 144 return; | 150 return; |
| 145 client_->ScheduleManageTiles(); | 151 client_->ScheduleManageTiles(); |
| 146 manage_tiles_pending_ = true; | 152 manage_tiles_pending_ = true; |
| 147 } | 153 } |
| 148 void DispatchMoreTasks(); | 154 void DispatchMoreTasks(); |
| 149 void GatherPixelRefsForTile(Tile* tile); | 155 void GatherPixelRefsForTile(Tile* tile); |
| 150 void DispatchImageDecodeTasksForTile(Tile* tile); | 156 void DispatchImageDecodeTasksForTile(Tile* tile); |
| 151 void DispatchOneImageDecodeTask( | 157 void DispatchOneImageDecodeTask( |
| 152 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); | 158 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); |
| 153 void OnImageDecodeTaskCompleted( | 159 void OnImageDecodeTaskCompleted( |
| 154 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); | 160 scoped_refptr<Tile> tile, |
| 161 uint32_t pixel_ref_id); | |
| 155 bool CanDispatchRasterTask(Tile* tile); | 162 bool CanDispatchRasterTask(Tile* tile); |
| 156 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); | 163 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); |
| 157 void DispatchOneRasterTask(scoped_refptr<Tile> tile); | 164 void DispatchOneRasterTask(scoped_refptr<Tile> tile); |
| 158 void PerformOneRaster(Tile* tile); | 165 void PerformOneRaster(Tile* tile); |
| 159 void OnRasterCompleted( | 166 void OnRasterCompleted( |
| 160 scoped_refptr<Tile> tile, | 167 scoped_refptr<Tile> tile, |
| 161 scoped_ptr<ResourcePool::Resource> resource, | 168 scoped_ptr<ResourcePool::Resource> resource, |
| 162 int manage_tiles_call_count_when_dispatched); | 169 int manage_tiles_call_count_when_dispatched); |
| 163 void OnRasterTaskCompleted( | 170 void OnRasterTaskCompleted( |
| 164 scoped_refptr<Tile> tile, | 171 scoped_refptr<Tile> tile, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 TileVector tiles_that_need_to_be_rasterized_; | 203 TileVector tiles_that_need_to_be_rasterized_; |
| 197 | 204 |
| 198 typedef std::list<Tile*> TileList; | 205 typedef std::list<Tile*> TileList; |
| 199 // Tiles with image decoding tasks. These tiles need to be rasterized | 206 // Tiles with image decoding tasks. These tiles need to be rasterized |
| 200 // when all the image decoding tasks finish. | 207 // when all the image decoding tasks finish. |
| 201 TileList tiles_with_image_decoding_tasks_; | 208 TileList tiles_with_image_decoding_tasks_; |
| 202 | 209 |
| 203 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; | 210 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; |
| 204 PixelRefMap pending_decode_tasks_; | 211 PixelRefMap pending_decode_tasks_; |
| 205 | 212 |
| 213 size_t bytes_pending_raster_; | |
| 214 | |
| 206 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 215 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
| 207 TileQueue tiles_with_pending_set_pixels_; | 216 TileQueue tiles_with_pending_set_pixels_; |
| 208 size_t bytes_pending_set_pixels_; | 217 size_t bytes_pending_set_pixels_; |
| 218 bool need_shallow_flush_; | |
| 209 bool ever_exceeded_memory_budget_; | 219 bool ever_exceeded_memory_budget_; |
| 210 MemoryHistory::Entry memory_stats_from_last_assign_; | 220 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 211 | 221 |
| 212 bool record_rendering_stats_; | 222 bool record_rendering_stats_; |
| 213 RenderingStats rendering_stats_; | 223 RenderingStats rendering_stats_; |
| 214 | 224 |
| 215 bool use_cheapness_estimator_; | 225 bool use_cheapness_estimator_; |
| 216 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 226 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
| 217 | 227 |
| 218 DISALLOW_COPY_AND_ASSIGN(TileManager); | 228 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 219 }; | 229 }; |
| 220 | 230 |
| 221 } // namespace cc | 231 } // namespace cc |
| 222 | 232 |
| 223 #endif // CC_TILE_MANAGER_H_ | 233 #endif // CC_TILE_MANAGER_H_ |
| OLD | NEW |