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

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: update 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 UpdateTilesToCurrentPile(const Region& layer_invalidation, 130 void UpdateTilesToCurrentPile(const Region& layer_invalidation,
131 const gfx::Size& new_layer_bounds); 131 const gfx::Size& new_layer_bounds);
132 void CreateMissingTilesInLiveTilesRect();
133 132
134 void SetClient(PictureLayerTilingClient* client); 133 void SetClient(PictureLayerTilingClient* client);
135 void set_resolution(TileResolution resolution) { resolution_ = resolution; } 134 void set_resolution(TileResolution resolution) { resolution_ = resolution; }
136 TileResolution resolution() const { return resolution_; } 135 TileResolution resolution() const { return resolution_; }
137 136
138 gfx::Rect TilingRect() const; 137 gfx::Rect TilingRect() const;
139 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 138 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
140 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 139 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
141 float contents_scale() const { return contents_scale_; } 140 float contents_scale() const { return contents_scale_; }
142 141
143 Tile* TileAt(int i, int j) const { 142 Tile* TileAt(int i, int j) const {
144 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 143 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
145 return (iter == tiles_.end()) ? NULL : iter->second.get(); 144 return (iter == tiles_.end()) ? NULL : iter->second.get();
146 } 145 }
147 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
148 void CreateAllTilesForTesting() { 160 void CreateAllTilesForTesting() {
149 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 }
150 } 170 }
151 171
152 const TilingData& TilingDataForTesting() const { return tiling_data_; } 172 const TilingData& TilingDataForTesting() const { return tiling_data_; }
153 173
154 std::vector<Tile*> AllTilesForTesting() const { 174 std::vector<Tile*> AllTilesForTesting() const {
155 std::vector<Tile*> all_tiles; 175 std::vector<Tile*> all_tiles;
156 for (TileMap::const_iterator it = tiles_.begin(); 176 for (TileMap::const_iterator it = tiles_.begin();
157 it != tiles_.end(); ++it) 177 it != tiles_.end(); ++it)
158 all_tiles.push_back(it->second.get()); 178 all_tiles.push_back(it->second.get());
159 return all_tiles; 179 return all_tiles;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 double current_frame_time_in_seconds, 237 double current_frame_time_in_seconds,
218 const OcclusionTracker<LayerImpl>* occlusion_tracker, 238 const OcclusionTracker<LayerImpl>* occlusion_tracker,
219 const LayerImpl* render_target, 239 const LayerImpl* render_target,
220 const gfx::Transform& draw_transform); 240 const gfx::Transform& draw_transform);
221 241
222 // Copies the src_tree priority into the dst_tree priority for all tiles. 242 // Copies the src_tree priority into the dst_tree priority for all tiles.
223 // The src_tree priority is reset to the lowest priority possible. This 243 // The src_tree priority is reset to the lowest priority possible. This
224 // also updates the pile on each tile to be the current client's pile. 244 // also updates the pile on each tile to be the current client's pile.
225 void DidBecomeActive(); 245 void DidBecomeActive();
226 246
227 // Resets the active priority for all tiles in a tiling, when an active
228 // tiling is becoming recycled. This may include some tiles which are
229 // not in the the pending tiling (due to invalidations). This must
230 // be called before DidBecomeActive, as it resets the active priority
231 // while DidBecomeActive promotes pending priority on a similar set of tiles.
232 void DidBecomeRecycled();
233
234 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { 247 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) {
235 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; 248 return frame_time_in_seconds != last_impl_frame_time_in_seconds_;
236 } 249 }
237 250
238 scoped_ptr<base::Value> AsValue() const; 251 scoped_ptr<base::Value> AsValue() const;
239 size_t GPUMemoryUsageInBytes() const; 252 size_t GPUMemoryUsageInBytes() const;
240 253
241 struct RectExpansionCache { 254 struct RectExpansionCache {
242 RectExpansionCache(); 255 RectExpansionCache();
243 256
(...skipping 20 matching lines...) Expand all
264 friend class TilingEvictionTileIterator; 277 friend class TilingEvictionTileIterator;
265 278
266 typedef std::pair<int, int> TileMapKey; 279 typedef std::pair<int, int> TileMapKey;
267 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; 280 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
268 281
269 PictureLayerTiling(float contents_scale, 282 PictureLayerTiling(float contents_scale,
270 const gfx::Size& layer_bounds, 283 const gfx::Size& layer_bounds,
271 PictureLayerTilingClient* client); 284 PictureLayerTilingClient* client);
272 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 285 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
273 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;
274 289
275 // Computes a skewport. The calculation extrapolates the last visible 290 // Computes a skewport. The calculation extrapolates the last visible
276 // 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
277 // would be in |skewport_target_time| seconds. Note that the skewport 292 // would be in |skewport_target_time| seconds. Note that the skewport
278 // is guaranteed to contain the current visible rect. 293 // is guaranteed to contain the current visible rect.
279 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, 294 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds,
280 const gfx::Rect& visible_rect_in_content_space) 295 const gfx::Rect& visible_rect_in_content_space)
281 const; 296 const;
282 297
283 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); 298 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority);
284 void Invalidate(const Region& layer_region); 299 void Invalidate(const Region& layer_region);
285 300
301 void SetTileAndTwinPriority(Tile* tile) const;
302 void SetTilePriority(Tile* tile) const;
303
286 // Given properties. 304 // Given properties.
287 float contents_scale_; 305 float contents_scale_;
288 gfx::Size layer_bounds_; 306 gfx::Size layer_bounds_;
289 TileResolution resolution_; 307 TileResolution resolution_;
290 PictureLayerTilingClient* client_; 308 PictureLayerTilingClient* client_;
291 309
292 // Internal data. 310 // Internal data.
293 TilingData tiling_data_; 311 TilingData tiling_data_;
294 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.
295 gfx::Rect live_tiles_rect_; 313 gfx::Rect live_tiles_rect_;
296 314
315 base::hash_set<std::pair<int, int> > occlusion_set_;
316
297 // State saved for computing velocities based upon finite differences. 317 // State saved for computing velocities based upon finite differences.
298 double last_impl_frame_time_in_seconds_; 318 double last_impl_frame_time_in_seconds_;
299 gfx::Rect last_visible_rect_in_content_space_; 319 gfx::Rect last_visible_rect_in_content_space_;
320 float content_to_screen_scale_;
300 321
301 gfx::Rect current_visible_rect_in_content_space_; 322 gfx::Rect current_visible_rect_in_content_space_;
302 gfx::Rect current_skewport_; 323 gfx::Rect current_skewport_;
303 gfx::Rect current_eventually_rect_; 324 gfx::Rect current_eventually_rect_;
304 gfx::Rect current_soon_border_rect_; 325 gfx::Rect current_soon_border_rect_;
305 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
306 std::vector<Tile*> eviction_tiles_cache_; 332 std::vector<Tile*> eviction_tiles_cache_;
307 bool eviction_tiles_cache_valid_;
308 TreePriority eviction_cache_tree_priority_;
309 333
310 private: 334 private:
311 DISALLOW_ASSIGN(PictureLayerTiling); 335 DISALLOW_ASSIGN(PictureLayerTiling);
312 336
313 RectExpansionCache expansion_cache_; 337 RectExpansionCache expansion_cache_;
314 }; 338 };
315 339
316 } // namespace cc 340 } // namespace cc
317 341
318 #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