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_PICTURE_LAYER_TILING_H_ | 5 #ifndef CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 6 #define CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 }; | 120 }; |
121 | 121 |
122 ~PictureLayerTiling(); | 122 ~PictureLayerTiling(); |
123 | 123 |
124 // Create a tiling with no tiles. CreateTiles must be called to add some. | 124 // Create a tiling with no tiles. CreateTiles must be called to add some. |
125 static scoped_ptr<PictureLayerTiling> Create( | 125 static scoped_ptr<PictureLayerTiling> Create( |
126 float contents_scale, | 126 float contents_scale, |
127 const gfx::Size& layer_bounds, | 127 const gfx::Size& layer_bounds, |
128 PictureLayerTilingClient* client); | 128 PictureLayerTilingClient* client); |
129 gfx::Size layer_bounds() const { return layer_bounds_; } | 129 gfx::Size layer_bounds() const { return layer_bounds_; } |
130 void SetLayerBounds(const gfx::Size& layer_bounds); | 130 void UpdateTilesToCurrentPile(const Region& layer_invalidation, |
131 void Invalidate(const Region& layer_region); | 131 const gfx::Size& new_layer_bounds); |
132 void RemoveTilesInRegion(const Region& layer_region); | |
133 void CreateMissingTilesInLiveTilesRect(); | 132 void CreateMissingTilesInLiveTilesRect(); |
134 | 133 |
135 void SetClient(PictureLayerTilingClient* client); | 134 void SetClient(PictureLayerTilingClient* client); |
136 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 135 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
137 TileResolution resolution() const { return resolution_; } | 136 TileResolution resolution() const { return resolution_; } |
138 | 137 |
139 gfx::Rect TilingRect() const; | 138 gfx::Rect TilingRect() const; |
140 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 139 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
141 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 140 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
142 float contents_scale() const { return contents_scale_; } | 141 float contents_scale() const { return contents_scale_; } |
143 | 142 |
144 Tile* TileAt(int i, int j) const { | 143 Tile* TileAt(int i, int j) const { |
145 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 144 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
146 return (iter == tiles_.end()) ? NULL : iter->second.get(); | 145 return (iter == tiles_.end()) ? NULL : iter->second.get(); |
147 } | 146 } |
148 | 147 |
149 void CreateAllTilesForTesting() { | 148 void CreateAllTilesForTesting() { |
150 SetLiveTilesRect(tiling_data_.tiling_rect()); | 149 SetLiveTilesRect(tiling_data_.tiling_rect()); |
151 } | 150 } |
152 | 151 |
| 152 const TilingData& TilingDataForTesting() const { return tiling_data_; } |
| 153 |
153 std::vector<Tile*> AllTilesForTesting() const { | 154 std::vector<Tile*> AllTilesForTesting() const { |
154 std::vector<Tile*> all_tiles; | 155 std::vector<Tile*> all_tiles; |
155 for (TileMap::const_iterator it = tiles_.begin(); | 156 for (TileMap::const_iterator it = tiles_.begin(); |
156 it != tiles_.end(); ++it) | 157 it != tiles_.end(); ++it) |
157 all_tiles.push_back(it->second.get()); | 158 all_tiles.push_back(it->second.get()); |
158 return all_tiles; | 159 return all_tiles; |
159 } | 160 } |
160 | 161 |
161 // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 162 // Iterate over all tiles to fill content_rect. Even if tiles are invalid |
162 // (i.e. no valid resource) this tiling should still iterate over them. | 163 // (i.e. no valid resource) this tiling should still iterate over them. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // also updates the pile on each tile to be the current client's pile. | 224 // also updates the pile on each tile to be the current client's pile. |
224 void DidBecomeActive(); | 225 void DidBecomeActive(); |
225 | 226 |
226 // Resets the active priority for all tiles in a tiling, when an active | 227 // Resets the active priority for all tiles in a tiling, when an active |
227 // tiling is becoming recycled. This may include some tiles which are | 228 // tiling is becoming recycled. This may include some tiles which are |
228 // not in the the pending tiling (due to invalidations). This must | 229 // not in the the pending tiling (due to invalidations). This must |
229 // be called before DidBecomeActive, as it resets the active priority | 230 // be called before DidBecomeActive, as it resets the active priority |
230 // while DidBecomeActive promotes pending priority on a similar set of tiles. | 231 // while DidBecomeActive promotes pending priority on a similar set of tiles. |
231 void DidBecomeRecycled(); | 232 void DidBecomeRecycled(); |
232 | 233 |
233 void UpdateTilesToCurrentPile(); | |
234 | |
235 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { | 234 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { |
236 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; | 235 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; |
237 } | 236 } |
238 | 237 |
239 scoped_ptr<base::Value> AsValue() const; | 238 scoped_ptr<base::Value> AsValue() const; |
240 size_t GPUMemoryUsageInBytes() const; | 239 size_t GPUMemoryUsageInBytes() const; |
241 | 240 |
242 struct RectExpansionCache { | 241 struct RectExpansionCache { |
243 RectExpansionCache(); | 242 RectExpansionCache(); |
244 | 243 |
(...skipping 30 matching lines...) Expand all Loading... |
275 | 274 |
276 // Computes a skewport. The calculation extrapolates the last visible | 275 // Computes a skewport. The calculation extrapolates the last visible |
277 // rect and the current visible rect to expand the skewport to where it | 276 // rect and the current visible rect to expand the skewport to where it |
278 // would be in |skewport_target_time| seconds. Note that the skewport | 277 // would be in |skewport_target_time| seconds. Note that the skewport |
279 // is guaranteed to contain the current visible rect. | 278 // is guaranteed to contain the current visible rect. |
280 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, | 279 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, |
281 const gfx::Rect& visible_rect_in_content_space) | 280 const gfx::Rect& visible_rect_in_content_space) |
282 const; | 281 const; |
283 | 282 |
284 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); | 283 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); |
285 void DoInvalidate(const Region& layer_region, bool recreate_tiles); | 284 void Invalidate(const Region& layer_region); |
286 | 285 |
287 // Given properties. | 286 // Given properties. |
288 float contents_scale_; | 287 float contents_scale_; |
289 gfx::Size layer_bounds_; | 288 gfx::Size layer_bounds_; |
290 TileResolution resolution_; | 289 TileResolution resolution_; |
291 PictureLayerTilingClient* client_; | 290 PictureLayerTilingClient* client_; |
292 | 291 |
293 // Internal data. | 292 // Internal data. |
294 TilingData tiling_data_; | 293 TilingData tiling_data_; |
295 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 294 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
(...skipping 14 matching lines...) Expand all Loading... |
310 | 309 |
311 private: | 310 private: |
312 DISALLOW_ASSIGN(PictureLayerTiling); | 311 DISALLOW_ASSIGN(PictureLayerTiling); |
313 | 312 |
314 RectExpansionCache expansion_cache_; | 313 RectExpansionCache expansion_cache_; |
315 }; | 314 }; |
316 | 315 |
317 } // namespace cc | 316 } // namespace cc |
318 | 317 |
319 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 318 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |