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

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

Issue 2629233002: cc: Remove separate x/y raster scales. (Closed)
Patch Set: Created 3 years, 11 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/test/fake_picture_layer_tiling_client.cc ('k') | cc/tiles/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_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 uint32_t value1_32 = value1; 74 uint32_t value1_32 = value1;
75 return (value1_32 << 16) | value2; 75 return (value1_32 << 16) | value2;
76 } 76 }
77 }; 77 };
78 78
79 class CC_EXPORT PictureLayerTiling { 79 class CC_EXPORT PictureLayerTiling {
80 public: 80 public:
81 static const int kBorderTexels = 1; 81 static const int kBorderTexels = 1;
82 82
83 PictureLayerTiling(WhichTree tree, 83 PictureLayerTiling(WhichTree tree,
84 const gfx::SizeF& raster_scales, 84 float raster_scale,
85 scoped_refptr<RasterSource> raster_source, 85 scoped_refptr<RasterSource> raster_source,
86 PictureLayerTilingClient* client, 86 PictureLayerTilingClient* client,
87 float min_preraster_distance, 87 float min_preraster_distance,
88 float max_preraster_distance); 88 float max_preraster_distance);
89 ~PictureLayerTiling(); 89 ~PictureLayerTiling();
90 90
91 PictureLayerTilingClient* client() const { return client_; } 91 PictureLayerTilingClient* client() const { return client_; }
92 92
93 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source); 93 void SetRasterSourceAndResize(scoped_refptr<RasterSource> raster_source);
94 void Invalidate(const Region& layer_invalidation); 94 void Invalidate(const Region& layer_invalidation);
(...skipping 18 matching lines...) Expand all
113 void set_can_require_tiles_for_activation(bool can_require_tiles) { 113 void set_can_require_tiles_for_activation(bool can_require_tiles) {
114 can_require_tiles_for_activation_ = can_require_tiles; 114 can_require_tiles_for_activation_ = can_require_tiles;
115 } 115 }
116 116
117 const scoped_refptr<RasterSource>& raster_source() const { 117 const scoped_refptr<RasterSource>& raster_source() const {
118 return raster_source_; 118 return raster_source_;
119 } 119 }
120 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); } 120 gfx::Size tiling_size() const { return tiling_data_.tiling_size(); }
121 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; } 121 gfx::Rect live_tiles_rect() const { return live_tiles_rect_; }
122 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); } 122 gfx::Size tile_size() const { return tiling_data_.max_texture_size(); }
123 float contents_scale_key() const { return raster_scales_.width(); } 123 float contents_scale() const { return contents_scale_; }
124 const gfx::SizeF& raster_scales() const { return raster_scales_; }
125 const TilingData* tiling_data() const { return &tiling_data_; } 124 const TilingData* tiling_data() const { return &tiling_data_; }
126 125
127 Tile* TileAt(int i, int j) const { 126 Tile* TileAt(int i, int j) const {
128 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j)); 127 TileMap::const_iterator iter = tiles_.find(TileMapKey(i, j));
129 return iter == tiles_.end() ? nullptr : iter->second.get(); 128 return iter == tiles_.end() ? nullptr : iter->second.get();
130 } 129 }
131 130
132 bool has_tiles() const { return !tiles_.empty(); } 131 bool has_tiles() const { return !tiles_.empty(); }
133 // all_tiles_done() can return false negatives. 132 // all_tiles_done() can return false negatives.
134 bool all_tiles_done() const { return all_tiles_done_; } 133 bool all_tiles_done() const { return all_tiles_done_; }
(...skipping 23 matching lines...) Expand all
158 } 157 }
159 158
160 void UpdateAllRequiredStateForTesting() { 159 void UpdateAllRequiredStateForTesting() {
161 for (const auto& key_tile_pair : tiles_) 160 for (const auto& key_tile_pair : tiles_)
162 UpdateRequiredStatesOnTile(key_tile_pair.second.get()); 161 UpdateRequiredStatesOnTile(key_tile_pair.second.get());
163 } 162 }
164 std::map<const Tile*, PrioritizedTile> 163 std::map<const Tile*, PrioritizedTile>
165 UpdateAndGetAllPrioritizedTilesForTesting() const; 164 UpdateAndGetAllPrioritizedTilesForTesting() const;
166 165
167 void SetAllTilesOccludedForTesting() { 166 void SetAllTilesOccludedForTesting() {
168 gfx::Rect viewport_in_layer_space = ScaleToEnclosingRect( 167 gfx::Rect viewport_in_layer_space =
169 current_visible_rect_, 1.f / raster_scales_.width(), 168 ScaleToEnclosingRect(current_visible_rect_, 1.f / contents_scale_);
170 1.f / raster_scales_.height());
171 current_occlusion_in_layer_space_ = 169 current_occlusion_in_layer_space_ =
172 Occlusion(gfx::Transform(), 170 Occlusion(gfx::Transform(),
173 SimpleEnclosedRegion(viewport_in_layer_space), 171 SimpleEnclosedRegion(viewport_in_layer_space),
174 SimpleEnclosedRegion(viewport_in_layer_space)); 172 SimpleEnclosedRegion(viewport_in_layer_space));
175 } 173 }
176 const gfx::Rect& GetCurrentVisibleRectForTesting() const { 174 const gfx::Rect& GetCurrentVisibleRectForTesting() const {
177 return current_visible_rect_; 175 return current_visible_rect_;
178 } 176 }
179 void SetTilePriorityRectsForTesting( 177 void SetTilePriorityRectsForTesting(
180 const gfx::Rect& visible_rect_in_content_space, 178 const gfx::Rect& visible_rect_in_content_space,
181 const gfx::Rect& skewport, 179 const gfx::Rect& skewport,
182 const gfx::Rect& soon_border_rect, 180 const gfx::Rect& soon_border_rect,
183 const gfx::Rect& eventually_rect) { 181 const gfx::Rect& eventually_rect) {
184 SetTilePriorityRects(gfx::SizeF(1.f, 1.f), visible_rect_in_content_space, 182 SetTilePriorityRects(1.f, visible_rect_in_content_space, skewport,
185 skewport, soon_border_rect, eventually_rect, 183 soon_border_rect, eventually_rect, Occlusion());
186 Occlusion());
187 } 184 }
188 185
189 // Iterate over all tiles to fill content_rect. Even if tiles are invalid 186 // 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. 187 // (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 188 // 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. 189 // exactly equal content_rect and no two geometry_rects should intersect.
193 class CC_EXPORT CoverageIterator { 190 class CC_EXPORT CoverageIterator {
194 public: 191 public:
195 CoverageIterator(); 192 CoverageIterator();
196 // This requests an iterator that produces a coverage of the 193 // This requests an iterator that produces a coverage of the
(...skipping 15 matching lines...) Expand all
212 CoverageIterator& operator++(); 209 CoverageIterator& operator++();
213 operator bool() const { return tile_j_ <= bottom_; } 210 operator bool() const { return tile_j_ <= bottom_; }
214 211
215 int i() const { return tile_i_; } 212 int i() const { return tile_i_; }
216 int j() const { return tile_j_; } 213 int j() const { return tile_j_; }
217 214
218 private: 215 private:
219 const PictureLayerTiling* tiling_ = nullptr; 216 const PictureLayerTiling* tiling_ = nullptr;
220 gfx::Size coverage_rect_max_bounds_; 217 gfx::Size coverage_rect_max_bounds_;
221 gfx::Rect coverage_rect_; 218 gfx::Rect coverage_rect_;
222 gfx::SizeF coverage_to_content_scale_; 219 float coverage_to_content_scale_;
223 220
224 Tile* current_tile_ = nullptr; 221 Tile* current_tile_ = nullptr;
225 gfx::Rect current_geometry_rect_; 222 gfx::Rect current_geometry_rect_;
226 int tile_i_ = 0; 223 int tile_i_ = 0;
227 int tile_j_ = 0; 224 int tile_j_ = 0;
228 int left_ = 0; 225 int left_ = 0;
229 int top_ = 0; 226 int top_ = 0;
230 int right_ = -1; 227 int right_ = -1;
231 int bottom_ = -1; 228 int bottom_ = -1;
232 229
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 270
274 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect); 271 void SetLiveTilesRect(const gfx::Rect& live_tiles_rect);
275 void VerifyLiveTilesRect(bool is_on_recycle_tree) const; 272 void VerifyLiveTilesRect(bool is_on_recycle_tree) const;
276 Tile* CreateTile(const Tile::CreateInfo& info); 273 Tile* CreateTile(const Tile::CreateInfo& info);
277 std::unique_ptr<Tile> TakeTileAt(int i, int j); 274 std::unique_ptr<Tile> TakeTileAt(int i, int j);
278 // Returns true if the Tile existed and was removed from the tiling. 275 // Returns true if the Tile existed and was removed from the tiling.
279 bool RemoveTileAt(int i, int j); 276 bool RemoveTileAt(int i, int j);
280 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const; 277 bool TilingMatchesTileIndices(const PictureLayerTiling* twin) const;
281 278
282 // Save the required data for computing tile priorities later. 279 // Save the required data for computing tile priorities later.
283 void SetTilePriorityRects(const gfx::SizeF& content_to_screen_scale, 280 void SetTilePriorityRects(float content_to_screen_scale,
284 const gfx::Rect& visible_rect_in_content_space, 281 const gfx::Rect& visible_rect_in_content_space,
285 const gfx::Rect& skewport, 282 const gfx::Rect& skewport,
286 const gfx::Rect& soon_border_rect, 283 const gfx::Rect& soon_border_rect,
287 const gfx::Rect& eventually_rect, 284 const gfx::Rect& eventually_rect,
288 const Occlusion& occlusion_in_layer_space); 285 const Occlusion& occlusion_in_layer_space);
289 286
290 bool IsTileOccludedOnCurrentTree(const Tile* tile) const; 287 bool IsTileOccludedOnCurrentTree(const Tile* tile) const;
291 Tile::CreateInfo CreateInfoForTile(int i, int j) const; 288 Tile::CreateInfo CreateInfoForTile(int i, int j) const;
292 bool ShouldCreateTileAt(const Tile::CreateInfo& info) const; 289 bool ShouldCreateTileAt(const Tile::CreateInfo& info) const;
293 bool IsTileOccluded(const Tile* tile) const; 290 bool IsTileOccluded(const Tile* tile) const;
(...skipping 28 matching lines...) Expand all
322 } 319 }
323 const gfx::Rect& current_soon_border_rect() const { 320 const gfx::Rect& current_soon_border_rect() const {
324 return current_soon_border_rect_; 321 return current_soon_border_rect_;
325 } 322 }
326 const gfx::Rect& current_eventually_rect() const { 323 const gfx::Rect& current_eventually_rect() const {
327 return current_eventually_rect_; 324 return current_eventually_rect_;
328 } 325 }
329 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles); 326 void RemoveTilesInRegion(const Region& layer_region, bool recreate_tiles);
330 327
331 // Given properties. 328 // Given properties.
332 const gfx::SizeF raster_scales_; 329 const float contents_scale_;
333 PictureLayerTilingClient* const client_; 330 PictureLayerTilingClient* const client_;
334 const WhichTree tree_; 331 const WhichTree tree_;
335 scoped_refptr<RasterSource> raster_source_; 332 scoped_refptr<RasterSource> raster_source_;
336 const float min_preraster_distance_; 333 const float min_preraster_distance_;
337 const float max_preraster_distance_; 334 const float max_preraster_distance_;
338 TileResolution resolution_ = NON_IDEAL_RESOLUTION; 335 TileResolution resolution_ = NON_IDEAL_RESOLUTION;
339 bool may_contain_low_resolution_tiles_ = false; 336 bool may_contain_low_resolution_tiles_ = false;
340 337
341 // Internal data. 338 // Internal data.
342 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels); 339 TilingData tiling_data_ = TilingData(gfx::Size(), gfx::Size(), kBorderTexels);
343 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map. 340 TileMap tiles_; // It is not legal to have a NULL tile in the tiles_ map.
344 gfx::Rect live_tiles_rect_; 341 gfx::Rect live_tiles_rect_;
345 342
346 bool can_require_tiles_for_activation_ = false; 343 bool can_require_tiles_for_activation_ = false;
347 344
348 // Iteration rects in content space. 345 // Iteration rects in content space.
349 gfx::Rect current_visible_rect_; 346 gfx::Rect current_visible_rect_;
350 gfx::Rect current_skewport_rect_; 347 gfx::Rect current_skewport_rect_;
351 gfx::Rect current_soon_border_rect_; 348 gfx::Rect current_soon_border_rect_;
352 gfx::Rect current_eventually_rect_; 349 gfx::Rect current_eventually_rect_;
353 // Other properties used for tile iteration and prioritization. 350 // Other properties used for tile iteration and prioritization.
354 gfx::SizeF current_content_to_screen_scale_; 351 float current_content_to_screen_scale_;
355 Occlusion current_occlusion_in_layer_space_; 352 Occlusion current_occlusion_in_layer_space_;
356 float max_skewport_extent_in_screen_space_ = 0.f; 353 float max_skewport_extent_in_screen_space_ = 0.f;
357 354
358 bool has_visible_rect_tiles_ = false; 355 bool has_visible_rect_tiles_ = false;
359 bool has_skewport_rect_tiles_ = false; 356 bool has_skewport_rect_tiles_ = false;
360 bool has_soon_border_rect_tiles_ = false; 357 bool has_soon_border_rect_tiles_ = false;
361 bool has_eventually_rect_tiles_ = false; 358 bool has_eventually_rect_tiles_ = false;
362 bool all_tiles_done_ = true; 359 bool all_tiles_done_ = true;
363 360
364 private: 361 private:
365 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling); 362 DISALLOW_COPY_AND_ASSIGN(PictureLayerTiling);
366 }; 363 };
367 364
368 } // namespace cc 365 } // namespace cc
369 366
370 #endif // CC_TILES_PICTURE_LAYER_TILING_H_ 367 #endif // CC_TILES_PICTURE_LAYER_TILING_H_
OLDNEW
« no previous file with comments | « cc/test/fake_picture_layer_tiling_client.cc ('k') | cc/tiles/picture_layer_tiling.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698