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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace cc { | 29 namespace cc { |
30 | 30 |
31 class PictureLayerTiling; | 31 class PictureLayerTiling; |
32 class RasterSource; | 32 class RasterSource; |
33 | 33 |
34 class CC_EXPORT PictureLayerTilingClient { | 34 class CC_EXPORT PictureLayerTilingClient { |
35 public: | 35 public: |
36 // Create a tile at the given content_rect (in the contents scale of the | 36 // Create a tile at the given content_rect (in the contents scale of the |
37 // tiling) This might return null if the client cannot create such a tile. | 37 // tiling) This might return null if the client cannot create such a tile. |
38 virtual scoped_refptr<Tile> CreateTile( | 38 virtual scoped_refptr<Tile> CreateTile(PictureLayerTiling* tiling, |
39 PictureLayerTiling* tiling, | 39 const gfx::Rect& content_rect, |
40 const gfx::Rect& content_rect) = 0; | 40 int flags) = 0; |
41 virtual gfx::Size CalculateTileSize( | 41 virtual gfx::Size CalculateTileSize( |
42 const gfx::Size& content_bounds) const = 0; | 42 const gfx::Size& content_bounds) const = 0; |
43 // This invalidation region defines the area (if any, it can by null) that | 43 // This invalidation region defines the area (if any, it can by null) that |
44 // tiles can not be shared between pending and active trees. | 44 // tiles can not be shared between pending and active trees. |
45 virtual const Region* GetPendingInvalidation() = 0; | 45 virtual const Region* GetPendingInvalidation() = 0; |
46 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling( | 46 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling( |
47 const PictureLayerTiling* tiling) const = 0; | 47 const PictureLayerTiling* tiling) const = 0; |
48 virtual PictureLayerTiling* GetRecycledTwinTiling( | 48 virtual PictureLayerTiling* GetRecycledTwinTiling( |
49 const PictureLayerTiling* tiling) = 0; | 49 const PictureLayerTiling* tiling) = 0; |
50 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0; | 50 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 static scoped_ptr<PictureLayerTiling> Create( | 124 static scoped_ptr<PictureLayerTiling> Create( |
125 float contents_scale, | 125 float contents_scale, |
126 const gfx::Size& layer_bounds, | 126 const gfx::Size& layer_bounds, |
127 PictureLayerTilingClient* client); | 127 PictureLayerTilingClient* client); |
128 gfx::Size layer_bounds() const { return layer_bounds_; } | 128 gfx::Size layer_bounds() const { return layer_bounds_; } |
129 void UpdateTilesToCurrentRasterSource(RasterSource* raster_source, | 129 void UpdateTilesToCurrentRasterSource(RasterSource* raster_source, |
130 const Region& layer_invalidation, | 130 const Region& layer_invalidation, |
131 const gfx::Size& new_layer_bounds); | 131 const gfx::Size& new_layer_bounds, |
| 132 base::TimeTicks frame_time); |
132 void CreateMissingTilesInLiveTilesRect(); | 133 void CreateMissingTilesInLiveTilesRect(); |
133 void RemoveTilesInRegion(const Region& layer_region); | 134 void RemoveTilesInRegion(const Region& layer_region); |
134 | 135 |
135 void SetClient(PictureLayerTilingClient* client); | 136 void SetClient(PictureLayerTilingClient* client); |
136 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 137 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
137 TileResolution resolution() const { return resolution_; } | 138 TileResolution resolution() const { return resolution_; } |
138 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 139 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
139 can_require_tiles_for_activation_ = can_require_tiles; | 140 can_require_tiles_for_activation_ = can_require_tiles; |
140 } | 141 } |
141 | 142 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 277 |
277 bool has_ever_been_updated() const { | 278 bool has_ever_been_updated() const { |
278 return last_impl_frame_time_in_seconds_ != 0.0; | 279 return last_impl_frame_time_in_seconds_ != 0.0; |
279 } | 280 } |
280 | 281 |
281 protected: | 282 protected: |
282 friend class CoverageIterator; | 283 friend class CoverageIterator; |
283 friend class TilingRasterTileIterator; | 284 friend class TilingRasterTileIterator; |
284 friend class TilingSetEvictionQueue; | 285 friend class TilingSetEvictionQueue; |
285 | 286 |
| 287 class CC_EXPORT TileInvalidationState { |
| 288 public: |
| 289 TileInvalidationState(); |
| 290 |
| 291 void Invalidate(base::TimeTicks current_frame_time); |
| 292 bool FrequentlyInvalidated() const; |
| 293 |
| 294 private: |
| 295 static const int kFrequentInvalidationThreshold; |
| 296 |
| 297 base::TimeTicks last_frame_time_; |
| 298 int frame_count_; |
| 299 }; |
| 300 |
286 typedef std::pair<int, int> TileMapKey; | 301 typedef std::pair<int, int> TileMapKey; |
287 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; | 302 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; |
| 303 typedef base::hash_map<TileMapKey, TileInvalidationState> |
| 304 TileInvalidationStateMap; |
288 | 305 |
289 PictureLayerTiling(float contents_scale, | 306 PictureLayerTiling(float contents_scale, |
290 const gfx::Size& layer_bounds, | 307 const gfx::Size& layer_bounds, |
291 PictureLayerTilingClient* client); | 308 PictureLayerTilingClient* client); |
292 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | 309 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
293 void VerifyLiveTilesRect(); | 310 void VerifyLiveTilesRect(); |
294 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); | 311 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); |
295 // Returns true if the Tile existed and was removed from the tiling. | 312 // Returns true if the Tile existed and was removed from the tiling. |
296 bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin); | 313 bool RemoveTileAt(int i, |
| 314 int j, |
| 315 PictureLayerTiling* recycled_twin, |
| 316 bool remove_invalidation_state); |
297 | 317 |
298 // Computes a skewport. The calculation extrapolates the last visible | 318 // Computes a skewport. The calculation extrapolates the last visible |
299 // rect and the current visible rect to expand the skewport to where it | 319 // rect and the current visible rect to expand the skewport to where it |
300 // would be in |skewport_target_time| seconds. Note that the skewport | 320 // would be in |skewport_target_time| seconds. Note that the skewport |
301 // is guaranteed to contain the current visible rect. | 321 // is guaranteed to contain the current visible rect. |
302 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, | 322 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, |
303 const gfx::Rect& visible_rect_in_content_space) | 323 const gfx::Rect& visible_rect_in_content_space) |
304 const; | 324 const; |
305 | 325 |
306 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); | 326 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); |
307 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, | 327 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, |
308 EvictionCategory category); | 328 EvictionCategory category); |
309 | 329 |
310 void Invalidate(const Region& layer_region); | 330 void Invalidate(const Region& layer_region, base::TimeTicks frame_time); |
311 | 331 |
312 void DoInvalidate(const Region& layer_region, | 332 void DoInvalidate(const Region& layer_region, |
313 bool recreate_invalidated_tiles); | 333 bool recreate_invalidated_tiles, |
| 334 base::TimeTicks frame_time); |
314 | 335 |
315 void UpdateTileAndTwinPriority(Tile* tile) const; | 336 void UpdateTileAndTwinPriority(Tile* tile) const; |
316 void UpdateTilePriority(Tile* tile) const; | 337 void UpdateTilePriority(Tile* tile) const; |
317 | 338 |
318 // Given properties. | 339 // Given properties. |
319 float contents_scale_; | 340 float contents_scale_; |
320 gfx::Size layer_bounds_; | 341 gfx::Size layer_bounds_; |
321 TileResolution resolution_; | 342 TileResolution resolution_; |
322 PictureLayerTilingClient* client_; | 343 PictureLayerTilingClient* client_; |
323 | 344 |
324 // Internal data. | 345 // Internal data. |
325 TilingData tiling_data_; | 346 TilingData tiling_data_; |
326 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 347 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
| 348 TileInvalidationStateMap tile_invalidation_states_; |
327 gfx::Rect live_tiles_rect_; | 349 gfx::Rect live_tiles_rect_; |
328 | 350 |
329 // State saved for computing velocities based upon finite differences. | 351 // State saved for computing velocities based upon finite differences. |
330 double last_impl_frame_time_in_seconds_; | 352 double last_impl_frame_time_in_seconds_; |
331 gfx::Rect last_viewport_in_layer_space_; | 353 gfx::Rect last_viewport_in_layer_space_; |
332 gfx::Rect last_visible_rect_in_content_space_; | 354 gfx::Rect last_visible_rect_in_content_space_; |
333 float content_to_screen_scale_; | 355 float content_to_screen_scale_; |
334 | 356 |
335 bool can_require_tiles_for_activation_; | 357 bool can_require_tiles_for_activation_; |
336 | 358 |
(...skipping 25 matching lines...) Expand all Loading... |
362 | 384 |
363 private: | 385 private: |
364 DISALLOW_ASSIGN(PictureLayerTiling); | 386 DISALLOW_ASSIGN(PictureLayerTiling); |
365 | 387 |
366 RectExpansionCache expansion_cache_; | 388 RectExpansionCache expansion_cache_; |
367 }; | 389 }; |
368 | 390 |
369 } // namespace cc | 391 } // namespace cc |
370 | 392 |
371 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 393 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |