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

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

Issue 1108773003: Revert of cc: Remove tile sharing from tilings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « cc/resources/eviction_tile_priority_queue.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 virtual bool RequiresHighResToDraw() const = 0; 51 virtual bool RequiresHighResToDraw() const = 0;
52 52
53 protected: 53 protected:
54 virtual ~PictureLayerTilingClient() {} 54 virtual ~PictureLayerTilingClient() {}
55 }; 55 };
56 56
57 class CC_EXPORT PictureLayerTiling { 57 class CC_EXPORT PictureLayerTiling {
58 public: 58 public:
59 static const int kBorderTexels = 1; 59 static const int kBorderTexels = 1;
60 60
61 PictureLayerTilingClient* client() const { return client_; }
62 ~PictureLayerTiling(); 61 ~PictureLayerTiling();
63 62
64 static float CalculateSoonBorderDistance( 63 static float CalculateSoonBorderDistance(
65 const gfx::Rect& visible_rect_in_content_space, 64 const gfx::Rect& visible_rect_in_content_space,
66 float content_to_screen_scale); 65 float content_to_screen_scale);
67 66
68 // Create a tiling with no tiles. CreateTile() must be called to add some. 67 // Create a tiling with no tiles. CreateTile() must be called to add some.
69 static scoped_ptr<PictureLayerTiling> Create( 68 static scoped_ptr<PictureLayerTiling> Create(
70 float contents_scale, 69 float contents_scale,
71 scoped_refptr<RasterSource> raster_source, 70 scoped_refptr<RasterSource> raster_source,
72 PictureLayerTilingClient* client, 71 PictureLayerTilingClient* client,
73 size_t max_tiles_for_interest_area, 72 size_t max_tiles_for_interest_area,
74 float skewport_target_time_in_seconds, 73 float skewport_target_time_in_seconds,
75 int skewport_extrapolation_limit_in_content_pixels); 74 int skewport_extrapolation_limit_in_content_pixels);
76 75
77 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); 76 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source);
78 void Invalidate(const Region& layer_invalidation); 77 void Invalidate(const Region& layer_invalidation);
79 void SetRasterSourceOnTiles(); 78 void SetRasterSourceOnTiles();
80 void CreateMissingTilesInLiveTilesRect(); 79 void CreateMissingTilesInLiveTilesRect();
81 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin,
82 const Region& layer_invalidation);
83 80
84 bool IsTileRequiredForActivation(const Tile* tile) const; 81 void CloneTilesAndPropertiesFrom(const PictureLayerTiling& twin_tiling);
85 bool IsTileRequiredForDraw(const Tile* tile) const;
86 82
87 void set_resolution(TileResolution resolution) { resolution_ = resolution; } 83 void set_resolution(TileResolution resolution) { resolution_ = resolution; }
88 TileResolution resolution() const { return resolution_; } 84 TileResolution resolution() const { return resolution_; }
89 void set_can_require_tiles_for_activation(bool can_require_tiles) { 85 void set_can_require_tiles_for_activation(bool can_require_tiles) {
90 can_require_tiles_for_activation_ = can_require_tiles; 86 can_require_tiles_for_activation_ = can_require_tiles;
91 } 87 }
92 88
93 RasterSource* raster_source() const { return raster_source_.get(); } 89 RasterSource* raster_source() const { return raster_source_.get(); }
94 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } 90 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); }
95 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 91 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
96 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 92 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
97 float contents_scale() const { return contents_scale_; } 93 float contents_scale() const { return contents_scale_; }
98 const TilingData* tiling_data() const { return &tiling_data_; } 94 const TilingData* tiling_data() const { return &tiling_data_; }
99 95
100 Tile* TileAt(int i, int j) const { 96 Tile* TileAt(int i, int j) const {
101 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 97 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
102 return iter == tiles_.end() ? nullptr : iter->second.get(); 98 return (iter == tiles_.end()) ? NULL : iter->second.get();
103 } 99 }
104 100
105 bool has_tiles() const { return !tiles_.empty(); }
106
107 // For testing functionality.
108 void CreateAllTilesForTesting() { 101 void CreateAllTilesForTesting() {
109 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); 102 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size()));
110 } 103 }
104
111 const TilingData& TilingDataForTesting() const { return tiling_data_; } 105 const TilingData& TilingDataForTesting() const { return tiling_data_; }
106
112 std::vector<Tile*> AllTilesForTesting() const { 107 std::vector<Tile*> AllTilesForTesting() const {
113 std::vector<Tile*> all_tiles; 108 std::vector<Tile*> all_tiles;
114 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 109 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
115 all_tiles.push_back(it->second.get()); 110 all_tiles.push_back(it->second.get());
116 return all_tiles; 111 return all_tiles;
117 } 112 }
113
118 void UpdateAllTilePrioritiesForTesting() { 114 void UpdateAllTilePrioritiesForTesting() {
119 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 115 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
120 UpdateTileAndTwinPriority(it->second.get()); 116 UpdateTileAndTwinPriority(it->second.get());
121 } 117 }
118
122 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const { 119 std::vector<scoped_refptr<Tile>> AllRefTilesForTesting() const {
123 std::vector<scoped_refptr<Tile>> all_tiles; 120 std::vector<scoped_refptr<Tile>> all_tiles;
124 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 121 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
125 all_tiles.push_back(it->second); 122 all_tiles.push_back(it->second);
126 return all_tiles; 123 return all_tiles;
127 } 124 }
125
128 void SetAllTilesOccludedForTesting() { 126 void SetAllTilesOccludedForTesting() {
129 gfx::Rect viewport_in_layer_space = 127 gfx::Rect viewport_in_layer_space =
130 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); 128 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_);
131 current_occlusion_in_layer_space_ = 129 current_occlusion_in_layer_space_ =
132 Occlusion(gfx::Transform(), 130 Occlusion(gfx::Transform(),
133 SimpleEnclosedRegion(viewport_in_layer_space), 131 SimpleEnclosedRegion(viewport_in_layer_space),
134 SimpleEnclosedRegion(viewport_in_layer_space)); 132 SimpleEnclosedRegion(viewport_in_layer_space));
135 } 133 }
134
136 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 135 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
137 return current_visible_rect_; 136 return current_visible_rect_;
138 } 137 }
139 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 }
140 void VerifyAllTilesHaveCurrentRasterSource() const; 165 void VerifyAllTilesHaveCurrentRasterSource() const;
141 166
142 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 167 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
143 // (i.e. no valid resource) this tiling should still iterate over them. 168 // (i.e. no valid resource) this tiling should still iterate over them.
144 // The union of all geometry_rect calls for each element iterated over should 169 // The union of all geometry_rect calls for each element iterated over should
145 // exactly equal content_rect and no two geometry_rects should intersect. 170 // exactly equal content_rect and no two geometry_rects should intersect.
146 class CC_EXPORT CoverageIterator { 171 class CC_EXPORT CoverageIterator {
147 public: 172 public:
148 CoverageIterator(); 173 CoverageIterator();
149 CoverageIterator(const PictureLayerTiling* tiling, 174 CoverageIterator(const PictureLayerTiling* tiling,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 int64 previous_target; 229 int64 previous_target;
205 }; 230 };
206 231
207 static 232 static
208 gfx::Rect ExpandRectEquallyToAreaBoundedBy( 233 gfx::Rect ExpandRectEquallyToAreaBoundedBy(
209 const gfx::Rect& starting_rect, 234 const gfx::Rect& starting_rect,
210 int64 target_area, 235 int64 target_area,
211 const gfx::Rect& bounding_rect, 236 const gfx::Rect& bounding_rect,
212 RectExpansionCache* cache); 237 RectExpansionCache* cache);
213 238
239 bool has_ever_been_updated() const {
240 return visible_rect_history_[0].frame_time_in_seconds != 0.0;
241 }
242
214 protected: 243 protected:
215 friend class CoverageIterator; 244 friend class CoverageIterator;
216 friend class TilingSetRasterQueueAll; 245 friend class TilingSetRasterQueueAll;
217 friend class TilingSetRasterQueueRequired; 246 friend class TilingSetRasterQueueRequired;
218 friend class TilingSetEvictionQueue; 247 friend class TilingSetEvictionQueue;
219 248
220 typedef std::pair<int, int> TileMapKey; 249 typedef std::pair<int, int> TileMapKey;
221 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; 250 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap;
222 251
223 struct FrameVisibleRect { 252 struct FrameVisibleRect {
224 gfx::Rect visible_rect_in_content_space; 253 gfx::Rect visible_rect_in_content_space;
225 double frame_time_in_seconds = 0.0; 254 double frame_time_in_seconds = 0.0;
226 }; 255 };
227 256
228 PictureLayerTiling(float contents_scale, 257 PictureLayerTiling(float contents_scale,
229 scoped_refptr<RasterSource> raster_source, 258 scoped_refptr<RasterSource> raster_source,
230 PictureLayerTilingClient* client, 259 PictureLayerTilingClient* client,
231 size_t max_tiles_for_interest_area, 260 size_t max_tiles_for_interest_area,
232 float skewport_target_time_in_seconds, 261 float skewport_target_time_in_seconds,
233 int skewport_extrapolation_limit_in_content_pixels); 262 int skewport_extrapolation_limit_in_content_pixels);
234 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 263 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
235 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; 264 void VerifyLiveTilesRect(bool is_on_recycle_tree) const;
236 Tile* CreateTile(int i, int j); 265 Tile* CreateTile(int i,
266 int j,
267 const PictureLayerTiling* twin_tiling,
268 PictureLayerTiling* recycled_twin);
237 // Returns true if the Tile existed and was removed from the tiling. 269 // Returns true if the Tile existed and was removed from the tiling.
238 bool RemoveTileAt(int i, int j); 270 bool RemoveTileAt(int i, int j, PictureLayerTiling* recycled_twin);
239 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const;
240 271
241 // Computes a skewport. The calculation extrapolates the last visible 272 // Computes a skewport. The calculation extrapolates the last visible
242 // 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
243 // would be in |skewport_target_time| seconds. Note that the skewport 274 // would be in |skewport_target_time| seconds. Note that the skewport
244 // is guaranteed to contain the current visible rect. 275 // is guaranteed to contain the current visible rect.
245 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, 276 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds,
246 const gfx::Rect& visible_rect_in_content_space) 277 const gfx::Rect& visible_rect_in_content_space)
247 const; 278 const;
248 279
249 // Save the required data for computing tile priorities later. 280 // Save the required data for computing tile priorities later.
250 void SetTilePriorityRects(float content_to_screen_scale_, 281 void UpdateTilePriorityRects(float content_to_screen_scale_,
251 const gfx::Rect& visible_rect_in_content_space, 282 const gfx::Rect& visible_rect_in_content_space,
252 const gfx::Rect& skewport, 283 const gfx::Rect& skewport,
253 const gfx::Rect& soon_border_rect, 284 const gfx::Rect& soon_border_rect,
254 const gfx::Rect& eventually_rect, 285 const gfx::Rect& eventually_rect,
255 const Occlusion& occlusion_in_layer_space); 286 const Occlusion& occlusion_in_layer_space);
256 287
288 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const;
257 bool NeedsUpdateForFrameAtTimeAndViewport( 289 bool NeedsUpdateForFrameAtTimeAndViewport(
258 double frame_time_in_seconds, 290 double frame_time_in_seconds,
259 const gfx::Rect& viewport_in_layer_space) { 291 const gfx::Rect& viewport_in_layer_space) {
260 return frame_time_in_seconds != 292 return frame_time_in_seconds !=
261 visible_rect_history_[0].frame_time_in_seconds || 293 visible_rect_history_[0].frame_time_in_seconds ||
262 viewport_in_layer_space != last_viewport_in_layer_space_; 294 viewport_in_layer_space != last_viewport_in_layer_space_;
263 } 295 }
264 void UpdateVisibleRectHistory( 296 void UpdateVisibleRectHistory(
265 double frame_time_in_seconds, 297 double frame_time_in_seconds,
266 const gfx::Rect& visible_rect_in_content_space) { 298 const gfx::Rect& visible_rect_in_content_space) {
267 visible_rect_history_[1] = visible_rect_history_[0]; 299 visible_rect_history_[1] = visible_rect_history_[0];
268 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;
269 visible_rect_history_[0].visible_rect_in_content_space = 301 visible_rect_history_[0].visible_rect_in_content_space =
270 visible_rect_in_content_space; 302 visible_rect_in_content_space;
271 // 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.
272 if (visible_rect_history_[1].frame_time_in_seconds == 0.0) 304 if (visible_rect_history_[1].frame_time_in_seconds == 0.0)
273 visible_rect_history_[1] = visible_rect_history_[0]; 305 visible_rect_history_[1] = visible_rect_history_[0];
274 } 306 }
275 bool IsTileOccludedOnCurrentTree(const Tile* tile) const;
276 bool ShouldCreateTileAt(int i, int j) const;
277 bool IsTileOccluded(const Tile* tile) const;
278 void UpdateTileAndTwinPriority(Tile* tile) const;
279 TilePriority ComputePriorityForTile(const Tile* tile) const;
280 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; }
281 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; }
282 bool has_soon_border_rect_tiles() const {
283 return has_soon_border_rect_tiles_;
284 }
285 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
286
287 const gfx::Rect& current_visible_rect() const {
288 return current_visible_rect_;
289 }
290 gfx::Rect pending_visible_rect() const {
291 const PictureLayerTiling* pending_tiling =
292 client_->GetTree() == ACTIVE_TREE
293 ? client_->GetPendingOrActiveTwinTiling(this)
294 : this;
295 if (pending_tiling)
296 return pending_tiling->current_visible_rect();
297 return gfx::Rect();
298 }
299 const gfx::Rect& current_skewport_rect() const {
300 return current_skewport_rect_;
301 }
302 const gfx::Rect& current_soon_border_rect() const {
303 return current_soon_border_rect_;
304 }
305 const gfx::Rect& current_eventually_rect() const {
306 return current_eventually_rect_;
307 }
308 bool has_ever_been_updated() const {
309 return visible_rect_history_[0].frame_time_in_seconds != 0.0;
310 }
311 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles);
312 307
313 const size_t max_tiles_for_interest_area_; 308 const size_t max_tiles_for_interest_area_;
314 const float skewport_target_time_in_seconds_; 309 const float skewport_target_time_in_seconds_;
315 const int skewport_extrapolation_limit_in_content_pixels_; 310 const int skewport_extrapolation_limit_in_content_pixels_;
316 311
317 // Given properties. 312 // Given properties.
318 const float contents_scale_; 313 const float contents_scale_;
319 PictureLayerTilingClient* const client_; 314 PictureLayerTilingClient* const client_;
320 scoped_refptr<RasterSource> raster_source_; 315 scoped_refptr<RasterSource> raster_source_;
321 TileResolution resolution_; 316 TileResolution resolution_;
(...skipping 25 matching lines...) Expand all
347 342
348 private: 343 private:
349 DISALLOW_ASSIGN(PictureLayerTiling); 344 DISALLOW_ASSIGN(PictureLayerTiling);
350 345
351 RectExpansionCache expansion_cache_; 346 RectExpansionCache expansion_cache_;
352 }; 347 };
353 348
354 } // namespace cc 349 } // namespace cc
355 350
356 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 351 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/resources/eviction_tile_priority_queue.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698