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

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

Powered by Google App Engine
This is Rietveld 408576698