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 30 matching lines...) Expand all Loading... |
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; |
51 virtual size_t GetMaxTilesForInterestArea() const = 0; | |
52 virtual float GetSkewportTargetTimeInSeconds() const = 0; | |
53 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0; | |
54 virtual WhichTree GetTree() const = 0; | 51 virtual WhichTree GetTree() const = 0; |
55 virtual bool RequiresHighResToDraw() const = 0; | 52 virtual bool RequiresHighResToDraw() const = 0; |
56 | 53 |
57 protected: | 54 protected: |
58 virtual ~PictureLayerTilingClient() {} | 55 virtual ~PictureLayerTilingClient() {} |
59 }; | 56 }; |
60 | 57 |
61 class CC_EXPORT PictureLayerTiling { | 58 class CC_EXPORT PictureLayerTiling { |
62 public: | 59 public: |
63 static const int kBorderTexels = 1; | 60 static const int kBorderTexels = 1; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 }; | 116 }; |
120 | 117 |
121 ~PictureLayerTiling(); | 118 ~PictureLayerTiling(); |
122 | 119 |
123 // Create a tiling with no tiles. CreateTiles must be called to add some. | 120 // 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 | 121 // TODO(danakj): Pass the raster_source here instead of the size, store the |
125 // raster source instead of layer bounds? | 122 // raster source instead of layer bounds? |
126 static scoped_ptr<PictureLayerTiling> Create( | 123 static scoped_ptr<PictureLayerTiling> Create( |
127 float contents_scale, | 124 float contents_scale, |
128 const gfx::Size& layer_bounds, | 125 const gfx::Size& layer_bounds, |
129 PictureLayerTilingClient* client); | 126 PictureLayerTilingClient* client, |
| 127 size_t max_tiles_for_interest_area, |
| 128 float skewport_target_time_in_seconds, |
| 129 int skewport_extrapolation_limit_in_content_pixels); |
| 130 |
130 gfx::Size layer_bounds() const { return layer_bounds_; } | 131 gfx::Size layer_bounds() const { return layer_bounds_; } |
131 void Resize(const gfx::Size& new_layer_bounds); | 132 void Resize(const gfx::Size& new_layer_bounds); |
132 void Invalidate(const Region& layer_invalidation); | 133 void Invalidate(const Region& layer_invalidation); |
133 void SetRasterSource(scoped_refptr<RasterSource> raster_source); | 134 void SetRasterSource(scoped_refptr<RasterSource> raster_source); |
134 void CreateMissingTilesInLiveTilesRect(); | 135 void CreateMissingTilesInLiveTilesRect(); |
135 | 136 |
136 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); | 137 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); |
137 | 138 |
138 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 139 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
139 TileResolution resolution() const { return resolution_; } | 140 TileResolution resolution() const { return resolution_; } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 protected: | 284 protected: |
284 friend class CoverageIterator; | 285 friend class CoverageIterator; |
285 friend class TilingRasterTileIterator; | 286 friend class TilingRasterTileIterator; |
286 friend class TilingSetEvictionQueue; | 287 friend class TilingSetEvictionQueue; |
287 | 288 |
288 typedef std::pair<int, int> TileMapKey; | 289 typedef std::pair<int, int> TileMapKey; |
289 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; | 290 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; |
290 | 291 |
291 PictureLayerTiling(float contents_scale, | 292 PictureLayerTiling(float contents_scale, |
292 const gfx::Size& layer_bounds, | 293 const gfx::Size& layer_bounds, |
293 PictureLayerTilingClient* client); | 294 PictureLayerTilingClient* client, |
| 295 size_t max_tiles_for_interest_area, |
| 296 float skewport_target_time_in_seconds, |
| 297 int skewport_extrapolation_limit_in_content_pixels); |
294 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | 298 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
295 void VerifyLiveTilesRect(); | 299 void VerifyLiveTilesRect(); |
296 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); | 300 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); |
297 // Returns true if the Tile existed and was removed from the tiling. | 301 // Returns true if the Tile existed and was removed from the tiling. |
298 bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin); | 302 bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin); |
299 | 303 |
300 // Computes a skewport. The calculation extrapolates the last visible | 304 // Computes a skewport. The calculation extrapolates the last visible |
301 // rect and the current visible rect to expand the skewport to where it | 305 // rect and the current visible rect to expand the skewport to where it |
302 // would be in |skewport_target_time| seconds. Note that the skewport | 306 // would be in |skewport_target_time| seconds. Note that the skewport |
303 // is guaranteed to contain the current visible rect. | 307 // is guaranteed to contain the current visible rect. |
304 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, | 308 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, |
305 const gfx::Rect& visible_rect_in_content_space) | 309 const gfx::Rect& visible_rect_in_content_space) |
306 const; | 310 const; |
307 | 311 |
308 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); | 312 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); |
309 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, | 313 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, |
310 EvictionCategory category); | 314 EvictionCategory category); |
311 | 315 |
312 // Save the required data for computing tile priorities later. | 316 // Save the required data for computing tile priorities later. |
313 void UpdateTilePriorityRects(float content_to_screen_scale_, | 317 void UpdateTilePriorityRects(float content_to_screen_scale_, |
314 const gfx::Rect& visible_rect_in_content_space, | 318 const gfx::Rect& visible_rect_in_content_space, |
315 const gfx::Rect& skewport, | 319 const gfx::Rect& skewport, |
316 const gfx::Rect& soon_border_rect, | 320 const gfx::Rect& soon_border_rect, |
317 const gfx::Rect& eventually_rect, | 321 const gfx::Rect& eventually_rect, |
318 const Occlusion& occlusion_in_layer_space); | 322 const Occlusion& occlusion_in_layer_space); |
319 | 323 |
320 void UpdateTileAndTwinPriority(Tile* tile) const; | 324 void UpdateTileAndTwinPriority(Tile* tile) const; |
321 void UpdateTilePriority(Tile* tile) const; | 325 void UpdateTilePriority(Tile* tile) const; |
322 | 326 |
| 327 const size_t max_tiles_for_interest_area_; |
| 328 const float skewport_target_time_in_seconds_; |
| 329 const int skewport_extrapolation_limit_in_content_pixels_; |
| 330 |
323 // Given properties. | 331 // Given properties. |
324 float contents_scale_; | 332 float contents_scale_; |
325 gfx::Size layer_bounds_; | 333 gfx::Size layer_bounds_; |
326 TileResolution resolution_; | 334 TileResolution resolution_; |
327 PictureLayerTilingClient* client_; | 335 PictureLayerTilingClient* client_; |
328 | 336 |
329 // Internal data. | 337 // Internal data. |
330 TilingData tiling_data_; | 338 TilingData tiling_data_; |
331 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 339 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
332 gfx::Rect live_tiles_rect_; | 340 gfx::Rect live_tiles_rect_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 375 |
368 private: | 376 private: |
369 DISALLOW_ASSIGN(PictureLayerTiling); | 377 DISALLOW_ASSIGN(PictureLayerTiling); |
370 | 378 |
371 RectExpansionCache expansion_cache_; | 379 RectExpansionCache expansion_cache_; |
372 }; | 380 }; |
373 | 381 |
374 } // namespace cc | 382 } // namespace cc |
375 | 383 |
376 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 384 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |