| 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/unique_notifier.h" | 18 #include "cc/base/unique_notifier.h" |
| 18 #include "cc/resources/eviction_tile_priority_queue.h" | 19 #include "cc/resources/eviction_tile_priority_queue.h" |
| 19 #include "cc/resources/memory_history.h" | 20 #include "cc/resources/memory_history.h" |
| 20 #include "cc/resources/raster_source.h" | 21 #include "cc/resources/raster_source.h" |
| 21 #include "cc/resources/raster_tile_priority_queue.h" | 22 #include "cc/resources/raster_tile_priority_queue.h" |
| 22 #include "cc/resources/resource_pool.h" | 23 #include "cc/resources/resource_pool.h" |
| 23 #include "cc/resources/tile.h" | 24 #include "cc/resources/tile.h" |
| 24 #include "cc/resources/tile_draw_info.h" | 25 #include "cc/resources/tile_draw_info.h" |
| 25 #include "cc/resources/tile_task_runner.h" | 26 #include "cc/resources/tile_task_runner.h" |
| 26 | 27 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 size_t completed_count; | 79 size_t completed_count; |
| 79 size_t canceled_count; | 80 size_t canceled_count; |
| 80 }; | 81 }; |
| 81 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | 82 scoped_refptr<base::trace_event::ConvertableToTraceFormat> |
| 82 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); | 83 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); |
| 83 | 84 |
| 84 // This class manages tiles, deciding which should get rasterized and which | 85 // This class manages tiles, deciding which should get rasterized and which |
| 85 // should no longer have any memory assigned to them. Tile objects are "owned" | 86 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 86 // by layers; they automatically register with the manager when they are | 87 // by layers; they automatically register with the manager when they are |
| 87 // created, and unregister from the manager when they are deleted. | 88 // created, and unregister from the manager when they are deleted. |
| 88 class CC_EXPORT TileManager : public TileTaskRunnerClient { | 89 class CC_EXPORT TileManager : public TileTaskRunnerClient, |
| 90 public RefCountedManager<Tile> { |
| 89 public: | 91 public: |
| 90 enum NamedTaskSet { | 92 enum NamedTaskSet { |
| 91 REQUIRED_FOR_ACTIVATION, | 93 REQUIRED_FOR_ACTIVATION, |
| 92 REQUIRED_FOR_DRAW, | 94 REQUIRED_FOR_DRAW, |
| 93 // PixelBufferTileTaskWorkerPool depends on ALL being last. | 95 // PixelBufferTileTaskWorkerPool depends on ALL being last. |
| 94 ALL | 96 ALL |
| 95 // Adding additional values requires increasing kNumberOfTaskSets in | 97 // Adding additional values requires increasing kNumberOfTaskSets in |
| 96 // tile_task_runner.h | 98 // tile_task_runner.h |
| 97 }; | 99 }; |
| 98 | 100 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 109 | 111 |
| 110 // Assigns tile memory and schedules work to prepare tiles for drawing. | 112 // Assigns tile memory and schedules work to prepare tiles for drawing. |
| 111 // - Runs client_->NotifyReadyToActivate() when all tiles required for | 113 // - Runs client_->NotifyReadyToActivate() when all tiles required for |
| 112 // activation are prepared, or failed to prepare due to OOM. | 114 // activation are prepared, or failed to prepare due to OOM. |
| 113 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are | 115 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are |
| 114 // prepared, or failed to prepare due to OOM. | 116 // prepared, or failed to prepare due to OOM. |
| 115 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); | 117 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state); |
| 116 | 118 |
| 117 void UpdateVisibleTiles(const GlobalStateThatImpactsTilePriority& state); | 119 void UpdateVisibleTiles(const GlobalStateThatImpactsTilePriority& state); |
| 118 | 120 |
| 119 ScopedTilePtr CreateTile(RasterSource* raster_source, | 121 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, |
| 120 const gfx::Size& desired_texture_size, | 122 const gfx::Size& desired_texture_size, |
| 121 const gfx::Rect& content_rect, | 123 const gfx::Rect& content_rect, |
| 122 float contents_scale, | 124 float contents_scale, |
| 123 int layer_id, | 125 int layer_id, |
| 124 int source_frame_number, | 126 int source_frame_number, |
| 125 int flags); | 127 int flags); |
| 126 | 128 |
| 127 bool IsReadyToActivate() const; | 129 bool IsReadyToActivate() const; |
| 128 bool IsReadyToDraw() const; | 130 bool IsReadyToDraw() const; |
| 129 | 131 |
| 130 scoped_refptr<base::trace_event::ConvertableToTraceFormat> BasicStateAsValue() | 132 scoped_refptr<base::trace_event::ConvertableToTraceFormat> BasicStateAsValue() |
| 131 const; | 133 const; |
| 132 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; | 134 void BasicStateAsValueInto(base::trace_event::TracedValue* dict) const; |
| 133 const MemoryHistory::Entry& memory_stats_from_last_assign() const { | 135 const MemoryHistory::Entry& memory_stats_from_last_assign() const { |
| 134 return memory_stats_from_last_assign_; | 136 return memory_stats_from_last_assign_; |
| 135 } | 137 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 protected: | 185 protected: |
| 184 TileManager(TileManagerClient* client, | 186 TileManager(TileManagerClient* client, |
| 185 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 187 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 186 ResourcePool* resource_pool, | 188 ResourcePool* resource_pool, |
| 187 TileTaskRunner* tile_task_runner, | 189 TileTaskRunner* tile_task_runner, |
| 188 size_t scheduled_raster_task_limit); | 190 size_t scheduled_raster_task_limit); |
| 189 | 191 |
| 190 void FreeResourcesForReleasedTiles(); | 192 void FreeResourcesForReleasedTiles(); |
| 191 void CleanUpReleasedTiles(); | 193 void CleanUpReleasedTiles(); |
| 192 | 194 |
| 195 // Overriden from RefCountedManager<Tile>: |
| 193 friend class Tile; | 196 friend class Tile; |
| 194 // Virtual for testing. | 197 void Release(Tile* tile) override; |
| 195 virtual void Release(Tile* tile); | |
| 196 | 198 |
| 197 // Overriden from TileTaskRunnerClient: | 199 // Overriden from TileTaskRunnerClient: |
| 198 void DidFinishRunningTileTasks(TaskSet task_set) override; | 200 void DidFinishRunningTileTasks(TaskSet task_set) override; |
| 199 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; | 201 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; |
| 200 | 202 |
| 201 typedef std::vector<Tile*> TileVector; | 203 typedef std::vector<Tile*> TileVector; |
| 202 typedef std::set<Tile*> TileSet; | 204 typedef std::set<Tile*> TileSet; |
| 203 | 205 |
| 204 // Virtual for test | 206 // Virtual for test |
| 205 virtual void ScheduleTasks( | 207 virtual void ScheduleTasks( |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 307 |
| 306 bool did_notify_ready_to_activate_; | 308 bool did_notify_ready_to_activate_; |
| 307 bool did_notify_ready_to_draw_; | 309 bool did_notify_ready_to_draw_; |
| 308 | 310 |
| 309 DISALLOW_COPY_AND_ASSIGN(TileManager); | 311 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 310 }; | 312 }; |
| 311 | 313 |
| 312 } // namespace cc | 314 } // namespace cc |
| 313 | 315 |
| 314 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 316 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
| OLD | NEW |