Chromium Code Reviews| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <unordered_map> | 13 #include <unordered_map> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "cc/base/region.h" | 18 #include "cc/base/region.h" |
| 19 #include "cc/base/scale_translate2d.h" | |
| 19 #include "cc/base/tiling_data.h" | 20 #include "cc/base/tiling_data.h" |
| 20 #include "cc/cc_export.h" | 21 #include "cc/cc_export.h" |
| 21 #include "cc/tiles/tile.h" | 22 #include "cc/tiles/tile.h" |
| 22 #include "cc/tiles/tile_priority.h" | 23 #include "cc/tiles/tile_priority.h" |
| 23 #include "cc/trees/occlusion.h" | 24 #include "cc/trees/occlusion.h" |
| 24 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 25 | 26 |
| 26 namespace base { | 27 namespace base { |
| 27 namespace trace_event { | 28 namespace trace_event { |
| 28 class TracedValue; | 29 class TracedValue; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 uint32_t value1_32 = value1; | 75 uint32_t value1_32 = value1; |
| 75 return (value1_32 << 16) | value2; | 76 return (value1_32 << 16) | value2; |
| 76 } | 77 } |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 class CC_EXPORT PictureLayerTiling { | 80 class CC_EXPORT PictureLayerTiling { |
| 80 public: | 81 public: |
| 81 static const int kBorderTexels = 1; | 82 static const int kBorderTexels = 1; |
| 82 | 83 |
| 83 PictureLayerTiling(WhichTree tree, | 84 PictureLayerTiling(WhichTree tree, |
| 84 float raster_scale, | 85 const ScaleTranslate2d& raster_transform, |
| 85 scoped_refptr<RasterSource> raster_source, | 86 scoped_refptr<RasterSource> raster_source, |
| 86 PictureLayerTilingClient* client, | 87 PictureLayerTilingClient* client, |
| 87 float min_preraster_distance, | 88 float min_preraster_distance, |
| 88 float max_preraster_distance); | 89 float max_preraster_distance); |
| 89 ~PictureLayerTiling(); | 90 ~PictureLayerTiling(); |
| 90 | 91 |
| 91 PictureLayerTilingClient* client() const { return client_; } | 92 PictureLayerTilingClient* client() const { return client_; } |
| 92 | 93 |
| 93 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); | 94 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); |
| 94 void Invalidate(const Region& layer_invalidation); | 95 void Invalidate(const Region& layer_invalidation); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 113 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 114 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
| 114 can_require_tiles_for_activation_ = can_require_tiles; | 115 can_require_tiles_for_activation_ = can_require_tiles; |
| 115 } | 116 } |
| 116 | 117 |
| 117 const scoped_refptr<RasterSource>& raster_source() const { | 118 const scoped_refptr<RasterSource>& raster_source() const { |
| 118 return raster_source_; | 119 return raster_source_; |
| 119 } | 120 } |
| 120 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } | 121 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } |
| 121 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 122 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 122 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 123 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
| 123 float contents_scale() const { return contents_scale_; } | 124 float contents_scale_key() const { return raster_transform_.scale(); } |
|
enne (OOO)
2017/03/29 12:57:37
Can you leave some more documentation here about h
trchen
2017/03/30 22:17:32
Done.
| |
| 125 const ScaleTranslate2d& raster_transform() const { return raster_transform_; } | |
| 124 const TilingData* tiling_data() const { return &tiling_data_; } | 126 const TilingData* tiling_data() const { return &tiling_data_; } |
| 125 | 127 |
| 126 Tile* TileAt(int i, int j) const { | 128 Tile* TileAt(int i, int j) const { |
| 127 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 129 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
| 128 return iter == tiles_.end() ? nullptr : iter->second.get(); | 130 return iter == tiles_.end() ? nullptr : iter->second.get(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 bool has_tiles() const { return !tiles_.empty(); } | 133 bool has_tiles() const { return !tiles_.empty(); } |
| 132 // all_tiles_done() can return false negatives. | 134 // all_tiles_done() can return false negatives. |
| 133 bool all_tiles_done() const { return all_tiles_done_; } | 135 bool all_tiles_done() const { return all_tiles_done_; } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 162 for (const auto& key_tile_pair : tiles_) { | 164 for (const auto& key_tile_pair : tiles_) { |
| 163 Tile* tile = key_tile_pair.second.get(); | 165 Tile* tile = key_tile_pair.second.get(); |
| 164 UpdateRequiredStatesOnTile(tile); | 166 UpdateRequiredStatesOnTile(tile); |
| 165 } | 167 } |
| 166 } | 168 } |
| 167 std::map<const Tile*, PrioritizedTile> | 169 std::map<const Tile*, PrioritizedTile> |
| 168 UpdateAndGetAllPrioritizedTilesForTesting() const; | 170 UpdateAndGetAllPrioritizedTilesForTesting() const; |
| 169 | 171 |
| 170 void SetAllTilesOccludedForTesting() { | 172 void SetAllTilesOccludedForTesting() { |
| 171 gfx::Rect viewport_in_layer_space = | 173 gfx::Rect viewport_in_layer_space = |
| 172 ScaleToEnclosingRect(current_visible_rect_, 1.f / contents_scale_); | 174 EnclosingLayerRectFromContentsRect(current_visible_rect_); |
| 173 current_occlusion_in_layer_space_ = | 175 current_occlusion_in_layer_space_ = |
| 174 Occlusion(gfx::Transform(), | 176 Occlusion(gfx::Transform(), |
| 175 SimpleEnclosedRegion(viewport_in_layer_space), | 177 SimpleEnclosedRegion(viewport_in_layer_space), |
| 176 SimpleEnclosedRegion(viewport_in_layer_space)); | 178 SimpleEnclosedRegion(viewport_in_layer_space)); |
| 177 } | 179 } |
| 178 const gfx::Rect& GetCurrentVisibleRectForTesting() const { | 180 const gfx::Rect& GetCurrentVisibleRectForTesting() const { |
| 179 return current_visible_rect_; | 181 return current_visible_rect_; |
| 180 } | 182 } |
| 181 void SetTilePriorityRectsForTesting( | 183 void SetTilePriorityRectsForTesting( |
| 182 const gfx::Rect& visible_rect_in_content_space, | 184 const gfx::Rect& visible_rect_in_content_space, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 213 CoverageIterator& operator++(); | 215 CoverageIterator& operator++(); |
| 214 operator bool() const { return tile_j_ <= bottom_; } | 216 operator bool() const { return tile_j_ <= bottom_; } |
| 215 | 217 |
| 216 int i() const { return tile_i_; } | 218 int i() const { return tile_i_; } |
| 217 int j() const { return tile_j_; } | 219 int j() const { return tile_j_; } |
| 218 | 220 |
| 219 private: | 221 private: |
| 220 const PictureLayerTiling* tiling_ = nullptr; | 222 const PictureLayerTiling* tiling_ = nullptr; |
| 221 gfx::Size coverage_rect_max_bounds_; | 223 gfx::Size coverage_rect_max_bounds_; |
| 222 gfx::Rect coverage_rect_; | 224 gfx::Rect coverage_rect_; |
| 223 float coverage_to_content_scale_; | 225 ScaleTranslate2d coverage_to_content_; |
| 224 | 226 |
| 225 Tile* current_tile_ = nullptr; | 227 Tile* current_tile_ = nullptr; |
| 226 gfx::Rect current_geometry_rect_; | 228 gfx::Rect current_geometry_rect_; |
| 227 int tile_i_ = 0; | 229 int tile_i_ = 0; |
| 228 int tile_j_ = 0; | 230 int tile_j_ = 0; |
| 229 int left_ = 0; | 231 int left_ = 0; |
| 230 int top_ = 0; | 232 int top_ = 0; |
| 231 int right_ = -1; | 233 int right_ = -1; |
| 232 int bottom_ = -1; | 234 int bottom_ = -1; |
| 233 | 235 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 return current_skewport_rect_; | 325 return current_skewport_rect_; |
| 324 } | 326 } |
| 325 const gfx::Rect& current_soon_border_rect() const { | 327 const gfx::Rect& current_soon_border_rect() const { |
| 326 return current_soon_border_rect_; | 328 return current_soon_border_rect_; |
| 327 } | 329 } |
| 328 const gfx::Rect& current_eventually_rect() const { | 330 const gfx::Rect& current_eventually_rect() const { |
| 329 return current_eventually_rect_; | 331 return current_eventually_rect_; |
| 330 } | 332 } |
| 331 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); | 333 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); |
| 332 | 334 |
| 335 gfx::Rect EnclosingContentsRectFromLayerRect( | |
| 336 const gfx::Rect& layer_rect) const; | |
| 337 gfx::Rect EnclosingLayerRectFromContentsRect( | |
| 338 const gfx::Rect& contents_rect) const; | |
| 339 | |
| 333 // Given properties. | 340 // Given properties. |
| 334 const float contents_scale_; | 341 const ScaleTranslate2d raster_transform_; |
| 335 PictureLayerTilingClient* const client_; | 342 PictureLayerTilingClient* const client_; |
| 336 const WhichTree tree_; | 343 const WhichTree tree_; |
| 337 scoped_refptr<RasterSource> raster_source_; | 344 scoped_refptr<RasterSource> raster_source_; |
| 338 const float min_preraster_distance_; | 345 const float min_preraster_distance_; |
| 339 const float max_preraster_distance_; | 346 const float max_preraster_distance_; |
| 340 TileResolution resolution_ = NON_IDEAL_RESOLUTION; | 347 TileResolution resolution_ = NON_IDEAL_RESOLUTION; |
| 341 bool may_contain_low_resolution_tiles_ = false; | 348 bool may_contain_low_resolution_tiles_ = false; |
| 342 | 349 |
| 343 // Internal data. | 350 // Internal data. |
| 344 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels); | 351 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels); |
| 345 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 352 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
| 346 gfx::Rect live_tiles_rect_; | 353 gfx::Rect live_tiles_rect_; |
| 347 | 354 |
| 348 bool can_require_tiles_for_activation_ = false; | 355 bool can_require_tiles_for_activation_ = false; |
| 349 | 356 |
| 350 // Iteration rects in content space. | 357 // Iteration rects in content space. |
| 351 gfx::Rect current_visible_rect_; | 358 gfx::Rect current_visible_rect_; |
| 352 gfx::Rect current_skewport_rect_; | 359 gfx::Rect current_skewport_rect_; |
| 353 gfx::Rect current_soon_border_rect_; | 360 gfx::Rect current_soon_border_rect_; |
| 354 gfx::Rect current_eventually_rect_; | 361 gfx::Rect current_eventually_rect_; |
| 355 // Other properties used for tile iteration and prioritization. | 362 // Other properties used for tile iteration and prioritization. |
| 356 float current_content_to_screen_scale_; | 363 float current_content_to_screen_scale_ = 0.f; |
| 357 Occlusion current_occlusion_in_layer_space_; | 364 Occlusion current_occlusion_in_layer_space_; |
| 358 float max_skewport_extent_in_screen_space_ = 0.f; | 365 float max_skewport_extent_in_screen_space_ = 0.f; |
| 359 | 366 |
| 360 bool has_visible_rect_tiles_ = false; | 367 bool has_visible_rect_tiles_ = false; |
| 361 bool has_skewport_rect_tiles_ = false; | 368 bool has_skewport_rect_tiles_ = false; |
| 362 bool has_soon_border_rect_tiles_ = false; | 369 bool has_soon_border_rect_tiles_ = false; |
| 363 bool has_eventually_rect_tiles_ = false; | 370 bool has_eventually_rect_tiles_ = false; |
| 364 bool all_tiles_done_ = true; | 371 bool all_tiles_done_ = true; |
| 365 | 372 |
| 366 private: | 373 private: |
| 367 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); | 374 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); |
| 368 }; | 375 }; |
| 369 | 376 |
| 370 } // namespace cc | 377 } // namespace cc |
| 371 | 378 |
| 372 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ | 379 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |