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

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

Issue 1028333002: Chromium -> Mojo roll. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/resources/picture.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "cc/base/cc_export.h" 15 #include "cc/base/cc_export.h"
16 #include "cc/base/region.h" 16 #include "cc/base/region.h"
17 #include "cc/base/tiling_data.h" 17 #include "cc/base/tiling_data.h"
18 #include "cc/resources/tile.h" 18 #include "cc/resources/tile.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 134 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
135 return current_visible_rect_; 135 return current_visible_rect_;
136 } 136 }
137 137
138 bool IsTileOccluded(const Tile* tile) const; 138 bool IsTileOccluded(const Tile* tile) const;
139 bool IsTileRequiredForActivationIfVisible(const Tile* tile) const; 139 bool IsTileRequiredForActivationIfVisible(const Tile* tile) const;
140 bool IsTileRequiredForDrawIfVisible(const Tile* tile) const; 140 bool IsTileRequiredForDrawIfVisible(const Tile* tile) const;
141 141
142 void UpdateTileAndTwinPriority(Tile* tile) const; 142 void UpdateTileAndTwinPriority(Tile* tile) const;
143 TilePriority ComputePriorityForTile(const Tile* tile) const;
144 void UpdateRequiredStateForTile(Tile* tile, WhichTree tree) const;
143 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; } 145 bool has_visible_rect_tiles() const { return has_visible_rect_tiles_; }
144 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; } 146 bool has_skewport_rect_tiles() const { return has_skewport_rect_tiles_; }
145 bool has_soon_border_rect_tiles() const { 147 bool has_soon_border_rect_tiles() const {
146 return has_soon_border_rect_tiles_; 148 return has_soon_border_rect_tiles_;
147 } 149 }
148 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; } 150 bool has_eventually_rect_tiles() const { return has_eventually_rect_tiles_; }
149 151
150 const gfx::Rect& current_visible_rect() const { 152 const gfx::Rect& current_visible_rect() const {
151 return current_visible_rect_; 153 return current_visible_rect_;
152 } 154 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 friend class PictureLayerTiling; 206 friend class PictureLayerTiling;
205 }; 207 };
206 208
207 void Reset(); 209 void Reset();
208 210
209 bool ComputeTilePriorityRects(const gfx::Rect& viewport_in_layer_space, 211 bool ComputeTilePriorityRects(const gfx::Rect& viewport_in_layer_space,
210 float ideal_contents_scale, 212 float ideal_contents_scale,
211 double current_frame_time_in_seconds, 213 double current_frame_time_in_seconds,
212 const Occlusion& occlusion_in_layer_space); 214 const Occlusion& occlusion_in_layer_space);
213 215
214 void GetAllTilesForTracing(std::set<const Tile*>* tiles) const; 216 void GetAllTilesAndPrioritiesForTracing(
217 std::map<const Tile*, TilePriority>* tile_map) const;
215 void AsValueInto(base::trace_event::TracedValue* array) const; 218 void AsValueInto(base::trace_event::TracedValue* array) const;
216 size_t GPUMemoryUsageInBytes() const; 219 size_t GPUMemoryUsageInBytes() const;
217 220
218 struct RectExpansionCache { 221 struct RectExpansionCache {
219 RectExpansionCache(); 222 RectExpansionCache();
220 223
221 gfx::Rect previous_start; 224 gfx::Rect previous_start;
222 gfx::Rect previous_bounds; 225 gfx::Rect previous_bounds;
223 gfx::Rect previous_result; 226 gfx::Rect previous_result;
224 int64 previous_target; 227 int64 previous_target;
225 }; 228 };
226 229
227 static 230 static
228 gfx::Rect ExpandRectEquallyToAreaBoundedBy( 231 gfx::Rect ExpandRectEquallyToAreaBoundedBy(
229 const gfx::Rect& starting_rect, 232 const gfx::Rect& starting_rect,
230 int64 target_area, 233 int64 target_area,
231 const gfx::Rect& bounding_rect, 234 const gfx::Rect& bounding_rect,
232 RectExpansionCache* cache); 235 RectExpansionCache* cache);
233 236
234 bool has_ever_been_updated() const { 237 bool has_ever_been_updated() const {
235 return last_impl_frame_time_in_seconds_ != 0.0; 238 return visible_rect_history_[0].frame_time_in_seconds != 0.0;
236 } 239 }
237 240
238 protected: 241 protected:
239 friend class CoverageIterator; 242 friend class CoverageIterator;
240 friend class TilingSetRasterQueueAll; 243 friend class TilingSetRasterQueueAll;
241 friend class TilingSetRasterQueueRequired; 244 friend class TilingSetRasterQueueRequired;
242 friend class TilingSetEvictionQueue; 245 friend class TilingSetEvictionQueue;
243 246
244 typedef std::pair<int, int> TileMapKey; 247 typedef std::pair<int, int> TileMapKey;
245 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap; 248 typedef base::hash_map<TileMapKey, scoped_refptr<Tile>> TileMap;
246 249
250 struct FrameVisibleRect {
251 gfx::Rect visible_rect_in_content_space;
252 double frame_time_in_seconds = 0.0;
253 };
254
247 PictureLayerTiling(float contents_scale, 255 PictureLayerTiling(float contents_scale,
248 scoped_refptr<RasterSource> raster_source, 256 scoped_refptr<RasterSource> raster_source,
249 PictureLayerTilingClient* client, 257 PictureLayerTilingClient* client,
250 size_t max_tiles_for_interest_area, 258 size_t max_tiles_for_interest_area,
251 float skewport_target_time_in_seconds, 259 float skewport_target_time_in_seconds,
252 int skewport_extrapolation_limit_in_content_pixels); 260 int skewport_extrapolation_limit_in_content_pixels);
253 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 261 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
254 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; 262 void VerifyLiveTilesRect(bool is_on_recycle_tree) const;
255 Tile* CreateTile(int i, 263 Tile* CreateTile(int i,
256 int j, 264 int j,
(...skipping 15 matching lines...) Expand all
272 const gfx::Rect& visible_rect_in_content_space, 280 const gfx::Rect& visible_rect_in_content_space,
273 const gfx::Rect& skewport, 281 const gfx::Rect& skewport,
274 const gfx::Rect& soon_border_rect, 282 const gfx::Rect& soon_border_rect,
275 const gfx::Rect& eventually_rect, 283 const gfx::Rect& eventually_rect,
276 const Occlusion& occlusion_in_layer_space); 284 const Occlusion& occlusion_in_layer_space);
277 285
278 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const; 286 void UpdateTilePriorityForTree(Tile* tile, WhichTree tree) const;
279 bool NeedsUpdateForFrameAtTimeAndViewport( 287 bool NeedsUpdateForFrameAtTimeAndViewport(
280 double frame_time_in_seconds, 288 double frame_time_in_seconds,
281 const gfx::Rect& viewport_in_layer_space) { 289 const gfx::Rect& viewport_in_layer_space) {
282 return frame_time_in_seconds != last_impl_frame_time_in_seconds_ || 290 return frame_time_in_seconds !=
291 visible_rect_history_[0].frame_time_in_seconds ||
283 viewport_in_layer_space != last_viewport_in_layer_space_; 292 viewport_in_layer_space != last_viewport_in_layer_space_;
284 } 293 }
294 void UpdateVisibleRectHistory(
295 double frame_time_in_seconds,
296 const gfx::Rect& visible_rect_in_content_space) {
297 visible_rect_history_[1] = visible_rect_history_[0];
298 visible_rect_history_[0].frame_time_in_seconds = frame_time_in_seconds;
299 visible_rect_history_[0].visible_rect_in_content_space =
300 visible_rect_in_content_space;
301 // If we don't have a second history item, set it to the most recent one.
302 if (visible_rect_history_[1].frame_time_in_seconds == 0.0)
303 visible_rect_history_[1] = visible_rect_history_[0];
304 }
285 305
286 const size_t max_tiles_for_interest_area_; 306 const size_t max_tiles_for_interest_area_;
287 const float skewport_target_time_in_seconds_; 307 const float skewport_target_time_in_seconds_;
288 const int skewport_extrapolation_limit_in_content_pixels_; 308 const int skewport_extrapolation_limit_in_content_pixels_;
289 309
290 // Given properties. 310 // Given properties.
291 const float contents_scale_; 311 const float contents_scale_;
292 PictureLayerTilingClient* const client_; 312 PictureLayerTilingClient* const client_;
293 scoped_refptr<RasterSource> raster_source_; 313 scoped_refptr<RasterSource> raster_source_;
294 TileResolution resolution_; 314 TileResolution resolution_;
295 315
296 // Internal data. 316 // Internal data.
297 TilingData tiling_data_; 317 TilingData tiling_data_;
298 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 318 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
299 gfx::Rect live_tiles_rect_; 319 gfx::Rect live_tiles_rect_;
300 320
321 gfx::Rect last_viewport_in_layer_space_;
301 // State saved for computing velocities based upon finite differences. 322 // State saved for computing velocities based upon finite differences.
302 double last_impl_frame_time_in_seconds_; 323 FrameVisibleRect visible_rect_history_[2];
303 gfx::Rect last_viewport_in_layer_space_;
304 gfx::Rect last_visible_rect_in_content_space_;
305 324
306 bool can_require_tiles_for_activation_; 325 bool can_require_tiles_for_activation_;
307 326
308 // Iteration rects in content space. 327 // Iteration rects in content space.
309 gfx::Rect current_visible_rect_; 328 gfx::Rect current_visible_rect_;
310 gfx::Rect current_skewport_rect_; 329 gfx::Rect current_skewport_rect_;
311 gfx::Rect current_soon_border_rect_; 330 gfx::Rect current_soon_border_rect_;
312 gfx::Rect current_eventually_rect_; 331 gfx::Rect current_eventually_rect_;
313 // Other properties used for tile iteration and prioritization. 332 // Other properties used for tile iteration and prioritization.
314 float current_content_to_screen_scale_; 333 float current_content_to_screen_scale_;
315 Occlusion current_occlusion_in_layer_space_; 334 Occlusion current_occlusion_in_layer_space_;
316 335
317 bool has_visible_rect_tiles_; 336 bool has_visible_rect_tiles_;
318 bool has_skewport_rect_tiles_; 337 bool has_skewport_rect_tiles_;
319 bool has_soon_border_rect_tiles_; 338 bool has_soon_border_rect_tiles_;
320 bool has_eventually_rect_tiles_; 339 bool has_eventually_rect_tiles_;
321 340
322 private: 341 private:
323 DISALLOW_ASSIGN(PictureLayerTiling); 342 DISALLOW_ASSIGN(PictureLayerTiling);
324 343
325 RectExpansionCache expansion_cache_; 344 RectExpansionCache expansion_cache_;
326 }; 345 };
327 346
328 } // namespace cc 347 } // namespace cc
329 348
330 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_ 349 #endif // CC_RESOURCES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/resources/picture.cc ('k') | cc/resources/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698