| OLD | NEW |
| 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_TILE_MANAGER_H_ | 5 #ifndef CC_TILE_MANAGER_H_ |
| 6 #define CC_TILE_MANAGER_H_ | 6 #define CC_TILE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <list> |
| 8 #include <queue> | 9 #include <queue> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 12 #include "base/hash_tables.h" |
| 11 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/values.h" | 14 #include "base/values.h" |
| 13 #include "cc/resource_pool.h" | 15 #include "cc/resource_pool.h" |
| 14 #include "cc/tile_priority.h" | 16 #include "cc/tile_priority.h" |
| 15 | 17 |
| 16 namespace cc { | 18 namespace cc { |
| 17 | 19 |
| 18 class RasterThread; | 20 class RasterThread; |
| 19 class ResourceProvider; | 21 class ResourceProvider; |
| 20 class Tile; | 22 class Tile; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 public: | 48 public: |
| 47 ManagedTileState(); | 49 ManagedTileState(); |
| 48 ~ManagedTileState(); | 50 ~ManagedTileState(); |
| 49 | 51 |
| 50 // Persisted state: valid all the time. | 52 // Persisted state: valid all the time. |
| 51 bool can_use_gpu_memory; | 53 bool can_use_gpu_memory; |
| 52 bool can_be_freed; | 54 bool can_be_freed; |
| 53 scoped_ptr<ResourcePool::Resource> resource; | 55 scoped_ptr<ResourcePool::Resource> resource; |
| 54 bool resource_is_being_initialized; | 56 bool resource_is_being_initialized; |
| 55 bool contents_swizzled; | 57 bool contents_swizzled; |
| 58 bool need_to_gather_pixel_refs; |
| 59 std::list<skia::LazyPixelRef*> pending_pixel_refs; |
| 56 | 60 |
| 57 // Ephemeral state, valid only during Manage. | 61 // Ephemeral state, valid only during Manage. |
| 58 TileManagerBin bin; | 62 TileManagerBin bin; |
| 59 TileResolution resolution; | 63 TileResolution resolution; |
| 60 float time_to_needed_in_seconds; | 64 float time_to_needed_in_seconds; |
| 61 }; | 65 }; |
| 62 | 66 |
| 63 // This class manages tiles, deciding which should get rasterized and which | 67 // This class manages tiles, deciding which should get rasterized and which |
| 64 // should no longer have any memory assigned to them. Tile objects are "owned" | 68 // should no longer have any memory assigned to them. Tile objects are "owned" |
| 65 // by layers; they automatically register with the manager when they are | 69 // by layers; they automatically register with the manager when they are |
| (...skipping 18 matching lines...) Expand all Loading... |
| 84 friend class Tile; | 88 friend class Tile; |
| 85 void RegisterTile(Tile*); | 89 void RegisterTile(Tile*); |
| 86 void UnregisterTile(Tile*); | 90 void UnregisterTile(Tile*); |
| 87 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); | 91 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); |
| 88 | 92 |
| 89 private: | 93 private: |
| 90 void AssignGpuMemoryToTiles(); | 94 void AssignGpuMemoryToTiles(); |
| 91 void FreeResourcesForTile(Tile*); | 95 void FreeResourcesForTile(Tile*); |
| 92 void ScheduleManageTiles(); | 96 void ScheduleManageTiles(); |
| 93 void ScheduleCheckForCompletedSetPixels(); | 97 void ScheduleCheckForCompletedSetPixels(); |
| 94 void DispatchMoreRasterTasks(); | 98 void DispatchMoreTasks(); |
| 95 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>); | 99 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>); |
| 96 void OnRasterTaskCompleted( | 100 void OnRasterTaskCompleted( |
| 97 scoped_refptr<Tile>, | 101 scoped_refptr<Tile>, |
| 98 scoped_ptr<ResourcePool::Resource>, | 102 scoped_ptr<ResourcePool::Resource>, |
| 99 scoped_refptr<PicturePileImpl>, | 103 scoped_refptr<PicturePileImpl>, |
| 100 RenderingStats*); | 104 RenderingStats*); |
| 101 void DidFinishTileInitialization(Tile*); | 105 void DidFinishTileInitialization(Tile*); |
| 106 void DispatchImageDecodingTasksForTile(Tile*); |
| 107 void OnImageDecodingTaskCompleted(scoped_refptr<Tile>, uint32_t); |
| 108 void DispatchOneImageDecodingTask( |
| 109 RasterThread*, scoped_refptr<Tile>, skia::LazyPixelRef*); |
| 110 RasterThread* GetFreeRasterThread(); |
| 102 | 111 |
| 103 TileManagerClient* client_; | 112 TileManagerClient* client_; |
| 104 scoped_ptr<ResourcePool> resource_pool_; | 113 scoped_ptr<ResourcePool> resource_pool_; |
| 105 bool manage_tiles_pending_; | 114 bool manage_tiles_pending_; |
| 106 bool check_for_completed_set_pixels_pending_; | 115 bool check_for_completed_set_pixels_pending_; |
| 107 | 116 |
| 108 GlobalStateThatImpactsTilePriority global_state_; | 117 GlobalStateThatImpactsTilePriority global_state_; |
| 109 | 118 |
| 110 typedef std::vector<Tile*> TileVector; | 119 typedef std::vector<Tile*> TileVector; |
| 111 TileVector tiles_; | 120 TileVector tiles_; |
| 112 TileVector tiles_that_need_to_be_rasterized_; | 121 TileVector tiles_that_need_to_be_rasterized_; |
| 113 | 122 |
| 123 typedef std::list<Tile*> TileList; |
| 124 // Tiles with image decoding tasks. These tiles need to be rasterized |
| 125 // when all the image decoding tasks finish. |
| 126 TileList tiles_with_image_decoding_tasks_; |
| 127 |
| 128 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; |
| 129 PixelRefMap pending_decode_tasks_; |
| 130 |
| 114 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 131 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
| 115 TileQueue tiles_with_pending_set_pixels_; | 132 TileQueue tiles_with_pending_set_pixels_; |
| 116 | 133 |
| 117 typedef ScopedPtrVector<RasterThread> RasterThreadVector; | 134 typedef ScopedPtrVector<RasterThread> RasterThreadVector; |
| 118 RasterThreadVector raster_threads_; | 135 RasterThreadVector raster_threads_; |
| 119 | 136 |
| 120 RenderingStats rendering_stats_; | 137 RenderingStats rendering_stats_; |
| 121 | 138 |
| 122 DISALLOW_COPY_AND_ASSIGN(TileManager); | 139 DISALLOW_COPY_AND_ASSIGN(TileManager); |
| 123 }; | 140 }; |
| 124 | 141 |
| 125 } // namespace cc | 142 } // namespace cc |
| 126 | 143 |
| 127 #endif // CC_TILE_MANAGER_H_ | 144 #endif // CC_TILE_MANAGER_H_ |
| OLD | NEW |