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

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

Issue 787803004: Update from https://crrev.com/307664 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase. 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
« no previous file with comments | « cc/resources/rasterizer.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Assigns tile memory and schedules work to prepare tiles for drawing.
110 // - Runs client_->NotifyReadyToActivate() when all tiles required for
111 // activation are prepared, or failed to prepare due to OOM.
112 // - Runs client_->NotifyReadyToDraw() when all tiles required draw are
113 // prepared, or failed to prepare due to OOM.
114 void PrepareTiles(const GlobalStateThatImpactsTilePriority& state);
110 115
111 void UpdateVisibleTiles(); 116 void UpdateVisibleTiles();
112 117
113 scoped_refptr<Tile> CreateTile(RasterSource* raster_source, 118 scoped_refptr<Tile> CreateTile(RasterSource* raster_source,
114 const gfx::Size& tile_size, 119 const gfx::Size& tile_size,
115 const gfx::Rect& content_rect, 120 const gfx::Rect& content_rect,
116 float contents_scale, 121 float contents_scale,
117 int layer_id, 122 int layer_id,
118 int source_frame_number, 123 int source_frame_number,
119 int flags); 124 int flags);
(...skipping 19 matching lines...) Expand all
139 Tile* tile = tiles[i]; 144 Tile* tile = tiles[i];
140 FreeResourcesForTile(tile); 145 FreeResourcesForTile(tile);
141 } 146 }
142 } 147 }
143 148
144 void SetGlobalStateForTesting( 149 void SetGlobalStateForTesting(
145 const GlobalStateThatImpactsTilePriority& state) { 150 const GlobalStateThatImpactsTilePriority& state) {
146 global_state_ = state; 151 global_state_ = state;
147 } 152 }
148 153
149 void SetRasterizerForTesting(Rasterizer* rasterizer); 154 void SetTileTaskRunnerForTesting(TileTaskRunner* tile_task_runner);
150 155
151 void FreeResourcesAndCleanUpReleasedTilesForTesting() { 156 void FreeResourcesAndCleanUpReleasedTilesForTesting() {
152 FreeResourcesForReleasedTiles(); 157 FreeResourcesForReleasedTiles();
153 CleanUpReleasedTiles(); 158 CleanUpReleasedTiles();
154 } 159 }
155 160
156 std::vector<Tile*> AllTilesForTesting() const { 161 std::vector<Tile*> AllTilesForTesting() const {
157 std::vector<Tile*> tiles; 162 std::vector<Tile*> tiles;
158 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); 163 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end();
159 ++it) { 164 ++it) {
160 tiles.push_back(it->second); 165 tiles.push_back(it->second);
161 } 166 }
162 return tiles; 167 return tiles;
163 } 168 }
164 169
165 void SetScheduledRasterTaskLimitForTesting(size_t limit) { 170 void SetScheduledRasterTaskLimitForTesting(size_t limit) {
166 scheduled_raster_task_limit_ = limit; 171 scheduled_raster_task_limit_ = limit;
167 } 172 }
168 173
169 protected: 174 protected:
170 TileManager(TileManagerClient* client, 175 TileManager(TileManagerClient* client,
171 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 176 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
172 ResourcePool* resource_pool, 177 ResourcePool* resource_pool,
173 Rasterizer* rasterizer, 178 TileTaskRunner* tile_task_runner,
174 RenderingStatsInstrumentation* rendering_stats_instrumentation, 179 RenderingStatsInstrumentation* rendering_stats_instrumentation,
175 size_t scheduled_raster_task_limit); 180 size_t scheduled_raster_task_limit);
176 181
177 void FreeResourcesForReleasedTiles(); 182 void FreeResourcesForReleasedTiles();
178 void CleanUpReleasedTiles(); 183 void CleanUpReleasedTiles();
179 184
180 // Overriden from RefCountedManager<Tile>: 185 // Overriden from RefCountedManager<Tile>:
181 friend class Tile; 186 friend class Tile;
182 void Release(Tile* tile) override; 187 void Release(Tile* tile) override;
183 188
184 // Overriden from RasterizerClient: 189 // Overriden from TileTaskRunnerClient:
185 void DidFinishRunningTasks(TaskSet task_set) override; 190 void DidFinishRunningTileTasks(TaskSet task_set) override;
186 TaskSetCollection TasksThatShouldBeForcedToComplete() const override; 191 TaskSetCollection TasksThatShouldBeForcedToComplete() const override;
187 192
188 typedef std::vector<Tile*> TileVector; 193 typedef std::vector<Tile*> TileVector;
189 typedef std::set<Tile*> TileSet; 194 typedef std::set<Tile*> TileSet;
190 195
191 // Virtual for test 196 // Virtual for test
192 virtual void ScheduleTasks( 197 virtual void ScheduleTasks(
193 const TileVector& tiles_that_need_to_be_rasterized); 198 const TileVector& tiles_that_need_to_be_rasterized);
194 199
195 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); 200 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 MemoryUsage* usage); 243 MemoryUsage* usage);
239 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority); 244 bool TilePriorityViolatesMemoryPolicy(const TilePriority& priority);
240 bool IsReadyToActivate() const; 245 bool IsReadyToActivate() const;
241 bool IsReadyToDraw() const; 246 bool IsReadyToDraw() const;
242 void CheckIfReadyToActivate(); 247 void CheckIfReadyToActivate();
243 void CheckIfReadyToDraw(); 248 void CheckIfReadyToDraw();
244 249
245 TileManagerClient* client_; 250 TileManagerClient* client_;
246 scoped_refptr<base::SequencedTaskRunner> task_runner_; 251 scoped_refptr<base::SequencedTaskRunner> task_runner_;
247 ResourcePool* resource_pool_; 252 ResourcePool* resource_pool_;
248 Rasterizer* rasterizer_; 253 TileTaskRunner* tile_task_runner_;
249 GlobalStateThatImpactsTilePriority global_state_; 254 GlobalStateThatImpactsTilePriority global_state_;
250 size_t scheduled_raster_task_limit_; 255 size_t scheduled_raster_task_limit_;
251 256
252 typedef base::hash_map<Tile::Id, Tile*> TileMap; 257 typedef base::hash_map<Tile::Id, Tile*> TileMap;
253 TileMap tiles_; 258 TileMap tiles_;
254 259
255 bool all_tiles_that_need_to_be_rasterized_are_scheduled_; 260 bool all_tiles_that_need_to_be_rasterized_are_scheduled_;
256 MemoryHistory::Entry memory_stats_from_last_assign_; 261 MemoryHistory::Entry memory_stats_from_last_assign_;
257 262
258 RenderingStatsInstrumentation* rendering_stats_instrumentation_; 263 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
259 264
260 bool did_check_for_completed_tasks_since_last_schedule_tasks_; 265 bool did_check_for_completed_tasks_since_last_schedule_tasks_;
261 bool did_oom_on_last_assign_; 266 bool did_oom_on_last_assign_;
262 267
263 typedef base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>> 268 typedef base::hash_map<uint32_t, scoped_refptr<ImageDecodeTask>>
264 PixelRefTaskMap; 269 PixelRefTaskMap;
265 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; 270 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap;
266 LayerPixelRefTaskMap image_decode_tasks_; 271 LayerPixelRefTaskMap image_decode_tasks_;
267 272
268 typedef base::hash_map<int, int> LayerCountMap; 273 typedef base::hash_map<int, int> LayerCountMap;
269 LayerCountMap used_layer_counts_; 274 LayerCountMap used_layer_counts_;
270 275
271 RasterTaskCompletionStats update_visible_tiles_stats_; 276 RasterTaskCompletionStats update_visible_tiles_stats_;
272 277
273 std::vector<Tile*> released_tiles_; 278 std::vector<Tile*> released_tiles_;
274 279
275 ResourceFormat resource_format_; 280 ResourceFormat resource_format_;
276 281
277 // Queue used when scheduling raster tasks. 282 // Queue used when scheduling raster tasks.
278 RasterTaskQueue raster_queue_; 283 TileTaskQueue raster_queue_;
279 284
280 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_; 285 std::vector<scoped_refptr<RasterTask>> orphan_raster_tasks_;
281 286
282 UniqueNotifier ready_to_activate_check_notifier_; 287 UniqueNotifier ready_to_activate_check_notifier_;
283 UniqueNotifier ready_to_draw_check_notifier_; 288 UniqueNotifier ready_to_draw_check_notifier_;
284 289
285 RasterTilePriorityQueue raster_priority_queue_; 290 RasterTilePriorityQueue raster_priority_queue_;
286 EvictionTilePriorityQueue eviction_priority_queue_; 291 EvictionTilePriorityQueue eviction_priority_queue_;
287 bool eviction_priority_queue_is_up_to_date_; 292 bool eviction_priority_queue_is_up_to_date_;
288 293
289 bool did_notify_ready_to_activate_; 294 bool did_notify_ready_to_activate_;
290 bool did_notify_ready_to_draw_; 295 bool did_notify_ready_to_draw_;
291 296
292 DISALLOW_COPY_AND_ASSIGN(TileManager); 297 DISALLOW_COPY_AND_ASSIGN(TileManager);
293 }; 298 };
294 299
295 } // namespace cc 300 } // namespace cc
296 301
297 #endif // CC_RESOURCES_TILE_MANAGER_H_ 302 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/resources/rasterizer.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698