| 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/cc_export.h" | 18 #include "cc/base/cc_export.h" |
| 19 #include "cc/base/region.h" | 19 #include "cc/base/region.h" |
| 20 #include "cc/base/scale_translate2d.h" |
| 20 #include "cc/base/tiling_data.h" | 21 #include "cc/base/tiling_data.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; |
| 29 } | 30 } |
| (...skipping 44 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 contents_scale, | 85 const ScaleTranslate2d& contents_transform, |
| 85 scoped_refptr<RasterSource> raster_source, | 86 scoped_refptr<RasterSource> raster_source, |
| 86 PictureLayerTilingClient* client); | 87 PictureLayerTilingClient* client); |
| 87 ~PictureLayerTiling(); | 88 ~PictureLayerTiling(); |
| 88 | 89 |
| 89 PictureLayerTilingClient* client() const { return client_; } | 90 PictureLayerTilingClient* client() const { return client_; } |
| 90 | 91 |
| 91 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); | 92 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); |
| 92 void Invalidate(const Region& layer_invalidation); | 93 void Invalidate(const Region& layer_invalidation); |
| 93 void CreateMissingTilesInLiveTilesRect(); | 94 void CreateMissingTilesInLiveTilesRect(); |
| 94 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin, | 95 void TakeTilesAndPropertiesFrom(PictureLayerTiling* pending_twin, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 111 void set_can_require_tiles_for_activation(bool can_require_tiles) { | 112 void set_can_require_tiles_for_activation(bool can_require_tiles) { |
| 112 can_require_tiles_for_activation_ = can_require_tiles; | 113 can_require_tiles_for_activation_ = can_require_tiles; |
| 113 } | 114 } |
| 114 | 115 |
| 115 const scoped_refptr<RasterSource>& raster_source() const { | 116 const scoped_refptr<RasterSource>& raster_source() const { |
| 116 return raster_source_; | 117 return raster_source_; |
| 117 } | 118 } |
| 118 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } | 119 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } |
| 119 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } | 120 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } |
| 120 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } | 121 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } |
| 121 float contents_scale() const { return contents_scale_; } | 122 // float contents_scale() const { return contents_scale_; } |
| 123 const ScaleTranslate2d& contents_transform() const { |
| 124 return contents_transform_; |
| 125 } |
| 122 const TilingData* tiling_data() const { return &tiling_data_; } | 126 const TilingData* tiling_data() const { return &tiling_data_; } |
| 123 | 127 |
| 124 Tile* TileAt(int i, int j) const { | 128 Tile* TileAt(int i, int j) const { |
| 125 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); | 129 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); |
| 126 return iter == tiles_.end() ? nullptr : iter->second.get(); | 130 return iter == tiles_.end() ? nullptr : iter->second.get(); |
| 127 } | 131 } |
| 128 | 132 |
| 129 bool has_tiles() const { return !tiles_.empty(); } | 133 bool has_tiles() const { return !tiles_.empty(); } |
| 130 // all_tiles_done() can return false negatives. | 134 // all_tiles_done() can return false negatives. |
| 131 bool all_tiles_done() const { return all_tiles_done_; } | 135 bool all_tiles_done() const { return all_tiles_done_; } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 156 | 160 |
| 157 void UpdateAllRequiredStateForTesting() { | 161 void UpdateAllRequiredStateForTesting() { |
| 158 for (const auto& key_tile_pair : tiles_) | 162 for (const auto& key_tile_pair : tiles_) |
| 159 UpdateRequiredStatesOnTile(key_tile_pair.second.get()); | 163 UpdateRequiredStatesOnTile(key_tile_pair.second.get()); |
| 160 } | 164 } |
| 161 std::map<const Tile*, PrioritizedTile> | 165 std::map<const Tile*, PrioritizedTile> |
| 162 UpdateAndGetAllPrioritizedTilesForTesting() const; | 166 UpdateAndGetAllPrioritizedTilesForTesting() const; |
| 163 | 167 |
| 164 void SetAllTilesOccludedForTesting() { | 168 void SetAllTilesOccludedForTesting() { |
| 165 gfx::Rect viewport_in_layer_space = | 169 gfx::Rect viewport_in_layer_space = |
| 166 ScaleToEnclosingRect(current_visible_rect_, 1.0f / contents_scale_); | 170 EnclosingLayerRectFromContentsRect(current_visible_rect_); |
| 167 current_occlusion_in_layer_space_ = | 171 current_occlusion_in_layer_space_ = |
| 168 Occlusion(gfx::Transform(), | 172 Occlusion(gfx::Transform(), |
| 169 SimpleEnclosedRegion(viewport_in_layer_space), | 173 SimpleEnclosedRegion(viewport_in_layer_space), |
| 170 SimpleEnclosedRegion(viewport_in_layer_space)); | 174 SimpleEnclosedRegion(viewport_in_layer_space)); |
| 171 } | 175 } |
| 172 const gfx::Rect& GetCurrentVisibleRectForTesting() const { | 176 const gfx::Rect& GetCurrentVisibleRectForTesting() const { |
| 173 return current_visible_rect_; | 177 return current_visible_rect_; |
| 174 } | 178 } |
| 175 void SetTilePriorityRectsForTesting( | 179 void SetTilePriorityRectsForTesting( |
| 176 const gfx::Rect& visible_rect_in_content_space, | 180 const gfx::Rect& visible_rect_in_content_space, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 204 | 208 |
| 205 CoverageIterator& operator++(); | 209 CoverageIterator& operator++(); |
| 206 operator bool() const { return tile_j_ <= bottom_; } | 210 operator bool() const { return tile_j_ <= bottom_; } |
| 207 | 211 |
| 208 int i() const { return tile_i_; } | 212 int i() const { return tile_i_; } |
| 209 int j() const { return tile_j_; } | 213 int j() const { return tile_j_; } |
| 210 | 214 |
| 211 private: | 215 private: |
| 212 const PictureLayerTiling* tiling_; | 216 const PictureLayerTiling* tiling_; |
| 213 gfx::Rect dest_rect_; | 217 gfx::Rect dest_rect_; |
| 214 float dest_to_content_scale_; | 218 ScaleTranslate2d dest_to_content_; |
| 215 | 219 |
| 216 Tile* current_tile_; | 220 Tile* current_tile_; |
| 217 gfx::Rect current_geometry_rect_; | 221 gfx::Rect current_geometry_rect_; |
| 218 int tile_i_; | 222 int tile_i_; |
| 219 int tile_j_; | 223 int tile_j_; |
| 220 int left_; | 224 int left_; |
| 221 int top_; | 225 int top_; |
| 222 int right_; | 226 int right_; |
| 223 int bottom_; | 227 int bottom_; |
| 224 | 228 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 return current_skewport_rect_; | 316 return current_skewport_rect_; |
| 313 } | 317 } |
| 314 const gfx::Rect& current_soon_border_rect() const { | 318 const gfx::Rect& current_soon_border_rect() const { |
| 315 return current_soon_border_rect_; | 319 return current_soon_border_rect_; |
| 316 } | 320 } |
| 317 const gfx::Rect& current_eventually_rect() const { | 321 const gfx::Rect& current_eventually_rect() const { |
| 318 return current_eventually_rect_; | 322 return current_eventually_rect_; |
| 319 } | 323 } |
| 320 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); | 324 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); |
| 321 | 325 |
| 326 gfx::Rect EnclosingContentsRectFromLayerRect( |
| 327 const gfx::Rect& layer_rect) const; |
| 328 gfx::Rect EnclosingLayerRectFromContentsRect( |
| 329 const gfx::Rect& contents_rect) const; |
| 330 |
| 322 // Given properties. | 331 // Given properties. |
| 323 const float contents_scale_; | 332 const ScaleTranslate2d contents_transform_; |
| 324 PictureLayerTilingClient* const client_; | 333 PictureLayerTilingClient* const client_; |
| 325 const WhichTree tree_; | 334 const WhichTree tree_; |
| 326 scoped_refptr<RasterSource> raster_source_; | 335 scoped_refptr<RasterSource> raster_source_; |
| 327 TileResolution resolution_; | 336 TileResolution resolution_; |
| 328 bool may_contain_low_resolution_tiles_; | 337 bool may_contain_low_resolution_tiles_; |
| 329 | 338 |
| 330 // Internal data. | 339 // Internal data. |
| 331 TilingData tiling_data_; | 340 TilingData tiling_data_; |
| 332 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. | 341 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. |
| 333 gfx::Rect live_tiles_rect_; | 342 gfx::Rect live_tiles_rect_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 349 bool has_eventually_rect_tiles_; | 358 bool has_eventually_rect_tiles_; |
| 350 bool all_tiles_done_; | 359 bool all_tiles_done_; |
| 351 | 360 |
| 352 private: | 361 private: |
| 353 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); | 362 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); |
| 354 }; | 363 }; |
| 355 | 364 |
| 356 } // namespace cc | 365 } // namespace cc |
| 357 | 366 |
| 358 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ | 367 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ |
| OLD | NEW |