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 <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 Phase phase_; | 114 Phase phase_; |
115 | 115 |
116 Tile* current_tile_; | 116 Tile* current_tile_; |
117 TilingData::Iterator visible_iterator_; | 117 TilingData::Iterator visible_iterator_; |
118 TilingData::SpiralDifferenceIterator spiral_iterator_; | 118 TilingData::SpiralDifferenceIterator spiral_iterator_; |
119 }; | 119 }; |
120 | 120 |
121 ~PictureLayerTiling(); | 121 ~PictureLayerTiling(); |
122 | 122 |
123 // Create a tiling with no tiles. CreateTiles must be called to add some. | 123 // Create a tiling with no tiles. CreateTiles must be called to add some. |
| 124 // TODO(danakj): Pass the raster_source here instead of the size, store the |
| 125 // raster source instead of layer bounds? |
124 static scoped_ptr<PictureLayerTiling> Create( | 126 static scoped_ptr<PictureLayerTiling> Create( |
125 float contents_scale, | 127 float contents_scale, |
126 const gfx::Size& layer_bounds, | 128 const gfx::Size& layer_bounds, |
127 PictureLayerTilingClient* client); | 129 PictureLayerTilingClient* client); |
128 gfx::Size layer_bounds() const { return layer_bounds_; } | 130 gfx::Size layer_bounds() const { return layer_bounds_; } |
129 void UpdateTilesToCurrentRasterSource(RasterSource* raster_source, | 131 void Resize(const gfx::Size& new_layer_bounds); |
130 const Region& layer_invalidation, | 132 void Invalidate(const Region& layer_invalidation); |
131 const gfx::Size& new_layer_bounds); | 133 void SetRasterSource(scoped_refptr<RasterSource> raster_source); |
132 void CreateMissingTilesInLiveTilesRect(); | 134 void CreateMissingTilesInLiveTilesRect(); |
133 void RemoveTilesInRegion(const Region& layer_region); | |
134 | 135 |
135 void SetClient(PictureLayerTilingClient* client); | 136 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); |
| 137 |
136 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 138 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
137 TileResolution resolution() const { return resolution_; } | 139 TileResolution resolution() const { return resolution_; } |
138 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 140 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
139 can_require_tiles_for_activation_ = can_require_tiles; | 141 can_require_tiles_for_activation_ = can_require_tiles; |
140 } | 142 } |
141 | 143 |
142 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } | 144 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } |
143 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 145 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
144 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 146 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
145 float contents_scale() const { return contents_scale_; } | 147 float contents_scale() const { return contents_scale_; } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // would be in |skewport_target_time| seconds. Note that the skewport | 302 // would be in |skewport_target_time| seconds. Note that the skewport |
301 // is guaranteed to contain the current visible rect. | 303 // is guaranteed to contain the current visible rect. |
302 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, | 304 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, |
303 const gfx::Rect& visible_rect_in_content_space) | 305 const gfx::Rect& visible_rect_in_content_space) |
304 const; | 306 const; |
305 | 307 |
306 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); | 308 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); |
307 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, | 309 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, |
308 EvictionCategory category); | 310 EvictionCategory category); |
309 | 311 |
310 void Invalidate(const Region& layer_region); | 312 // Save the required data for computing tile priorities later. |
311 | 313 void UpdateTilePriorityRects(float content_to_screen_scale_, |
312 void DoInvalidate(const Region& layer_region, | 314 const gfx::Rect& visible_rect_in_content_space, |
313 bool recreate_invalidated_tiles); | 315 const gfx::Rect& skewport, |
| 316 const gfx::Rect& soon_border_rect, |
| 317 const gfx::Rect& eventually_rect, |
| 318 const Occlusion& occlusion_in_layer_space); |
314 | 319 |
315 void UpdateTileAndTwinPriority(Tile* tile) const; | 320 void UpdateTileAndTwinPriority(Tile* tile) const; |
316 void UpdateTilePriority(Tile* tile) const; | 321 void UpdateTilePriority(Tile* tile) const; |
317 | 322 |
318 // Given properties. | 323 // Given properties. |
319 float contents_scale_; | 324 float contents_scale_; |
320 gfx::Size layer_bounds_; | 325 gfx::Size layer_bounds_; |
321 TileResolution resolution_; | 326 TileResolution resolution_; |
322 PictureLayerTilingClient* client_; | 327 PictureLayerTilingClient* client_; |
323 | 328 |
324 // Internal data. | 329 // Internal data. |
325 TilingData tiling_data_; | 330 TilingData tiling_data_; |
326 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 331 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
327 gfx::Rect live_tiles_rect_; | 332 gfx::Rect live_tiles_rect_; |
328 | 333 |
329 // State saved for computing velocities based upon finite differences. | 334 // State saved for computing velocities based upon finite differences. |
330 double last_impl_frame_time_in_seconds_; | 335 double last_impl_frame_time_in_seconds_; |
331 gfx::Rect last_viewport_in_layer_space_; | 336 gfx::Rect last_viewport_in_layer_space_; |
332 gfx::Rect last_visible_rect_in_content_space_; | 337 gfx::Rect last_visible_rect_in_content_space_; |
333 float content_to_screen_scale_; | |
334 | 338 |
335 bool can_require_tiles_for_activation_; | 339 bool can_require_tiles_for_activation_; |
336 | 340 |
337 // Iteration rects in content space | 341 // Iteration rects in content space. |
338 gfx::Rect current_visible_rect_; | 342 gfx::Rect current_visible_rect_; |
339 gfx::Rect current_skewport_rect_; | 343 gfx::Rect current_skewport_rect_; |
340 gfx::Rect current_soon_border_rect_; | 344 gfx::Rect current_soon_border_rect_; |
341 gfx::Rect current_eventually_rect_; | 345 gfx::Rect current_eventually_rect_; |
| 346 // Other properties used for tile iteration and prioritization. |
| 347 float current_content_to_screen_scale_; |
| 348 Occlusion current_occlusion_in_layer_space_; |
342 | 349 |
343 bool has_visible_rect_tiles_; | 350 bool has_visible_rect_tiles_; |
344 bool has_skewport_rect_tiles_; | 351 bool has_skewport_rect_tiles_; |
345 bool has_soon_border_rect_tiles_; | 352 bool has_soon_border_rect_tiles_; |
346 bool has_eventually_rect_tiles_; | 353 bool has_eventually_rect_tiles_; |
347 | 354 |
348 Occlusion current_occlusion_in_layer_space_; | |
349 | |
350 // TODO(reveman): Remove this in favour of an array of eviction_tiles_ when we | 355 // TODO(reveman): Remove this in favour of an array of eviction_tiles_ when we |
351 // change all enums to have a consistent way of getting the count/last | 356 // change all enums to have a consistent way of getting the count/last |
352 // element. | 357 // element. |
353 std::vector<Tile*> eviction_tiles_now_; | 358 std::vector<Tile*> eviction_tiles_now_; |
354 std::vector<Tile*> eviction_tiles_now_and_required_for_activation_; | 359 std::vector<Tile*> eviction_tiles_now_and_required_for_activation_; |
355 std::vector<Tile*> eviction_tiles_soon_; | 360 std::vector<Tile*> eviction_tiles_soon_; |
356 std::vector<Tile*> eviction_tiles_soon_and_required_for_activation_; | 361 std::vector<Tile*> eviction_tiles_soon_and_required_for_activation_; |
357 std::vector<Tile*> eviction_tiles_eventually_; | 362 std::vector<Tile*> eviction_tiles_eventually_; |
358 std::vector<Tile*> eviction_tiles_eventually_and_required_for_activation_; | 363 std::vector<Tile*> eviction_tiles_eventually_and_required_for_activation_; |
359 | 364 |
360 bool eviction_tiles_cache_valid_; | 365 bool eviction_tiles_cache_valid_; |
361 TreePriority eviction_cache_tree_priority_; | 366 TreePriority eviction_cache_tree_priority_; |
362 | 367 |
363 private: | 368 private: |
364 DISALLOW_ASSIGN(PictureLayerTiling); | 369 DISALLOW_ASSIGN(PictureLayerTiling); |
365 | 370 |
366 RectExpansionCache expansion_cache_; | 371 RectExpansionCache expansion_cache_; |
367 }; | 372 }; |
368 | 373 |
369 } // namespace cc | 374 } // namespace cc |
370 | 375 |
371 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 376 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |