Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Side by Side Diff: cc/resources/tile_manager.h

Issue 786583002: cc: Renaming Rasterizer and RasterWorkerPool interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test. Update include files alphabetic orders. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/managed_tile_state.h" 21 #include "cc/resources/managed_tile_state.h"
22 #include "cc/resources/memory_history.h" 22 #include "cc/resources/memory_history.h"
23 #include "cc/resources/raster_source.h" 23 #include "cc/resources/raster_source.h"
24 #include "cc/resources/raster_tile_priority_queue.h" 24 #include "cc/resources/raster_tile_priority_queue.h"
25 #include "cc/resources/rasterizer.h"
26 #include "cc/resources/resource_pool.h" 25 #include "cc/resources/resource_pool.h"
27 #include "cc/resources/tile.h" 26 #include "cc/resources/tile.h"
27 #include "cc/resources/tile_task_runner.h"
28 28
29 namespace base { 29 namespace base {
30 namespace debug { 30 namespace debug {
31 class ConvertableToTraceFormat; 31 class ConvertableToTraceFormat;
32 class TracedValue; 32 class TracedValue;
33 } 33 }
34 } 34 }
35 35
36 namespace cc { 36 namespace cc {
37 class PictureLayerImpl; 37 class PictureLayerImpl;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 size_t completed_count; 79 size_t completed_count;
80 size_t canceled_count; 80 size_t canceled_count;
81 }; 81 };
82 scoped_refptr<base::debug::ConvertableToTraceFormat> 82 scoped_refptr<base::debug::ConvertableToTraceFormat>
83 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats); 83 RasterTaskCompletionStatsAsValue(const RasterTaskCompletionStats& stats);
84 84
85 // This class manages tiles, deciding which should get rasterized and which 85 // This class manages tiles, deciding which should get rasterized and which
86 // 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"
87 // by layers; they automatically register with the manager when they are 87 // by layers; they automatically register with the manager when they are
88 // created, and unregister from the manager when they are deleted. 88 // created, and unregister from the manager when they are deleted.
89 class CC_EXPORT TileManager : public RasterizerClient, 89 class CC_EXPORT TileManager : public TileTaskRunnerClient,
90 public RefCountedManager<Tile> { 90 public RefCountedManager<Tile> {
91 public: 91 public:
92 enum NamedTaskSet { 92 enum NamedTaskSet {
93 ALL, 93 ALL,
94 REQUIRED_FOR_ACTIVATION, 94 REQUIRED_FOR_ACTIVATION,
95 REQUIRED_FOR_DRAW 95 REQUIRED_FOR_DRAW
96 // Adding additional values requires increasing kNumberOfTaskSets in 96 // Adding additional values requires increasing kNumberOfTaskSets in
97 // rasterizer.h 97 // rasterizer.h
98 }; 98 };
99 99
100 static scoped_ptr<TileManager> Create( 100 static scoped_ptr<TileManager> Create(
101 TileManagerClient* client, 101 TileManagerClient* client,
102 base::SequencedTaskRunner* task_runner, 102 base::SequencedTaskRunner* task_runner,
103 ResourcePool* resource_pool, 103 ResourcePool* resource_pool,
104 Rasterizer* rasterizer, 104 TileTaskRunner* tile_task_runner,
105 RenderingStatsInstrumentation* rendering_stats_instrumentation, 105 RenderingStatsInstrumentation* rendering_stats_instrumentation,
106 size_t scheduled_raster_task_limit); 106 size_t scheduled_raster_task_limit);
107 ~TileManager() override; 107 ~TileManager() override;
108 108
109 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); 109 void ManageTiles(const GlobalStateThatImpactsTilePriority& state);
110 110
111 void UpdateVisibleTiles(); 111 void UpdateVisibleTiles();
112 112
113 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, 113 scoped_refptr<Tile> CreateTile(RasterSource* raster_source,
114 const gfx::Size& tile_size, 114 const gfx::Size& tile_size,
(...skipping 24 matching lines...) Expand all
139 Tile* tile = tiles[i]; 139 Tile* tile = tiles[i];
140 FreeResourcesForTile(tile); 140 FreeResourcesForTile(tile);
141 } 141 }
142 } 142 }
143 143
144 void SetGlobalStateForTesting( 144 void SetGlobalStateForTesting(
145 const GlobalStateThatImpactsTilePriority& state) { 145 const GlobalStateThatImpactsTilePriority& state) {
146 global_state_ = state; 146 global_state_ = state;
147 } 147 }
148 148
149 void SetRasterizerForTesting(Rasterizer* rasterizer); 149 void SetTileTaskRunnerForTesting(TileTaskRunner* tile_task_runner);
150 150
151 void FreeResourcesAndCleanUpReleasedTilesForTesting() { 151 void FreeResourcesAndCleanUpReleasedTilesForTesting() {
152 FreeResourcesForReleasedTiles(); 152 FreeResourcesForReleasedTiles();
153 CleanUpReleasedTiles(); 153 CleanUpReleasedTiles();
154 } 154 }
155 155
156 std::vector<Tile*> AllTilesForTesting() const { 156 std::vector<Tile*> AllTilesForTesting() const {
157 std::vector<Tile*> tiles; 157 std::vector<Tile*> tiles;
158 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); 158 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end();
159 ++it) { 159 ++it) {
160 tiles.push_back(it->second); 160 tiles.push_back(it->second);
161 } 161 }
162 return tiles; 162 return tiles;
163 } 163 }
164 164
165 void SetScheduledRasterTaskLimitForTesting(size_t limit) { 165 void SetScheduledRasterTaskLimitForTesting(size_t limit) {
166 scheduled_raster_task_limit_ = limit; 166 scheduled_raster_task_limit_ = limit;
167 } 167 }
168 168
169 protected: 169 protected:
170 TileManager(TileManagerClient* client, 170 TileManager(TileManagerClient* client,
171 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 171 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
172 ResourcePool* resource_pool, 172 ResourcePool* resource_pool,
173 Rasterizer* rasterizer, 173 TileTaskRunner* tile_task_runner,
174 RenderingStatsInstrumentation* rendering_stats_instrumentation, 174 RenderingStatsInstrumentation* rendering_stats_instrumentation,
175 size_t scheduled_raster_task_limit); 175 size_t scheduled_raster_task_limit);
176 176
177 void FreeResourcesForReleasedTiles(); 177 void FreeResourcesForReleasedTiles();
178 void CleanUpReleasedTiles(); 178 void CleanUpReleasedTiles();
179 179
180 // Overriden from RefCountedManager<Tile>: 180 // Overriden from RefCountedManager<Tile>:
181 friend class Tile; 181 friend class Tile;
182 void Release(Tile* tile) override; 182 void Release(Tile* tile) override;
183 183
184 // Overriden from RasterizerClient: 184 // Overriden from TileTaskRunnerClient:
185 void DidFinishRunningTasks(TaskSet task_set) override; 185 void DidFinishRunningTileTasks(TaskSet task_set) override;
186 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; 186 TaskSetCollection TasksThatShouldBeForcedToComplete() const override;
187 187
188 typedef std::vector<Tile*> TileVector; 188 typedef std::vector<Tile*> TileVector;
189 typedef std::set<Tile*> TileSet; 189 typedef std::set<Tile*> TileSet;
190 190
191 // Virtual for test 191 // Virtual for test
192 virtual void ScheduleTasks( 192 virtual void ScheduleTasks(
193 const TileVector& tiles_that_need_to_be_rasterized); 193 const TileVector& tiles_that_need_to_be_rasterized);
194 194
195 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); 195 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 MemoryUsage* usage); 238 MemoryUsage* usage);
239 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); 239 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority);
240 bool IsReadyToActivate() const; 240 bool IsReadyToActivate() const;
241 bool IsReadyToDraw() const; 241 bool IsReadyToDraw() const;
242 void CheckIfReadyToActivate(); 242 void CheckIfReadyToActivate();
243 void CheckIfReadyToDraw(); 243 void CheckIfReadyToDraw();
244 244
245 TileManagerClient* client_; 245 TileManagerClient* client_;
246 scoped_refptr<base::SequencedTaskRunner> task_runner_; 246 scoped_refptr<base::SequencedTaskRunner> task_runner_;
247 ResourcePool* resource_pool_; 247 ResourcePool* resource_pool_;
248 Rasterizer* rasterizer_; 248 TileTaskRunner* tile_task_runner_;
249 GlobalStateThatImpactsTilePriority global_state_; 249 GlobalStateThatImpactsTilePriority global_state_;
250 size_t scheduled_raster_task_limit_; 250 size_t scheduled_raster_task_limit_;
251 251
252 typedef base::hash_map<Tile::Id, Tile*> TileMap; 252 typedef base::hash_map<Tile::Id, Tile*> TileMap;
253 TileMap tiles_; 253 TileMap tiles_;
254 254
255 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; 255 bool all_tiles_that_need_to_be_rasterized_are_scheduled_;
256 MemoryHistory::Entry memory_stats_from_last_assign_; 256 MemoryHistory::Entry memory_stats_from_last_assign_;
257 257
258 RenderingStatsInstrumentation* rendering_stats_instrumentation_; 258 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
259 259
260 bool did_check_for_completed_tasks_since_last_schedule_tasks_; 260 bool did_check_for_completed_tasks_since_last_schedule_tasks_;
261 bool did_oom_on_last_assign_; 261 bool did_oom_on_last_assign_;
262 262
263 typedef base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>> 263 typedef base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>>
264 PixelRefTaskMap; 264 PixelRefTaskMap;
265 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; 265 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap;
266 LayerPixelRefTaskMap image_decode_tasks_; 266 LayerPixelRefTaskMap image_decode_tasks_;
267 267
268 typedef base::hash_map<int, int> LayerCountMap; 268 typedef base::hash_map<int, int> LayerCountMap;
269 LayerCountMap used_layer_counts_; 269 LayerCountMap used_layer_counts_;
270 270
271 RasterTaskCompletionStats update_visible_tiles_stats_; 271 RasterTaskCompletionStats update_visible_tiles_stats_;
272 272
273 std::vector<Tile*> released_tiles_; 273 std::vector<Tile*> released_tiles_;
274 274
275 ResourceFormat resource_format_; 275 ResourceFormat resource_format_;
276 276
277 // Queue used when scheduling raster tasks. 277 // Queue used when scheduling raster tasks.
278 RasterTaskQueue raster_queue_; 278 TileTaskQueue raster_queue_;
279 279
280 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; 280 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_;
281 281
282 UniqueNotifier ready_to_activate_check_notifier_; 282 UniqueNotifier ready_to_activate_check_notifier_;
283 UniqueNotifier ready_to_draw_check_notifier_; 283 UniqueNotifier ready_to_draw_check_notifier_;
284 284
285 RasterTilePriorityQueue raster_priority_queue_; 285 RasterTilePriorityQueue raster_priority_queue_;
286 EvictionTilePriorityQueue eviction_priority_queue_; 286 EvictionTilePriorityQueue eviction_priority_queue_;
287 bool eviction_priority_queue_is_up_to_date_; 287 bool eviction_priority_queue_is_up_to_date_;
288 288
289 bool did_notify_ready_to_activate_; 289 bool did_notify_ready_to_activate_;
290 bool did_notify_ready_to_draw_; 290 bool did_notify_ready_to_draw_;
291 291
292 DISALLOW_COPY_AND_ASSIGN(TileManager); 292 DISALLOW_COPY_AND_ASSIGN(TileManager);
293 }; 293 };
294 294
295 } // namespace cc 295 } // namespace cc
296 296
297 #endif // CC_RESOURCES_TILE_MANAGER_H_ 297 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698