| 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_MANAGER_H_ | 5 #ifndef CC_RESOURCES_TILE_MANAGER_H_ |
| 6 #define CC_RESOURCES_TILE_MANAGER_H_ | 6 #define CC_RESOURCES_TILE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/containers/hash_tables.h" | 14 #include "base/containers/hash_tables.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "cc/base/ref_counted_managed.h" | 17 #include "cc/base/ref_counted_managed.h" |
| 18 #include "cc/base/unique_notifier.h" | 18 #include "cc/base/unique_notifier.h" |
| 19 #include "cc/debug/rendering_stats_instrumentation.h" | 19 #include "cc/debug/rendering_stats_instrumentation.h" |
| 20 #include "cc/resources/eviction_tile_priority_queue.h" | 20 #include "cc/resources/eviction_tile_priority_queue.h" |
| 21 #include "cc/resources/gpu_rasterizer.h" |
| 21 #include "cc/resources/managed_tile_state.h" | 22 #include "cc/resources/managed_tile_state.h" |
| 22 #include "cc/resources/memory_history.h" | 23 #include "cc/resources/memory_history.h" |
| 23 #include "cc/resources/raster_source.h" | 24 #include "cc/resources/raster_source.h" |
| 24 #include "cc/resources/raster_tile_priority_queue.h" | 25 #include "cc/resources/raster_tile_priority_queue.h" |
| 25 #include "cc/resources/rasterizer.h" | 26 #include "cc/resources/rasterizer.h" |
| 26 #include "cc/resources/resource_pool.h" | 27 #include "cc/resources/resource_pool.h" |
| 27 #include "cc/resources/tile.h" | 28 #include "cc/resources/tile.h" |
| 28 | 29 |
| 29 namespace base { | 30 namespace base { |
| 30 namespace debug { | 31 namespace debug { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 REQUIRED_FOR_DRAW | 96 REQUIRED_FOR_DRAW |
| 96 // Adding additional values requires increasing kNumberOfTaskSets in | 97 // Adding additional values requires increasing kNumberOfTaskSets in |
| 97 // rasterizer.h | 98 // rasterizer.h |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 static scoped_ptr<TileManager> Create( | 101 static scoped_ptr<TileManager> Create( |
| 101 TileManagerClient* client, | 102 TileManagerClient* client, |
| 102 base::SequencedTaskRunner* task_runner, | 103 base::SequencedTaskRunner* task_runner, |
| 103 ResourcePool* resource_pool, | 104 ResourcePool* resource_pool, |
| 104 Rasterizer* rasterizer, | 105 Rasterizer* rasterizer, |
| 106 GpuRasterizer* gpu_rasterizer, |
| 105 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 107 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 106 size_t scheduled_raster_task_limit); | 108 size_t scheduled_raster_task_limit); |
| 107 ~TileManager() override; | 109 ~TileManager() override; |
| 108 | 110 |
| 111 void RasterizeTiles(const GlobalStateThatImpactsTilePriority& state); |
| 109 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); | 112 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); |
| 110 | 113 |
| 111 void UpdateVisibleTiles(); | 114 void UpdateVisibleTiles(); |
| 112 | 115 |
| 113 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, | 116 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, |
| 114 const gfx::Size& tile_size, | 117 const gfx::Size& tile_size, |
| 115 const gfx::Rect& content_rect, | 118 const gfx::Rect& content_rect, |
| 116 float contents_scale, | 119 float contents_scale, |
| 117 int layer_id, | 120 int layer_id, |
| 118 int source_frame_number, | 121 int source_frame_number, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 158 |
| 156 std::vector<Tile*> AllTilesForTesting() const { | 159 std::vector<Tile*> AllTilesForTesting() const { |
| 157 std::vector<Tile*> tiles; | 160 std::vector<Tile*> tiles; |
| 158 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); | 161 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); |
| 159 ++it) { | 162 ++it) { |
| 160 tiles.push_back(it->second); | 163 tiles.push_back(it->second); |
| 161 } | 164 } |
| 162 return tiles; | 165 return tiles; |
| 163 } | 166 } |
| 164 | 167 |
| 168 void CompleteRasterTask(Tile::Id tile, |
| 169 scoped_ptr<ScopedResource> resource, |
| 170 const RasterSource::SolidColorAnalysis& analysis); |
| 171 |
| 165 protected: | 172 protected: |
| 166 TileManager(TileManagerClient* client, | 173 TileManager(TileManagerClient* client, |
| 167 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 174 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 168 ResourcePool* resource_pool, | 175 ResourcePool* resource_pool, |
| 169 Rasterizer* rasterizer, | 176 Rasterizer* rasterizer, |
| 177 GpuRasterizer* gpu_rasterizer, |
| 170 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 178 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 171 size_t scheduled_raster_task_limit); | 179 size_t scheduled_raster_task_limit); |
| 172 | 180 |
| 173 void FreeResourcesForReleasedTiles(); | 181 void FreeResourcesForReleasedTiles(); |
| 174 void CleanUpReleasedTiles(); | 182 void CleanUpReleasedTiles(); |
| 175 | 183 |
| 176 // Overriden from RefCountedManager<Tile>: | 184 // Overriden from RefCountedManager<Tile>: |
| 177 friend class Tile; | 185 friend class Tile; |
| 178 void Release(Tile* tile) override; | 186 void Release(Tile* tile) override; |
| 179 | 187 |
| 180 // Overriden from RasterizerClient: | 188 // Overriden from RasterizerClient: |
| 181 void DidFinishRunningTasks(TaskSet task_set) override; | 189 void DidFinishRunningTasks(TaskSet task_set) override; |
| 182 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; | 190 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; |
| 183 | 191 |
| 184 typedef std::vector<Tile*> TileVector; | 192 typedef std::vector<Tile*> TileVector; |
| 185 typedef std::set<Tile*> TileSet; | 193 typedef std::set<Tile*> TileSet; |
| 186 | 194 |
| 187 // Virtual for test | 195 // Virtual for test |
| 188 virtual void ScheduleTasks( | 196 virtual void ScheduleTasks( |
| 189 const TileVector& tiles_that_need_to_be_rasterized); | 197 const TileVector& tiles_that_need_to_be_rasterized); |
| 190 | 198 |
| 191 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); | 199 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized, |
| 200 size_t scheduled_raser_task_limit); |
| 192 | 201 |
| 193 private: | 202 private: |
| 194 class MemoryUsage { | 203 class MemoryUsage { |
| 195 public: | 204 public: |
| 196 MemoryUsage(); | 205 MemoryUsage(); |
| 197 MemoryUsage(int64 memory_bytes, int resource_count); | 206 MemoryUsage(int64 memory_bytes, int resource_count); |
| 198 | 207 |
| 199 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); | 208 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); |
| 200 static MemoryUsage FromTile(const Tile* tile); | 209 static MemoryUsage FromTile(const Tile* tile); |
| 201 | 210 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); | 244 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); |
| 236 bool IsReadyToActivate() const; | 245 bool IsReadyToActivate() const; |
| 237 bool IsReadyToDraw() const; | 246 bool IsReadyToDraw() const; |
| 238 void CheckIfReadyToActivate(); | 247 void CheckIfReadyToActivate(); |
| 239 void CheckIfReadyToDraw(); | 248 void CheckIfReadyToDraw(); |
| 240 | 249 |
| 241 TileManagerClient* client_; | 250 TileManagerClient* client_; |
| 242 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 251 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 243 ResourcePool* resource_pool_; | 252 ResourcePool* resource_pool_; |
| 244 Rasterizer* rasterizer_; | 253 Rasterizer* rasterizer_; |
| 254 GpuRasterizer* gpu_rasterizer_; |
| 245 GlobalStateThatImpactsTilePriority global_state_; | 255 GlobalStateThatImpactsTilePriority global_state_; |
| 246 const size_t scheduled_raster_task_limit_; | 256 const size_t scheduled_raster_task_limit_; |
| 247 | 257 |
| 248 typedef base::hash_map<Tile::Id, Tile*> TileMap; | 258 typedef base::hash_map<Tile::Id, Tile*> TileMap; |
| 249 TileMap tiles_; | 259 TileMap tiles_; |
| 250 | 260 |
| 251 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 261 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
| 252 MemoryHistory::Entry memory_stats_from_last_assign_; | 262 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 253 | 263 |
| 254 RenderingStatsInstrumentation* rendering_stats_instrumentation_; | 264 RenderingStatsInstrumentation* rendering_stats_instrumentation_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 281 RasterTilePriorityQueue raster_priority_queue_; | 291 RasterTilePriorityQueue raster_priority_queue_; |
| 282 EvictionTilePriorityQueue eviction_priority_queue_; | 292 EvictionTilePriorityQueue eviction_priority_queue_; |
| 283 bool eviction_priority_queue_is_up_to_date_; | 293 bool eviction_priority_queue_is_up_to_date_; |
| 284 | 294 |
| 285 DISALLOW_COPY_AND_ASSIGN(TileManager); | 295 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 286 }; | 296 }; |
| 287 | 297 |
| 288 } // namespace cc | 298 } // namespace cc |
| 289 | 299 |
| 290 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 300 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |