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

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

Issue 296453009: cc: Get rid of rasterizer delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: removed redundant get Created 6 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
« no previous file with comments | « cc/resources/rasterizer_delegate.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/debug/rendering_stats_instrumentation.h" 18 #include "cc/debug/rendering_stats_instrumentation.h"
19 #include "cc/layers/picture_layer_impl.h" 19 #include "cc/layers/picture_layer_impl.h"
20 #include "cc/resources/managed_tile_state.h" 20 #include "cc/resources/managed_tile_state.h"
21 #include "cc/resources/memory_history.h" 21 #include "cc/resources/memory_history.h"
22 #include "cc/resources/picture_pile_impl.h" 22 #include "cc/resources/picture_pile_impl.h"
23 #include "cc/resources/prioritized_tile_set.h" 23 #include "cc/resources/prioritized_tile_set.h"
24 #include "cc/resources/rasterizer.h" 24 #include "cc/resources/rasterizer.h"
25 #include "cc/resources/rasterizer_delegate.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"
28 27
29 namespace cc { 28 namespace cc {
30 class RasterizerDelegate;
31 class ResourceProvider; 29 class ResourceProvider;
32 30
33 class CC_EXPORT TileManagerClient { 31 class CC_EXPORT TileManagerClient {
34 public: 32 public:
35 virtual void NotifyReadyToActivate() = 0; 33 virtual void NotifyReadyToActivate() = 0;
36 virtual void NotifyTileInitialized(const Tile* tile) = 0; 34 virtual void NotifyTileInitialized(const Tile* tile) = 0;
37 35
38 protected: 36 protected:
39 virtual ~TileManagerClient() {} 37 virtual ~TileManagerClient() {}
40 }; 38 };
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 TreePriority tree_priority_; 149 TreePriority tree_priority_;
152 EvictionOrderComparator comparator_; 150 EvictionOrderComparator comparator_;
153 151
154 DISALLOW_COPY_AND_ASSIGN(EvictionTileIterator); 152 DISALLOW_COPY_AND_ASSIGN(EvictionTileIterator);
155 }; 153 };
156 154
157 static scoped_ptr<TileManager> Create( 155 static scoped_ptr<TileManager> Create(
158 TileManagerClient* client, 156 TileManagerClient* client,
159 ResourcePool* resource_pool, 157 ResourcePool* resource_pool,
160 Rasterizer* rasterizer, 158 Rasterizer* rasterizer,
161 Rasterizer* gpu_rasterizer,
162 bool use_rasterize_on_demand, 159 bool use_rasterize_on_demand,
163 RenderingStatsInstrumentation* rendering_stats_instrumentation); 160 RenderingStatsInstrumentation* rendering_stats_instrumentation);
164 virtual ~TileManager(); 161 virtual ~TileManager();
165 162
166 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); 163 void ManageTiles(const GlobalStateThatImpactsTilePriority& state);
167 164
168 // Returns true when visible tiles have been initialized. 165 // Returns true when visible tiles have been initialized.
169 bool UpdateVisibleTiles(); 166 bool UpdateVisibleTiles();
170 167
171 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, 168 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void SetGlobalStateForTesting( 215 void SetGlobalStateForTesting(
219 const GlobalStateThatImpactsTilePriority& state) { 216 const GlobalStateThatImpactsTilePriority& state) {
220 // Soft limit is used for resource pool such that 217 // Soft limit is used for resource pool such that
221 // memory returns to soft limit after going over. 218 // memory returns to soft limit after going over.
222 if (state != global_state_) { 219 if (state != global_state_) {
223 global_state_ = state; 220 global_state_ = state;
224 prioritized_tiles_dirty_ = true; 221 prioritized_tiles_dirty_ = true;
225 } 222 }
226 } 223 }
227 224
228 void SetRasterizersForTesting(Rasterizer* rasterizer, 225 void SetRasterizerForTesting(Rasterizer* rasterizer);
229 Rasterizer* gpu_rasterizer);
230 226
231 void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); } 227 void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); }
232 228
233 protected: 229 protected:
234 TileManager(TileManagerClient* client, 230 TileManager(TileManagerClient* client,
235 ResourcePool* resource_pool, 231 ResourcePool* resource_pool,
236 Rasterizer* rasterizer, 232 Rasterizer* rasterizer,
237 Rasterizer* gpu_rasterizer,
238 bool use_rasterize_on_demand, 233 bool use_rasterize_on_demand,
239 RenderingStatsInstrumentation* rendering_stats_instrumentation); 234 RenderingStatsInstrumentation* rendering_stats_instrumentation);
240 235
241 // Methods called by Tile 236 // Methods called by Tile
242 friend class Tile; 237 friend class Tile;
243 void DidChangeTilePriority(Tile* tile); 238 void DidChangeTilePriority(Tile* tile);
244 239
245 void CleanUpReleasedTiles(); 240 void CleanUpReleasedTiles();
246 241
247 // Overriden from RefCountedManager<Tile>: 242 // Overriden from RefCountedManager<Tile>:
248 virtual void Release(Tile* tile) OVERRIDE; 243 virtual void Release(Tile* tile) OVERRIDE;
249 244
250 // Overriden from RasterizerClient: 245 // Overriden from RasterizerClient:
251 virtual bool ShouldForceTasksRequiredForActivationToComplete() const OVERRIDE; 246 virtual bool ShouldForceTasksRequiredForActivationToComplete() const OVERRIDE;
252 virtual void DidFinishRunningTasks() OVERRIDE; 247 virtual void DidFinishRunningTasks() OVERRIDE;
253 virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE; 248 virtual void DidFinishRunningTasksRequiredForActivation() OVERRIDE;
254 249
255 typedef std::vector<Tile*> TileVector; 250 typedef std::vector<Tile*> TileVector;
256 typedef std::set<Tile*> TileSet; 251 typedef std::set<Tile*> TileSet;
257 252
258 // Virtual for test 253 // Virtual for test
259 virtual void ScheduleTasks( 254 virtual void ScheduleTasks(
260 const TileVector& tiles_that_need_to_be_rasterized); 255 const TileVector& tiles_that_need_to_be_rasterized);
261 256
262 void AssignGpuMemoryToTiles(PrioritizedTileSet* tiles, 257 void AssignGpuMemoryToTiles(PrioritizedTileSet* tiles,
263 TileVector* tiles_that_need_to_be_rasterized); 258 TileVector* tiles_that_need_to_be_rasterized);
264 void GetTilesWithAssignedBins(PrioritizedTileSet* tiles); 259 void GetTilesWithAssignedBins(PrioritizedTileSet* tiles);
265 260
266 private: 261 private:
267 enum RasterizerType {
268 RASTERIZER_TYPE_DEFAULT,
269 RASTERIZER_TYPE_GPU,
270 NUM_RASTERIZER_TYPES
271 };
272
273 void OnImageDecodeTaskCompleted(int layer_id, 262 void OnImageDecodeTaskCompleted(int layer_id,
274 SkPixelRef* pixel_ref, 263 SkPixelRef* pixel_ref,
275 bool was_canceled); 264 bool was_canceled);
276 void OnRasterTaskCompleted(Tile::Id tile, 265 void OnRasterTaskCompleted(Tile::Id tile,
277 scoped_ptr<ScopedResource> resource, 266 scoped_ptr<ScopedResource> resource,
278 RasterMode raster_mode, 267 RasterMode raster_mode,
279 const PicturePileImpl::Analysis& analysis, 268 const PicturePileImpl::Analysis& analysis,
280 bool was_canceled); 269 bool was_canceled);
281 270
282 inline size_t BytesConsumedIfAllocated(const Tile* tile) const { 271 inline size_t BytesConsumedIfAllocated(const Tile* tile) const {
283 return Resource::MemorySizeBytes(tile->size(), 272 return Resource::MemorySizeBytes(tile->size(),
284 resource_pool_->resource_format()); 273 resource_pool_->resource_format());
285 } 274 }
286 275
287 void FreeResourceForTile(Tile* tile, RasterMode mode); 276 void FreeResourceForTile(Tile* tile, RasterMode mode);
288 void FreeResourcesForTile(Tile* tile); 277 void FreeResourcesForTile(Tile* tile);
289 void FreeUnusedResourcesForTile(Tile* tile); 278 void FreeUnusedResourcesForTile(Tile* tile);
290 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, 279 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile,
291 SkPixelRef* pixel_ref); 280 SkPixelRef* pixel_ref);
292 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); 281 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile);
293 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; 282 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const;
294 void UpdatePrioritizedTileSetIfNeeded(); 283 void UpdatePrioritizedTileSetIfNeeded();
295 void CleanUpLayers(); 284 void CleanUpLayers();
296 285
297 TileManagerClient* client_; 286 TileManagerClient* client_;
298 ResourcePool* resource_pool_; 287 ResourcePool* resource_pool_;
299 scoped_ptr<RasterizerDelegate> rasterizer_delegate_; 288 Rasterizer* rasterizer_;
300 GlobalStateThatImpactsTilePriority global_state_; 289 GlobalStateThatImpactsTilePriority global_state_;
301 290
302 typedef base::hash_map<Tile::Id, Tile*> TileMap; 291 typedef base::hash_map<Tile::Id, Tile*> TileMap;
303 TileMap tiles_; 292 TileMap tiles_;
304 293
305 PrioritizedTileSet prioritized_tiles_; 294 PrioritizedTileSet prioritized_tiles_;
306 bool prioritized_tiles_dirty_; 295 bool prioritized_tiles_dirty_;
307 296
308 bool all_tiles_that_need_to_be_rasterized_have_memory_; 297 bool all_tiles_that_need_to_be_rasterized_have_memory_;
309 bool all_tiles_required_for_activation_have_memory_; 298 bool all_tiles_required_for_activation_have_memory_;
(...skipping 21 matching lines...) Expand all
331 LayerCountMap used_layer_counts_; 320 LayerCountMap used_layer_counts_;
332 321
333 RasterTaskCompletionStats update_visible_tiles_stats_; 322 RasterTaskCompletionStats update_visible_tiles_stats_;
334 323
335 std::vector<Tile*> released_tiles_; 324 std::vector<Tile*> released_tiles_;
336 325
337 bool use_rasterize_on_demand_; 326 bool use_rasterize_on_demand_;
338 327
339 ResourceFormat resource_format_; 328 ResourceFormat resource_format_;
340 329
341 // Queues used when scheduling raster tasks. 330 // Queue used when scheduling raster tasks.
342 RasterTaskQueue raster_queue_[NUM_RASTERIZER_TYPES]; 331 RasterTaskQueue raster_queue_;
343 332
344 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; 333 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_;
345 334
346 std::vector<PictureLayerImpl*> layers_; 335 std::vector<PictureLayerImpl*> layers_;
347 336
348 DISALLOW_COPY_AND_ASSIGN(TileManager); 337 DISALLOW_COPY_AND_ASSIGN(TileManager);
349 }; 338 };
350 339
351 } // namespace cc 340 } // namespace cc
352 341
353 #endif // CC_RESOURCES_TILE_MANAGER_H_ 342 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/resources/rasterizer_delegate.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698