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 #include "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 contents_scale)).IsEmpty()) | 72 contents_scale)).IsEmpty()) |
73 << "Tiling created with scale too small as contents become empty." | 73 << "Tiling created with scale too small as contents become empty." |
74 << " Layer bounds: " << raster_source_->GetSize().ToString() | 74 << " Layer bounds: " << raster_source_->GetSize().ToString() |
75 << " Contents scale: " << contents_scale; | 75 << " Contents scale: " << contents_scale; |
76 | 76 |
77 tiling_data_.SetTilingSize(content_bounds); | 77 tiling_data_.SetTilingSize(content_bounds); |
78 tiling_data_.SetMaxTextureSize(tile_size); | 78 tiling_data_.SetMaxTextureSize(tile_size); |
79 } | 79 } |
80 | 80 |
81 PictureLayerTiling::~PictureLayerTiling() { | 81 PictureLayerTiling::~PictureLayerTiling() { |
82 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | |
83 it->second->set_shared(false); | |
84 } | 82 } |
85 | 83 |
86 // static | 84 // static |
87 float PictureLayerTiling::CalculateSoonBorderDistance( | 85 float PictureLayerTiling::CalculateSoonBorderDistance( |
88 const gfx::Rect& visible_rect_in_content_space, | 86 const gfx::Rect& visible_rect_in_content_space, |
89 float content_to_screen_scale) { | 87 float content_to_screen_scale) { |
90 float max_dimension = std::max(visible_rect_in_content_space.width(), | 88 float max_dimension = std::max(visible_rect_in_content_space.width(), |
91 visible_rect_in_content_space.height()); | 89 visible_rect_in_content_space.height()); |
92 return std::min( | 90 return std::min( |
93 kMaxSoonBorderDistanceInScreenPixels / content_to_screen_scale, | 91 kMaxSoonBorderDistanceInScreenPixels / content_to_screen_scale, |
94 max_dimension * kSoonBorderDistanceViewportPercentage); | 92 max_dimension * kSoonBorderDistanceViewportPercentage); |
95 } | 93 } |
96 | 94 |
97 Tile* PictureLayerTiling::CreateTile(int i, | 95 Tile* PictureLayerTiling::CreateTile(int i, int j) { |
98 int j, | |
99 const PictureLayerTiling* twin_tiling, | |
100 PictureLayerTiling* recycled_twin) { | |
101 // Can't have both a (pending or active) twin and a recycled twin tiling. | |
102 DCHECK_IMPLIES(twin_tiling, !recycled_twin); | |
103 DCHECK_IMPLIES(recycled_twin, !twin_tiling); | |
104 TileMapKey key(i, j); | 96 TileMapKey key(i, j); |
105 DCHECK(tiles_.find(key) == tiles_.end()); | 97 DCHECK(tiles_.find(key) == tiles_.end()); |
106 | 98 |
107 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | 99 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); |
108 gfx::Rect tile_rect = paint_rect; | 100 gfx::Rect tile_rect = paint_rect; |
109 tile_rect.set_size(tiling_data_.max_texture_size()); | 101 tile_rect.set_size(tiling_data_.max_texture_size()); |
110 | 102 |
111 // Check our twin for a valid tile. | |
enne (OOO)
2015/04/09 17:54:23
I'm not 100% opposed to different classes for pend
vmpstr
2015/04/10 20:25:13
Acknowledged.
| |
112 if (twin_tiling && | |
113 tiling_data_.max_texture_size() == | |
114 twin_tiling->tiling_data_.max_texture_size()) { | |
115 if (Tile* candidate_tile = twin_tiling->TileAt(i, j)) { | |
116 gfx::Rect rect = | |
117 gfx::ScaleToEnclosingRect(paint_rect, 1.0f / contents_scale_); | |
118 const Region* invalidation = client_->GetPendingInvalidation(); | |
119 if (!invalidation || !invalidation->Intersects(rect)) { | |
120 DCHECK(!candidate_tile->is_shared()); | |
121 DCHECK_EQ(i, candidate_tile->tiling_i_index()); | |
122 DCHECK_EQ(j, candidate_tile->tiling_j_index()); | |
123 candidate_tile->set_shared(true); | |
124 tiles_[key] = candidate_tile; | |
125 return candidate_tile; | |
126 } | |
127 } | |
128 } | |
129 | |
130 if (!raster_source_->CoversRect(tile_rect, contents_scale_)) | 103 if (!raster_source_->CoversRect(tile_rect, contents_scale_)) |
131 return nullptr; | 104 return nullptr; |
132 | 105 |
133 // Create a new tile because our twin didn't have a valid one. | |
134 scoped_refptr<Tile> tile = client_->CreateTile(contents_scale_, tile_rect); | 106 scoped_refptr<Tile> tile = client_->CreateTile(contents_scale_, tile_rect); |
135 DCHECK(!tile->is_shared()); | |
136 tile->set_tiling_index(i, j); | 107 tile->set_tiling_index(i, j); |
137 tiles_[key] = tile; | 108 tiles_[key] = tile; |
138 | |
139 if (recycled_twin) { | |
140 DCHECK(recycled_twin->tiles_.find(key) == recycled_twin->tiles_.end()); | |
141 // Do what recycled_twin->CreateTile() would do. | |
142 tile->set_shared(true); | |
143 recycled_twin->tiles_[key] = tile; | |
144 } | |
145 return tile.get(); | 109 return tile.get(); |
146 } | 110 } |
147 | 111 |
148 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { | 112 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { |
149 const PictureLayerTiling* twin_tiling = | |
150 client_->GetPendingOrActiveTwinTiling(this); | |
151 // There is no recycled twin during commit from the main thread which is when | |
152 // this occurs. | |
153 PictureLayerTiling* null_recycled_twin = nullptr; | |
154 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
155 bool include_borders = false; | 113 bool include_borders = false; |
156 for (TilingData::Iterator iter( | 114 for (TilingData::Iterator iter(&tiling_data_, live_tiles_rect_, |
157 &tiling_data_, live_tiles_rect_, include_borders); | 115 include_borders); |
158 iter; | 116 iter; ++iter) { |
159 ++iter) { | |
160 TileMapKey key = iter.index(); | 117 TileMapKey key = iter.index(); |
161 TileMap::iterator find = tiles_.find(key); | 118 TileMap::iterator find = tiles_.find(key); |
162 if (find != tiles_.end()) | 119 if (find != tiles_.end()) |
163 continue; | 120 continue; |
164 CreateTile(key.first, key.second, twin_tiling, null_recycled_twin); | 121 |
122 if (ShouldCreateTileAt(key.first, key.second)) | |
123 CreateTile(key.first, key.second); | |
165 } | 124 } |
166 | |
167 VerifyLiveTilesRect(false); | 125 VerifyLiveTilesRect(false); |
168 } | 126 } |
169 | 127 |
170 void PictureLayerTiling::CloneTilesAndPropertiesFrom( | 128 void PictureLayerTiling::TakeTilesAndPropertiesFrom( |
171 const PictureLayerTiling& twin_tiling) { | 129 PictureLayerTiling* pending_twin) { |
172 DCHECK_EQ(&twin_tiling, client_->GetPendingOrActiveTwinTiling(this)); | 130 SetRasterSourceAndResize(pending_twin->raster_source_); |
131 std::vector<TileMapKey> to_remove; | |
132 // If the new raster source covers a tile, then update the tile's raster | |
133 // source. Otherwise, the tile has to be removed since it's not fully covered. | |
134 // TODO(vmpstr): Figure out how to pass "remove a tile" information from | |
enne (OOO)
2015/04/09 17:54:24
Is this TODO an optimization, in that you think ch
vmpstr
2015/04/10 20:25:13
This is both an optimization and a simplification
| |
135 // pending to active. | |
136 for (const auto& tile_pair : tiles_) { | |
137 Tile* tile = tile_pair.second.get(); | |
138 if (raster_source_->CoversRect(tile->content_rect(), | |
danakj
2015/04/08 00:13:06
Doing scaling math for every tile here is a bit sa
vmpstr
2015/04/10 20:25:13
Yeep.
| |
139 tile->contents_scale())) { | |
140 tile->set_raster_source(raster_source_.get()); | |
141 } else { | |
142 to_remove.push_back(tile_pair.first); | |
143 } | |
144 } | |
145 for (const auto& key : to_remove) | |
146 RemoveTileAt(key.first, key.second); | |
173 | 147 |
174 SetRasterSourceAndResize(twin_tiling.raster_source_); | 148 resolution_ = pending_twin->resolution_; |
175 DCHECK_EQ(twin_tiling.contents_scale_, contents_scale_); | 149 SetLiveTilesRect(pending_twin->live_tiles_rect()); |
176 DCHECK_EQ(twin_tiling.raster_source_, raster_source_); | |
177 DCHECK_EQ(twin_tiling.tile_size().ToString(), tile_size().ToString()); | |
178 | 150 |
179 resolution_ = twin_tiling.resolution_; | 151 for (const auto& tile_pair : pending_twin->tiles_) |
danakj
2015/04/08 00:13:06
can you // this is copying the tiles_ from the pen
vmpstr
2015/04/10 20:25:13
I'm not sure what is bad here? Any method (short o
| |
152 tiles_[tile_pair.first] = tile_pair.second; | |
153 pending_twin->tiles_.clear(); | |
180 | 154 |
181 SetLiveTilesRect(twin_tiling.live_tiles_rect()); | 155 VerifyLiveTilesRect(false); |
182 | 156 |
183 // Recreate unshared tiles. | 157 SetTilePriorityRects(pending_twin->current_content_to_screen_scale_, |
184 std::vector<TileMapKey> to_remove; | 158 pending_twin->current_visible_rect_, |
185 for (const auto& tile_map_pair : tiles_) { | 159 pending_twin->current_skewport_rect_, |
186 TileMapKey key = tile_map_pair.first; | 160 pending_twin->current_soon_border_rect_, |
187 Tile* tile = tile_map_pair.second.get(); | 161 pending_twin->current_eventually_rect_, |
188 if (!tile->is_shared()) | 162 pending_twin->current_occlusion_in_layer_space_); |
189 to_remove.push_back(key); | |
190 } | |
191 // The recycled twin does not exist since there is a pending twin (which is | |
192 // |twin_tiling|). | |
193 PictureLayerTiling* null_recycled_twin = nullptr; | |
194 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
195 for (const auto& key : to_remove) { | |
196 RemoveTileAt(key.first, key.second, null_recycled_twin); | |
197 CreateTile(key.first, key.second, &twin_tiling, null_recycled_twin); | |
198 } | |
199 | |
200 // Create any missing tiles from the |twin_tiling|. | |
201 for (const auto& tile_map_pair : twin_tiling.tiles_) { | |
202 TileMapKey key = tile_map_pair.first; | |
203 Tile* tile = tile_map_pair.second.get(); | |
204 if (!tile->is_shared()) | |
205 CreateTile(key.first, key.second, &twin_tiling, null_recycled_twin); | |
206 } | |
207 | |
208 DCHECK_EQ(twin_tiling.tiles_.size(), tiles_.size()); | |
209 #if DCHECK_IS_ON() | |
210 for (const auto& tile_map_pair : tiles_) | |
211 DCHECK(tile_map_pair.second->is_shared()); | |
212 VerifyLiveTilesRect(false); | |
213 #endif | |
214 | |
215 UpdateTilePriorityRects(twin_tiling.current_content_to_screen_scale_, | |
216 twin_tiling.current_visible_rect_, | |
217 twin_tiling.current_skewport_rect_, | |
218 twin_tiling.current_soon_border_rect_, | |
219 twin_tiling.current_eventually_rect_, | |
220 twin_tiling.current_occlusion_in_layer_space_); | |
221 } | 163 } |
222 | 164 |
223 void PictureLayerTiling::SetRasterSourceAndResize( | 165 void PictureLayerTiling::SetRasterSourceAndResize( |
224 scoped_refptr<RasterSource> raster_source) { | 166 scoped_refptr<RasterSource> raster_source) { |
225 DCHECK(!raster_source->IsSolidColor()); | 167 DCHECK(!raster_source->IsSolidColor()); |
226 gfx::Size old_layer_bounds = raster_source_->GetSize(); | 168 gfx::Size old_layer_bounds = raster_source_->GetSize(); |
227 raster_source_.swap(raster_source); | 169 raster_source_.swap(raster_source); |
228 gfx::Size new_layer_bounds = raster_source_->GetSize(); | 170 gfx::Size new_layer_bounds = raster_source_->GetSize(); |
229 gfx::Size content_bounds = | 171 gfx::Size content_bounds = |
230 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); | 172 gfx::ToCeiledSize(gfx::ScaleSize(new_layer_bounds, contents_scale_)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 int after_bottom = -1; | 205 int after_bottom = -1; |
264 if (!live_tiles_rect_.IsEmpty()) { | 206 if (!live_tiles_rect_.IsEmpty()) { |
265 after_right = | 207 after_right = |
266 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); | 208 tiling_data_.TileXIndexFromSrcCoord(live_tiles_rect_.right() - 1); |
267 after_bottom = | 209 after_bottom = |
268 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); | 210 tiling_data_.TileYIndexFromSrcCoord(live_tiles_rect_.bottom() - 1); |
269 } | 211 } |
270 | 212 |
271 // There is no recycled twin since this is run on the pending tiling | 213 // There is no recycled twin since this is run on the pending tiling |
272 // during commit, and on the active tree during activate. | 214 // during commit, and on the active tree during activate. |
273 PictureLayerTiling* null_recycled_twin = nullptr; | |
274 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
275 | |
276 // Drop tiles outside the new layer bounds if the layer shrank. | 215 // Drop tiles outside the new layer bounds if the layer shrank. |
277 for (int i = after_right + 1; i <= before_right; ++i) { | 216 for (int i = after_right + 1; i <= before_right; ++i) { |
278 for (int j = before_top; j <= before_bottom; ++j) | 217 for (int j = before_top; j <= before_bottom; ++j) |
279 RemoveTileAt(i, j, null_recycled_twin); | 218 RemoveTileAt(i, j); |
280 } | 219 } |
281 for (int i = before_left; i <= after_right; ++i) { | 220 for (int i = before_left; i <= after_right; ++i) { |
282 for (int j = after_bottom + 1; j <= before_bottom; ++j) | 221 for (int j = after_bottom + 1; j <= before_bottom; ++j) |
283 RemoveTileAt(i, j, null_recycled_twin); | 222 RemoveTileAt(i, j); |
284 } | 223 } |
285 | 224 |
286 // If the layer grew, the live_tiles_rect_ is not changed, but a new row | |
287 // and/or column of tiles may now exist inside the same live_tiles_rect_. | |
288 const PictureLayerTiling* twin_tiling = | |
289 client_->GetPendingOrActiveTwinTiling(this); | |
290 if (after_right > before_right) { | 225 if (after_right > before_right) { |
291 DCHECK_EQ(after_right, before_right + 1); | 226 DCHECK_EQ(after_right, before_right + 1); |
292 for (int j = before_top; j <= after_bottom; ++j) | 227 for (int j = before_top; j <= after_bottom; ++j) { |
293 CreateTile(after_right, j, twin_tiling, null_recycled_twin); | 228 if (ShouldCreateTileAt(after_right, j)) |
229 CreateTile(after_right, j); | |
230 } | |
294 } | 231 } |
295 if (after_bottom > before_bottom) { | 232 if (after_bottom > before_bottom) { |
296 DCHECK_EQ(after_bottom, before_bottom + 1); | 233 DCHECK_EQ(after_bottom, before_bottom + 1); |
297 for (int i = before_left; i <= before_right; ++i) | 234 for (int i = before_left; i <= before_right; ++i) { |
298 CreateTile(i, after_bottom, twin_tiling, null_recycled_twin); | 235 if (ShouldCreateTileAt(i, after_bottom)) |
236 CreateTile(i, after_bottom); | |
237 } | |
299 } | 238 } |
300 } | 239 } |
301 | 240 |
302 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { | 241 void PictureLayerTiling::Invalidate(const Region& layer_invalidation) { |
242 // We don't need to invalidate the pending tiling, since | |
243 // CreateMissingTilesInLiveTilesRect will populate all the tiles that we need. | |
244 if (client_->GetTree() == PENDING_TREE) | |
245 return; | |
246 | |
247 // We only invalidate the active tiling when it's orphaned: it has no pending | |
248 // twin, so it's slated for removal in the future. | |
249 DCHECK(!client_->GetPendingOrActiveTwinTiling(this)); | |
303 if (live_tiles_rect_.IsEmpty()) | 250 if (live_tiles_rect_.IsEmpty()) |
304 return; | 251 return; |
305 std::vector<TileMapKey> new_tile_keys; | 252 std::vector<TileMapKey> new_tile_keys; |
306 gfx::Rect expanded_live_tiles_rect = | 253 gfx::Rect expanded_live_tiles_rect = |
307 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); | 254 tiling_data_.ExpandRectIgnoringBordersToTileBounds(live_tiles_rect_); |
308 for (Region::Iterator iter(layer_invalidation); iter.has_rect(); | 255 for (Region::Iterator iter(layer_invalidation); iter.has_rect(); |
309 iter.next()) { | 256 iter.next()) { |
310 gfx::Rect layer_rect = iter.rect(); | 257 gfx::Rect layer_rect = iter.rect(); |
311 gfx::Rect content_rect = | 258 gfx::Rect content_rect = |
312 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); | 259 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); |
313 // Consider tiles inside the live tiles rect even if only their border | 260 // Consider tiles inside the live tiles rect even if only their border |
314 // pixels intersect the invalidation. But don't consider tiles outside | 261 // pixels intersect the invalidation. But don't consider tiles outside |
315 // the live tiles rect with the same conditions, as they won't exist. | 262 // the live tiles rect with the same conditions, as they won't exist. |
316 int border_pixels = tiling_data_.border_texels(); | 263 int border_pixels = tiling_data_.border_texels(); |
317 content_rect.Inset(-border_pixels, -border_pixels); | 264 content_rect.Inset(-border_pixels, -border_pixels); |
318 // Avoid needless work by not bothering to invalidate where there aren't | 265 // Avoid needless work by not bothering to invalidate where there aren't |
319 // tiles. | 266 // tiles. |
320 content_rect.Intersect(expanded_live_tiles_rect); | 267 content_rect.Intersect(expanded_live_tiles_rect); |
321 if (content_rect.IsEmpty()) | 268 if (content_rect.IsEmpty()) |
322 continue; | 269 continue; |
323 // Since the content_rect includes border pixels already, don't include | 270 // Since the content_rect includes border pixels already, don't include |
324 // borders when iterating to avoid double counting them. | 271 // borders when iterating to avoid double counting them. |
325 bool include_borders = false; | 272 bool include_borders = false; |
326 for (TilingData::Iterator iter( | 273 for ( |
327 &tiling_data_, content_rect, include_borders); | 274 TilingData::Iterator iter(&tiling_data_, content_rect, include_borders); |
328 iter; | 275 iter; ++iter) { |
329 ++iter) { | 276 if (RemoveTileAt(iter.index_x(), iter.index_y())) |
330 // There is no recycled twin for the pending tree during commit, or for | |
331 // the active tree during activation. | |
332 PictureLayerTiling* null_recycled_twin = nullptr; | |
333 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
334 if (RemoveTileAt(iter.index_x(), iter.index_y(), null_recycled_twin)) | |
335 new_tile_keys.push_back(iter.index()); | 277 new_tile_keys.push_back(iter.index()); |
336 } | 278 } |
337 } | 279 } |
338 | 280 |
339 if (!new_tile_keys.empty()) { | 281 for (const auto& key : new_tile_keys) |
340 // During commit from the main thread, invalidations can never be shared | 282 CreateTile(key.first, key.second); |
341 // with the active tree since the active tree has different content there. | |
342 // And when invalidating an active-tree tiling, it means there was no | |
343 // pending tiling to clone from. | |
344 const PictureLayerTiling* null_twin_tiling = nullptr; | |
345 PictureLayerTiling* null_recycled_twin = nullptr; | |
346 DCHECK_EQ(null_recycled_twin, client_->GetRecycledTwinTiling(this)); | |
347 for (size_t i = 0; i < new_tile_keys.size(); ++i) { | |
348 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, | |
349 null_twin_tiling, null_recycled_twin); | |
350 } | |
351 } | |
352 } | 283 } |
353 | 284 |
354 void PictureLayerTiling::SetRasterSourceOnTiles() { | 285 void PictureLayerTiling::SetRasterSourceOnTiles() { |
355 // Shared (ie. non-invalidated) tiles on the pending tree are updated to use | 286 if (client_->GetTree() == PENDING_TREE) |
356 // the new raster source. When this raster source is activated, the raster | 287 return; |
357 // source will remain valid for shared tiles in the active tree. | 288 |
358 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) | 289 // TODO(vmpstr): Make iterators return the raster source instead. |
359 it->second->set_raster_source(raster_source_); | 290 for (auto& tile_pair : tiles_) |
360 VerifyLiveTilesRect(false); | 291 tile_pair.second->set_raster_source(raster_source_.get()); |
292 } | |
293 | |
294 bool PictureLayerTiling::ShouldCreateTileAt(int i, int j) const { | |
295 // Active tree should always create a tile. | |
enne (OOO)
2015/04/09 17:54:23
O_O
Can the active tree DCHECK that its raster so
vmpstr
2015/04/10 20:25:13
So this is the reason I split the classes into two
enne (OOO)
2015/04/10 21:16:28
Maybe the answer here is just better comments abou
vmpstr
2015/04/10 22:24:29
Added a comment.
| |
296 if (client_->GetTree() == ACTIVE_TREE) | |
297 return true; | |
298 | |
299 // If the pending tree has no active twin, then it needs to create all tiles. | |
300 const PictureLayerTiling* active_twin = | |
301 client_->GetPendingOrActiveTwinTiling(this); | |
302 if (!active_twin) | |
303 return true; | |
304 | |
305 // Pending tree will override the entire active tree if indices don't match. | |
306 if (!TilingMatchesTileIndices(active_twin)) | |
307 return true; | |
308 | |
309 gfx::Rect paint_rect = tiling_data_.TileBoundsWithBorder(i, j); | |
310 gfx::Rect tile_rect = paint_rect; | |
311 tile_rect.set_size(tiling_data_.max_texture_size()); | |
312 | |
313 // If the active tree can't create a tile, because of its raster source, then | |
314 // the pending tree should create one. | |
315 if (!active_twin->raster_source()->CoversRect(tile_rect, contents_scale())) | |
316 return true; | |
317 | |
318 const Region* layer_invalidation = client_->GetPendingInvalidation(); | |
319 gfx::Rect layer_rect = | |
320 gfx::ScaleToEnclosingRect(tile_rect, 1.f / contents_scale()); | |
321 | |
322 // If this tile is invalidated, then the pending tree should create one. | |
323 if (layer_invalidation && layer_invalidation->Intersects(layer_rect)) | |
324 return true; | |
325 | |
326 // If the active tree doesn't have a tile here, but it's in the pending tree's | |
327 // visible rect, then the pending tree should create a tile. This can happen | |
328 // if the pending visible rect is outside of the active tree's live tiles | |
329 // rect. In those situations, we need to block activation until we're ready to | |
330 // display content, which will have to come from the pending tree. | |
331 if (!active_twin->TileAt(i, j) && current_visible_rect_.Intersects(tile_rect)) | |
332 return true; | |
333 | |
334 // In all other cases, the pending tree doesn't need to create a tile. | |
335 return false; | |
336 } | |
337 | |
338 bool PictureLayerTiling::TilingMatchesTileIndices( | |
339 const PictureLayerTiling* twin) const { | |
340 return tiling_data_.max_texture_size() == | |
341 twin->tiling_data_.max_texture_size(); | |
361 } | 342 } |
362 | 343 |
363 PictureLayerTiling::CoverageIterator::CoverageIterator() | 344 PictureLayerTiling::CoverageIterator::CoverageIterator() |
364 : tiling_(NULL), | 345 : tiling_(NULL), |
365 current_tile_(NULL), | 346 current_tile_(NULL), |
366 tile_i_(0), | 347 tile_i_(0), |
367 tile_j_(0), | 348 tile_j_(0), |
368 left_(0), | 349 left_(0), |
369 top_(0), | 350 top_(0), |
370 right_(-1), | 351 right_(-1), |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 texture_rect.Scale(dest_to_content_scale_, | 473 texture_rect.Scale(dest_to_content_scale_, |
493 dest_to_content_scale_); | 474 dest_to_content_scale_); |
494 texture_rect.Intersect(gfx::Rect(tiling_->tiling_size())); | 475 texture_rect.Intersect(gfx::Rect(tiling_->tiling_size())); |
495 if (texture_rect.IsEmpty()) | 476 if (texture_rect.IsEmpty()) |
496 return texture_rect; | 477 return texture_rect; |
497 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); | 478 texture_rect.Offset(-tex_origin.OffsetFromOrigin()); |
498 | 479 |
499 return texture_rect; | 480 return texture_rect; |
500 } | 481 } |
501 | 482 |
502 bool PictureLayerTiling::RemoveTileAt(int i, | 483 bool PictureLayerTiling::RemoveTileAt(int i, int j) { |
503 int j, | |
504 PictureLayerTiling* recycled_twin) { | |
505 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); | 484 TileMap::iterator found = tiles_.find(TileMapKey(i, j)); |
506 if (found == tiles_.end()) | 485 if (found == tiles_.end()) |
507 return false; | 486 return false; |
508 found->second->set_shared(false); | |
509 tiles_.erase(found); | 487 tiles_.erase(found); |
510 if (recycled_twin) { | |
511 // Recycled twin does not also have a recycled twin, so pass null. | |
512 recycled_twin->RemoveTileAt(i, j, nullptr); | |
513 } | |
514 return true; | 488 return true; |
515 } | 489 } |
516 | 490 |
517 void PictureLayerTiling::Reset() { | 491 void PictureLayerTiling::Reset() { |
518 live_tiles_rect_ = gfx::Rect(); | 492 live_tiles_rect_ = gfx::Rect(); |
519 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | |
520 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
521 it->second->set_shared(false); | |
522 if (recycled_twin) | |
523 recycled_twin->RemoveTileAt(it->first.first, it->first.second, nullptr); | |
524 } | |
525 tiles_.clear(); | 493 tiles_.clear(); |
526 } | 494 } |
527 | 495 |
528 gfx::Rect PictureLayerTiling::ComputeSkewport( | 496 gfx::Rect PictureLayerTiling::ComputeSkewport( |
529 double current_frame_time_in_seconds, | 497 double current_frame_time_in_seconds, |
530 const gfx::Rect& visible_rect_in_content_space) const { | 498 const gfx::Rect& visible_rect_in_content_space) const { |
531 gfx::Rect skewport = visible_rect_in_content_space; | 499 gfx::Rect skewport = visible_rect_in_content_space; |
532 if (skewport.IsEmpty()) | 500 if (skewport.IsEmpty()) |
533 return skewport; | 501 return skewport; |
534 | 502 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
624 float content_to_screen_scale = ideal_contents_scale / contents_scale_; | 592 float content_to_screen_scale = ideal_contents_scale / contents_scale_; |
625 gfx::Rect soon_border_rect = visible_rect_in_content_space; | 593 gfx::Rect soon_border_rect = visible_rect_in_content_space; |
626 float border = CalculateSoonBorderDistance(visible_rect_in_content_space, | 594 float border = CalculateSoonBorderDistance(visible_rect_in_content_space, |
627 content_to_screen_scale); | 595 content_to_screen_scale); |
628 soon_border_rect.Inset(-border, -border, -border, -border); | 596 soon_border_rect.Inset(-border, -border, -border, -border); |
629 | 597 |
630 UpdateVisibleRectHistory(current_frame_time_in_seconds, | 598 UpdateVisibleRectHistory(current_frame_time_in_seconds, |
631 visible_rect_in_content_space); | 599 visible_rect_in_content_space); |
632 last_viewport_in_layer_space_ = viewport_in_layer_space; | 600 last_viewport_in_layer_space_ = viewport_in_layer_space; |
633 | 601 |
602 SetTilePriorityRects(content_to_screen_scale, visible_rect_in_content_space, | |
603 skewport, soon_border_rect, eventually_rect, | |
604 occlusion_in_layer_space); | |
634 SetLiveTilesRect(eventually_rect); | 605 SetLiveTilesRect(eventually_rect); |
635 UpdateTilePriorityRects( | |
636 content_to_screen_scale, visible_rect_in_content_space, skewport, | |
637 soon_border_rect, eventually_rect, occlusion_in_layer_space); | |
638 return true; | 606 return true; |
639 } | 607 } |
640 | 608 |
641 void PictureLayerTiling::UpdateTilePriorityRects( | 609 void PictureLayerTiling::SetTilePriorityRects( |
642 float content_to_screen_scale, | 610 float content_to_screen_scale, |
643 const gfx::Rect& visible_rect_in_content_space, | 611 const gfx::Rect& visible_rect_in_content_space, |
644 const gfx::Rect& skewport, | 612 const gfx::Rect& skewport, |
645 const gfx::Rect& soon_border_rect, | 613 const gfx::Rect& soon_border_rect, |
646 const gfx::Rect& eventually_rect, | 614 const gfx::Rect& eventually_rect, |
647 const Occlusion& occlusion_in_layer_space) { | 615 const Occlusion& occlusion_in_layer_space) { |
648 current_visible_rect_ = visible_rect_in_content_space; | 616 current_visible_rect_ = visible_rect_in_content_space; |
649 current_skewport_rect_ = skewport; | 617 current_skewport_rect_ = skewport; |
650 current_soon_border_rect_ = soon_border_rect; | 618 current_soon_border_rect_ = soon_border_rect; |
651 current_eventually_rect_ = eventually_rect; | 619 current_eventually_rect_ = eventually_rect; |
(...skipping 10 matching lines...) Expand all Loading... | |
662 | 630 |
663 void PictureLayerTiling::SetLiveTilesRect( | 631 void PictureLayerTiling::SetLiveTilesRect( |
664 const gfx::Rect& new_live_tiles_rect) { | 632 const gfx::Rect& new_live_tiles_rect) { |
665 DCHECK(new_live_tiles_rect.IsEmpty() || | 633 DCHECK(new_live_tiles_rect.IsEmpty() || |
666 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) | 634 gfx::Rect(tiling_size()).Contains(new_live_tiles_rect)) |
667 << "tiling_size: " << tiling_size().ToString() | 635 << "tiling_size: " << tiling_size().ToString() |
668 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); | 636 << " new_live_tiles_rect: " << new_live_tiles_rect.ToString(); |
669 if (live_tiles_rect_ == new_live_tiles_rect) | 637 if (live_tiles_rect_ == new_live_tiles_rect) |
670 return; | 638 return; |
671 | 639 |
672 PictureLayerTiling* recycled_twin = client_->GetRecycledTwinTiling(this); | |
673 | |
674 // Iterate to delete all tiles outside of our new live_tiles rect. | 640 // Iterate to delete all tiles outside of our new live_tiles rect. |
675 for (TilingData::DifferenceIterator iter(&tiling_data_, | 641 for (TilingData::DifferenceIterator iter(&tiling_data_, live_tiles_rect_, |
676 live_tiles_rect_, | |
677 new_live_tiles_rect); | 642 new_live_tiles_rect); |
678 iter; | 643 iter; ++iter) { |
679 ++iter) { | 644 RemoveTileAt(iter.index_x(), iter.index_y()); |
680 RemoveTileAt(iter.index_x(), iter.index_y(), recycled_twin); | |
681 } | 645 } |
682 | 646 |
683 const PictureLayerTiling* twin_tiling = | |
684 client_->GetPendingOrActiveTwinTiling(this); | |
685 | |
686 // Iterate to allocate new tiles for all regions with newly exposed area. | 647 // Iterate to allocate new tiles for all regions with newly exposed area. |
687 for (TilingData::DifferenceIterator iter(&tiling_data_, | 648 for (TilingData::DifferenceIterator iter(&tiling_data_, new_live_tiles_rect, |
688 new_live_tiles_rect, | |
689 live_tiles_rect_); | 649 live_tiles_rect_); |
690 iter; | 650 iter; ++iter) { |
691 ++iter) { | |
692 TileMapKey key(iter.index()); | 651 TileMapKey key(iter.index()); |
693 CreateTile(key.first, key.second, twin_tiling, recycled_twin); | 652 if (ShouldCreateTileAt(key.first, key.second)) |
653 CreateTile(key.first, key.second); | |
694 } | 654 } |
695 | 655 |
696 live_tiles_rect_ = new_live_tiles_rect; | 656 live_tiles_rect_ = new_live_tiles_rect; |
697 VerifyLiveTilesRect(false); | 657 VerifyLiveTilesRect(false); |
698 if (recycled_twin) { | |
699 recycled_twin->live_tiles_rect_ = live_tiles_rect_; | |
700 recycled_twin->VerifyLiveTilesRect(true); | |
701 } | |
702 } | 658 } |
703 | 659 |
704 void PictureLayerTiling::VerifyLiveTilesRect(bool is_on_recycle_tree) const { | 660 void PictureLayerTiling::VerifyLiveTilesRect(bool is_on_recycle_tree) const { |
705 #if DCHECK_IS_ON() | 661 #if DCHECK_IS_ON() |
706 for (auto it = tiles_.begin(); it != tiles_.end(); ++it) { | 662 for (auto it = tiles_.begin(); it != tiles_.end(); ++it) { |
707 if (!it->second.get()) | 663 if (!it->second.get()) |
708 continue; | 664 continue; |
709 DCHECK(it->first.first < tiling_data_.num_tiles_x()) | 665 DCHECK(it->first.first < tiling_data_.num_tiles_x()) |
710 << this << " " << it->first.first << "," << it->first.second | 666 << this << " " << it->first.first << "," << it->first.second |
711 << " num_tiles_x " << tiling_data_.num_tiles_x() << " live_tiles_rect " | 667 << " num_tiles_x " << tiling_data_.num_tiles_x() << " live_tiles_rect " |
712 << live_tiles_rect_.ToString(); | 668 << live_tiles_rect_.ToString(); |
713 DCHECK(it->first.second < tiling_data_.num_tiles_y()) | 669 DCHECK(it->first.second < tiling_data_.num_tiles_y()) |
714 << this << " " << it->first.first << "," << it->first.second | 670 << this << " " << it->first.first << "," << it->first.second |
715 << " num_tiles_y " << tiling_data_.num_tiles_y() << " live_tiles_rect " | 671 << " num_tiles_y " << tiling_data_.num_tiles_y() << " live_tiles_rect " |
716 << live_tiles_rect_.ToString(); | 672 << live_tiles_rect_.ToString(); |
717 DCHECK(tiling_data_.TileBounds(it->first.first, it->first.second) | 673 DCHECK(tiling_data_.TileBounds(it->first.first, it->first.second) |
718 .Intersects(live_tiles_rect_)) | 674 .Intersects(live_tiles_rect_)) |
719 << this << " " << it->first.first << "," << it->first.second | 675 << this << " " << it->first.first << "," << it->first.second |
720 << " tile bounds " | 676 << " tile bounds " |
721 << tiling_data_.TileBounds(it->first.first, it->first.second).ToString() | 677 << tiling_data_.TileBounds(it->first.first, it->first.second).ToString() |
722 << " live_tiles_rect " << live_tiles_rect_.ToString(); | 678 << " live_tiles_rect " << live_tiles_rect_.ToString(); |
723 DCHECK_IMPLIES(is_on_recycle_tree, it->second->is_shared()); | 679 DCHECK_IMPLIES(is_on_recycle_tree, it->second->is_shared()); |
724 } | 680 } |
725 #endif | 681 #endif |
726 } | 682 } |
727 | 683 |
728 bool PictureLayerTiling::IsTileOccluded(const Tile* tile) const { | 684 bool PictureLayerTiling::IsTileOccluded(const Tile* tile) const { |
729 DCHECK(tile); | 685 // If this tile is not occluded on this tree, then it is not occluded. |
686 if (!IsTileOccludedOnCurrentTree(tile)) | |
687 return false; | |
730 | 688 |
689 // Otherwise, if this is the pending tree, we're done and the tile is | |
690 // occluded. | |
691 if (client_->GetTree() == PENDING_TREE) | |
692 return true; | |
693 | |
694 // On the active tree however, we need to check if this tile will be | |
695 // unoccluded upon activation, in which case it has to be considered | |
696 // unoccluded. | |
697 const PictureLayerTiling* pending_twin = | |
698 client_->GetPendingOrActiveTwinTiling(this); | |
699 if (pending_twin) { | |
700 // If there's a pending tile in the same position. Or if the pending twin | |
701 // would have to be creating all tiles, then we don't need to worry about | |
702 // occlusion on the twin. | |
703 if (!TilingMatchesTileIndices(pending_twin) || | |
704 pending_twin->TileAt(tile->tiling_i_index(), tile->tiling_j_index())) { | |
705 return true; | |
706 } | |
707 return pending_twin->IsTileOccludedOnCurrentTree(tile); | |
708 } | |
709 return true; | |
710 } | |
711 | |
712 bool PictureLayerTiling::IsTileOccludedOnCurrentTree(const Tile* tile) const { | |
731 if (!current_occlusion_in_layer_space_.HasOcclusion()) | 713 if (!current_occlusion_in_layer_space_.HasOcclusion()) |
732 return false; | 714 return false; |
733 | |
734 gfx::Rect tile_query_rect = | 715 gfx::Rect tile_query_rect = |
735 gfx::IntersectRects(tile->content_rect(), current_visible_rect_); | 716 gfx::IntersectRects(tile->content_rect(), current_visible_rect_); |
736 | |
737 // Explicitly check if the tile is outside the viewport. If so, we need to | 717 // Explicitly check if the tile is outside the viewport. If so, we need to |
738 // return false, since occlusion for this tile is unknown. | 718 // return false, since occlusion for this tile is unknown. |
739 // TODO(vmpstr): Since the current visible rect is really a viewport in | |
740 // layer space, we should probably clip tile query rect to tiling bounds | |
741 // or live tiles rect. | |
742 if (tile_query_rect.IsEmpty()) | 719 if (tile_query_rect.IsEmpty()) |
743 return false; | 720 return false; |
744 | 721 |
745 if (contents_scale_ != 1.f) { | 722 if (contents_scale_ != 1.f) { |
746 tile_query_rect = | 723 tile_query_rect = |
747 gfx::ScaleToEnclosingRect(tile_query_rect, 1.0f / contents_scale_); | 724 gfx::ScaleToEnclosingRect(tile_query_rect, 1.f / contents_scale_); |
748 } | 725 } |
749 | |
750 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); | 726 return current_occlusion_in_layer_space_.IsOccluded(tile_query_rect); |
751 } | 727 } |
752 | 728 |
753 bool PictureLayerTiling::IsTileRequiredForActivationIfVisible( | 729 bool PictureLayerTiling::IsTileRequiredForActivation(const Tile* tile) const { |
754 const Tile* tile) const { | 730 if (client_->GetTree() == PENDING_TREE) { |
755 DCHECK_EQ(PENDING_TREE, client_->GetTree()); | 731 // If we're not allowed to required tiles for activation, then the tile is |
enne (OOO)
2015/04/09 17:54:23
*require
| |
732 // not required. | |
733 if (!can_require_tiles_for_activation_) | |
734 return false; | |
756 | 735 |
757 // This function assumes that the tile is visible (i.e. in the viewport). The | 736 // If this is not a high res tiling, then the tile is not required. |
758 // caller needs to make sure that this condition is met to ensure we don't | 737 if (resolution_ != HIGH_RESOLUTION) |
759 // block activation on tiles outside of the viewport. | 738 return false; |
760 | 739 |
761 // If we are not allowed to mark tiles as required for activation, then don't | 740 // If the tile is occluded, then it's not required. |
762 // do it. | 741 if (IsTileOccluded(tile)) |
763 if (!can_require_tiles_for_activation_) | 742 return false; |
743 | |
744 bool tile_in_visible_rect = | |
745 tile->content_rect().Intersects(current_visible_rect_); | |
746 if (tile_in_visible_rect && client_->RequiresHighResToDraw()) | |
747 return true; | |
748 | |
749 // Otherwise, the tile is required if it's in the pending tree's visible | |
enne (OOO)
2015/04/09 17:54:23
I think this comment (and a lot of other ones in t
vmpstr
2015/04/10 20:25:13
Done.
| |
750 // rect. | |
751 return tile_in_visible_rect; | |
752 } | |
753 | |
754 DCHECK(client_->GetTree() == ACTIVE_TREE); | |
755 const PictureLayerTiling* pending_twin = | |
756 client_->GetPendingOrActiveTwinTiling(this); | |
757 // If we don't have a pending tree, or the pending tree will overwrite the | |
758 // given tile, then it is not required for activation. | |
759 if (!pending_twin || !TilingMatchesTileIndices(pending_twin) || | |
760 pending_twin->TileAt(tile->tiling_i_index(), tile->tiling_j_index())) { | |
761 return false; | |
762 } | |
763 // Otherwise, ask the pending twin if this tile is required for activation. | |
764 return pending_twin->IsTileRequiredForActivation(tile); | |
765 } | |
766 | |
767 bool PictureLayerTiling::IsTileRequiredForDraw(const Tile* tile) const { | |
768 if (client_->GetTree() == PENDING_TREE) | |
764 return false; | 769 return false; |
765 | 770 |
766 if (resolution_ != HIGH_RESOLUTION) | 771 if (resolution_ != HIGH_RESOLUTION) |
767 return false; | 772 return false; |
768 | 773 |
769 if (IsTileOccluded(tile)) | 774 bool tile_is_visible = current_visible_rect_.Intersects(tile->content_rect()); |
775 if (!tile_is_visible) | |
770 return false; | 776 return false; |
771 | 777 |
772 if (client_->RequiresHighResToDraw()) | 778 if (IsTileOccludedOnCurrentTree(tile)) |
773 return true; | |
774 | |
775 const PictureLayerTiling* twin_tiling = | |
776 client_->GetPendingOrActiveTwinTiling(this); | |
777 if (!twin_tiling) | |
778 return true; | |
779 | |
780 if (twin_tiling->raster_source()->GetSize() != raster_source()->GetSize()) | |
781 return true; | |
782 | |
783 if (twin_tiling->current_visible_rect_ != current_visible_rect_) | |
784 return true; | |
785 | |
786 Tile* twin_tile = | |
787 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); | |
788 // If twin tile is missing, it might not have a recording, so we don't need | |
789 // this tile to be required for activation. | |
790 if (!twin_tile) | |
791 return false; | 779 return false; |
792 | |
793 return true; | |
794 } | |
795 | |
796 bool PictureLayerTiling::IsTileRequiredForDrawIfVisible( | |
797 const Tile* tile) const { | |
798 DCHECK_EQ(ACTIVE_TREE, client_->GetTree()); | |
799 | |
800 // This function assumes that the tile is visible (i.e. in the viewport). | |
801 | |
802 if (resolution_ != HIGH_RESOLUTION) | |
803 return false; | |
804 | |
805 if (IsTileOccluded(tile)) | |
806 return false; | |
807 | |
808 return true; | 780 return true; |
809 } | 781 } |
810 | 782 |
811 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { | 783 void PictureLayerTiling::UpdateTileAndTwinPriority(Tile* tile) const { |
784 // TODO(vmpstr): Remove references to tree/twin_tree in tile. | |
812 WhichTree tree = client_->GetTree(); | 785 WhichTree tree = client_->GetTree(); |
813 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; | 786 WhichTree twin_tree = tree == ACTIVE_TREE ? PENDING_TREE : ACTIVE_TREE; |
814 | |
815 tile->SetPriority(tree, ComputePriorityForTile(tile)); | 787 tile->SetPriority(tree, ComputePriorityForTile(tile)); |
816 UpdateRequiredStateForTile(tile, tree); | 788 tile->SetPriority(twin_tree, TilePriority()); |
817 | 789 bool is_tile_occluded = IsTileOccluded(tile); |
818 const PictureLayerTiling* twin_tiling = | 790 tile->set_is_occluded(tree, is_tile_occluded); |
819 client_->GetPendingOrActiveTwinTiling(this); | 791 tile->set_is_occluded(twin_tree, is_tile_occluded); |
820 if (!tile->is_shared() || !twin_tiling) { | 792 tile->set_required_for_activation(IsTileRequiredForActivation(tile)); |
821 tile->SetPriority(twin_tree, TilePriority()); | 793 tile->set_required_for_draw(IsTileRequiredForDraw(tile)); |
822 tile->set_is_occluded(twin_tree, false); | |
823 if (twin_tree == PENDING_TREE) | |
824 tile->set_required_for_activation(false); | |
825 else | |
826 tile->set_required_for_draw(false); | |
827 return; | |
828 } | |
829 | |
830 tile->SetPriority(twin_tree, twin_tiling->ComputePriorityForTile(tile)); | |
831 twin_tiling->UpdateRequiredStateForTile(tile, twin_tree); | |
832 } | |
833 | |
834 void PictureLayerTiling::UpdateRequiredStateForTile(Tile* tile, | |
835 WhichTree tree) const { | |
836 if (tile->priority(tree).priority_bin == TilePriority::NOW) { | |
837 if (tree == PENDING_TREE) { | |
838 tile->set_required_for_activation( | |
839 IsTileRequiredForActivationIfVisible(tile)); | |
840 } else { | |
841 tile->set_required_for_draw(IsTileRequiredForDrawIfVisible(tile)); | |
842 } | |
843 tile->set_is_occluded(tree, IsTileOccluded(tile)); | |
844 return; | |
845 } | |
846 | |
847 // Non-NOW bin tiles are not required or occluded. | |
848 if (tree == PENDING_TREE) | |
849 tile->set_required_for_activation(false); | |
850 else | |
851 tile->set_required_for_draw(false); | |
852 tile->set_is_occluded(tree, false); | |
853 } | 794 } |
854 | 795 |
855 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { | 796 void PictureLayerTiling::VerifyAllTilesHaveCurrentRasterSource() const { |
856 #if DCHECK_IS_ON() | 797 #if DCHECK_IS_ON() |
857 for (const auto& tile_pair : tiles_) | 798 for (const auto& tile_pair : tiles_) |
858 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); | 799 DCHECK_EQ(raster_source_.get(), tile_pair.second->raster_source()); |
859 #endif | 800 #endif |
860 } | 801 } |
861 | 802 |
862 TilePriority PictureLayerTiling::ComputePriorityForTile( | 803 TilePriority PictureLayerTiling::ComputePriorityForTile( |
863 const Tile* tile) const { | 804 const Tile* tile) const { |
864 // TODO(vmpstr): See if this can be moved to iterators. | 805 // TODO(vmpstr): See if this can be moved to iterators. |
865 TilePriority::PriorityBin max_tile_priority_bin = | 806 TilePriority::PriorityBin max_tile_priority_bin = |
866 client_->GetMaxTilePriorityBin(); | 807 client_->GetMaxTilePriorityBin(); |
867 | 808 |
868 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); | 809 DCHECK_EQ(TileAt(tile->tiling_i_index(), tile->tiling_j_index()), tile); |
869 gfx::Rect tile_bounds = | 810 gfx::Rect tile_bounds = |
870 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); | 811 tiling_data_.TileBounds(tile->tiling_i_index(), tile->tiling_j_index()); |
871 | 812 |
872 if (max_tile_priority_bin <= TilePriority::NOW && | 813 if (max_tile_priority_bin <= TilePriority::NOW && |
873 current_visible_rect_.Intersects(tile_bounds)) { | 814 current_visible_rect_.Intersects(tile_bounds)) { |
874 return TilePriority(resolution_, TilePriority::NOW, 0); | 815 return TilePriority(resolution_, TilePriority::NOW, 0); |
875 } | 816 } |
876 | 817 |
818 if (max_tile_priority_bin <= TilePriority::SOON && | |
819 pending_visible_rect().Intersects(tile_bounds)) { | |
820 return TilePriority(resolution_, TilePriority::SOON, 0); | |
821 } | |
822 | |
877 DCHECK_GT(current_content_to_screen_scale_, 0.f); | 823 DCHECK_GT(current_content_to_screen_scale_, 0.f); |
878 float distance_to_visible = | 824 float distance_to_visible = |
879 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * | 825 current_visible_rect_.ManhattanInternalDistance(tile_bounds) * |
880 current_content_to_screen_scale_; | 826 current_content_to_screen_scale_; |
881 | 827 |
882 if (max_tile_priority_bin <= TilePriority::SOON && | 828 if (max_tile_priority_bin <= TilePriority::SOON && |
883 (current_soon_border_rect_.Intersects(tile_bounds) || | 829 (current_soon_border_rect_.Intersects(tile_bounds) || |
884 current_skewport_rect_.Intersects(tile_bounds))) { | 830 current_skewport_rect_.Intersects(tile_bounds))) { |
885 return TilePriority(resolution_, TilePriority::SOON, distance_to_visible); | 831 return TilePriority(resolution_, TilePriority::SOON, distance_to_visible); |
886 } | 832 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1074 break; | 1020 break; |
1075 } | 1021 } |
1076 | 1022 |
1077 gfx::Rect result(origin_x, origin_y, width, height); | 1023 gfx::Rect result(origin_x, origin_y, width, height); |
1078 if (cache) | 1024 if (cache) |
1079 cache->previous_result = result; | 1025 cache->previous_result = result; |
1080 return result; | 1026 return result; |
1081 } | 1027 } |
1082 | 1028 |
1083 } // namespace cc | 1029 } // namespace cc |
OLD | NEW |