Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 scoped_refptr<RasterSource> raster_source, | 70 scoped_refptr<RasterSource> raster_source, |
| 71 PictureLayerTilingClient* client, | 71 PictureLayerTilingClient* client, |
| 72 size_t max_tiles_for_interest_area, | 72 size_t max_tiles_for_interest_area, |
| 73 float skewport_target_time_in_seconds, | 73 float skewport_target_time_in_seconds, |
| 74 int skewport_extrapolation_limit_in_content_pixels); | 74 int skewport_extrapolation_limit_in_content_pixels); |
| 75 | 75 |
| 76 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); | 76 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); |
| 77 void Invalidate(const Region& layer_invalidation); | 77 void Invalidate(const Region& layer_invalidation); |
| 78 void SetRasterSourceOnTiles(); | 78 void SetRasterSourceOnTiles(); |
| 79 void CreateMissingTilesInLiveTilesRect(); | 79 void CreateMissingTilesInLiveTilesRect(); |
| 80 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin); | |
| 80 | 81 |
| 81 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); | 82 bool IsTileOccluded(const Tile* tile) const; |
| 83 bool IsTileRequiredForActivation(const Tile* tile) const; | |
| 84 bool IsTileRequiredForDraw(const Tile* tile) const; | |
| 82 | 85 |
| 83 void set_resolution(TileResolution resolution) { resolution_ = resolution; } | 86 void set_resolution(TileResolution resolution) { resolution_ = resolution; } |
| 84 TileResolution resolution() const { return resolution_; } | 87 TileResolution resolution() const { return resolution_; } |
| 85 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 88 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
| 86 can_require_tiles_for_activation_ = can_require_tiles; | 89 can_require_tiles_for_activation_ = can_require_tiles; |
| 87 } | 90 } |
| 88 | 91 |
| 89 RasterSource* raster_source() const { return raster_source_.get(); } | 92 RasterSource* raster_source() const { return raster_source_.get(); } |
| 90 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } | 93 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } |
| 91 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 94 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 92 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 95 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
| 93 float contents_scale() const { return contents_scale_; } | 96 float contents_scale() const { return contents_scale_; } |
| 94 | 97 |
| 95 Tile* TileAt(int i, int j) const { | 98 Tile* TileAt(int i, int j) const { |
| 96 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 99 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
| 97 return (iter == tiles_.end()) ? NULL : iter->second.get(); | 100 return (iter == tiles_.end()) ? nullptr : iter->second.get(); |
|
enne (OOO)
2015/04/09 17:54:24
unnecessary parens?
vmpstr
2015/04/10 20:25:13
Done.
vmpstr
2015/04/10 20:25:14
Done.
| |
| 98 } | 101 } |
| 99 | 102 |
| 103 void UpdateTileAndTwinPriority(Tile* tile) const; | |
|
enne (OOO)
2015/04/09 17:54:24
Can you make these not all public if they don't ne
vmpstr
2015/04/10 20:25:14
Done.
| |
| 104 TilePriority ComputePriorityForTile(const Tile* tile) const; | |
| 105 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; } | |
| 106 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; } | |
| 107 bool has_soon_border_rect_tiles() const { | |
| 108 return has_soon_border_rect_tiles_; | |
| 109 } | |
| 110 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; } | |
| 111 | |
| 112 const gfx::Rect& current_visible_rect() const { | |
| 113 return current_visible_rect_; | |
| 114 } | |
| 115 const gfx::Rect& pending_visible_rect() const { | |
| 116 const PictureLayerTiling* twin = | |
| 117 client_->GetTree() == ACTIVE_TREE | |
| 118 ? client_->GetPendingOrActiveTwinTiling(this) | |
| 119 : this; | |
| 120 if (twin) | |
| 121 return twin->current_visible_rect(); | |
| 122 return current_visible_rect(); | |
| 123 } | |
| 124 const gfx::Rect& current_skewport_rect() const { | |
| 125 return current_skewport_rect_; | |
| 126 } | |
| 127 const gfx::Rect& current_soon_border_rect() const { | |
| 128 return current_soon_border_rect_; | |
| 129 } | |
| 130 const gfx::Rect& current_eventually_rect() const { | |
| 131 return current_eventually_rect_; | |
| 132 } | |
| 133 | |
| 134 // For testing functionality. | |
| 100 void CreateAllTilesForTesting() { | 135 void CreateAllTilesForTesting() { |
| 101 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); | 136 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); |
| 102 } | 137 } |
| 103 | |
| 104 const TilingData& TilingDataForTesting() const { return tiling_data_; } | 138 const TilingData& TilingDataForTesting() const { return tiling_data_; } |
| 105 | |
| 106 std::vector<Tile*> AllTilesForTesting() const { | 139 std::vector<Tile*> AllTilesForTesting() const { |
| 107 std::vector<Tile*> all_tiles; | 140 std::vector<Tile*> all_tiles; |
| 108 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 141 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
| 109 all_tiles.push_back(it->second.get()); | 142 all_tiles.push_back(it->second.get()); |
| 110 return all_tiles; | 143 return all_tiles; |
| 111 } | 144 } |
| 112 | |
| 113 void UpdateAllTilePrioritiesForTesting() { | 145 void UpdateAllTilePrioritiesForTesting() { |
| 114 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 146 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
| 115 UpdateTileAndTwinPriority(it->second.get()); | 147 UpdateTileAndTwinPriority(it->second.get()); |
| 116 } | 148 } |
| 117 | |
| 118 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const { | 149 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const { |
| 119 std::vector<scoped_refptr<Tile>> all_tiles; | 150 std::vector<scoped_refptr<Tile>> all_tiles; |
| 120 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 151 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) |
| 121 all_tiles.push_back(it->second); | 152 all_tiles.push_back(it->second); |
| 122 return all_tiles; | 153 return all_tiles; |
| 123 } | 154 } |
| 124 | |
| 125 void SetAllTilesOccludedForTesting() { | 155 void SetAllTilesOccludedForTesting() { |
| 126 gfx::Rect viewport_in_layer_space = | 156 gfx::Rect viewport_in_layer_space = |
| 127 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); | 157 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); |
| 128 current_occlusion_in_layer_space_ = | 158 current_occlusion_in_layer_space_ = |
| 129 Occlusion(gfx::Transform(), | 159 Occlusion(gfx::Transform(), |
| 130 SimpleEnclosedRegion(viewport_in_layer_space), | 160 SimpleEnclosedRegion(viewport_in_layer_space), |
| 131 SimpleEnclosedRegion(viewport_in_layer_space)); | 161 SimpleEnclosedRegion(viewport_in_layer_space)); |
| 132 } | 162 } |
| 133 | |
| 134 const gfx::Rect& GetCurrentVisibleRectForTesting() const { | 163 const gfx::Rect& GetCurrentVisibleRectForTesting() const { |
| 135 return current_visible_rect_; | 164 return current_visible_rect_; |
| 136 } | 165 } |
| 137 | 166 |
| 138 bool IsTileOccluded(const Tile* tile) const; | |
| 139 bool IsTileRequiredForActivationIfVisible(const Tile* tile) const; | |
| 140 bool IsTileRequiredForDrawIfVisible(const Tile* tile) const; | |
| 141 | |
| 142 void UpdateTileAndTwinPriority(Tile* tile) const; | |
| 143 TilePriority ComputePriorityForTile(const Tile* tile) const; | |
| 144 void UpdateRequiredStateForTile(Tile* tile, WhichTree tree) const; | |
| 145 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; } | |
| 146 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; } | |
| 147 bool has_soon_border_rect_tiles() const { | |
| 148 return has_soon_border_rect_tiles_; | |
| 149 } | |
| 150 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; } | |
| 151 | |
| 152 const gfx::Rect& current_visible_rect() const { | |
| 153 return current_visible_rect_; | |
| 154 } | |
| 155 const gfx::Rect& current_skewport_rect() const { | |
| 156 return current_skewport_rect_; | |
| 157 } | |
| 158 const gfx::Rect& current_soon_border_rect() const { | |
| 159 return current_soon_border_rect_; | |
| 160 } | |
| 161 const gfx::Rect& current_eventually_rect() const { | |
| 162 return current_eventually_rect_; | |
| 163 } | |
| 164 void VerifyAllTilesHaveCurrentRasterSource() const; | 167 void VerifyAllTilesHaveCurrentRasterSource() const; |
| 165 | 168 |
| 166 // Iterate over all tiles to fill content_rect. Even if tiles are invalid | 169 // Iterate over all tiles to fill content_rect. Even if tiles are invalid |
| 167 // (i.e. no valid resource) this tiling should still iterate over them. | 170 // (i.e. no valid resource) this tiling should still iterate over them. |
| 168 // The union of all geometry_rect calls for each element iterated over should | 171 // The union of all geometry_rect calls for each element iterated over should |
| 169 // exactly equal content_rect and no two geometry_rects should intersect. | 172 // exactly equal content_rect and no two geometry_rects should intersect. |
| 170 class CC_EXPORT CoverageIterator { | 173 class CC_EXPORT CoverageIterator { |
| 171 public: | 174 public: |
| 172 CoverageIterator(); | 175 CoverageIterator(); |
| 173 CoverageIterator(const PictureLayerTiling* tiling, | 176 CoverageIterator(const PictureLayerTiling* tiling, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 }; | 257 }; |
| 255 | 258 |
| 256 PictureLayerTiling(float contents_scale, | 259 PictureLayerTiling(float contents_scale, |
| 257 scoped_refptr<RasterSource> raster_source, | 260 scoped_refptr<RasterSource> raster_source, |
| 258 PictureLayerTilingClient* client, | 261 PictureLayerTilingClient* client, |
| 259 size_t max_tiles_for_interest_area, | 262 size_t max_tiles_for_interest_area, |
| 260 float skewport_target_time_in_seconds, | 263 float skewport_target_time_in_seconds, |
| 261 int skewport_extrapolation_limit_in_content_pixels); | 264 int skewport_extrapolation_limit_in_content_pixels); |
| 262 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | 265 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
| 263 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; | 266 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; |
| 264 Tile* CreateTile(int i, | 267 Tile* CreateTile(int i, int j); |
| 265 int j, | |
| 266 const PictureLayerTiling* twin_tiling, | |
| 267 PictureLayerTiling* recycled_twin); | |
| 268 // Returns true if the Tile existed and was removed from the tiling. | 268 // Returns true if the Tile existed and was removed from the tiling. |
| 269 bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin); | 269 bool RemoveTileAt(int i, int j); |
| 270 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const; | |
| 270 | 271 |
| 271 // Computes a skewport. The calculation extrapolates the last visible | 272 // Computes a skewport. The calculation extrapolates the last visible |
| 272 // rect and the current visible rect to expand the skewport to where it | 273 // rect and the current visible rect to expand the skewport to where it |
| 273 // would be in |skewport_target_time| seconds. Note that the skewport | 274 // would be in |skewport_target_time| seconds. Note that the skewport |
| 274 // is guaranteed to contain the current visible rect. | 275 // is guaranteed to contain the current visible rect. |
| 275 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, | 276 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, |
| 276 const gfx::Rect& visible_rect_in_content_space) | 277 const gfx::Rect& visible_rect_in_content_space) |
| 277 const; | 278 const; |
| 278 | 279 |
| 279 // Save the required data for computing tile priorities later. | 280 // Save the required data for computing tile priorities later. |
| 280 void UpdateTilePriorityRects(float content_to_screen_scale_, | 281 void SetTilePriorityRects(float content_to_screen_scale_, |
| 281 const gfx::Rect& visible_rect_in_content_space, | 282 const gfx::Rect& visible_rect_in_content_space, |
| 282 const gfx::Rect& skewport, | 283 const gfx::Rect& skewport, |
| 283 const gfx::Rect& soon_border_rect, | 284 const gfx::Rect& soon_border_rect, |
| 284 const gfx::Rect& eventually_rect, | 285 const gfx::Rect& eventually_rect, |
| 285 const Occlusion& occlusion_in_layer_space); | 286 const Occlusion& occlusion_in_layer_space); |
| 286 | 287 |
| 287 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const; | 288 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const; |
| 288 bool NeedsUpdateForFrameAtTimeAndViewport( | 289 bool NeedsUpdateForFrameAtTimeAndViewport( |
| 289 double frame_time_in_seconds, | 290 double frame_time_in_seconds, |
| 290 const gfx::Rect& viewport_in_layer_space) { | 291 const gfx::Rect& viewport_in_layer_space) { |
| 291 return frame_time_in_seconds != | 292 return frame_time_in_seconds != |
| 292 visible_rect_history_[0].frame_time_in_seconds || | 293 visible_rect_history_[0].frame_time_in_seconds || |
| 293 viewport_in_layer_space != last_viewport_in_layer_space_; | 294 viewport_in_layer_space != last_viewport_in_layer_space_; |
| 294 } | 295 } |
| 295 void UpdateVisibleRectHistory( | 296 void UpdateVisibleRectHistory( |
| 296 double frame_time_in_seconds, | 297 double frame_time_in_seconds, |
| 297 const gfx::Rect& visible_rect_in_content_space) { | 298 const gfx::Rect& visible_rect_in_content_space) { |
| 298 visible_rect_history_[1] = visible_rect_history_[0]; | 299 visible_rect_history_[1] = visible_rect_history_[0]; |
| 299 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds; | 300 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds; |
| 300 visible_rect_history_[0].visible_rect_in_content_space = | 301 visible_rect_history_[0].visible_rect_in_content_space = |
| 301 visible_rect_in_content_space; | 302 visible_rect_in_content_space; |
| 302 // If we don't have a second history item, set it to the most recent one. | 303 // If we don't have a second history item, set it to the most recent one. |
| 303 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) | 304 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) |
| 304 visible_rect_history_[1] = visible_rect_history_[0]; | 305 visible_rect_history_[1] = visible_rect_history_[0]; |
| 305 } | 306 } |
| 307 bool IsTileOccludedOnCurrentTree(const Tile* tile) const; | |
| 308 bool ShouldCreateTileAt(int i, int j) const; | |
| 306 | 309 |
| 307 const size_t max_tiles_for_interest_area_; | 310 const size_t max_tiles_for_interest_area_; |
| 308 const float skewport_target_time_in_seconds_; | 311 const float skewport_target_time_in_seconds_; |
| 309 const int skewport_extrapolation_limit_in_content_pixels_; | 312 const int skewport_extrapolation_limit_in_content_pixels_; |
| 310 | 313 |
| 311 // Given properties. | 314 // Given properties. |
| 312 const float contents_scale_; | 315 const float contents_scale_; |
| 313 PictureLayerTilingClient* const client_; | 316 PictureLayerTilingClient* const client_; |
| 314 scoped_refptr<RasterSource> raster_source_; | 317 scoped_refptr<RasterSource> raster_source_; |
| 315 TileResolution resolution_; | 318 TileResolution resolution_; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 341 | 344 |
| 342 private: | 345 private: |
| 343 DISALLOW_ASSIGN(PictureLayerTiling); | 346 DISALLOW_ASSIGN(PictureLayerTiling); |
| 344 | 347 |
| 345 RectExpansionCache expansion_cache_; | 348 RectExpansionCache expansion_cache_; |
| 346 }; | 349 }; |
| 347 | 350 |
| 348 } // namespace cc | 351 } // namespace cc |
| 349 | 352 |
| 350 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ | 353 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |