Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: cc/resources/picture_layer_tiling.h

Issue 1051993002: cc: Remove tile sharing from tilings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
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(float contents_scale, 38 virtual scoped_refptr<Tile> CreateTile(
39 const gfx::Rect& content_rect) = 0; 39 float contents_scale,
40 const gfx::Rect& content_rect,
41 scoped_refptr<RasterSource>* raster_source) = 0;
40 virtual gfx::Size CalculateTileSize( 42 virtual gfx::Size CalculateTileSize(
41 const gfx::Size& content_bounds) const = 0; 43 const gfx::Size& content_bounds) const = 0;
42 // This invalidation region defines the area (if any, it can by null) that 44 // This invalidation region defines the area (if any, it can by null) that
43 // tiles can not be shared between pending and active trees. 45 // tiles can not be shared between pending and active trees.
44 virtual const Region* GetPendingInvalidation() = 0; 46 virtual const Region* GetPendingInvalidation() = 0;
45 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling( 47 virtual const PictureLayerTiling* GetPendingOrActiveTwinTiling(
46 const PictureLayerTiling* tiling) const = 0; 48 const PictureLayerTiling* tiling) const = 0;
47 virtual PictureLayerTiling* GetRecycledTwinTiling( 49 virtual PictureLayerTiling* GetRecycledTwinTiling(
48 const PictureLayerTiling* tiling) = 0; 50 const PictureLayerTiling* tiling) = 0;
49 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0; 51 virtual TilePriority::PriorityBin GetMaxTilePriorityBin() const = 0;
(...skipping 18 matching lines...) Expand all
68 static scoped_ptr<PictureLayerTiling> Create( 70 static scoped_ptr<PictureLayerTiling> Create(
69 float contents_scale, 71 float contents_scale,
70 scoped_refptr<RasterSource> raster_source, 72 scoped_refptr<RasterSource> raster_source,
71 PictureLayerTilingClient* client, 73 PictureLayerTilingClient* client,
72 size_t max_tiles_for_interest_area, 74 size_t max_tiles_for_interest_area,
73 float skewport_target_time_in_seconds, 75 float skewport_target_time_in_seconds,
74 int skewport_extrapolation_limit_in_content_pixels); 76 int skewport_extrapolation_limit_in_content_pixels);
75 77
76 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); 78 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source);
77 void Invalidate(const Region& layer_invalidation); 79 void Invalidate(const Region& layer_invalidation);
78 void SetRasterSourceOnTiles();
79 void CreateMissingTilesInLiveTilesRect(); 80 void CreateMissingTilesInLiveTilesRect();
81 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin);
80 82
81 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling); 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 const TilingData* tiling_data() const { return &tiling_data_; } 97 const TilingData* tiling_data() const { return &tiling_data_; }
95 98
96 Tile* TileAt(int i, int j) const { 99 Tile* TileAt(int i, int j) const {
97 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 100 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
98 return (iter == tiles_.end()) ? NULL : iter->second.get(); 101 return iter == tiles_.end() ? nullptr : iter->second.get();
99 } 102 }
100 103
104 bool has_tiles() const { return !tiles_.empty(); }
105
106 // For testing functionality.
101 void CreateAllTilesForTesting() { 107 void CreateAllTilesForTesting() {
102 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); 108 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size()));
103 } 109 }
104
105 const TilingData& TilingDataForTesting() const { return tiling_data_; } 110 const TilingData& TilingDataForTesting() const { return tiling_data_; }
106
107 std::vector<Tile*> AllTilesForTesting() const { 111 std::vector<Tile*> AllTilesForTesting() const {
108 std::vector<Tile*> all_tiles; 112 std::vector<Tile*> all_tiles;
109 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 113 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
110 all_tiles.push_back(it->second.get()); 114 all_tiles.push_back(it->second.get());
111 return all_tiles; 115 return all_tiles;
112 } 116 }
113
114 void UpdateAllTilePrioritiesForTesting() { 117 void UpdateAllTilePrioritiesForTesting() {
115 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 118 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
116 UpdateTileAndTwinPriority(it->second.get()); 119 UpdateTileAndTwinPriority(it->second.get());
117 } 120 }
118
119 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const { 121 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const {
120 std::vector<scoped_refptr<Tile>> all_tiles; 122 std::vector<scoped_refptr<Tile>> all_tiles;
121 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 123 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
122 all_tiles.push_back(it->second); 124 all_tiles.push_back(it->second);
123 return all_tiles; 125 return all_tiles;
124 } 126 }
125
126 void SetAllTilesOccludedForTesting() { 127 void SetAllTilesOccludedForTesting() {
127 gfx::Rect viewport_in_layer_space = 128 gfx::Rect viewport_in_layer_space =
128 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); 129 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_);
129 current_occlusion_in_layer_space_ = 130 current_occlusion_in_layer_space_ =
130 Occlusion(gfx::Transform(), 131 Occlusion(gfx::Transform(),
131 SimpleEnclosedRegion(viewport_in_layer_space), 132 SimpleEnclosedRegion(viewport_in_layer_space),
132 SimpleEnclosedRegion(viewport_in_layer_space)); 133 SimpleEnclosedRegion(viewport_in_layer_space));
133 } 134 }
134
135 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 135 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
136 return current_visible_rect_; 136 return current_visible_rect_;
137 } 137 }
138 138
139 bool IsTileOccluded(const Tile* tile) const;
140 bool IsTileRequiredForActivationIfVisible(const Tile* tile) const;
141 bool IsTileRequiredForDrawIfVisible(const Tile* tile) const;
142
143 void UpdateTileAndTwinPriority(Tile* tile) const;
144 TilePriority ComputePriorityForTile(const Tile* tile) const;
145 void UpdateRequiredStateForTile(Tile* tile, WhichTree tree) const;
146 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; }
147 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; }
148 bool has_soon_border_rect_tiles() const {
149 return has_soon_border_rect_tiles_;
150 }
151 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
152
153 const gfx::Rect& current_visible_rect() const {
154 return current_visible_rect_;
155 }
156 const gfx::Rect& current_skewport_rect() const {
157 return current_skewport_rect_;
158 }
159 const gfx::Rect& current_soon_border_rect() const {
160 return current_soon_border_rect_;
161 }
162 const gfx::Rect& current_eventually_rect() const {
163 return current_eventually_rect_;
164 }
165 void VerifyAllTilesHaveCurrentRasterSource() const; 139 void VerifyAllTilesHaveCurrentRasterSource() const;
166 140
167 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 141 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
168 // (i.e. no valid resource) this tiling should still iterate over them. 142 // (i.e. no valid resource) this tiling should still iterate over them.
169 // The union of all geometry_rect calls for each element iterated over should 143 // The union of all geometry_rect calls for each element iterated over should
170 // exactly equal content_rect and no two geometry_rects should intersect. 144 // exactly equal content_rect and no two geometry_rects should intersect.
171 class CC_EXPORT CoverageIterator { 145 class CC_EXPORT CoverageIterator {
172 public: 146 public:
173 CoverageIterator(); 147 CoverageIterator();
174 CoverageIterator(const PictureLayerTiling* tiling, 148 CoverageIterator(const PictureLayerTiling* tiling,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 int64 previous_target; 203 int64 previous_target;
230 }; 204 };
231 205
232 static 206 static
233 gfx::Rect ExpandRectEquallyToAreaBoundedBy( 207 gfx::Rect ExpandRectEquallyToAreaBoundedBy(
234 const gfx::Rect& starting_rect, 208 const gfx::Rect& starting_rect,
235 int64 target_area, 209 int64 target_area,
236 const gfx::Rect& bounding_rect, 210 const gfx::Rect& bounding_rect,
237 RectExpansionCache* cache); 211 RectExpansionCache* cache);
238 212
239 bool has_ever_been_updated() const {
240 return visible_rect_history_[0].frame_time_in_seconds != 0.0;
241 }
242
243 protected: 213 protected:
244 friend class CoverageIterator; 214 friend class CoverageIterator;
245 friend class TilingSetRasterQueueAll; 215 friend class TilingSetRasterQueueAll;
246 friend class TilingSetRasterQueueRequired; 216 friend class TilingSetRasterQueueRequired;
247 friend class TilingSetEvictionQueue; 217 friend class TilingSetEvictionQueue;
248 218
249 typedef std::pair<int, int> TileMapKey; 219 typedef std::pair<int, int> TileMapKey;
250 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; 220 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap;
251 221
252 struct FrameVisibleRect { 222 struct FrameVisibleRect {
253 gfx::Rect visible_rect_in_content_space; 223 gfx::Rect visible_rect_in_content_space;
254 double frame_time_in_seconds = 0.0; 224 double frame_time_in_seconds = 0.0;
255 }; 225 };
256 226
257 PictureLayerTiling(float contents_scale, 227 PictureLayerTiling(float contents_scale,
258 scoped_refptr<RasterSource> raster_source, 228 scoped_refptr<RasterSource> raster_source,
259 PictureLayerTilingClient* client, 229 PictureLayerTilingClient* client,
260 size_t max_tiles_for_interest_area, 230 size_t max_tiles_for_interest_area,
261 float skewport_target_time_in_seconds, 231 float skewport_target_time_in_seconds,
262 int skewport_extrapolation_limit_in_content_pixels); 232 int skewport_extrapolation_limit_in_content_pixels);
263 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 233 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
264 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; 234 void VerifyLiveTilesRect(bool is_on_recycle_tree) const;
265 Tile* CreateTile(int i, 235 Tile* CreateTile(int i, int j);
266 int j,
267 const PictureLayerTiling* twin_tiling,
268 PictureLayerTiling* recycled_twin);
269 // Returns true if the Tile existed and was removed from the tiling. 236 // Returns true if the Tile existed and was removed from the tiling.
270 bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin); 237 bool RemoveTileAt(int i, int j);
238 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const;
271 239
272 // Computes a skewport. The calculation extrapolates the last visible 240 // Computes a skewport. The calculation extrapolates the last visible
273 // rect and the current visible rect to expand the skewport to where it 241 // rect and the current visible rect to expand the skewport to where it
274 // would be in |skewport_target_time| seconds. Note that the skewport 242 // would be in |skewport_target_time| seconds. Note that the skewport
275 // is guaranteed to contain the current visible rect. 243 // is guaranteed to contain the current visible rect.
276 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, 244 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds,
277 const gfx::Rect& visible_rect_in_content_space) 245 const gfx::Rect& visible_rect_in_content_space)
278 const; 246 const;
279 247
280 // Save the required data for computing tile priorities later. 248 // Save the required data for computing tile priorities later.
281 void UpdateTilePriorityRects(float content_to_screen_scale_, 249 void SetTilePriorityRects(float content_to_screen_scale_,
282 const gfx::Rect& visible_rect_in_content_space, 250 const gfx::Rect& visible_rect_in_content_space,
283 const gfx::Rect& skewport, 251 const gfx::Rect& skewport,
284 const gfx::Rect& soon_border_rect, 252 const gfx::Rect& soon_border_rect,
285 const gfx::Rect& eventually_rect, 253 const gfx::Rect& eventually_rect,
286 const Occlusion& occlusion_in_layer_space); 254 const Occlusion& occlusion_in_layer_space);
287 255
288 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const;
289 bool NeedsUpdateForFrameAtTimeAndViewport( 256 bool NeedsUpdateForFrameAtTimeAndViewport(
290 double frame_time_in_seconds, 257 double frame_time_in_seconds,
291 const gfx::Rect& viewport_in_layer_space) { 258 const gfx::Rect& viewport_in_layer_space) {
292 return frame_time_in_seconds != 259 return frame_time_in_seconds !=
293 visible_rect_history_[0].frame_time_in_seconds || 260 visible_rect_history_[0].frame_time_in_seconds ||
294 viewport_in_layer_space != last_viewport_in_layer_space_; 261 viewport_in_layer_space != last_viewport_in_layer_space_;
295 } 262 }
296 void UpdateVisibleRectHistory( 263 void UpdateVisibleRectHistory(
297 double frame_time_in_seconds, 264 double frame_time_in_seconds,
298 const gfx::Rect& visible_rect_in_content_space) { 265 const gfx::Rect& visible_rect_in_content_space) {
299 visible_rect_history_[1] = visible_rect_history_[0]; 266 visible_rect_history_[1] = visible_rect_history_[0];
300 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds; 267 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds;
301 visible_rect_history_[0].visible_rect_in_content_space = 268 visible_rect_history_[0].visible_rect_in_content_space =
302 visible_rect_in_content_space; 269 visible_rect_in_content_space;
303 // If we don't have a second history item, set it to the most recent one. 270 // If we don't have a second history item, set it to the most recent one.
304 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) 271 if (visible_rect_history_[1].frame_time_in_seconds == 0.0)
305 visible_rect_history_[1] = visible_rect_history_[0]; 272 visible_rect_history_[1] = visible_rect_history_[0];
306 } 273 }
274 bool IsTileOccludedOnCurrentTree(const Tile* tile) const;
275 bool ShouldCreateTileAt(int i, int j) const;
276 bool IsTileOccluded(const Tile* tile) const;
277 void UpdateTileAndTwinPriority(Tile* tile) const;
278 TilePriority ComputePriorityForTile(const Tile* tile) const;
279 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_soon_border_rect_tiles() const {
282 return has_soon_border_rect_tiles_;
283 }
284 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
285
286 const gfx::Rect& current_visible_rect() const {
287 return current_visible_rect_;
288 }
289 gfx::Rect pending_visible_rect() const {
290 const PictureLayerTiling* pending_tiling =
291 client_->GetTree() == ACTIVE_TREE
292 ? client_->GetPendingOrActiveTwinTiling(this)
293 : this;
294 if (pending_tiling)
295 return pending_tiling->current_visible_rect();
296 return gfx::Rect();
297 }
298 const gfx::Rect& current_skewport_rect() const {
299 return current_skewport_rect_;
300 }
301 const gfx::Rect& current_soon_border_rect() const {
302 return current_soon_border_rect_;
303 }
304 const gfx::Rect& current_eventually_rect() const {
305 return current_eventually_rect_;
306 }
307 bool has_ever_been_updated() const {
308 return visible_rect_history_[0].frame_time_in_seconds != 0.0;
309 }
307 310
308 const size_t max_tiles_for_interest_area_; 311 const size_t max_tiles_for_interest_area_;
309 const float skewport_target_time_in_seconds_; 312 const float skewport_target_time_in_seconds_;
310 const int skewport_extrapolation_limit_in_content_pixels_; 313 const int skewport_extrapolation_limit_in_content_pixels_;
311 314
312 // Given properties. 315 // Given properties.
313 const float contents_scale_; 316 const float contents_scale_;
314 PictureLayerTilingClient* const client_; 317 PictureLayerTilingClient* const client_;
315 scoped_refptr<RasterSource> raster_source_; 318 scoped_refptr<RasterSource> raster_source_;
316 TileResolution resolution_; 319 TileResolution resolution_;
(...skipping 16 matching lines...) Expand all
333 gfx::Rect current_eventually_rect_; 336 gfx::Rect current_eventually_rect_;
334 // Other properties used for tile iteration and prioritization. 337 // Other properties used for tile iteration and prioritization.
335 float current_content_to_screen_scale_; 338 float current_content_to_screen_scale_;
336 Occlusion current_occlusion_in_layer_space_; 339 Occlusion current_occlusion_in_layer_space_;
337 340
338 bool has_visible_rect_tiles_; 341 bool has_visible_rect_tiles_;
339 bool has_skewport_rect_tiles_; 342 bool has_skewport_rect_tiles_;
340 bool has_soon_border_rect_tiles_; 343 bool has_soon_border_rect_tiles_;
341 bool has_eventually_rect_tiles_; 344 bool has_eventually_rect_tiles_;
342 345
346 std::vector<TileMapKey> failed_tile_indices_;
347
343 private: 348 private:
344 DISALLOW_ASSIGN(PictureLayerTiling); 349 DISALLOW_ASSIGN(PictureLayerTiling);
345 350
346 RectExpansionCache expansion_cache_; 351 RectExpansionCache expansion_cache_;
347 }; 352 };
348 353
349 } // namespace cc 354 } // namespace cc
350 355
351 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 356 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698