OLD | NEW |
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_TILES_PICTURE_LAYER_TILING_H_ | 5 #ifndef CC_TILES_PICTURE_LAYER_TILING_H_ |
6 #define CC_TILES_PICTURE_LAYER_TILING_H_ | 6 #define CC_TILES_PICTURE_LAYER_TILING_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
25 | 25 |
26 namespace base { | 26 namespace base { |
27 namespace trace_event { | 27 namespace trace_event { |
28 class TracedValue; | 28 class TracedValue; |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 namespace cc { | 32 namespace cc { |
33 | 33 |
34 class DisplayListRasterSource; | 34 class RasterSource; |
35 class PictureLayerTiling; | 35 class PictureLayerTiling; |
36 class PrioritizedTile; | 36 class PrioritizedTile; |
37 | 37 |
38 class CC_EXPORT PictureLayerTilingClient { | 38 class CC_EXPORT PictureLayerTilingClient { |
39 public: | 39 public: |
40 // Create a tile at the given content_rect (in the contents scale of the | 40 // Create a tile at the given content_rect (in the contents scale of the |
41 // tiling) This might return null if the client cannot create such a tile. | 41 // tiling) This might return null if the client cannot create such a tile. |
42 virtual ScopedTilePtr CreateTile(const Tile::CreateInfo& info) = 0; | 42 virtual ScopedTilePtr CreateTile(const Tile::CreateInfo& info) = 0; |
43 virtual gfx::Size CalculateTileSize( | 43 virtual gfx::Size CalculateTileSize( |
44 const gfx::Size& content_bounds) const = 0; | 44 const gfx::Size& content_bounds) const = 0; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 ~PictureLayerTiling(); | 84 ~PictureLayerTiling(); |
85 | 85 |
86 static float CalculateSoonBorderDistance( | 86 static float CalculateSoonBorderDistance( |
87 const gfx::Rect& visible_rect_in_content_space, | 87 const gfx::Rect& visible_rect_in_content_space, |
88 float content_to_screen_scale); | 88 float content_to_screen_scale); |
89 | 89 |
90 // Create a tiling with no tiles. CreateTile() must be called to add some. | 90 // Create a tiling with no tiles. CreateTile() must be called to add some. |
91 static scoped_ptr<PictureLayerTiling> Create( | 91 static scoped_ptr<PictureLayerTiling> Create( |
92 WhichTree tree, | 92 WhichTree tree, |
93 float contents_scale, | 93 float contents_scale, |
94 scoped_refptr<DisplayListRasterSource> raster_source, | 94 scoped_refptr<RasterSource> raster_source, |
95 PictureLayerTilingClient* client, | 95 PictureLayerTilingClient* client, |
96 size_t tiling_interest_area_padding, | 96 size_t tiling_interest_area_padding, |
97 float skewport_target_time_in_seconds, | 97 float skewport_target_time_in_seconds, |
98 int skewport_extrapolation_limit_in_content_pixels); | 98 int skewport_extrapolation_limit_in_content_pixels); |
99 | 99 |
100 void SetRasterSourceAndResize( | 100 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); |
101 scoped_refptr<DisplayListRasterSource> raster_source); | |
102 void Invalidate(const Region& layer_invalidation); | 101 void Invalidate(const Region& layer_invalidation); |
103 void CreateMissingTilesInLiveTilesRect(); | 102 void CreateMissingTilesInLiveTilesRect(); |
104 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin, | 103 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin, |
105 const Region& layer_invalidation); | 104 const Region& layer_invalidation); |
106 | 105 |
107 bool IsTileRequiredForActivation(const Tile* tile) const; | 106 bool IsTileRequiredForActivation(const Tile* tile) const; |
108 bool IsTileRequiredForDraw(const Tile* tile) const; | 107 bool IsTileRequiredForDraw(const Tile* tile) const; |
109 | 108 |
110 void set_resolution(TileResolution resolution) { | 109 void set_resolution(TileResolution resolution) { |
111 resolution_ = resolution; | 110 resolution_ = resolution; |
112 may_contain_low_resolution_tiles_ |= resolution == LOW_RESOLUTION; | 111 may_contain_low_resolution_tiles_ |= resolution == LOW_RESOLUTION; |
113 } | 112 } |
114 TileResolution resolution() const { return resolution_; } | 113 TileResolution resolution() const { return resolution_; } |
115 bool may_contain_low_resolution_tiles() const { | 114 bool may_contain_low_resolution_tiles() const { |
116 return may_contain_low_resolution_tiles_; | 115 return may_contain_low_resolution_tiles_; |
117 } | 116 } |
118 void reset_may_contain_low_resolution_tiles() { | 117 void reset_may_contain_low_resolution_tiles() { |
119 may_contain_low_resolution_tiles_ = false; | 118 may_contain_low_resolution_tiles_ = false; |
120 } | 119 } |
121 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 120 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
122 can_require_tiles_for_activation_ = can_require_tiles; | 121 can_require_tiles_for_activation_ = can_require_tiles; |
123 } | 122 } |
124 | 123 |
125 const scoped_refptr<DisplayListRasterSource>& raster_source() const { | 124 const scoped_refptr<RasterSource>& raster_source() const { |
126 return raster_source_; | 125 return raster_source_; |
127 } | 126 } |
128 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } | 127 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } |
129 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 128 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
130 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 129 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
131 float contents_scale() const { return contents_scale_; } | 130 float contents_scale() const { return contents_scale_; } |
132 const TilingData* tiling_data() const { return &tiling_data_; } | 131 const TilingData* tiling_data() const { return &tiling_data_; } |
133 | 132 |
134 Tile* TileAt(int i, int j) const { | 133 Tile* TileAt(int i, int j) const { |
135 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 134 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 268 |
270 using TileMap = std::unordered_map<TileMapKey, ScopedTilePtr, TileMapKeyHash>; | 269 using TileMap = std::unordered_map<TileMapKey, ScopedTilePtr, TileMapKeyHash>; |
271 | 270 |
272 struct FrameVisibleRect { | 271 struct FrameVisibleRect { |
273 gfx::Rect visible_rect_in_content_space; | 272 gfx::Rect visible_rect_in_content_space; |
274 double frame_time_in_seconds = 0.0; | 273 double frame_time_in_seconds = 0.0; |
275 }; | 274 }; |
276 | 275 |
277 PictureLayerTiling(WhichTree tree, | 276 PictureLayerTiling(WhichTree tree, |
278 float contents_scale, | 277 float contents_scale, |
279 scoped_refptr<DisplayListRasterSource> raster_source, | 278 scoped_refptr<RasterSource> raster_source, |
280 PictureLayerTilingClient* client, | 279 PictureLayerTilingClient* client, |
281 size_t tiling_interest_area_padding, | 280 size_t tiling_interest_area_padding, |
282 float skewport_target_time_in_seconds, | 281 float skewport_target_time_in_seconds, |
283 int skewport_extrapolation_limit_in_content_pixels); | 282 int skewport_extrapolation_limit_in_content_pixels); |
284 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); | 283 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); |
285 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; | 284 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; |
286 Tile* CreateTile(const Tile::CreateInfo& info); | 285 Tile* CreateTile(const Tile::CreateInfo& info); |
287 ScopedTilePtr TakeTileAt(int i, int j); | 286 ScopedTilePtr TakeTileAt(int i, int j); |
288 // Returns true if the Tile existed and was removed from the tiling. | 287 // Returns true if the Tile existed and was removed from the tiling. |
289 bool RemoveTileAt(int i, int j); | 288 bool RemoveTileAt(int i, int j); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); | 367 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); |
369 | 368 |
370 const size_t tiling_interest_area_padding_; | 369 const size_t tiling_interest_area_padding_; |
371 const float skewport_target_time_in_seconds_; | 370 const float skewport_target_time_in_seconds_; |
372 const int skewport_extrapolation_limit_in_content_pixels_; | 371 const int skewport_extrapolation_limit_in_content_pixels_; |
373 | 372 |
374 // Given properties. | 373 // Given properties. |
375 const float contents_scale_; | 374 const float contents_scale_; |
376 PictureLayerTilingClient* const client_; | 375 PictureLayerTilingClient* const client_; |
377 const WhichTree tree_; | 376 const WhichTree tree_; |
378 scoped_refptr<DisplayListRasterSource> raster_source_; | 377 scoped_refptr<RasterSource> raster_source_; |
379 TileResolution resolution_; | 378 TileResolution resolution_; |
380 bool may_contain_low_resolution_tiles_; | 379 bool may_contain_low_resolution_tiles_; |
381 | 380 |
382 // Internal data. | 381 // Internal data. |
383 TilingData tiling_data_; | 382 TilingData tiling_data_; |
384 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 383 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
385 gfx::Rect live_tiles_rect_; | 384 gfx::Rect live_tiles_rect_; |
386 | 385 |
387 gfx::Rect last_viewport_in_layer_space_; | 386 gfx::Rect last_viewport_in_layer_space_; |
388 // State saved for computing velocities based upon finite differences. | 387 // State saved for computing velocities based upon finite differences. |
(...skipping 16 matching lines...) Expand all Loading... |
405 bool has_eventually_rect_tiles_; | 404 bool has_eventually_rect_tiles_; |
406 bool all_tiles_done_; | 405 bool all_tiles_done_; |
407 | 406 |
408 private: | 407 private: |
409 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); | 408 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); |
410 }; | 409 }; |
411 | 410 |
412 } // namespace cc | 411 } // namespace cc |
413 | 412 |
414 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ | 413 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ |
OLD | NEW |