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 <list> |
9 #include <queue> | 9 #include <queue> |
10 #include <vector> | 10 #include <vector> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Persisted state: valid all the time. | 52 // Persisted state: valid all the time. |
53 bool can_use_gpu_memory; | 53 bool can_use_gpu_memory; |
54 bool can_be_freed; | 54 bool can_be_freed; |
55 scoped_ptr<ResourcePool::Resource> resource; | 55 scoped_ptr<ResourcePool::Resource> resource; |
56 bool resource_is_being_initialized; | 56 bool resource_is_being_initialized; |
57 bool contents_swizzled; | 57 bool contents_swizzled; |
58 bool need_to_gather_pixel_refs; | 58 bool need_to_gather_pixel_refs; |
59 std::list<skia::LazyPixelRef*> pending_pixel_refs; | 59 std::list<skia::LazyPixelRef*> pending_pixel_refs; |
60 | 60 |
61 // Ephemeral state, valid only during Manage. | 61 // Ephemeral state, valid only during Manage. |
62 TileManagerBin bin; | 62 TileManagerBin bin[NUM_TREES]; |
| 63 // Bin used to determine raster priority. |
| 64 TileManagerBin raster_bin; |
63 TileResolution resolution; | 65 TileResolution resolution; |
64 float time_to_needed_in_seconds; | 66 float time_to_needed_in_seconds; |
65 }; | 67 }; |
66 | 68 |
67 // This class manages tiles, deciding which should get rasterized and which | 69 // This class manages tiles, deciding which should get rasterized and which |
68 // should no longer have any memory assigned to them. Tile objects are "owned" | 70 // should no longer have any memory assigned to them. Tile objects are "owned" |
69 // by layers; they automatically register with the manager when they are | 71 // by layers; they automatically register with the manager when they are |
70 // created, and unregister from the manager when they are deleted. | 72 // created, and unregister from the manager when they are deleted. |
71 class CC_EXPORT TileManager { | 73 class CC_EXPORT TileManager { |
72 public: | 74 public: |
73 TileManager(TileManagerClient* client, | 75 TileManager(TileManagerClient* client, |
74 ResourceProvider *resource_provider, | 76 ResourceProvider *resource_provider, |
75 size_t num_raster_threads); | 77 size_t num_raster_threads); |
76 virtual ~TileManager(); | 78 virtual ~TileManager(); |
77 | 79 |
78 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_
state_; } | 80 const GlobalStateThatImpactsTilePriority& GlobalState() const { return global_
state_; } |
79 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 81 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
80 | 82 |
81 void ManageTiles(); | 83 void ManageTiles(); |
82 void CheckForCompletedSetPixels(); | 84 void CheckForCompletedSetPixels(); |
83 | 85 |
84 void renderingStats(RenderingStats* stats); | 86 void GetRenderingStats(RenderingStats* stats); |
| 87 |
| 88 int GetTilesInBinCount(TileManagerBin bin, WhichTree tree); |
| 89 int GetDrawableTilesInBinCount(TileManagerBin bin, WhichTree tree); |
85 | 90 |
86 protected: | 91 protected: |
87 // Methods called by Tile | 92 // Methods called by Tile |
88 friend class Tile; | 93 friend class Tile; |
89 void RegisterTile(Tile*); | 94 void RegisterTile(Tile*); |
90 void UnregisterTile(Tile*); | 95 void UnregisterTile(Tile*); |
91 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); | 96 void WillModifyTilePriority(Tile*, WhichTree, const TilePriority& new_priority
); |
92 | 97 |
93 private: | 98 private: |
| 99 void ResetBinCounts(); |
94 void AssignGpuMemoryToTiles(); | 100 void AssignGpuMemoryToTiles(); |
95 void FreeResourcesForTile(Tile*); | 101 void FreeResourcesForTile(Tile*); |
96 void ScheduleManageTiles(); | 102 void ScheduleManageTiles(); |
97 void ScheduleCheckForCompletedSetPixels(); | 103 void ScheduleCheckForCompletedSetPixels(); |
98 void DispatchMoreTasks(); | 104 void DispatchMoreTasks(); |
99 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>); | 105 void DispatchOneRasterTask(RasterThread*, scoped_refptr<Tile>); |
100 void OnRasterTaskCompleted( | 106 void OnRasterTaskCompleted( |
101 scoped_refptr<Tile>, | 107 scoped_refptr<Tile>, |
102 scoped_ptr<ResourcePool::Resource>, | 108 scoped_ptr<ResourcePool::Resource>, |
103 scoped_refptr<PicturePileImpl>, | 109 scoped_refptr<PicturePileImpl>, |
(...skipping 10 matching lines...) Expand all Loading... |
114 RasterThread* GetFreeRasterThread(); | 120 RasterThread* GetFreeRasterThread(); |
115 | 121 |
116 TileManagerClient* client_; | 122 TileManagerClient* client_; |
117 scoped_ptr<ResourcePool> resource_pool_; | 123 scoped_ptr<ResourcePool> resource_pool_; |
118 bool manage_tiles_pending_; | 124 bool manage_tiles_pending_; |
119 int manage_tiles_call_count_; | 125 int manage_tiles_call_count_; |
120 bool check_for_completed_set_pixels_pending_; | 126 bool check_for_completed_set_pixels_pending_; |
121 | 127 |
122 GlobalStateThatImpactsTilePriority global_state_; | 128 GlobalStateThatImpactsTilePriority global_state_; |
123 | 129 |
| 130 int tiles_in_bin_count_[NUM_BINS][NUM_TREES]; |
| 131 int drawable_tiles_in_bin_count_[NUM_BINS][NUM_TREES]; |
| 132 |
124 typedef std::vector<Tile*> TileVector; | 133 typedef std::vector<Tile*> TileVector; |
125 TileVector tiles_; | 134 TileVector tiles_; |
126 TileVector tiles_that_need_to_be_rasterized_; | 135 TileVector tiles_that_need_to_be_rasterized_; |
127 | 136 |
128 typedef std::list<Tile*> TileList; | 137 typedef std::list<Tile*> TileList; |
129 // Tiles with image decoding tasks. These tiles need to be rasterized | 138 // Tiles with image decoding tasks. These tiles need to be rasterized |
130 // when all the image decoding tasks finish. | 139 // when all the image decoding tasks finish. |
131 TileList tiles_with_image_decoding_tasks_; | 140 TileList tiles_with_image_decoding_tasks_; |
132 | 141 |
133 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; | 142 typedef base::hash_map<uint32_t, skia::LazyPixelRef*> PixelRefMap; |
134 PixelRefMap pending_decode_tasks_; | 143 PixelRefMap pending_decode_tasks_; |
135 | 144 |
136 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 145 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
137 TileQueue tiles_with_pending_set_pixels_; | 146 TileQueue tiles_with_pending_set_pixels_; |
138 | 147 |
139 typedef ScopedPtrVector<RasterThread> RasterThreadVector; | 148 typedef ScopedPtrVector<RasterThread> RasterThreadVector; |
140 RasterThreadVector raster_threads_; | 149 RasterThreadVector raster_threads_; |
141 | 150 |
142 RenderingStats rendering_stats_; | 151 RenderingStats rendering_stats_; |
143 | 152 |
144 DISALLOW_COPY_AND_ASSIGN(TileManager); | 153 DISALLOW_COPY_AND_ASSIGN(TileManager); |
145 }; | 154 }; |
146 | 155 |
147 } // namespace cc | 156 } // namespace cc |
148 | 157 |
149 #endif // CC_TILE_MANAGER_H_ | 158 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |