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 <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 namespace trace_event { | 24 namespace trace_event { |
25 class TracedValue; | 25 class TracedValue; |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 namespace cc { | 29 namespace cc { |
30 | 30 |
31 class PictureLayerTiling; | 31 class PictureLayerTiling; |
| 32 class PrioritizedTile; |
32 class RasterSource; | 33 class RasterSource; |
33 | 34 |
34 class CC_EXPORT PictureLayerTilingClient { | 35 class CC_EXPORT PictureLayerTilingClient { |
35 public: | 36 public: |
36 // Create a tile at the given content_rect (in the contents scale of the | 37 // 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. | 38 // tiling) This might return null if the client cannot create such a tile. |
38 virtual scoped_refptr<Tile> CreateTile(float contents_scale, | 39 virtual scoped_refptr<Tile> CreateTile(float contents_scale, |
39 const gfx::Rect& content_rect) = 0; | 40 const gfx::Rect& content_rect) = 0; |
40 virtual gfx::Size CalculateTileSize( | 41 virtual gfx::Size CalculateTileSize( |
41 const gfx::Size& content_bounds) const = 0; | 42 const gfx::Size& content_bounds) const = 0; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void CreateAllTilesForTesting() { | 107 void CreateAllTilesForTesting() { |
107 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); | 108 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); |
108 } | 109 } |
109 const TilingData& TilingDataForTesting() const { return tiling_data_; } | 110 const TilingData& TilingDataForTesting() const { return tiling_data_; } |
110 std::vector<Tile*> AllTilesForTesting() const { | 111 std::vector<Tile*> AllTilesForTesting() const { |
111 std::vector<Tile*> all_tiles; | 112 std::vector<Tile*> all_tiles; |
112 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 113 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
113 all_tiles.push_back(it->second.get()); | 114 all_tiles.push_back(it->second.get()); |
114 return all_tiles; | 115 return all_tiles; |
115 } | 116 } |
116 void UpdateAllTilePrioritiesForTesting() { | 117 std::map<const Tile*, PrioritizedTile> |
117 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 118 UpdateAndGetAllPrioritizedTilesForTesting(); |
118 UpdateTilePriority(it->second.get()); | 119 |
119 } | |
120 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const { | 120 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const { |
121 std::vector<scoped_refptr<Tile>> all_tiles; | 121 std::vector<scoped_refptr<Tile>> all_tiles; |
122 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 122 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
123 all_tiles.push_back(it->second); | 123 all_tiles.push_back(it->second); |
124 return all_tiles; | 124 return all_tiles; |
125 } | 125 } |
126 void SetAllTilesOccludedForTesting() { | 126 void SetAllTilesOccludedForTesting() { |
127 gfx::Rect viewport_in_layer_space = | 127 gfx::Rect viewport_in_layer_space = |
128 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); | 128 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); |
129 current_occlusion_in_layer_space_ = | 129 current_occlusion_in_layer_space_ = |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 static | 205 static |
206 gfx::Rect ExpandRectEquallyToAreaBoundedBy( | 206 gfx::Rect ExpandRectEquallyToAreaBoundedBy( |
207 const gfx::Rect& starting_rect, | 207 const gfx::Rect& starting_rect, |
208 int64 target_area, | 208 int64 target_area, |
209 const gfx::Rect& bounding_rect, | 209 const gfx::Rect& bounding_rect, |
210 RectExpansionCache* cache); | 210 RectExpansionCache* cache); |
211 | 211 |
212 protected: | 212 protected: |
213 friend class CoverageIterator; | 213 friend class CoverageIterator; |
| 214 friend class PrioritizedTile; |
214 friend class TilingSetRasterQueueAll; | 215 friend class TilingSetRasterQueueAll; |
215 friend class TilingSetRasterQueueRequired; | 216 friend class TilingSetRasterQueueRequired; |
216 friend class TilingSetEvictionQueue; | 217 friend class TilingSetEvictionQueue; |
217 | 218 |
218 typedef std::pair<int, int> TileMapKey; | 219 typedef std::pair<int, int> TileMapKey; |
219 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; | 220 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; |
220 | 221 |
221 struct FrameVisibleRect { | 222 struct FrameVisibleRect { |
222 gfx::Rect visible_rect_in_content_space; | 223 gfx::Rect visible_rect_in_content_space; |
223 double frame_time_in_seconds = 0.0; | 224 double frame_time_in_seconds = 0.0; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds; | 268 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds; |
268 visible_rect_history_[0].visible_rect_in_content_space = | 269 visible_rect_history_[0].visible_rect_in_content_space = |
269 visible_rect_in_content_space; | 270 visible_rect_in_content_space; |
270 // If we don't have a second history item, set it to the most recent one. | 271 // If we don't have a second history item, set it to the most recent one. |
271 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) | 272 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) |
272 visible_rect_history_[1] = visible_rect_history_[0]; | 273 visible_rect_history_[1] = visible_rect_history_[0]; |
273 } | 274 } |
274 bool IsTileOccludedOnCurrentTree(const Tile* tile) const; | 275 bool IsTileOccludedOnCurrentTree(const Tile* tile) const; |
275 bool ShouldCreateTileAt(int i, int j) const; | 276 bool ShouldCreateTileAt(int i, int j) const; |
276 bool IsTileOccluded(const Tile* tile) const; | 277 bool IsTileOccluded(const Tile* tile) const; |
277 void UpdateTilePriority(Tile* tile) const; | 278 void UpdateTilePriority(PrioritizedTile* prioritized_tile) const; |
278 TilePriority ComputePriorityForTile(const Tile* tile) const; | 279 TilePriority ComputePriorityForTile(const Tile* tile) const; |
279 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; } | 280 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; } |
280 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; } | 281 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; } |
281 bool has_soon_border_rect_tiles() const { | 282 bool has_soon_border_rect_tiles() const { |
282 return has_soon_border_rect_tiles_; | 283 return has_soon_border_rect_tiles_; |
283 } | 284 } |
284 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; } | 285 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; } |
285 | 286 |
286 const gfx::Rect& current_visible_rect() const { | 287 const gfx::Rect& current_visible_rect() const { |
287 return current_visible_rect_; | 288 return current_visible_rect_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 347 |
347 private: | 348 private: |
348 DISALLOW_ASSIGN(PictureLayerTiling); | 349 DISALLOW_ASSIGN(PictureLayerTiling); |
349 | 350 |
350 RectExpansionCache expansion_cache_; | 351 RectExpansionCache expansion_cache_; |
351 }; | 352 }; |
352 | 353 |
353 } // namespace cc | 354 } // namespace cc |
354 | 355 |
355 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 356 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |