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> |
11 | 11 |
12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/time.h" | |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "cc/memory_history.h" | 16 #include "cc/memory_history.h" |
16 #include "cc/rendering_stats.h" | 17 #include "cc/rendering_stats.h" |
17 #include "cc/resource_pool.h" | 18 #include "cc/resource_pool.h" |
18 #include "cc/tile_priority.h" | 19 #include "cc/tile_priority.h" |
19 | 20 |
20 namespace cc { | 21 namespace cc { |
21 class RasterWorkerPool; | 22 class RasterWorkerPool; |
22 class ResourceProvider; | 23 class ResourceProvider; |
23 class Tile; | 24 class Tile; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 89 |
89 // This class manages tiles, deciding which should get rasterized and which | 90 // This class manages tiles, deciding which should get rasterized and which |
90 // should no longer have any memory assigned to them. Tile objects are "owned" | 91 // should no longer have any memory assigned to them. Tile objects are "owned" |
91 // by layers; they automatically register with the manager when they are | 92 // by layers; they automatically register with the manager when they are |
92 // created, and unregister from the manager when they are deleted. | 93 // created, and unregister from the manager when they are deleted. |
93 class CC_EXPORT TileManager { | 94 class CC_EXPORT TileManager { |
94 public: | 95 public: |
95 TileManager(TileManagerClient* client, | 96 TileManager(TileManagerClient* client, |
96 ResourceProvider *resource_provider, | 97 ResourceProvider *resource_provider, |
97 size_t num_raster_threads, | 98 size_t num_raster_threads, |
98 bool record_rendering_stats); | 99 bool record_rendering_stats, |
100 bool use_cheapess_estimator); | |
99 virtual ~TileManager(); | 101 virtual ~TileManager(); |
100 | 102 |
101 const GlobalStateThatImpactsTilePriority& GlobalState() const { | 103 const GlobalStateThatImpactsTilePriority& GlobalState() const { |
102 return global_state_; | 104 return global_state_; |
103 } | 105 } |
104 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); | 106 void SetGlobalState(const GlobalStateThatImpactsTilePriority& state); |
105 | 107 |
106 void ManageTiles(); | 108 void ManageTiles(); |
107 void CheckForCompletedTileUploads(); | 109 void CheckForCompletedTileUploads(); |
110 void ResetCheapRasterBudget(); | |
108 | 111 |
109 scoped_ptr<base::Value> AsValue() const; | 112 scoped_ptr<base::Value> AsValue() const; |
110 void GetMemoryStats(size_t* memoryRequiredBytes, | 113 void GetMemoryStats(size_t* memoryRequiredBytes, |
111 size_t* memoryNiceToHaveBytes, | 114 size_t* memoryNiceToHaveBytes, |
112 size_t* memoryUsedBytes) const; | 115 size_t* memoryUsedBytes) const; |
113 void GetRenderingStats(RenderingStats* stats); | 116 void GetRenderingStats(RenderingStats* stats); |
114 bool HasPendingWorkScheduled(WhichTree tree) const; | 117 bool HasPendingWorkScheduled(WhichTree tree) const; |
115 | 118 |
116 const MemoryHistory::Entry& memory_stats_from_last_assign() const { return mem ory_stats_from_last_assign_; } | 119 const MemoryHistory::Entry& memory_stats_from_last_assign() const { return mem ory_stats_from_last_assign_; } |
117 | 120 |
(...skipping 19 matching lines...) Expand all Loading... | |
137 client_->ScheduleManageTiles(); | 140 client_->ScheduleManageTiles(); |
138 manage_tiles_pending_ = true; | 141 manage_tiles_pending_ = true; |
139 } | 142 } |
140 void DispatchMoreTasks(); | 143 void DispatchMoreTasks(); |
141 void GatherPixelRefsForTile(Tile* tile); | 144 void GatherPixelRefsForTile(Tile* tile); |
142 void DispatchImageDecodeTasksForTile(Tile* tile); | 145 void DispatchImageDecodeTasksForTile(Tile* tile); |
143 void DispatchOneImageDecodeTask( | 146 void DispatchOneImageDecodeTask( |
144 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); | 147 scoped_refptr<Tile> tile, skia::LazyPixelRef* pixel_ref); |
145 void OnImageDecodeTaskCompleted( | 148 void OnImageDecodeTaskCompleted( |
146 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); | 149 scoped_refptr<Tile> tile, uint32_t pixel_ref_id); |
147 bool CanDispatchRasterTask(Tile* tile); | 150 bool CanDispatchRasterTask(Tile* tile) const; |
151 bool CanPerformCheapRaster(Tile* tile) const; | |
152 scoped_ptr<ResourcePool::Resource> PrepareTileForRaster(Tile* tile); | |
148 void DispatchOneRasterTask(scoped_refptr<Tile> tile); | 153 void DispatchOneRasterTask(scoped_refptr<Tile> tile); |
154 void PerformOneRaster(Tile* tile); | |
155 void OnRasterCompleted( | |
156 scoped_refptr<Tile> tile, | |
157 scoped_ptr<ResourcePool::Resource> resource, | |
158 int manage_tiles_call_count_when_dispatched); | |
149 void OnRasterTaskCompleted( | 159 void OnRasterTaskCompleted( |
150 scoped_refptr<Tile> tile, | 160 scoped_refptr<Tile> tile, |
151 scoped_ptr<ResourcePool::Resource> resource, | 161 scoped_ptr<ResourcePool::Resource> resource, |
152 int manage_tiles_call_count_when_dispatched); | 162 int manage_tiles_call_count_when_dispatched); |
153 void DidFinishTileInitialization(Tile* tile); | 163 void DidFinishTileInitialization(Tile* tile); |
154 void DidTileRasterStateChange(Tile* tile, TileRasterState state); | 164 void DidTileRasterStateChange(Tile* tile, TileRasterState state); |
155 void DidTileBinChange(Tile* tile, | 165 void DidTileBinChange(Tile* tile, |
156 TileManagerBin bin, | 166 TileManagerBin bin, |
157 WhichTree tree); | 167 WhichTree tree); |
158 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; | 168 scoped_ptr<Value> GetMemoryRequirementsAsValue() const; |
159 | 169 |
160 static void RunRasterTask(uint8* buffer, | 170 static void PerformRaster(uint8* buffer, |
161 const gfx::Rect& rect, | 171 const gfx::Rect& rect, |
162 float contents_scale, | 172 float contents_scale, |
163 PicturePileImpl* picture_pile, | 173 PicturePileImpl* picture_pile, |
164 RenderingStats* stats); | 174 RenderingStats* stats); |
165 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, | 175 static void RunImageDecodeTask(skia::LazyPixelRef* pixel_ref, |
reveman
2013/02/05 20:59:13
PerformImageDecode to be consistent?
Sami
2013/02/06 15:25:14
Yeah, good idea.
| |
166 RenderingStats* stats); | 176 RenderingStats* stats); |
167 | 177 |
168 TileManagerClient* client_; | 178 TileManagerClient* client_; |
169 scoped_ptr<ResourcePool> resource_pool_; | 179 scoped_ptr<ResourcePool> resource_pool_; |
170 scoped_ptr<RasterWorkerPool> raster_worker_pool_; | 180 scoped_ptr<RasterWorkerPool> raster_worker_pool_; |
171 bool manage_tiles_pending_; | 181 bool manage_tiles_pending_; |
172 int manage_tiles_call_count_; | 182 int manage_tiles_call_count_; |
173 | 183 |
174 GlobalStateThatImpactsTilePriority global_state_; | 184 GlobalStateThatImpactsTilePriority global_state_; |
175 | 185 |
(...skipping 11 matching lines...) Expand all Loading... | |
187 | 197 |
188 typedef std::queue<scoped_refptr<Tile> > TileQueue; | 198 typedef std::queue<scoped_refptr<Tile> > TileQueue; |
189 TileQueue tiles_with_pending_set_pixels_; | 199 TileQueue tiles_with_pending_set_pixels_; |
190 size_t bytes_pending_set_pixels_; | 200 size_t bytes_pending_set_pixels_; |
191 bool ever_exceeded_memory_budget_; | 201 bool ever_exceeded_memory_budget_; |
192 MemoryHistory::Entry memory_stats_from_last_assign_; | 202 MemoryHistory::Entry memory_stats_from_last_assign_; |
193 | 203 |
194 bool record_rendering_stats_; | 204 bool record_rendering_stats_; |
195 RenderingStats rendering_stats_; | 205 RenderingStats rendering_stats_; |
196 | 206 |
207 bool use_cheapness_estimator_; | |
208 int cheap_raster_count_; | |
209 base::TimeDelta cheap_raster_time_; | |
210 | |
197 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; | 211 int raster_state_count_[NUM_STATES][NUM_TREES][NUM_BINS]; |
198 | 212 |
199 DISALLOW_COPY_AND_ASSIGN(TileManager); | 213 DISALLOW_COPY_AND_ASSIGN(TileManager); |
200 }; | 214 }; |
201 | 215 |
202 } // namespace cc | 216 } // namespace cc |
203 | 217 |
204 #endif // CC_TILE_MANAGER_H_ | 218 #endif // CC_TILE_MANAGER_H_ |
OLD | NEW |