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(float contents_scale, |
39 PictureLayerTiling* tiling, | 39 const gfx::Rect& content_rect) = 0; |
40 const gfx::Rect& content_rect) = 0; | |
41 virtual gfx::Size CalculateTileSize( | 40 virtual gfx::Size CalculateTileSize( |
42 const gfx::Size& content_bounds) const = 0; | 41 const gfx::Size& content_bounds) const = 0; |
43 // This invalidation region defines the area (if any, it can by null) that | 42 // This invalidation region defines the area (if any, it can by null) that |
44 // tiles can not be shared between pending and active trees. | 43 // tiles can not be shared between pending and active trees. |
45 virtual const Region* GetPendingInvalidation() = 0; | 44 virtual const Region* GetPendingInvalidation() = 0; |
46 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling( | 45 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling( |
47 const PictureLayerTiling* tiling) const = 0; | 46 const PictureLayerTiling* tiling) const = 0; |
48 virtual PictureLayerTiling* GetRecycledTwinTiling( | 47 virtual PictureLayerTiling* GetRecycledTwinTiling( |
49 const PictureLayerTiling* tiling) = 0; | 48 const PictureLayerTiling* tiling) = 0; |
50 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0; | 49 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 100 |
102 Phase phase_; | 101 Phase phase_; |
103 | 102 |
104 Tile* current_tile_; | 103 Tile* current_tile_; |
105 TilingData::Iterator visible_iterator_; | 104 TilingData::Iterator visible_iterator_; |
106 TilingData::SpiralDifferenceIterator spiral_iterator_; | 105 TilingData::SpiralDifferenceIterator spiral_iterator_; |
107 }; | 106 }; |
108 | 107 |
109 ~PictureLayerTiling(); | 108 ~PictureLayerTiling(); |
110 | 109 |
111 // Create a tiling with no tiles. CreateTiles must be called to add some. | 110 // Create a tiling with no tiles. CreateTile() must be called to add some. |
112 // TODO(danakj): Pass the raster_source here instead of the size, store the | |
113 // raster source instead of layer bounds? | |
114 static scoped_ptr<PictureLayerTiling> Create( | 111 static scoped_ptr<PictureLayerTiling> Create( |
115 float contents_scale, | 112 float contents_scale, |
116 const gfx::Size& layer_bounds, | 113 scoped_refptr<RasterSource> raster_source, |
117 PictureLayerTilingClient* client, | 114 PictureLayerTilingClient* client, |
118 size_t max_tiles_for_interest_area, | 115 size_t max_tiles_for_interest_area, |
119 float skewport_target_time_in_seconds, | 116 float skewport_target_time_in_seconds, |
120 int skewport_extrapolation_limit_in_content_pixels); | 117 int skewport_extrapolation_limit_in_content_pixels); |
121 | 118 |
122 gfx::Size layer_bounds() const { return layer_bounds_; } | 119 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); |
123 void Resize(const gfx::Size& new_layer_bounds); | |
124 void Invalidate(const Region& layer_invalidation); | 120 void Invalidate(const Region& layer_invalidation); |
125 void SetRasterSource(scoped_refptr<RasterSource> raster_source); | 121 void SetRasterSourceOnTiles(); |
126 void CreateMissingTilesInLiveTilesRect(); | 122 void CreateMissingTilesInLiveTilesRect(); |
127 | 123 |
128 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); | 124 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); |
129 | 125 |
130 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 126 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
131 TileResolution resolution() const { return resolution_; } | 127 TileResolution resolution() const { return resolution_; } |
132 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 128 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
133 can_require_tiles_for_activation_ = can_require_tiles; | 129 can_require_tiles_for_activation_ = can_require_tiles; |
134 } | 130 } |
135 | 131 |
| 132 RasterSource* raster_source() const { return raster_source_.get(); } |
136 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } | 133 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } |
137 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 134 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
138 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 135 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
139 float contents_scale() const { return contents_scale_; } | 136 float contents_scale() const { return contents_scale_; } |
140 | 137 |
141 Tile* TileAt(int i, int j) const { | 138 Tile* TileAt(int i, int j) const { |
142 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 139 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
143 return (iter == tiles_.end()) ? NULL : iter->second.get(); | 140 return (iter == tiles_.end()) ? NULL : iter->second.get(); |
144 } | 141 } |
145 | 142 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 264 |
268 protected: | 265 protected: |
269 friend class CoverageIterator; | 266 friend class CoverageIterator; |
270 friend class TilingRasterTileIterator; | 267 friend class TilingRasterTileIterator; |
271 friend class TilingSetEvictionQueue; | 268 friend class TilingSetEvictionQueue; |
272 | 269 |
273 typedef std::pair<int, int> TileMapKey; | 270 typedef std::pair<int, int> TileMapKey; |
274 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; | 271 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; |
275 | 272 |
276 PictureLayerTiling(float contents_scale, | 273 PictureLayerTiling(float contents_scale, |
277 const gfx::Size& layer_bounds, | 274 scoped_refptr<RasterSource> raster_source, |
278 PictureLayerTilingClient* client, | 275 PictureLayerTilingClient* client, |
279 size_t max_tiles_for_interest_area, | 276 size_t max_tiles_for_interest_area, |
280 float skewport_target_time_in_seconds, | 277 float skewport_target_time_in_seconds, |
281 int skewport_extrapolation_limit_in_content_pixels); | 278 int skewport_extrapolation_limit_in_content_pixels); |
282 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | 279 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
283 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; | 280 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; |
284 Tile* CreateTile(int i, | 281 Tile* CreateTile(int i, |
285 int j, | 282 int j, |
286 const PictureLayerTiling* twin_tiling, | 283 const PictureLayerTiling* twin_tiling, |
287 PictureLayerTiling* recycled_twin); | 284 PictureLayerTiling* recycled_twin); |
(...skipping 25 matching lines...) Expand all Loading... |
313 viewport_in_layer_space != last_viewport_in_layer_space_; | 310 viewport_in_layer_space != last_viewport_in_layer_space_; |
314 } | 311 } |
315 | 312 |
316 const size_t max_tiles_for_interest_area_; | 313 const size_t max_tiles_for_interest_area_; |
317 const float skewport_target_time_in_seconds_; | 314 const float skewport_target_time_in_seconds_; |
318 const int skewport_extrapolation_limit_in_content_pixels_; | 315 const int skewport_extrapolation_limit_in_content_pixels_; |
319 | 316 |
320 // Given properties. | 317 // Given properties. |
321 const float contents_scale_; | 318 const float contents_scale_; |
322 PictureLayerTilingClient* const client_; | 319 PictureLayerTilingClient* const client_; |
323 gfx::Size layer_bounds_; | 320 scoped_refptr<RasterSource> raster_source_; |
324 TileResolution resolution_; | 321 TileResolution resolution_; |
325 | 322 |
326 // Internal data. | 323 // Internal data. |
327 TilingData tiling_data_; | 324 TilingData tiling_data_; |
328 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 325 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
329 gfx::Rect live_tiles_rect_; | 326 gfx::Rect live_tiles_rect_; |
330 | 327 |
331 // State saved for computing velocities based upon finite differences. | 328 // State saved for computing velocities based upon finite differences. |
332 double last_impl_frame_time_in_seconds_; | 329 double last_impl_frame_time_in_seconds_; |
333 gfx::Rect last_viewport_in_layer_space_; | 330 gfx::Rect last_viewport_in_layer_space_; |
(...skipping 17 matching lines...) Expand all Loading... |
351 | 348 |
352 private: | 349 private: |
353 DISALLOW_ASSIGN(PictureLayerTiling); | 350 DISALLOW_ASSIGN(PictureLayerTiling); |
354 | 351 |
355 RectExpansionCache expansion_cache_; | 352 RectExpansionCache expansion_cache_; |
356 }; | 353 }; |
357 | 354 |
358 } // namespace cc | 355 } // namespace cc |
359 | 356 |
360 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 357 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |