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

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, 4 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 30 matching lines...) Expand all
41 virtual PicturePileImpl* GetPile() = 0; 41 virtual PicturePileImpl* GetPile() = 0;
42 virtual gfx::Size CalculateTileSize( 42 virtual gfx::Size CalculateTileSize(
43 const gfx::Size& content_bounds) const = 0; 43 const gfx::Size& content_bounds) const = 0;
44 virtual const Region* GetInvalidation() = 0; 44 virtual const Region* GetInvalidation() = 0;
45 virtual const PictureLayerTiling* GetTwinTiling( 45 virtual const PictureLayerTiling* GetTwinTiling(
46 const PictureLayerTiling* tiling) const = 0; 46 const PictureLayerTiling* tiling) const = 0;
47 virtual size_t GetMaxTilesForInterestArea() const = 0; 47 virtual size_t GetMaxTilesForInterestArea() const = 0;
48 virtual float GetSkewportTargetTimeInSeconds() const = 0; 48 virtual float GetSkewportTargetTimeInSeconds() const = 0;
49 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0; 49 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0;
50 virtual WhichTree GetTree() const = 0; 50 virtual WhichTree GetTree() const = 0;
51 virtual bool RequiresHighResToDraw() const = 0;
51 52
52 protected: 53 protected:
53 virtual ~PictureLayerTilingClient() {} 54 virtual ~PictureLayerTilingClient() {}
54 }; 55 };
55 56
56 class CC_EXPORT PictureLayerTiling { 57 class CC_EXPORT PictureLayerTiling {
57 public: 58 public:
58 enum EvictionCategory { 59 enum EvictionCategory {
59 EVENTUALLY, 60 EVENTUALLY,
60 EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION, 61 EVENTUALLY_AND_REQUIRED_FOR_ACTIVATION,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 enum Phase { 94 enum Phase {
94 VISIBLE_RECT, 95 VISIBLE_RECT,
95 SKEWPORT_RECT, 96 SKEWPORT_RECT,
96 SOON_BORDER_RECT, 97 SOON_BORDER_RECT,
97 EVENTUALLY_RECT 98 EVENTUALLY_RECT
98 }; 99 };
99 100
100 void AdvancePhase(); 101 void AdvancePhase();
101 bool TileNeedsRaster(Tile* tile) const { 102 bool TileNeedsRaster(Tile* tile) const {
102 RasterMode mode = tile->DetermineRasterModeForTree(tree_); 103 RasterMode mode = tile->DetermineRasterModeForTree(tree_);
103 return !tile->is_occluded(tree_) && tile->NeedsRasterForMode(mode); 104 return !tiling_->IsTileOccluded(tile) && tile->NeedsRasterForMode(mode);
104 } 105 }
105 106
106 PictureLayerTiling* tiling_; 107 PictureLayerTiling* tiling_;
107 108
108 Phase phase_; 109 Phase phase_;
109 WhichTree tree_; 110 WhichTree tree_;
110 111
111 Tile* current_tile_; 112 Tile* current_tile_;
112 TilingData::Iterator visible_iterator_; 113 TilingData::Iterator visible_iterator_;
113 TilingData::SpiralDifferenceIterator spiral_iterator_; 114 TilingData::SpiralDifferenceIterator spiral_iterator_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 160 }
160 161
161 void CreateAllTilesForTesting() { 162 void CreateAllTilesForTesting() {
162 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size())); 163 SetLiveTilesRect(gfx::Rect(tiling_data_.tiling_size()));
163 } 164 }
164 165
165 const TilingData& TilingDataForTesting() const { return tiling_data_; } 166 const TilingData& TilingDataForTesting() const { return tiling_data_; }
166 167
167 std::vector<Tile*> AllTilesForTesting() const { 168 std::vector<Tile*> AllTilesForTesting() const {
168 std::vector<Tile*> all_tiles; 169 std::vector<Tile*> all_tiles;
169 for (TileMap::const_iterator it = tiles_.begin(); 170 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
170 it != tiles_.end(); ++it)
171 all_tiles.push_back(it->second.get()); 171 all_tiles.push_back(it->second.get());
172 return all_tiles; 172 return all_tiles;
173 } 173 }
174 174
175 void UpdateAllTilePrioritiesForTesting() {
176 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
177 UpdateTileAndTwinPriority(it->second.get());
178 }
179
175 std::vector<scoped_refptr<Tile> > AllRefTilesForTesting() const { 180 std::vector<scoped_refptr<Tile> > AllRefTilesForTesting() const {
176 std::vector<scoped_refptr<Tile> > all_tiles; 181 std::vector<scoped_refptr<Tile> > all_tiles;
177 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) 182 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it)
178 all_tiles.push_back(it->second); 183 all_tiles.push_back(it->second);
179 return all_tiles; 184 return all_tiles;
180 } 185 }
181 186
187 void SetAllTilesOccludedForTesting() {
188 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end();
189 ++it) {
190 occlusion_set_.insert(std::make_pair(it->second->tiling_i_index(),
191 it->second->tiling_j_index()));
192 }
193 }
194
182 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 195 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
183 return current_visible_rect_; 196 return current_visible_rect_;
184 } 197 }
185 198
199 bool IsTileOccluded(const Tile* tile) const;
200 bool IsTileRequiredForActivation(const Tile* tile) const;
201
186 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 202 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
187 // (i.e. no valid resource) this tiling should still iterate over them. 203 // (i.e. no valid resource) this tiling should still iterate over them.
188 // The union of all geometry_rect calls for each element iterated over should 204 // The union of all geometry_rect calls for each element iterated over should
189 // exactly equal content_rect and no two geometry_rects should intersect. 205 // exactly equal content_rect and no two geometry_rects should intersect.
190 class CC_EXPORT CoverageIterator { 206 class CC_EXPORT CoverageIterator {
191 public: 207 public:
192 CoverageIterator(); 208 CoverageIterator();
193 CoverageIterator(const PictureLayerTiling* tiling, 209 CoverageIterator(const PictureLayerTiling* tiling,
194 float dest_scale, 210 float dest_scale,
195 const gfx::Rect& rect); 211 const gfx::Rect& rect);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 252
237 void UpdateTilePriorities( 253 void UpdateTilePriorities(
238 WhichTree tree, 254 WhichTree tree,
239 const gfx::Rect& visible_layer_rect, 255 const gfx::Rect& visible_layer_rect,
240 float ideal_contents_scale, 256 float ideal_contents_scale,
241 double current_frame_time_in_seconds, 257 double current_frame_time_in_seconds,
242 const OcclusionTracker<LayerImpl>* occlusion_tracker, 258 const OcclusionTracker<LayerImpl>* occlusion_tracker,
243 const LayerImpl* render_target, 259 const LayerImpl* render_target,
244 const gfx::Transform& draw_transform); 260 const gfx::Transform& draw_transform);
245 261
246 // Copies the src_tree priority into the dst_tree priority for all tiles.
247 // The src_tree priority is reset to the lowest priority possible. This
248 // also updates the pile on each tile to be the current client's pile.
249 void DidBecomeActive();
250
251 // Resets the active priority for all tiles in a tiling, when an active
252 // tiling is becoming recycled. This may include some tiles which are
253 // not in the the pending tiling (due to invalidations). This must
254 // be called before DidBecomeActive, as it resets the active priority
255 // while DidBecomeActive promotes pending priority on a similar set of tiles.
256 void DidBecomeRecycled();
257
258 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { 262 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) {
259 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; 263 return frame_time_in_seconds != last_impl_frame_time_in_seconds_;
260 } 264 }
261 265
262 void AsValueInto(base::debug::TracedValue* array) const; 266 void AsValueInto(base::debug::TracedValue* array) const;
263 size_t GPUMemoryUsageInBytes() const; 267 size_t GPUMemoryUsageInBytes() const;
264 268
265 struct RectExpansionCache { 269 struct RectExpansionCache {
266 RectExpansionCache(); 270 RectExpansionCache();
267 271
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 310
307 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority); 311 void UpdateEvictionCacheIfNeeded(TreePriority tree_priority);
308 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority, 312 const std::vector<Tile*>* GetEvictionTiles(TreePriority tree_priority,
309 EvictionCategory category); 313 EvictionCategory category);
310 314
311 void Invalidate(const Region& layer_region); 315 void Invalidate(const Region& layer_region);
312 316
313 void DoInvalidate(const Region& layer_region, 317 void DoInvalidate(const Region& layer_region,
314 bool recreate_invalidated_tiles); 318 bool recreate_invalidated_tiles);
315 319
320 void UpdateTileAndTwinPriority(Tile* tile) const;
321 void UpdateTilePriority(Tile* tile) const;
322
316 // Given properties. 323 // Given properties.
317 float contents_scale_; 324 float contents_scale_;
318 gfx::Size layer_bounds_; 325 gfx::Size layer_bounds_;
319 TileResolution resolution_; 326 TileResolution resolution_;
320 PictureLayerTilingClient* client_; 327 PictureLayerTilingClient* client_;
321 328
322 // Internal data. 329 // Internal data.
323 TilingData tiling_data_; 330 TilingData tiling_data_;
324 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 331 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
325 gfx::Rect live_tiles_rect_; 332 gfx::Rect live_tiles_rect_;
326 333
334 base::hash_set<std::pair<int, int> > occlusion_set_;
335
327 // State saved for computing velocities based upon finite differences. 336 // State saved for computing velocities based upon finite differences.
328 double last_impl_frame_time_in_seconds_; 337 double last_impl_frame_time_in_seconds_;
329 gfx::Rect last_visible_rect_in_content_space_; 338 gfx::Rect last_visible_rect_in_content_space_;
339 float content_to_screen_scale_;
330 340
331 // Iteration rects in content space 341 // Iteration rects in content space
332 gfx::Rect current_visible_rect_; 342 gfx::Rect current_visible_rect_;
333 gfx::Rect current_skewport_rect_; 343 gfx::Rect current_skewport_rect_;
334 gfx::Rect current_soon_border_rect_; 344 gfx::Rect current_soon_border_rect_;
335 gfx::Rect current_eventually_rect_; 345 gfx::Rect current_eventually_rect_;
336 346
337 bool has_visible_rect_tiles_; 347 bool has_visible_rect_tiles_;
338 bool has_skewport_rect_tiles_; 348 bool has_skewport_rect_tiles_;
339 bool has_soon_border_rect_tiles_; 349 bool has_soon_border_rect_tiles_;
(...skipping 14 matching lines...) Expand all
354 364
355 private: 365 private:
356 DISALLOW_ASSIGN(PictureLayerTiling); 366 DISALLOW_ASSIGN(PictureLayerTiling);
357 367
358 RectExpansionCache expansion_cache_; 368 RectExpansionCache expansion_cache_;
359 }; 369 };
360 370
361 } // namespace cc 371 } // namespace cc
362 372
363 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 373 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698