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_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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 typedef std::vector<Tile*> TileVector; | 181 typedef std::vector<Tile*> TileVector; |
182 typedef std::set<Tile*> TileSet; | 182 typedef std::set<Tile*> TileSet; |
183 | 183 |
184 // Virtual for test | 184 // Virtual for test |
185 virtual void ScheduleTasks( | 185 virtual void ScheduleTasks( |
186 const TileVector& tiles_that_need_to_be_rasterized); | 186 const TileVector& tiles_that_need_to_be_rasterized); |
187 | 187 |
188 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); | 188 void AssignGpuMemoryToTiles(TileVector* tiles_that_need_to_be_rasterized); |
189 | 189 |
190 private: | 190 private: |
| 191 // TODO(boliu): Replace with int64? |
191 class MemoryUsage { | 192 class MemoryUsage { |
192 public: | 193 public: |
193 MemoryUsage(); | 194 MemoryUsage(); |
194 MemoryUsage(int64 memory_bytes, int resource_count); | 195 explicit MemoryUsage(int64 memory_bytes); |
195 | 196 |
196 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); | 197 static MemoryUsage FromConfig(const gfx::Size& size, ResourceFormat format); |
197 static MemoryUsage FromTile(const Tile* tile); | 198 static MemoryUsage FromTile(const Tile* tile); |
198 | 199 |
199 MemoryUsage& operator+=(const MemoryUsage& other); | 200 MemoryUsage& operator+=(const MemoryUsage& other); |
200 MemoryUsage& operator-=(const MemoryUsage& other); | 201 MemoryUsage& operator-=(const MemoryUsage& other); |
201 MemoryUsage operator-(const MemoryUsage& other); | 202 MemoryUsage operator-(const MemoryUsage& other); |
202 | 203 |
203 bool Exceeds(const MemoryUsage& limit) const; | 204 bool Exceeds(const MemoryUsage& limit) const; |
204 int64 memory_bytes() const { return memory_bytes_; } | 205 int64 memory_bytes() const { return memory_bytes_; } |
205 | 206 |
206 private: | 207 private: |
207 int64 memory_bytes_; | 208 int64 memory_bytes_; |
208 int resource_count_; | |
209 }; | 209 }; |
210 | 210 |
211 void OnImageDecodeTaskCompleted(int layer_id, | 211 void OnImageDecodeTaskCompleted(int layer_id, |
212 SkPixelRef* pixel_ref, | 212 SkPixelRef* pixel_ref, |
213 bool was_canceled); | 213 bool was_canceled); |
214 void OnRasterTaskCompleted(Tile::Id tile, | 214 void OnRasterTaskCompleted(Tile::Id tile, |
215 scoped_ptr<ScopedResource> resource, | 215 scoped_ptr<ScopedResource> resource, |
216 const PicturePileImpl::Analysis& analysis, | 216 const PicturePileImpl::Analysis& analysis, |
217 bool was_canceled); | 217 bool was_canceled); |
218 | 218 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 RasterTilePriorityQueue raster_priority_queue_; | 276 RasterTilePriorityQueue raster_priority_queue_; |
277 EvictionTilePriorityQueue eviction_priority_queue_; | 277 EvictionTilePriorityQueue eviction_priority_queue_; |
278 bool eviction_priority_queue_is_up_to_date_; | 278 bool eviction_priority_queue_is_up_to_date_; |
279 | 279 |
280 DISALLOW_COPY_AND_ASSIGN(TileManager); | 280 DISALLOW_COPY_AND_ASSIGN(TileManager); |
281 }; | 281 }; |
282 | 282 |
283 } // namespace cc | 283 } // namespace cc |
284 | 284 |
285 #endif // CC_RESOURCES_TILE_MANAGER_H_ | 285 #endif // CC_RESOURCES_TILE_MANAGER_H_ |
OLD | NEW |