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

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

Issue 183663003: cc: Add tiling raster tile iterators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 27 matching lines...) Expand all
38 virtual size_t GetMaxTilesForInterestArea() const = 0; 38 virtual size_t GetMaxTilesForInterestArea() const = 0;
39 virtual float GetSkewportTargetTimeInSeconds() const = 0; 39 virtual float GetSkewportTargetTimeInSeconds() const = 0;
40 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0; 40 virtual int GetSkewportExtrapolationLimitInContentPixels() const = 0;
41 41
42 protected: 42 protected:
43 virtual ~PictureLayerTilingClient() {} 43 virtual ~PictureLayerTilingClient() {}
44 }; 44 };
45 45
46 class CC_EXPORT PictureLayerTiling { 46 class CC_EXPORT PictureLayerTiling {
47 public: 47 public:
48 class CC_EXPORT TilingRasterTileIterator {
49 public:
50 TilingRasterTileIterator();
51 explicit TilingRasterTileIterator(PictureLayerTiling* tiling);
52 ~TilingRasterTileIterator();
53
54 operator bool() const {
55 return tiling_ && tiling_->RasterTileForPriority(current_index_);
56 }
57 void operator++();
58 Tile* operator*() { return tiling_->RasterTileForPriority(current_index_); }
59
60 bool HasVisibleTiles() const {
61 if (!tiling_)
62 return false;
63 return tiling_->HasVisibleTilesAtOrAfterPriority(current_index_);
64 }
65
66 private:
67 PictureLayerTiling* tiling_;
68 size_t current_index_;
69 };
70
71 class TilingEvictionTileIterator {
72 public:
73 TilingEvictionTileIterator();
74 explicit TilingEvictionTileIterator(PictureLayerTiling* tiling);
75 ~TilingEvictionTileIterator();
76
77 operator bool() const {
78 return tiling_ && tiling_->EvictionTileForPriority(current_index_);
79 }
80 void operator++();
81 Tile* operator*() {
82 return tiling_->EvictionTileForPriority(current_index_);
83 }
84
85 private:
86 PictureLayerTiling* tiling_;
87 size_t current_index_;
88 };
89
48 ~PictureLayerTiling(); 90 ~PictureLayerTiling();
49 91
50 // Create a tiling with no tiles. CreateTiles must be called to add some. 92 // Create a tiling with no tiles. CreateTiles must be called to add some.
51 static scoped_ptr<PictureLayerTiling> Create( 93 static scoped_ptr<PictureLayerTiling> Create(
52 float contents_scale, 94 float contents_scale,
53 const gfx::Size& layer_bounds, 95 const gfx::Size& layer_bounds,
54 PictureLayerTilingClient* client); 96 PictureLayerTilingClient* client);
55 gfx::Size layer_bounds() const { return layer_bounds_; } 97 gfx::Size layer_bounds() const { return layer_bounds_; }
56 void SetLayerBounds(const gfx::Size& layer_bounds); 98 void SetLayerBounds(const gfx::Size& layer_bounds);
57 void Invalidate(const Region& layer_region); 99 void Invalidate(const Region& layer_region);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // be called before DidBecomeActive, as it resets the active priority 194 // be called before DidBecomeActive, as it resets the active priority
153 // while DidBecomeActive promotes pending priority on a similar set of tiles. 195 // while DidBecomeActive promotes pending priority on a similar set of tiles.
154 void DidBecomeRecycled(); 196 void DidBecomeRecycled();
155 197
156 void UpdateTilesToCurrentPile(); 198 void UpdateTilesToCurrentPile();
157 199
158 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) { 200 bool NeedsUpdateForFrameAtTime(double frame_time_in_seconds) {
159 return frame_time_in_seconds != last_impl_frame_time_in_seconds_; 201 return frame_time_in_seconds != last_impl_frame_time_in_seconds_;
160 } 202 }
161 203
204 size_t RequiredGPUMemoryInBytes() const;
205
162 scoped_ptr<base::Value> AsValue() const; 206 scoped_ptr<base::Value> AsValue() const;
163 size_t GPUMemoryUsageInBytes() const; 207 size_t GPUMemoryUsageInBytes() const;
164 208
165 struct RectExpansionCache { 209 struct RectExpansionCache {
166 RectExpansionCache(); 210 RectExpansionCache();
167 211
168 gfx::Rect previous_start; 212 gfx::Rect previous_start;
169 gfx::Rect previous_bounds; 213 gfx::Rect previous_bounds;
170 gfx::Rect previous_result; 214 gfx::Rect previous_result;
171 int64 previous_target; 215 int64 previous_target;
172 }; 216 };
173 217
174 static 218 static
175 gfx::Rect ExpandRectEquallyToAreaBoundedBy( 219 gfx::Rect ExpandRectEquallyToAreaBoundedBy(
176 const gfx::Rect& starting_rect, 220 const gfx::Rect& starting_rect,
177 int64 target_area, 221 int64 target_area,
178 const gfx::Rect& bounding_rect, 222 const gfx::Rect& bounding_rect,
179 RectExpansionCache* cache); 223 RectExpansionCache* cache);
180 224
181 bool has_ever_been_updated() const { 225 bool has_ever_been_updated() const {
182 return last_impl_frame_time_in_seconds_ != 0.0; 226 return last_impl_frame_time_in_seconds_ != 0.0;
183 } 227 }
184 228
185 protected: 229 protected:
230 friend class TilingRasterTileIterator;
231 friend class TilingEvictionTileIterator;
232
186 typedef std::pair<int, int> TileMapKey; 233 typedef std::pair<int, int> TileMapKey;
187 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap; 234 typedef base::hash_map<TileMapKey, scoped_refptr<Tile> > TileMap;
188 235
189 PictureLayerTiling(float contents_scale, 236 PictureLayerTiling(float contents_scale,
190 const gfx::Size& layer_bounds, 237 const gfx::Size& layer_bounds,
191 PictureLayerTilingClient* client); 238 PictureLayerTilingClient* client);
192 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 239 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
193 void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling); 240 void CreateTile(int i, int j, const PictureLayerTiling* twin_tiling);
194 241
195 // Computes a skewport. The calculation extrapolates the last visible 242 // Computes a skewport. The calculation extrapolates the last visible
196 // rect and the current visible rect to expand the skewport to where it 243 // rect and the current visible rect to expand the skewport to where it
197 // would be in |skewport_target_time| seconds. Note that the skewport 244 // would be in |skewport_target_time| seconds. Note that the skewport
198 // is guaranteed to contain the current visible rect. 245 // is guaranteed to contain the current visible rect.
199 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds, 246 gfx::Rect ComputeSkewport(double current_frame_time_in_seconds,
200 const gfx::Rect& visible_rect_in_content_space) 247 const gfx::Rect& visible_rect_in_content_space)
201 const; 248 const;
202 249
250 Tile* RasterTileForPriority(size_t priority_index);
251 Tile* EvictionTileForPriority(size_t priority_index);
252 bool HasVisibleTilesAtOrAfterPriority(size_t prioroity_index) const;
253
203 // Given properties. 254 // Given properties.
204 float contents_scale_; 255 float contents_scale_;
205 gfx::Size layer_bounds_; 256 gfx::Size layer_bounds_;
206 TileResolution resolution_; 257 TileResolution resolution_;
207 PictureLayerTilingClient* client_; 258 PictureLayerTilingClient* client_;
208 259
209 // Internal data. 260 // Internal data.
210 TilingData tiling_data_; 261 TilingData tiling_data_;
211 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 262 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
212 gfx::Rect live_tiles_rect_; 263 gfx::Rect live_tiles_rect_;
213 264
214 // State saved for computing velocities based upon finite differences. 265 // State saved for computing velocities based upon finite differences.
215 double last_impl_frame_time_in_seconds_; 266 double last_impl_frame_time_in_seconds_;
216 gfx::RectF last_visible_rect_in_content_space_; 267 gfx::Rect last_visible_rect_in_content_space_;
268
269 // Tile bins used to return tiles in raster and eviction iterators.
270 std::vector<Tile*> visible_tiles_;
271 std::vector<Tile*> skewport_tiles_;
272 bool skewport_tiles_sorted_;
273 std::vector<Tile*> eventually_tiles_;
274 bool eventually_tiles_sorted_;
275 std::vector<Tile*> eviction_tiles_;
276 bool eviction_tiles_sorted_;
277
278 WhichTree last_update_tree_;
217 279
218 friend class CoverageIterator; 280 friend class CoverageIterator;
219 281
220 private: 282 private:
221 DISALLOW_ASSIGN(PictureLayerTiling); 283 DISALLOW_ASSIGN(PictureLayerTiling);
222 284
223 RectExpansionCache expansion_cache_; 285 RectExpansionCache expansion_cache_;
224 }; 286 };
225 287
226 } // namespace cc 288 } // namespace cc
227 289
228 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 290 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698