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

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

Issue 287643004: Re-land: cc: Examine layers to determine if we're ready to activate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: init check_if_ready_to_activate_pending_ properly 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/layers/picture_layer_impl_unittest.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>
(...skipping 12 matching lines...) Expand all
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/resource_pool.h" 25 #include "cc/resources/resource_pool.h"
26 #include "cc/resources/tile.h" 26 #include "cc/resources/tile.h"
27 27
28 namespace cc { 28 namespace cc {
29 class ResourceProvider; 29 class ResourceProvider;
30 30
31 class CC_EXPORT TileManagerClient { 31 class CC_EXPORT TileManagerClient {
32 public: 32 public:
33 // Called when all tiles marked as required for activation are ready to draw.
33 virtual void NotifyReadyToActivate() = 0; 34 virtual void NotifyReadyToActivate() = 0;
34 virtual void NotifyTileInitialized(const Tile* tile) = 0; 35
36 // Called when the visible representation of a tile might have changed. Some
37 // examples are:
38 // - Tile version initialized.
39 // - Tile resources freed.
40 // - Tile marked for on-demand raster.
41 virtual void NotifyTileStateChanged(const Tile* tile) = 0;
35 42
36 protected: 43 protected:
37 virtual ~TileManagerClient() {} 44 virtual ~TileManagerClient() {}
38 }; 45 };
39 46
40 struct RasterTaskCompletionStats { 47 struct RasterTaskCompletionStats {
41 RasterTaskCompletionStats(); 48 RasterTaskCompletionStats();
42 49
43 size_t completed_count; 50 size_t completed_count;
44 size_t canceled_count; 51 size_t canceled_count;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 std::vector<PairedPictureLayerIterator> paired_iterators_; 154 std::vector<PairedPictureLayerIterator> paired_iterators_;
148 std::vector<PairedPictureLayerIterator*> iterator_heap_; 155 std::vector<PairedPictureLayerIterator*> iterator_heap_;
149 TreePriority tree_priority_; 156 TreePriority tree_priority_;
150 EvictionOrderComparator comparator_; 157 EvictionOrderComparator comparator_;
151 158
152 DISALLOW_COPY_AND_ASSIGN(EvictionTileIterator); 159 DISALLOW_COPY_AND_ASSIGN(EvictionTileIterator);
153 }; 160 };
154 161
155 static scoped_ptr<TileManager> Create( 162 static scoped_ptr<TileManager> Create(
156 TileManagerClient* client, 163 TileManagerClient* client,
164 base::SequencedTaskRunner* task_runner,
157 ResourcePool* resource_pool, 165 ResourcePool* resource_pool,
158 Rasterizer* rasterizer, 166 Rasterizer* rasterizer,
159 bool use_rasterize_on_demand,
160 RenderingStatsInstrumentation* rendering_stats_instrumentation); 167 RenderingStatsInstrumentation* rendering_stats_instrumentation);
161 virtual ~TileManager(); 168 virtual ~TileManager();
162 169
163 void ManageTiles(const GlobalStateThatImpactsTilePriority& state); 170 void ManageTiles(const GlobalStateThatImpactsTilePriority& state);
164 171
165 // Returns true when visible tiles have been initialized. 172 // Returns true when visible tiles have been initialized.
166 bool UpdateVisibleTiles(); 173 bool UpdateVisibleTiles();
167 174
168 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile, 175 scoped_refptr<Tile> CreateTile(PicturePileImpl* picture_pile,
169 const gfx::Size& tile_size, 176 const gfx::Size& tile_size,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 prioritized_tiles_dirty_ = true; 228 prioritized_tiles_dirty_ = true;
222 } 229 }
223 } 230 }
224 231
225 void SetRasterizerForTesting(Rasterizer* rasterizer); 232 void SetRasterizerForTesting(Rasterizer* rasterizer);
226 233
227 void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); } 234 void CleanUpReleasedTilesForTesting() { CleanUpReleasedTiles(); }
228 235
229 protected: 236 protected:
230 TileManager(TileManagerClient* client, 237 TileManager(TileManagerClient* client,
238 base::SequencedTaskRunner* task_runner,
231 ResourcePool* resource_pool, 239 ResourcePool* resource_pool,
232 Rasterizer* rasterizer, 240 Rasterizer* rasterizer,
233 bool use_rasterize_on_demand,
234 RenderingStatsInstrumentation* rendering_stats_instrumentation); 241 RenderingStatsInstrumentation* rendering_stats_instrumentation);
235 242
236 // Methods called by Tile 243 // Methods called by Tile
237 friend class Tile; 244 friend class Tile;
238 void DidChangeTilePriority(Tile* tile); 245 void DidChangeTilePriority(Tile* tile);
239 246
240 void CleanUpReleasedTiles(); 247 void CleanUpReleasedTiles();
241 248
242 // Overriden from RefCountedManager<Tile>: 249 // Overriden from RefCountedManager<Tile>:
243 virtual void Release(Tile* tile) OVERRIDE; 250 virtual void Release(Tile* tile) OVERRIDE;
(...skipping 25 matching lines...) Expand all
269 bool was_canceled); 276 bool was_canceled);
270 277
271 inline size_t BytesConsumedIfAllocated(const Tile* tile) const { 278 inline size_t BytesConsumedIfAllocated(const Tile* tile) const {
272 return Resource::MemorySizeBytes(tile->size(), 279 return Resource::MemorySizeBytes(tile->size(),
273 resource_pool_->resource_format()); 280 resource_pool_->resource_format());
274 } 281 }
275 282
276 void FreeResourceForTile(Tile* tile, RasterMode mode); 283 void FreeResourceForTile(Tile* tile, RasterMode mode);
277 void FreeResourcesForTile(Tile* tile); 284 void FreeResourcesForTile(Tile* tile);
278 void FreeUnusedResourcesForTile(Tile* tile); 285 void FreeUnusedResourcesForTile(Tile* tile);
286 void FreeResourcesForTileAndNotifyClientIfTileWasReadyToDraw(Tile* tile);
279 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile, 287 scoped_refptr<ImageDecodeTask> CreateImageDecodeTask(Tile* tile,
280 SkPixelRef* pixel_ref); 288 SkPixelRef* pixel_ref);
281 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile); 289 scoped_refptr<RasterTask> CreateRasterTask(Tile* tile);
282 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const; 290 scoped_ptr<base::Value> GetMemoryRequirementsAsValue() const;
283 void UpdatePrioritizedTileSetIfNeeded(); 291 void UpdatePrioritizedTileSetIfNeeded();
284 void CleanUpLayers(); 292 void CleanUpLayers();
285 293
294 bool IsReadyToActivate() const;
295 void ScheduleCheckIfReadyToActivate();
296 void CheckIfReadyToActivate();
297
286 TileManagerClient* client_; 298 TileManagerClient* client_;
299 scoped_refptr<base::SequencedTaskRunner> task_runner_;
287 ResourcePool* resource_pool_; 300 ResourcePool* resource_pool_;
288 Rasterizer* rasterizer_; 301 Rasterizer* rasterizer_;
289 GlobalStateThatImpactsTilePriority global_state_; 302 GlobalStateThatImpactsTilePriority global_state_;
290 303
291 typedef base::hash_map<Tile::Id, Tile*> TileMap; 304 typedef base::hash_map<Tile::Id, Tile*> TileMap;
292 TileMap tiles_; 305 TileMap tiles_;
293 306
294 PrioritizedTileSet prioritized_tiles_; 307 PrioritizedTileSet prioritized_tiles_;
295 bool prioritized_tiles_dirty_; 308 bool prioritized_tiles_dirty_;
296 309
(...skipping 19 matching lines...) Expand all
316 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap; 329 typedef base::hash_map<int, PixelRefTaskMap> LayerPixelRefTaskMap;
317 LayerPixelRefTaskMap image_decode_tasks_; 330 LayerPixelRefTaskMap image_decode_tasks_;
318 331
319 typedef base::hash_map<int, int> LayerCountMap; 332 typedef base::hash_map<int, int> LayerCountMap;
320 LayerCountMap used_layer_counts_; 333 LayerCountMap used_layer_counts_;
321 334
322 RasterTaskCompletionStats update_visible_tiles_stats_; 335 RasterTaskCompletionStats update_visible_tiles_stats_;
323 336
324 std::vector<Tile*> released_tiles_; 337 std::vector<Tile*> released_tiles_;
325 338
326 bool use_rasterize_on_demand_;
327
328 ResourceFormat resource_format_; 339 ResourceFormat resource_format_;
329 340
330 // Queue used when scheduling raster tasks. 341 // Queue used when scheduling raster tasks.
331 RasterTaskQueue raster_queue_; 342 RasterTaskQueue raster_queue_;
332 343
333 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_; 344 std::vector<scoped_refptr<RasterTask> > orphan_raster_tasks_;
334 345
335 std::vector<PictureLayerImpl*> layers_; 346 std::vector<PictureLayerImpl*> layers_;
336 347
348 bool check_if_ready_to_activate_pending_;
349
350 base::WeakPtrFactory<TileManager> weak_ptr_factory_;
351
337 DISALLOW_COPY_AND_ASSIGN(TileManager); 352 DISALLOW_COPY_AND_ASSIGN(TileManager);
338 }; 353 };
339 354
340 } // namespace cc 355 } // namespace cc
341 356
342 #endif // CC_RESOURCES_TILE_MANAGER_H_ 357 #endif // CC_RESOURCES_TILE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/layers/picture_layer_impl_unittest.cc ('k') | cc/resources/tile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698