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 UpdateTilesToCurrentRasterSource(RasterSource* raster_source, |
130 const Region& layer_invalidation, | 132 const Region& layer_invalidation, |
131 const gfx::Size& new_layer_bounds); | 133 const gfx::Size& layer_bounds); |
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& other); |
| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 void Invalidate(const Region& layer_region); |
311 | 313 |
312 void DoInvalidate(const Region& layer_region, | 314 void DoInvalidate(const Region& layer_region, |
313 bool recreate_invalidated_tiles); | 315 bool recreate_invalidated_tiles); |
314 | 316 |
| 317 // Save the required data for computing tile priorities later. |
| 318 void UpdateTilePriorityRects(float content_to_screen_scale_, |
| 319 const gfx::Rect& visible_rect_in_content_space, |
| 320 const gfx::Rect& skewport, |
| 321 const gfx::Rect& soon_border_rect, |
| 322 const gfx::Rect& eventually_rect, |
| 323 const Occlusion& occlusion_in_layer_space); |
| 324 |
315 void UpdateTileAndTwinPriority(Tile* tile) const; | 325 void UpdateTileAndTwinPriority(Tile* tile) const; |
316 void UpdateTilePriority(Tile* tile) const; | 326 void UpdateTilePriority(Tile* tile) const; |
317 | 327 |
318 // Given properties. | 328 // Given properties. |
319 float contents_scale_; | 329 float contents_scale_; |
320 gfx::Size layer_bounds_; | 330 gfx::Size layer_bounds_; |
321 TileResolution resolution_; | 331 TileResolution resolution_; |
322 PictureLayerTilingClient* client_; | 332 PictureLayerTilingClient* client_; |
323 | 333 |
324 // Internal data. | 334 // Internal data. |
325 TilingData tiling_data_; | 335 TilingData tiling_data_; |
326 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 336 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
327 gfx::Rect live_tiles_rect_; | 337 gfx::Rect live_tiles_rect_; |
328 | 338 |
329 // State saved for computing velocities based upon finite differences. | 339 // State saved for computing velocities based upon finite differences. |
330 double last_impl_frame_time_in_seconds_; | 340 double last_impl_frame_time_in_seconds_; |
331 gfx::Rect last_viewport_in_layer_space_; | 341 gfx::Rect last_viewport_in_layer_space_; |
332 gfx::Rect last_visible_rect_in_content_space_; | 342 gfx::Rect last_visible_rect_in_content_space_; |
333 float content_to_screen_scale_; | |
334 | 343 |
335 bool can_require_tiles_for_activation_; | 344 bool can_require_tiles_for_activation_; |
336 | 345 |
337 // Iteration rects in content space | 346 // Iteration rects in content space. |
338 gfx::Rect current_visible_rect_; | 347 gfx::Rect current_visible_rect_; |
339 gfx::Rect current_skewport_rect_; | 348 gfx::Rect current_skewport_rect_; |
340 gfx::Rect current_soon_border_rect_; | 349 gfx::Rect current_soon_border_rect_; |
341 gfx::Rect current_eventually_rect_; | 350 gfx::Rect current_eventually_rect_; |
| 351 // Other properties used for tile iteration and prioritization. |
| 352 float current_content_to_screen_scale_; |
| 353 Occlusion current_occlusion_in_layer_space_; |
342 | 354 |
343 bool has_visible_rect_tiles_; | 355 bool has_visible_rect_tiles_; |
344 bool has_skewport_rect_tiles_; | 356 bool has_skewport_rect_tiles_; |
345 bool has_soon_border_rect_tiles_; | 357 bool has_soon_border_rect_tiles_; |
346 bool has_eventually_rect_tiles_; | 358 bool has_eventually_rect_tiles_; |
347 | 359 |
348 Occlusion current_occlusion_in_layer_space_; | |
349 | |
350 // TODO(reveman): Remove this in favour of an array of eviction_tiles_ when we | 360 // 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 | 361 // change all enums to have a consistent way of getting the count/last |
352 // element. | 362 // element. |
353 std::vector<Tile*> eviction_tiles_now_; | 363 std::vector<Tile*> eviction_tiles_now_; |
354 std::vector<Tile*> eviction_tiles_now_and_required_for_activation_; | 364 std::vector<Tile*> eviction_tiles_now_and_required_for_activation_; |
355 std::vector<Tile*> eviction_tiles_soon_; | 365 std::vector<Tile*> eviction_tiles_soon_; |
356 std::vector<Tile*> eviction_tiles_soon_and_required_for_activation_; | 366 std::vector<Tile*> eviction_tiles_soon_and_required_for_activation_; |
357 std::vector<Tile*> eviction_tiles_eventually_; | 367 std::vector<Tile*> eviction_tiles_eventually_; |
358 std::vector<Tile*> eviction_tiles_eventually_and_required_for_activation_; | 368 std::vector<Tile*> eviction_tiles_eventually_and_required_for_activation_; |
359 | 369 |
360 bool eviction_tiles_cache_valid_; | 370 bool eviction_tiles_cache_valid_; |
361 TreePriority eviction_cache_tree_priority_; | 371 TreePriority eviction_cache_tree_priority_; |
362 | 372 |
363 private: | 373 private: |
364 DISALLOW_ASSIGN(PictureLayerTiling); | 374 DISALLOW_ASSIGN(PictureLayerTiling); |
365 | 375 |
366 RectExpansionCache expansion_cache_; | 376 RectExpansionCache expansion_cache_; |
367 }; | 377 }; |
368 | 378 |
369 } // namespace cc | 379 } // namespace cc |
370 | 380 |
371 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 381 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |