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

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: 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())
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_; 87 gfx::Rect visible_rect_in_content_space_;
84 gfx::Rect skewport_in_content_space_; 88 gfx::Rect skewport_in_content_space_;
85 gfx::Rect eventually_rect_in_content_space_; 89 gfx::Rect eventually_rect_in_content_space_;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 ~PictureLayerTiling(); 126 ~PictureLayerTiling();
123 127
124 // Create a tiling with no tiles. CreateTiles must be called to add some. 128 // Create a tiling with no tiles. CreateTiles must be called to add some.
125 static scoped_ptr<PictureLayerTiling> Create( 129 static scoped_ptr<PictureLayerTiling> Create(
126 float contents_scale, 130 float contents_scale,
127 const gfx::Size& layer_bounds, 131 const gfx::Size& layer_bounds,
128 PictureLayerTilingClient* client); 132 PictureLayerTilingClient* client);
129 gfx::Size layer_bounds() const { return layer_bounds_; } 133 gfx::Size layer_bounds() const { return layer_bounds_; }
130 void SetLayerBounds(const gfx::Size& layer_bounds); 134 void SetLayerBounds(const gfx::Size& layer_bounds);
131 void Invalidate(const Region& layer_region); 135 void Invalidate(const Region& layer_region);
132 void RemoveTilesInRegion(const Region& layer_region);
133 void CreateMissingTilesInLiveTilesRect();
134 136
135 void SetClient(PictureLayerTilingClient* client); 137 void SetClient(PictureLayerTilingClient* client);
136 void set_resolution(TileResolution resolution) { resolution_ = resolution; } 138 void set_resolution(TileResolution resolution) { resolution_ = resolution; }
137 TileResolution resolution() const { return resolution_; } 139 TileResolution resolution() const { return resolution_; }
138 140
139 gfx::Rect TilingRect() const; 141 gfx::Rect TilingRect() const;
140 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 142 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
141 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 143 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
142 float contents_scale() const { return contents_scale_; } 144 float contents_scale() const { return contents_scale_; }
143 145
144 Tile* TileAt(int i, int j) const { 146 Tile* TileAt(int i, int j) const {
145 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 147 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
146 return (iter == tiles_.end()) ? NULL : iter->second.get(); 148 return (iter == tiles_.end()) ? NULL : iter->second.get();
147 } 149 }
148 150
151 Tile* GetOrCreateTileAt(int i, int j);
152
153 void CreateInterestRectTilesForTesting() {
154 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, true); iter;
155 ++iter) {
156 Tile* tile = GetOrCreateTileAt(iter.index_x(), iter.index_y());
157 if (tile) {
158 UpdateTileOcclusion(tile);
159 SetTilePriority(tile, true);
160 }
161 }
162 }
163
149 void CreateAllTilesForTesting() { 164 void CreateAllTilesForTesting() {
150 SetLiveTilesRect(tiling_data_.tiling_rect()); 165 SetLiveTilesRect(tiling_data_.tiling_rect());
166 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, true); iter;
167 ++iter) {
168 Tile* tile = GetOrCreateTileAt(iter.index_x(), iter.index_y());
169 if (tile) {
170 UpdateTileOcclusion(tile);
171 SetTilePriority(tile, true);
172 }
173 }
151 } 174 }
152 175
153 std::vector<Tile*> AllTilesForTesting() const { 176 std::vector<Tile*> AllTilesForTesting() const {
154 std::vector<Tile*> all_tiles; 177 std::vector<Tile*> all_tiles;
155 for (TileMap::const_iterator it = tiles_.begin(); 178 for (TileMap::const_iterator it = tiles_.begin();
156 it != tiles_.end(); ++it) 179 it != tiles_.end(); ++it)
157 all_tiles.push_back(it->second.get()); 180 all_tiles.push_back(it->second.get());
158 return all_tiles; 181 return all_tiles;
159 } 182 }
160 183
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 double current_frame_time_in_seconds, 239 double current_frame_time_in_seconds,
217 const OcclusionTracker<LayerImpl>* occlusion_tracker, 240 const OcclusionTracker<LayerImpl>* occlusion_tracker,
218 const LayerImpl* render_target, 241 const LayerImpl* render_target,
219 const gfx::Transform& draw_transform); 242 const gfx::Transform& draw_transform);
220 243
221 // Copies the src_tree priority into the dst_tree priority for all tiles. 244 // 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 245 // 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. 246 // also updates the pile on each tile to be the current client's pile.
224 void DidBecomeActive(); 247 void DidBecomeActive();
225 248
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(); 249 void UpdateTilesToCurrentPile();
234 250
235 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { 251 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) {
236 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; 252 return frame_time_in_seconds != last_impl_frame_time_in_seconds_;
237 } 253 }
238 254
239 scoped_ptr<base::Value> AsValue() const; 255 scoped_ptr<base::Value> AsValue() const;
240 size_t GPUMemoryUsageInBytes() const; 256 size_t GPUMemoryUsageInBytes() const;
241 257
242 struct RectExpansionCache { 258 struct RectExpansionCache {
(...skipping 22 matching lines...) Expand all
265 friend class TilingEvictionTileIterator; 281 friend class TilingEvictionTileIterator;
266 282
267 typedef std::pair<int, int> TileMapKey; 283 typedef std::pair<int, int> TileMapKey;
268 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; 284 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
269 285
270 PictureLayerTiling(float contents_scale, 286 PictureLayerTiling(float contents_scale,
271 const gfx::Size& layer_bounds, 287 const gfx::Size& layer_bounds,
272 PictureLayerTilingClient* client); 288 PictureLayerTilingClient* client);
273 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 289 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
274 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); 290 Tile* CreateTile(int i, int j, const PictureLayerTiling* twin_tiling);
291 void UpdateTileOcclusion(Tile* tile);
292 bool IsTileRequiredForActivation(Tile* tile) const;
275 293
276 // Computes a skewport. The calculation extrapolates the last visible 294 // Computes a skewport. The calculation extrapolates the last visible
277 // rect and the current visible rect to expand the skewport to where it 295 // 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 296 // would be in |skewport_target_time| seconds. Note that the skewport
279 // is guaranteed to contain the current visible rect. 297 // is guaranteed to contain the current visible rect.
280 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, 298 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds,
281 const gfx::Rect& visible_rect_in_content_space) 299 const gfx::Rect& visible_rect_in_content_space)
282 const; 300 const;
283 301
284 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); 302 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority);
285 void DoInvalidate(const Region& layer_region, bool recreate_tiles); 303 void DoInvalidate(const Region& layer_region, bool recreate_tiles);
286 304
305 void SetTilePriority(Tile* tile, bool include_twin) const;
306
287 // Given properties. 307 // Given properties.
288 float contents_scale_; 308 float contents_scale_;
289 gfx::Size layer_bounds_; 309 gfx::Size layer_bounds_;
290 TileResolution resolution_; 310 TileResolution resolution_;
291 PictureLayerTilingClient* client_; 311 PictureLayerTilingClient* client_;
292 312
293 // Internal data. 313 // Internal data.
294 TilingData tiling_data_; 314 TilingData tiling_data_;
295 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 315 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
296 gfx::Rect live_tiles_rect_; 316 gfx::Rect live_tiles_rect_;
297 317
318 base::hash_set<std::pair<int, int> > occlusion_set_;
vmpstr 2014/07/02 23:51:29 The idea here is to just store indecies of occlude
319
298 // State saved for computing velocities based upon finite differences. 320 // State saved for computing velocities based upon finite differences.
299 double last_impl_frame_time_in_seconds_; 321 double last_impl_frame_time_in_seconds_;
300 gfx::Rect last_visible_rect_in_content_space_; 322 gfx::Rect last_visible_rect_in_content_space_;
323 float content_to_screen_scale_;
301 324
302 gfx::Rect current_visible_rect_in_content_space_; 325 gfx::Rect current_visible_rect_in_content_space_;
303 gfx::Rect current_skewport_; 326 gfx::Rect current_skewport_;
304 gfx::Rect current_eventually_rect_; 327 gfx::Rect current_eventually_rect_;
305 gfx::Rect current_soon_border_rect_; 328 gfx::Rect current_soon_border_rect_;
306 329
307 std::vector<Tile*> eviction_tiles_cache_; 330 std::vector<Tile*> eviction_tiles_cache_;
308 bool eviction_tiles_cache_valid_;
309 TreePriority eviction_cache_tree_priority_;
310 331
311 private: 332 private:
312 DISALLOW_ASSIGN(PictureLayerTiling); 333 DISALLOW_ASSIGN(PictureLayerTiling);
313 334
314 RectExpansionCache expansion_cache_; 335 RectExpansionCache expansion_cache_;
315 }; 336 };
316 337
317 } // namespace cc 338 } // namespace cc
318 339
319 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 340 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698