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

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

Issue 14689004: Re-land: cc: Cancel and re-prioritize worker pool tasks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move alignment check to RP Created 7 years, 7 months 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 | Annotate | Revision Log
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 <list> 8 #include <list>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 }; 54 };
55 scoped_ptr<base::Value> TileManagerBinPriorityAsValue( 55 scoped_ptr<base::Value> TileManagerBinPriorityAsValue(
56 TileManagerBinPriority bin); 56 TileManagerBinPriority bin);
57 57
58 // This class manages tiles, deciding which should get rasterized and which 58 // This class manages tiles, deciding which should get rasterized and which
59 // should no longer have any memory assigned to them. Tile objects are "owned" 59 // should no longer have any memory assigned to them. Tile objects are "owned"
60 // by layers; they automatically register with the manager when they are 60 // by layers; they automatically register with the manager when they are
61 // created, and unregister from the manager when they are deleted. 61 // created, and unregister from the manager when they are deleted.
62 class CC_EXPORT TileManager : public WorkerPoolClient { 62 class CC_EXPORT TileManager : public WorkerPoolClient {
63 public: 63 public:
64 typedef base::hash_set<uint32_t> PixelRefSet;
65
64 TileManager(TileManagerClient* client, 66 TileManager(TileManagerClient* client,
65 ResourceProvider *resource_provider, 67 ResourceProvider *resource_provider,
66 size_t num_raster_threads, 68 size_t num_raster_threads,
67 bool use_color_estimator, 69 bool use_color_estimator,
68 bool prediction_benchmarking, 70 bool prediction_benchmarking,
69 RenderingStatsInstrumentation* rendering_stats_instrumentation); 71 RenderingStatsInstrumentation* rendering_stats_instrumentation);
70 virtual ~TileManager(); 72 virtual ~TileManager();
71 73
72 const GlobalStateThatImpactsTilePriority& GlobalState() const { 74 const GlobalStateThatImpactsTilePriority& GlobalState() const {
73 return global_state_; 75 return global_state_;
(...skipping 24 matching lines...) Expand all
98 void RegisterTile(Tile* tile); 100 void RegisterTile(Tile* tile);
99 void UnregisterTile(Tile* tile); 101 void UnregisterTile(Tile* tile);
100 void WillModifyTilePriority( 102 void WillModifyTilePriority(
101 Tile* tile, WhichTree tree, const TilePriority& new_priority) { 103 Tile* tile, WhichTree tree, const TilePriority& new_priority) {
102 // TODO(nduca): Do something smarter if reprioritization turns out to be 104 // TODO(nduca): Do something smarter if reprioritization turns out to be
103 // costly. 105 // costly.
104 ScheduleManageTiles(); 106 ScheduleManageTiles();
105 } 107 }
106 108
107 // Virtual for test 109 // Virtual for test
108 virtual void DispatchMoreTasks(); 110 virtual void ScheduleTasks();
109 111
110 private: 112 private:
111 // Data that is passed to raster tasks. 113 // Data that is passed to raster tasks.
112 struct RasterTaskMetadata { 114 struct RasterTaskMetadata {
113 bool prediction_benchmarking; 115 bool prediction_benchmarking;
114 bool is_tile_in_pending_tree_now_bin; 116 bool is_tile_in_pending_tree_now_bin;
115 TileResolution tile_resolution; 117 TileResolution tile_resolution;
116 int layer_id; 118 int layer_id;
117 }; 119 };
118 120
119 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const;
120
121 void AssignBinsToTiles(); 121 void AssignBinsToTiles();
122 void SortTiles(); 122 void SortTiles();
123 void AssignGpuMemoryToTiles(); 123 void AssignGpuMemoryToTiles();
124 void FreeResourcesForTile(Tile* tile); 124 void FreeResourcesForTile(Tile* tile);
125 void ScheduleManageTiles() { 125 void ScheduleManageTiles() {
126 if (manage_tiles_pending_) 126 if (manage_tiles_pending_)
127 return; 127 return;
128 client_->ScheduleManageTiles(); 128 client_->ScheduleManageTiles();
129 manage_tiles_pending_ = true; 129 manage_tiles_pending_ = true;
130 } 130 }
131 bool DispatchImageDecodeTasksForTile(Tile* tile); 131 bool ScheduleImageDecodeTasks(
132 void DispatchOneImageDecodeTask( 132 RasterWorkerPool::Task::Queue* task_queue,
133 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); 133 PixelRefSet* decode_tasks,
134 Tile* tile);
135 RasterWorkerPool::Task CreateImageDecodeTask(
136 Tile* tile, skia::LazyPixelRef* pixel_ref);
134 void OnImageDecodeTaskCompleted( 137 void OnImageDecodeTaskCompleted(
135 scoped_refptr<Tile> tile, 138 scoped_refptr<Tile> tile,
136 uint32_t pixel_ref_id); 139 uint32_t pixel_ref_id,
137 bool CanDispatchRasterTask(Tile* tile) const; 140 bool was_cancelled);
138 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); 141 RasterTaskMetadata GetRasterTaskMetadata(const Tile& tile) const;
139 void DispatchOneRasterTask(scoped_refptr<Tile> tile); 142 RasterWorkerPool::Task CreateRasterTask(Tile* tile);
140 void OnRasterTaskCompleted( 143 void OnRasterTaskCompleted(
141 scoped_refptr<Tile> tile, 144 scoped_refptr<Tile> tile,
142 scoped_ptr<ResourcePool::Resource> resource, 145 scoped_ptr<ResourcePool::Resource> resource,
143 PicturePileImpl::Analysis* analysis, 146 PicturePileImpl::Analysis* analysis,
144 int manage_tiles_call_count_when_dispatched); 147 bool was_cancelled);
145 void DidFinishTileInitialization(Tile* tile); 148 void DidFinishTileInitialization(Tile* tile);
146 void DidTileTreeBinChange(Tile* tile, 149 void DidTileTreeBinChange(Tile* tile,
147 TileManagerBin new_tree_bin, 150 TileManagerBin new_tree_bin,
148 WhichTree tree); 151 WhichTree tree);
149 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; 152 scoped_ptr<Value> GetMemoryRequirementsAsValue() const;
150 153
154 static void RunImageDecodeTask(
155 skia::LazyPixelRef* pixel_ref,
156 RenderingStatsInstrumentation* stats_instrumentation);
151 static void RunAnalyzeAndRasterTask( 157 static void RunAnalyzeAndRasterTask(
152 const RasterWorkerPool::RasterCallback& analyze_task, 158 const RasterWorkerPool::PictureTask::Callback& analyze_task,
153 const RasterWorkerPool::RasterCallback& raster_task, 159 const RasterWorkerPool::PictureTask::Callback& raster_task,
154 PicturePileImpl* picture_pile); 160 PicturePileImpl* picture_pile);
155 static void RunAnalyzeTask( 161 static void RunAnalyzeTask(
156 PicturePileImpl::Analysis* analysis, 162 PicturePileImpl::Analysis* analysis,
157 gfx::Rect rect, 163 gfx::Rect rect,
158 float contents_scale, 164 float contents_scale,
159 bool use_color_estimator, 165 bool use_color_estimator,
160 const RasterTaskMetadata& metadata, 166 const RasterTaskMetadata& metadata,
161 RenderingStatsInstrumentation* stats_instrumentation, 167 RenderingStatsInstrumentation* stats_instrumentation,
162 PicturePileImpl* picture_pile); 168 PicturePileImpl* picture_pile);
163 static void RunRasterTask( 169 static void RunRasterTask(
164 uint8* buffer, 170 uint8* buffer,
165 PicturePileImpl::Analysis* analysis, 171 PicturePileImpl::Analysis* analysis,
166 gfx::Rect rect, 172 gfx::Rect rect,
167 float contents_scale, 173 float contents_scale,
168 const RasterTaskMetadata& metadata, 174 const RasterTaskMetadata& metadata,
169 RenderingStatsInstrumentation* stats_instrumentation, 175 RenderingStatsInstrumentation* stats_instrumentation,
170 PicturePileImpl* picture_pile); 176 PicturePileImpl* picture_pile);
171 static void RunImageDecodeTask(
172 skia::LazyPixelRef* pixel_ref,
173 RenderingStatsInstrumentation* stats_instrumentation);
174 177
175 static void RecordSolidColorPredictorResults(const SkPMColor* actual_colors, 178 static void RecordSolidColorPredictorResults(const SkPMColor* actual_colors,
176 size_t color_count, 179 size_t color_count,
177 bool is_predicted_solid, 180 bool is_predicted_solid,
178 SkPMColor predicted_color); 181 SkPMColor predicted_color);
179 182
180 TileManagerClient* client_; 183 TileManagerClient* client_;
181 scoped_ptr<ResourcePool> resource_pool_; 184 scoped_ptr<ResourcePool> resource_pool_;
182 scoped_ptr<RasterWorkerPool> raster_worker_pool_; 185 scoped_ptr<RasterWorkerPool> raster_worker_pool_;
183 bool manage_tiles_pending_; 186 bool manage_tiles_pending_;
184 int manage_tiles_call_count_;
185 187
186 GlobalStateThatImpactsTilePriority global_state_; 188 GlobalStateThatImpactsTilePriority global_state_;
187 189
188 typedef std::vector<Tile*> TileVector; 190 typedef std::vector<Tile*> TileVector;
189 TileVector tiles_; 191 TileVector tiles_;
190 TileVector tiles_that_need_to_be_rasterized_; 192 TileVector tiles_that_need_to_be_rasterized_;
191 193
192 typedef base::hash_set<uint32_t> PixelRefSet; 194 typedef base::hash_map<uint32_t, RasterWorkerPool::Task> PixelRefMap;
193 PixelRefSet pending_decode_tasks_; 195 PixelRefMap pending_decode_tasks_;
194 196
195 typedef std::queue<scoped_refptr<Tile> > TileQueue; 197 typedef std::queue<scoped_refptr<Tile> > TileQueue;
196 TileQueue tiles_with_pending_upload_; 198 TileQueue tiles_with_pending_upload_;
197 size_t bytes_pending_upload_; 199 size_t bytes_pending_upload_;
198 bool has_performed_uploads_since_last_flush_; 200 bool has_performed_uploads_since_last_flush_;
199 bool ever_exceeded_memory_budget_; 201 bool ever_exceeded_memory_budget_;
200 MemoryHistory::Entry memory_stats_from_last_assign_; 202 MemoryHistory::Entry memory_stats_from_last_assign_;
201 203
202 RenderingStatsInstrumentation* rendering_stats_instrumentation_; 204 RenderingStatsInstrumentation* rendering_stats_instrumentation_;
203 205
204 bool use_color_estimator_; 206 bool use_color_estimator_;
205 bool prediction_benchmarking_; 207 bool prediction_benchmarking_;
206 bool did_initialize_visible_tile_; 208 bool did_initialize_visible_tile_;
207 209
208 size_t pending_tasks_;
209 size_t max_pending_tasks_; 210 size_t max_pending_tasks_;
210 211
211 DISALLOW_COPY_AND_ASSIGN(TileManager); 212 DISALLOW_COPY_AND_ASSIGN(TileManager);
212 }; 213 };
213 214
214 } // namespace cc 215 } // namespace cc
215 216
216 #endif // CC_RESOURCES_TILE_MANAGER_H_ 217 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698