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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 int left_; | 226 int left_; |
230 int top_; | 227 int top_; |
231 int right_; | 228 int right_; |
232 int bottom_; | 229 int bottom_; |
233 | 230 |
234 friend class PictureLayerTiling; | 231 friend class PictureLayerTiling; |
235 }; | 232 }; |
236 | 233 |
237 void Reset(); | 234 void Reset(); |
238 | 235 |
239 void ComputeTilePriorityRects(const gfx::Rect& viewport_in_layer_space, | 236 bool ComputeTilePriorityRects(const gfx::Rect& viewport_in_layer_space, |
240 float ideal_contents_scale, | 237 float ideal_contents_scale, |
241 double current_frame_time_in_seconds, | 238 double current_frame_time_in_seconds, |
242 const Occlusion& occlusion_in_layer_space); | 239 const Occlusion& occlusion_in_layer_space); |
243 | 240 |
244 bool NeedsUpdateForFrameAtTimeAndViewport( | |
245 double frame_time_in_seconds, | |
246 const gfx::Rect& viewport_in_layer_space) { | |
247 return frame_time_in_seconds != last_impl_frame_time_in_seconds_ || | |
248 viewport_in_layer_space != last_viewport_in_layer_space_; | |
249 } | |
250 | |
251 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const; | 241 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const; |
252 void AsValueInto(base::debug::TracedValue* array) const; | 242 void AsValueInto(base::debug::TracedValue* array) const; |
253 size_t GPUMemoryUsageInBytes() const; | 243 size_t GPUMemoryUsageInBytes() const; |
254 | 244 |
255 struct RectExpansionCache { | 245 struct RectExpansionCache { |
256 RectExpansionCache(); | 246 RectExpansionCache(); |
257 | 247 |
258 gfx::Rect previous_start; | 248 gfx::Rect previous_start; |
259 gfx::Rect previous_bounds; | 249 gfx::Rect previous_bounds; |
260 gfx::Rect previous_result; | 250 gfx::Rect previous_result; |
(...skipping 13 matching lines...) Expand all Loading... |
274 | 264 |
275 protected: | 265 protected: |
276 friend class CoverageIterator; | 266 friend class CoverageIterator; |
277 friend class TilingRasterTileIterator; | 267 friend class TilingRasterTileIterator; |
278 friend class TilingSetEvictionQueue; | 268 friend class TilingSetEvictionQueue; |
279 | 269 |
280 typedef std::pair<int, int> TileMapKey; | 270 typedef std::pair<int, int> TileMapKey; |
281 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; | 271 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; |
282 | 272 |
283 PictureLayerTiling(float contents_scale, | 273 PictureLayerTiling(float contents_scale, |
284 const gfx::Size& layer_bounds, | 274 scoped_refptr<RasterSource> raster_source, |
285 PictureLayerTilingClient* client, | 275 PictureLayerTilingClient* client, |
286 size_t max_tiles_for_interest_area, | 276 size_t max_tiles_for_interest_area, |
287 float skewport_target_time_in_seconds, | 277 float skewport_target_time_in_seconds, |
288 int skewport_extrapolation_limit_in_content_pixels); | 278 int skewport_extrapolation_limit_in_content_pixels); |
289 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | 279 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
290 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; | 280 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; |
291 Tile* CreateTile(int i, | 281 Tile* CreateTile(int i, |
292 int j, | 282 int j, |
293 const PictureLayerTiling* twin_tiling, | 283 const PictureLayerTiling* twin_tiling, |
294 PictureLayerTiling* recycled_twin); | 284 PictureLayerTiling* recycled_twin); |
(...skipping 11 matching lines...) Expand all Loading... |
306 // Save the required data for computing tile priorities later. | 296 // Save the required data for computing tile priorities later. |
307 void UpdateTilePriorityRects(float content_to_screen_scale_, | 297 void UpdateTilePriorityRects(float content_to_screen_scale_, |
308 const gfx::Rect& visible_rect_in_content_space, | 298 const gfx::Rect& visible_rect_in_content_space, |
309 const gfx::Rect& skewport, | 299 const gfx::Rect& skewport, |
310 const gfx::Rect& soon_border_rect, | 300 const gfx::Rect& soon_border_rect, |
311 const gfx::Rect& eventually_rect, | 301 const gfx::Rect& eventually_rect, |
312 const Occlusion& occlusion_in_layer_space); | 302 const Occlusion& occlusion_in_layer_space); |
313 | 303 |
314 void UpdateTileAndTwinPriority(Tile* tile) const; | 304 void UpdateTileAndTwinPriority(Tile* tile) const; |
315 void UpdateTilePriority(Tile* tile) const; | 305 void UpdateTilePriority(Tile* tile) const; |
| 306 bool NeedsUpdateForFrameAtTimeAndViewport( |
| 307 double frame_time_in_seconds, |
| 308 const gfx::Rect& viewport_in_layer_space) { |
| 309 return frame_time_in_seconds != last_impl_frame_time_in_seconds_ || |
| 310 viewport_in_layer_space != last_viewport_in_layer_space_; |
| 311 } |
316 | 312 |
317 const size_t max_tiles_for_interest_area_; | 313 const size_t max_tiles_for_interest_area_; |
318 const float skewport_target_time_in_seconds_; | 314 const float skewport_target_time_in_seconds_; |
319 const int skewport_extrapolation_limit_in_content_pixels_; | 315 const int skewport_extrapolation_limit_in_content_pixels_; |
320 | 316 |
321 // Given properties. | 317 // Given properties. |
322 const float contents_scale_; | 318 const float contents_scale_; |
323 PictureLayerTilingClient* const client_; | 319 PictureLayerTilingClient* const client_; |
324 gfx::Size layer_bounds_; | 320 scoped_refptr<RasterSource> raster_source_; |
325 TileResolution resolution_; | 321 TileResolution resolution_; |
326 | 322 |
327 // Internal data. | 323 // Internal data. |
328 TilingData tiling_data_; | 324 TilingData tiling_data_; |
329 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. |
330 gfx::Rect live_tiles_rect_; | 326 gfx::Rect live_tiles_rect_; |
331 | 327 |
332 // State saved for computing velocities based upon finite differences. | 328 // State saved for computing velocities based upon finite differences. |
333 double last_impl_frame_time_in_seconds_; | 329 double last_impl_frame_time_in_seconds_; |
334 gfx::Rect last_viewport_in_layer_space_; | 330 gfx::Rect last_viewport_in_layer_space_; |
(...skipping 17 matching lines...) Expand all Loading... |
352 | 348 |
353 private: | 349 private: |
354 DISALLOW_ASSIGN(PictureLayerTiling); | 350 DISALLOW_ASSIGN(PictureLayerTiling); |
355 | 351 |
356 RectExpansionCache expansion_cache_; | 352 RectExpansionCache expansion_cache_; |
357 }; | 353 }; |
358 | 354 |
359 } // namespace cc | 355 } // namespace cc |
360 | 356 |
361 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 357 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |