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

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

Issue 2566613002: [4/5] Add translated rasterization support for PictureLayerTilingSet & below (Closed)
Patch Set: Created 4 years 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
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_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
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 const gfx::SizeF& raster_scales, 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
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_key() const { return raster_scales_.width(); } 124 float contents_scale_key() const { return raster_transform_.scale(); }
124 const gfx::SizeF& raster_scales() const { return raster_scales_; } 125 const ScaleTranslate2d& raster_transform() const {
126 return raster_transform_;
127 }
125 const TilingData* tiling_data() const { return &tiling_data_; } 128 const TilingData* tiling_data() const { return &tiling_data_; }
126 129
127 Tile* TileAt(int i, int j) const { 130 Tile* TileAt(int i, int j) const {
128 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 131 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
129 return iter == tiles_.end() ? nullptr : iter->second.get(); 132 return iter == tiles_.end() ? nullptr : iter->second.get();
130 } 133 }
131 134
132 bool has_tiles() const { return !tiles_.empty(); } 135 bool has_tiles() const { return !tiles_.empty(); }
133 // all_tiles_done() can return false negatives. 136 // all_tiles_done() can return false negatives.
134 bool all_tiles_done() const { return all_tiles_done_; } 137 bool all_tiles_done() const { return all_tiles_done_; }
(...skipping 23 matching lines...) Expand all
158 } 161 }
159 162
160 void UpdateAllRequiredStateForTesting() { 163 void UpdateAllRequiredStateForTesting() {
161 for (const auto& key_tile_pair : tiles_) 164 for (const auto& key_tile_pair : tiles_)
162 UpdateRequiredStatesOnTile(key_tile_pair.second.get()); 165 UpdateRequiredStatesOnTile(key_tile_pair.second.get());
163 } 166 }
164 std::map<const Tile*, PrioritizedTile> 167 std::map<const Tile*, PrioritizedTile>
165 UpdateAndGetAllPrioritizedTilesForTesting() const; 168 UpdateAndGetAllPrioritizedTilesForTesting() const;
166 169
167 void SetAllTilesOccludedForTesting() { 170 void SetAllTilesOccludedForTesting() {
168 gfx::Rect viewport_in_layer_space = ScaleToEnclosingRect( 171 gfx::Rect viewport_in_layer_space =
169 current_visible_rect_, 1.f / raster_scales_.width(), 172 EnclosingLayerRectFromContentsRect(current_visible_rect_);
170 1.f / raster_scales_.height());
171 current_occlusion_in_layer_space_ = 173 current_occlusion_in_layer_space_ =
172 Occlusion(gfx::Transform(), 174 Occlusion(gfx::Transform(),
173 SimpleEnclosedRegion(viewport_in_layer_space), 175 SimpleEnclosedRegion(viewport_in_layer_space),
174 SimpleEnclosedRegion(viewport_in_layer_space)); 176 SimpleEnclosedRegion(viewport_in_layer_space));
175 } 177 }
176 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 178 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
177 return current_visible_rect_; 179 return current_visible_rect_;
178 } 180 }
179 void SetTilePriorityRectsForTesting( 181 void SetTilePriorityRectsForTesting(
180 const gfx::Rect& visible_rect_in_content_space, 182 const gfx::Rect& visible_rect_in_content_space,
181 const gfx::Rect& skewport, 183 const gfx::Rect& skewport,
182 const gfx::Rect& soon_border_rect, 184 const gfx::Rect& soon_border_rect,
183 const gfx::Rect& eventually_rect) { 185 const gfx::Rect& eventually_rect) {
184 SetTilePriorityRects(gfx::SizeF(1.f, 1.f), visible_rect_in_content_space, 186 SetTilePriorityRects(1.f, visible_rect_in_content_space,
185 skewport, soon_border_rect, eventually_rect, 187 skewport, soon_border_rect, eventually_rect,
186 Occlusion()); 188 Occlusion());
187 } 189 }
188 190
189 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 191 // Iterate over all tiles to fill content_rect. Even if tiles are invalid
190 // (i.e. no valid resource) this tiling should still iterate over them. 192 // (i.e. no valid resource) this tiling should still iterate over them.
191 // The union of all geometry_rect calls for each element iterated over should 193 // The union of all geometry_rect calls for each element iterated over should
192 // exactly equal content_rect and no two geometry_rects should intersect. 194 // exactly equal content_rect and no two geometry_rects should intersect.
193 class CC_EXPORT CoverageIterator { 195 class CC_EXPORT CoverageIterator {
194 public: 196 public:
(...skipping 17 matching lines...) Expand all
212 CoverageIterator& operator++(); 214 CoverageIterator& operator++();
213 operator bool() const { return tile_j_ <= bottom_; } 215 operator bool() const { return tile_j_ <= bottom_; }
214 216
215 int i() const { return tile_i_; } 217 int i() const { return tile_i_; }
216 int j() const { return tile_j_; } 218 int j() const { return tile_j_; }
217 219
218 private: 220 private:
219 const PictureLayerTiling* tiling_ = nullptr; 221 const PictureLayerTiling* tiling_ = nullptr;
220 gfx::Size coverage_rect_max_bounds_; 222 gfx::Size coverage_rect_max_bounds_;
221 gfx::Rect coverage_rect_; 223 gfx::Rect coverage_rect_;
222 gfx::SizeF coverage_to_content_scale_; 224 ScaleTranslate2d coverage_to_content_;
223 225
224 Tile* current_tile_ = nullptr; 226 Tile* current_tile_ = nullptr;
225 gfx::Rect current_geometry_rect_; 227 gfx::Rect current_geometry_rect_;
226 int tile_i_ = 0; 228 int tile_i_ = 0;
227 int tile_j_ = 0; 229 int tile_j_ = 0;
228 int left_ = 0; 230 int left_ = 0;
229 int top_ = 0; 231 int top_ = 0;
230 int right_ = -1; 232 int right_ = -1;
231 int bottom_ = -1; 233 int bottom_ = -1;
232 234
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 274
273 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 275 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
274 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; 276 void VerifyLiveTilesRect(bool is_on_recycle_tree) const;
275 Tile* CreateTile(const Tile::CreateInfo& info); 277 Tile* CreateTile(const Tile::CreateInfo& info);
276 ScopedTilePtr TakeTileAt(int i, int j); 278 ScopedTilePtr TakeTileAt(int i, int j);
277 // Returns true if the Tile existed and was removed from the tiling. 279 // Returns true if the Tile existed and was removed from the tiling.
278 bool RemoveTileAt(int i, int j); 280 bool RemoveTileAt(int i, int j);
279 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const; 281 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const;
280 282
281 // Save the required data for computing tile priorities later. 283 // Save the required data for computing tile priorities later.
282 void SetTilePriorityRects(const gfx::SizeF& content_to_screen_scale, 284 void SetTilePriorityRects(float content_to_screen_scale,
283 const gfx::Rect& visible_rect_in_content_space, 285 const gfx::Rect& visible_rect_in_content_space,
284 const gfx::Rect& skewport, 286 const gfx::Rect& skewport,
285 const gfx::Rect& soon_border_rect, 287 const gfx::Rect& soon_border_rect,
286 const gfx::Rect& eventually_rect, 288 const gfx::Rect& eventually_rect,
287 const Occlusion& occlusion_in_layer_space); 289 const Occlusion& occlusion_in_layer_space);
288 290
289 bool IsTileOccludedOnCurrentTree(const Tile* tile) const; 291 bool IsTileOccludedOnCurrentTree(const Tile* tile) const;
290 Tile::CreateInfo CreateInfoForTile(int i, int j) const; 292 Tile::CreateInfo CreateInfoForTile(int i, int j) const;
291 bool ShouldCreateTileAt(const Tile::CreateInfo& info) const; 293 bool ShouldCreateTileAt(const Tile::CreateInfo& info) const;
292 bool IsTileOccluded(const Tile* tile) const; 294 bool IsTileOccluded(const Tile* tile) const;
(...skipping 27 matching lines...) Expand all
320 return current_skewport_rect_; 322 return current_skewport_rect_;
321 } 323 }
322 const gfx::Rect& current_soon_border_rect() const { 324 const gfx::Rect& current_soon_border_rect() const {
323 return current_soon_border_rect_; 325 return current_soon_border_rect_;
324 } 326 }
325 const gfx::Rect& current_eventually_rect() const { 327 const gfx::Rect& current_eventually_rect() const {
326 return current_eventually_rect_; 328 return current_eventually_rect_;
327 } 329 }
328 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); 330 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles);
329 331
332 gfx::Rect EnclosingContentsRectFromLayerRect(
333 const gfx::Rect& layer_rect) const;
334 gfx::Rect EnclosingLayerRectFromContentsRect(
335 const gfx::Rect& contents_rect) const;
336
330 // Given properties. 337 // Given properties.
331 const gfx::SizeF raster_scales_; 338 const ScaleTranslate2d raster_transform_;
332 PictureLayerTilingClient* const client_; 339 PictureLayerTilingClient* const client_;
333 const WhichTree tree_; 340 const WhichTree tree_;
334 scoped_refptr<RasterSource> raster_source_; 341 scoped_refptr<RasterSource> raster_source_;
335 const float min_preraster_distance_; 342 const float min_preraster_distance_;
336 const float max_preraster_distance_; 343 const float max_preraster_distance_;
337 TileResolution resolution_ = NON_IDEAL_RESOLUTION; 344 TileResolution resolution_ = NON_IDEAL_RESOLUTION;
338 bool may_contain_low_resolution_tiles_ = false; 345 bool may_contain_low_resolution_tiles_ = false;
339 346
340 // Internal data. 347 // Internal data.
341 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels); 348 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels);
342 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 349 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
343 gfx::Rect live_tiles_rect_; 350 gfx::Rect live_tiles_rect_;
344 351
345 bool can_require_tiles_for_activation_ = false; 352 bool can_require_tiles_for_activation_ = false;
346 353
347 // Iteration rects in content space. 354 // Iteration rects in content space.
348 gfx::Rect current_visible_rect_; 355 gfx::Rect current_visible_rect_;
349 gfx::Rect current_skewport_rect_; 356 gfx::Rect current_skewport_rect_;
350 gfx::Rect current_soon_border_rect_; 357 gfx::Rect current_soon_border_rect_;
351 gfx::Rect current_eventually_rect_; 358 gfx::Rect current_eventually_rect_;
352 // Other properties used for tile iteration and prioritization. 359 // Other properties used for tile iteration and prioritization.
353 gfx::SizeF current_content_to_screen_scale_; 360 float current_content_to_screen_scale_ = 0.f;
354 Occlusion current_occlusion_in_layer_space_; 361 Occlusion current_occlusion_in_layer_space_;
355 float max_skewport_extent_in_screen_space_ = 0.f; 362 float max_skewport_extent_in_screen_space_ = 0.f;
356 363
357 bool has_visible_rect_tiles_ = false; 364 bool has_visible_rect_tiles_ = false;
358 bool has_skewport_rect_tiles_ = false; 365 bool has_skewport_rect_tiles_ = false;
359 bool has_soon_border_rect_tiles_ = false; 366 bool has_soon_border_rect_tiles_ = false;
360 bool has_eventually_rect_tiles_ = false; 367 bool has_eventually_rect_tiles_ = false;
361 bool all_tiles_done_ = true; 368 bool all_tiles_done_ = true;
362 369
363 private: 370 private:
364 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); 371 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling);
365 }; 372 };
366 373
367 } // namespace cc 374 } // namespace cc
368 375
369 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ 376 #endif // CC_TILES_PICTURE_LAYER_TILING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698