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

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

Issue 367833003: cc: Start using raster/eviction iterators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: perf test fix Created 6 years, 5 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 | Annotate | Revision Log
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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 const gfx::Rect& content_rect) = 0; 34 const gfx::Rect& content_rect) = 0;
35 virtual PicturePileImpl* GetPile() = 0; 35 virtual PicturePileImpl* GetPile() = 0;
36 virtual gfx::Size CalculateTileSize( 36 virtual gfx::Size CalculateTileSize(
37 const gfx::Size& content_bounds) const = 0; 37 const gfx::Size& content_bounds) const = 0;
38 virtual const Region* GetInvalidation() = 0; 38 virtual const Region* GetInvalidation() = 0;
39 virtual const PictureLayerTiling* GetTwinTiling( 39 virtual const PictureLayerTiling* GetTwinTiling(
40 const PictureLayerTiling* tiling) const = 0; 40 const PictureLayerTiling* tiling) const = 0;
41 virtual size_t GetMaxTilesForInterestArea() const = 0; 41 virtual size_t GetMaxTilesForInterestArea() const = 0;
42 virtual float GetSkewportTargetTimeInSeconds() const = 0; 42 virtual float GetSkewportTargetTimeInSeconds() const = 0;
43 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0; 43 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0;
44 virtual WhichTree GetTree() const = 0;
45 virtual bool RequiresHighResToDraw() const = 0;
44 46
45 protected: 47 protected:
46 virtual ~PictureLayerTilingClient() {} 48 virtual ~PictureLayerTilingClient() {}
47 }; 49 };
48 50
49 class CC_EXPORT PictureLayerTiling { 51 class CC_EXPORT PictureLayerTiling {
50 public: 52 public:
51 class CC_EXPORT TilingRasterTileIterator { 53 class CC_EXPORT TilingRasterTileIterator {
52 public: 54 public:
53 TilingRasterTileIterator(); 55 TilingRasterTileIterator();
(...skipping 12 matching lines...) Expand all
66 return tiling_->tiling_data_.TileBounds(visible_iterator_.index_x(), 68 return tiling_->tiling_data_.TileBounds(visible_iterator_.index_x(),
67 visible_iterator_.index_y()); 69 visible_iterator_.index_y());
68 } 70 }
69 return tiling_->tiling_data_.TileBounds(spiral_iterator_.index_x(), 71 return tiling_->tiling_data_.TileBounds(spiral_iterator_.index_x(),
70 spiral_iterator_.index_y()); 72 spiral_iterator_.index_y());
71 } 73 }
72 74
73 private: 75 private:
74 void AdvancePhase(); 76 void AdvancePhase();
75 bool TileNeedsRaster(Tile* tile) const { 77 bool TileNeedsRaster(Tile* tile) const {
78 if (tile->is_occluded(tree_))
79 return false;
76 RasterMode mode = tile->DetermineRasterModeForTree(tree_); 80 RasterMode mode = tile->DetermineRasterModeForTree(tree_);
77 return tile->NeedsRasterForMode(mode); 81 return tile->NeedsRasterForMode(mode);
78 } 82 }
79 83
80 PictureLayerTiling* tiling_; 84 PictureLayerTiling* tiling_;
81 85
82 TilePriority::PriorityBin type_; 86 TilePriority::PriorityBin type_;
83 gfx::Rect visible_rect_in_content_space_;
84 gfx::Rect skewport_in_content_space_;
85 gfx::Rect eventually_rect_in_content_space_;
86 gfx::Rect soon_border_rect_in_content_space_;
87 WhichTree tree_; 87 WhichTree tree_;
88 88
89 Tile* current_tile_; 89 Tile* current_tile_;
90 TilingData::Iterator visible_iterator_; 90 TilingData::Iterator visible_iterator_;
91 TilingData::SpiralDifferenceIterator spiral_iterator_; 91 TilingData::SpiralDifferenceIterator spiral_iterator_;
92 bool skewport_processed_; 92 bool skewport_processed_;
93 }; 93 };
94 94
95 class CC_EXPORT TilingEvictionTileIterator { 95 class CC_EXPORT TilingEvictionTileIterator {
96 public: 96 public:
(...skipping 25 matching lines...) Expand all
122 ~PictureLayerTiling(); 122 ~PictureLayerTiling();
123 123
124 // Create a tiling with no tiles. CreateTiles must be called to add some. 124 // Create a tiling with no tiles. CreateTiles must be called to add some.
125 static scoped_ptr<PictureLayerTiling> Create( 125 static scoped_ptr<PictureLayerTiling> Create(
126 float contents_scale, 126 float contents_scale,
127 const gfx::Size& layer_bounds, 127 const gfx::Size& layer_bounds,
128 PictureLayerTilingClient* client); 128 PictureLayerTilingClient* client);
129 gfx::Size layer_bounds() const { return layer_bounds_; } 129 gfx::Size layer_bounds() const { return layer_bounds_; }
130 void SetLayerBounds(const gfx::Size& layer_bounds); 130 void SetLayerBounds(const gfx::Size& layer_bounds);
131 void Invalidate(const Region& layer_region); 131 void Invalidate(const Region& layer_region);
132 void RemoveTilesInRegion(const Region& layer_region);
133 void CreateMissingTilesInLiveTilesRect();
134 132
135 void SetClient(PictureLayerTilingClient* client); 133 void SetClient(PictureLayerTilingClient* client);
136 void set_resolution(TileResolution resolution) { resolution_ = resolution; } 134 void set_resolution(TileResolution resolution) { resolution_ = resolution; }
137 TileResolution resolution() const { return resolution_; } 135 TileResolution resolution() const { return resolution_; }
138 136
139 gfx::Rect TilingRect() const; 137 gfx::Rect TilingRect() const;
140 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 138 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
141 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 139 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
142 float contents_scale() const { return contents_scale_; } 140 float contents_scale() const { return contents_scale_; }
143 141
144 Tile* TileAt(int i, int j) const { 142 Tile* TileAt(int i, int j) const {
145 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 143 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
146 return (iter == tiles_.end()) ? NULL : iter->second.get(); 144 return (iter == tiles_.end()) ? NULL : iter->second.get();
147 } 145 }
148 146
147 Tile* GetOrCreateTileAt(int i, int j);
148
149 void CreateInterestRectTilesForTesting() {
150 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, true); iter;
151 ++iter) {
152 Tile* tile = GetOrCreateTileAt(iter.index_x(), iter.index_y());
153 if (tile) {
154 UpdateTileOcclusion(tile);
155 SetTileAndTwinPriority(tile);
156 }
157 }
158 }
159
149 void CreateAllTilesForTesting() { 160 void CreateAllTilesForTesting() {
150 SetLiveTilesRect(tiling_data_.tiling_rect()); 161 SetLiveTilesRect(tiling_data_.tiling_rect());
162 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, true); iter;
163 ++iter) {
164 Tile* tile = GetOrCreateTileAt(iter.index_x(), iter.index_y());
165 if (tile) {
166 UpdateTileOcclusion(tile);
167 SetTileAndTwinPriority(tile);
168 }
169 }
151 } 170 }
152 171
153 std::vector<Tile*> AllTilesForTesting() const { 172 std::vector<Tile*> AllTilesForTesting() const {
154 std::vector<Tile*> all_tiles; 173 std::vector<Tile*> all_tiles;
155 for (TileMap::const_iterator it = tiles_.begin(); 174 for (TileMap::const_iterator it = tiles_.begin();
156 it != tiles_.end(); ++it) 175 it != tiles_.end(); ++it)
157 all_tiles.push_back(it->second.get()); 176 all_tiles.push_back(it->second.get());
158 return all_tiles; 177 return all_tiles;
159 } 178 }
160 179
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 double current_frame_time_in_seconds, 235 double current_frame_time_in_seconds,
217 const OcclusionTracker<LayerImpl>* occlusion_tracker, 236 const OcclusionTracker<LayerImpl>* occlusion_tracker,
218 const LayerImpl* render_target, 237 const LayerImpl* render_target,
219 const gfx::Transform& draw_transform); 238 const gfx::Transform& draw_transform);
220 239
221 // Copies the src_tree priority into the dst_tree priority for all tiles. 240 // Copies the src_tree priority into the dst_tree priority for all tiles.
222 // The src_tree priority is reset to the lowest priority possible. This 241 // The src_tree priority is reset to the lowest priority possible. This
223 // also updates the pile on each tile to be the current client's pile. 242 // also updates the pile on each tile to be the current client's pile.
224 void DidBecomeActive(); 243 void DidBecomeActive();
225 244
226 // Resets the active priority for all tiles in a tiling, when an active
227 // tiling is becoming recycled. This may include some tiles which are
228 // not in the the pending tiling (due to invalidations). This must
229 // be called before DidBecomeActive, as it resets the active priority
230 // while DidBecomeActive promotes pending priority on a similar set of tiles.
231 void DidBecomeRecycled();
232
233 void UpdateTilesToCurrentPile(); 245 void UpdateTilesToCurrentPile();
234 246
235 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { 247 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) {
236 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; 248 return frame_time_in_seconds != last_impl_frame_time_in_seconds_;
237 } 249 }
238 250
239 scoped_ptr<base::Value> AsValue() const; 251 scoped_ptr<base::Value> AsValue() const;
240 size_t GPUMemoryUsageInBytes() const; 252 size_t GPUMemoryUsageInBytes() const;
241 253
242 struct RectExpansionCache { 254 struct RectExpansionCache {
(...skipping 22 matching lines...) Expand all
265 friend class TilingEvictionTileIterator; 277 friend class TilingEvictionTileIterator;
266 278
267 typedef std::pair<int, int> TileMapKey; 279 typedef std::pair<int, int> TileMapKey;
268 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; 280 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
269 281
270 PictureLayerTiling(float contents_scale, 282 PictureLayerTiling(float contents_scale,
271 const gfx::Size& layer_bounds, 283 const gfx::Size& layer_bounds,
272 PictureLayerTilingClient* client); 284 PictureLayerTilingClient* client);
273 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 285 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
274 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); 286 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling);
287 void UpdateTileOcclusion(Tile* tile);
288 bool IsTileRequiredForActivation(Tile* tile) const;
275 289
276 // Computes a skewport. The calculation extrapolates the last visible 290 // Computes a skewport. The calculation extrapolates the last visible
277 // rect and the current visible rect to expand the skewport to where it 291 // rect and the current visible rect to expand the skewport to where it
278 // would be in |skewport_target_time| seconds. Note that the skewport 292 // would be in |skewport_target_time| seconds. Note that the skewport
279 // is guaranteed to contain the current visible rect. 293 // is guaranteed to contain the current visible rect.
280 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, 294 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds,
281 const gfx::Rect& visible_rect_in_content_space) 295 const gfx::Rect& visible_rect_in_content_space)
282 const; 296 const;
283 297
284 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); 298 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority);
285 void DoInvalidate(const Region& layer_region, bool recreate_tiles); 299 void DoInvalidate(const Region& layer_region, bool recreate_tiles);
286 300
301 void SetTileAndTwinPriority(Tile* tile) const;
302 void SetTilePriority(Tile* tile) const;
303
287 // Given properties. 304 // Given properties.
288 float contents_scale_; 305 float contents_scale_;
289 gfx::Size layer_bounds_; 306 gfx::Size layer_bounds_;
290 TileResolution resolution_; 307 TileResolution resolution_;
291 PictureLayerTilingClient* client_; 308 PictureLayerTilingClient* client_;
292 309
293 // Internal data. 310 // Internal data.
294 TilingData tiling_data_; 311 TilingData tiling_data_;
295 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 312 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
296 gfx::Rect live_tiles_rect_; 313 gfx::Rect live_tiles_rect_;
297 314
315 base::hash_set<std::pair<int, int> > occlusion_set_;
316
298 // State saved for computing velocities based upon finite differences. 317 // State saved for computing velocities based upon finite differences.
299 double last_impl_frame_time_in_seconds_; 318 double last_impl_frame_time_in_seconds_;
300 gfx::Rect last_visible_rect_in_content_space_; 319 gfx::Rect last_visible_rect_in_content_space_;
320 float content_to_screen_scale_;
301 321
302 gfx::Rect current_visible_rect_in_content_space_; 322 gfx::Rect current_visible_rect_in_content_space_;
303 gfx::Rect current_skewport_; 323 gfx::Rect current_skewport_;
304 gfx::Rect current_eventually_rect_; 324 gfx::Rect current_eventually_rect_;
305 gfx::Rect current_soon_border_rect_; 325 gfx::Rect current_soon_border_rect_;
306 326
327 bool current_visible_rect_has_tiles_;
328 bool current_skewport_has_tiles_;
329 bool current_eventually_rect_has_tiles_;
330 bool current_soon_border_rect_has_tiles_;
331
307 std::vector<Tile*> eviction_tiles_cache_; 332 std::vector<Tile*> eviction_tiles_cache_;
308 bool eviction_tiles_cache_valid_;
309 TreePriority eviction_cache_tree_priority_;
310 333
311 private: 334 private:
312 DISALLOW_ASSIGN(PictureLayerTiling); 335 DISALLOW_ASSIGN(PictureLayerTiling);
313 336
314 RectExpansionCache expansion_cache_; 337 RectExpansionCache expansion_cache_;
315 }; 338 };
316 339
317 } // namespace cc 340 } // namespace cc
318 341
319 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 342 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698