| 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_TILES_TILE_MANAGER_H_ | 5 #ifndef CC_TILES_TILE_MANAGER_H_ |
| 6 #define CC_TILES_TILE_MANAGER_H_ | 6 #define CC_TILES_TILE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ImageDecodeCache* image_decode_cache, | 123 ImageDecodeCache* image_decode_cache, |
| 124 TaskGraphRunner* task_graph_runner, | 124 TaskGraphRunner* task_graph_runner, |
| 125 RasterBufferProvider* raster_buffer_provider, | 125 RasterBufferProvider* raster_buffer_provider, |
| 126 size_t scheduled_raster_task_limit, | 126 size_t scheduled_raster_task_limit, |
| 127 bool use_gpu_rasterization); | 127 bool use_gpu_rasterization); |
| 128 | 128 |
| 129 // This causes any completed raster work to finalize, so that tiles get up to | 129 // This causes any completed raster work to finalize, so that tiles get up to |
| 130 // date draw information. | 130 // date draw information. |
| 131 void Flush(); | 131 void Flush(); |
| 132 | 132 |
| 133 ScopedTilePtr CreateTile(const Tile::CreateInfo& info, | 133 std::unique_ptr<Tile> CreateTile(const Tile::CreateInfo& info, |
| 134 int layer_id, | 134 int layer_id, |
| 135 int source_frame_number, | 135 int source_frame_number, |
| 136 int flags); | 136 int flags); |
| 137 | 137 |
| 138 bool IsReadyToActivate() const; | 138 bool IsReadyToActivate() const; |
| 139 bool IsReadyToDraw() const; | 139 bool IsReadyToDraw() const; |
| 140 | 140 |
| 141 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 141 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 142 BasicStateAsValue() const; | 142 BasicStateAsValue() const; |
| 143 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 143 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
| 144 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 144 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 145 return memory_stats_from_last_assign_; | 145 return memory_stats_from_last_assign_; |
| 146 } | 146 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 171 void SetTileTaskManagerForTesting( | 171 void SetTileTaskManagerForTesting( |
| 172 std::unique_ptr<TileTaskManager> tile_task_manager) { | 172 std::unique_ptr<TileTaskManager> tile_task_manager) { |
| 173 tile_task_manager_ = std::move(tile_task_manager); | 173 tile_task_manager_ = std::move(tile_task_manager); |
| 174 } | 174 } |
| 175 | 175 |
| 176 void SetRasterBufferProviderForTesting( | 176 void SetRasterBufferProviderForTesting( |
| 177 RasterBufferProvider* raster_buffer_provider) { | 177 RasterBufferProvider* raster_buffer_provider) { |
| 178 raster_buffer_provider_ = raster_buffer_provider; | 178 raster_buffer_provider_ = raster_buffer_provider; |
| 179 } | 179 } |
| 180 | 180 |
| 181 void FreeResourcesAndCleanUpReleasedTilesForTesting() { | |
| 182 FreeResourcesForReleasedTiles(); | |
| 183 CleanUpReleasedTiles(); | |
| 184 } | |
| 185 | |
| 186 std::vector<Tile*> AllTilesForTesting() const { | 181 std::vector<Tile*> AllTilesForTesting() const { |
| 187 std::vector<Tile*> tiles; | 182 std::vector<Tile*> tiles; |
| 188 for (auto& tile_pair : tiles_) | 183 for (auto& tile_pair : tiles_) |
| 189 tiles.push_back(tile_pair.second); | 184 tiles.push_back(tile_pair.second); |
| 190 return tiles; | 185 return tiles; |
| 191 } | 186 } |
| 192 | 187 |
| 193 void SetScheduledRasterTaskLimitForTesting(size_t limit) { | 188 void SetScheduledRasterTaskLimitForTesting(size_t limit) { |
| 194 scheduled_raster_task_limit_ = limit; | 189 scheduled_raster_task_limit_ = limit; |
| 195 } | 190 } |
| 196 | 191 |
| 197 void CheckIfMoreTilesNeedToBePreparedForTesting() { | 192 void CheckIfMoreTilesNeedToBePreparedForTesting() { |
| 198 CheckIfMoreTilesNeedToBePrepared(); | 193 CheckIfMoreTilesNeedToBePrepared(); |
| 199 } | 194 } |
| 200 | 195 |
| 201 void SetMoreTilesNeedToBeRasterizedForTesting() { | 196 void SetMoreTilesNeedToBeRasterizedForTesting() { |
| 202 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; | 197 all_tiles_that_need_to_be_rasterized_are_scheduled_ = false; |
| 203 } | 198 } |
| 204 | 199 |
| 205 bool HasScheduledTileTasksForTesting() const { | 200 bool HasScheduledTileTasksForTesting() const { |
| 206 return has_scheduled_tile_tasks_; | 201 return has_scheduled_tile_tasks_; |
| 207 } | 202 } |
| 208 | 203 |
| 209 void OnRasterTaskCompleted(std::unique_ptr<RasterBuffer> raster_buffer, | 204 void OnRasterTaskCompleted(std::unique_ptr<RasterBuffer> raster_buffer, |
| 210 Tile* tile, | 205 Tile::Id tile_id, |
| 211 Resource* resource, | 206 Resource* resource, |
| 212 bool was_canceled); | 207 bool was_canceled); |
| 213 | 208 |
| 214 protected: | 209 protected: |
| 215 void FreeResourcesForReleasedTiles(); | |
| 216 void CleanUpReleasedTiles(); | |
| 217 | |
| 218 friend class Tile; | 210 friend class Tile; |
| 219 // Virtual for testing. | 211 // Must be called by tile during destruction. |
| 220 virtual void Release(Tile* tile); | 212 void Release(Tile* tile); |
| 221 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } | 213 Tile::Id GetUniqueTileId() { return ++next_tile_id_; } |
| 222 | 214 |
| 223 private: | 215 private: |
| 224 class MemoryUsage { | 216 class MemoryUsage { |
| 225 public: | 217 public: |
| 226 MemoryUsage(); | 218 MemoryUsage(); |
| 227 MemoryUsage(size_t memory_bytes, size_t resource_count); | 219 MemoryUsage(size_t memory_bytes, size_t resource_count); |
| 228 | 220 |
| 229 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); | 221 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); |
| 230 static MemoryUsage FromTile(const Tile* tile); | 222 static MemoryUsage FromTile(const Tile* tile); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; | 311 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; |
| 320 MemoryHistory::Entry memory_stats_from_last_assign_; | 312 MemoryHistory::Entry memory_stats_from_last_assign_; |
| 321 | 313 |
| 322 bool did_check_for_completed_tasks_since_last_schedule_tasks_; | 314 bool did_check_for_completed_tasks_since_last_schedule_tasks_; |
| 323 bool did_oom_on_last_assign_; | 315 bool did_oom_on_last_assign_; |
| 324 | 316 |
| 325 ImageController image_controller_; | 317 ImageController image_controller_; |
| 326 | 318 |
| 327 RasterTaskCompletionStats flush_stats_; | 319 RasterTaskCompletionStats flush_stats_; |
| 328 | 320 |
| 329 std::vector<Tile*> released_tiles_; | |
| 330 | |
| 331 TaskGraph graph_; | 321 TaskGraph graph_; |
| 332 | 322 |
| 333 UniqueNotifier more_tiles_need_prepare_check_notifier_; | 323 UniqueNotifier more_tiles_need_prepare_check_notifier_; |
| 334 | 324 |
| 335 Signals signals_; | 325 Signals signals_; |
| 336 | 326 |
| 337 UniqueNotifier signals_check_notifier_; | 327 UniqueNotifier signals_check_notifier_; |
| 338 | 328 |
| 339 bool has_scheduled_tile_tasks_; | 329 bool has_scheduled_tile_tasks_; |
| 340 | 330 |
| 341 uint64_t prepare_tiles_count_; | 331 uint64_t prepare_tiles_count_; |
| 342 uint64_t next_tile_id_; | 332 uint64_t next_tile_id_; |
| 343 | 333 |
| 344 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; | 334 std::unordered_map<Tile::Id, std::vector<DrawImage>> scheduled_draw_images_; |
| 345 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; | 335 std::vector<scoped_refptr<TileTask>> locked_image_tasks_; |
| 346 const bool check_tile_priority_inversion_; | 336 const bool check_tile_priority_inversion_; |
| 347 | 337 |
| 348 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; | 338 base::WeakPtrFactory<TileManager> task_set_finished_weak_ptr_factory_; |
| 349 | 339 |
| 350 DISALLOW_COPY_AND_ASSIGN(TileManager); | 340 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 351 }; | 341 }; |
| 352 | 342 |
| 353 } // namespace cc | 343 } // namespace cc |
| 354 | 344 |
| 355 #endif // CC_TILES_TILE_MANAGER_H_ | 345 #endif // CC_TILES_TILE_MANAGER_H_ |
| OLD | NEW |