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 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 } | 57 } |
58 | 58 |
59 PictureLayerTiling::PictureLayerTiling(float contents_scale, | 59 PictureLayerTiling::PictureLayerTiling(float contents_scale, |
60 const gfx::Size& layer_bounds, | 60 const gfx::Size& layer_bounds, |
61 PictureLayerTilingClient* client) | 61 PictureLayerTilingClient* client) |
62 : contents_scale_(contents_scale), | 62 : contents_scale_(contents_scale), |
63 layer_bounds_(layer_bounds), | 63 layer_bounds_(layer_bounds), |
64 resolution_(NON_IDEAL_RESOLUTION), | 64 resolution_(NON_IDEAL_RESOLUTION), |
65 client_(client), | 65 client_(client), |
66 tiling_data_(gfx::Size(), gfx::Rect(), true), | 66 tiling_data_(gfx::Size(), gfx::Rect(), true), |
67 last_impl_frame_time_in_seconds_(0.0), | 67 last_impl_frame_time_in_seconds_(0.0) { |
68 eviction_tiles_cache_valid_(false), | |
69 eviction_cache_tree_priority_(SAME_PRIORITY_FOR_BOTH_TREES) { | |
70 gfx::Size content_bounds = | 68 gfx::Size content_bounds = |
71 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); | 69 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)); |
72 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); | 70 gfx::Size tile_size = client_->CalculateTileSize(content_bounds); |
73 | 71 |
74 DCHECK(!gfx::ToFlooredSize( | 72 DCHECK(!gfx::ToFlooredSize( |
75 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << | 73 gfx::ScaleSize(layer_bounds, contents_scale)).IsEmpty()) << |
76 "Tiling created with scale too small as contents become empty." << | 74 "Tiling created with scale too small as contents become empty." << |
77 " Layer bounds: " << layer_bounds.ToString() << | 75 " Layer bounds: " << layer_bounds.ToString() << |
78 " Contents scale: " << contents_scale; | 76 " Contents scale: " << contents_scale; |
79 | 77 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 gfx::ScaleToEnclosingRect(paint_rect, 1.0f / contents_scale_); | 109 gfx::ScaleToEnclosingRect(paint_rect, 1.0f / contents_scale_); |
112 if (!client_->GetInvalidation()->Intersects(rect)) { | 110 if (!client_->GetInvalidation()->Intersects(rect)) { |
113 tiles_[key] = candidate_tile; | 111 tiles_[key] = candidate_tile; |
114 return candidate_tile; | 112 return candidate_tile; |
115 } | 113 } |
116 } | 114 } |
117 } | 115 } |
118 | 116 |
119 // Create a new tile because our twin didn't have a valid one. | 117 // Create a new tile because our twin didn't have a valid one. |
120 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); | 118 scoped_refptr<Tile> tile = client_->CreateTile(this, tile_rect); |
121 if (tile.get()) | 119 if (tile.get()) { |
120 tile->set_tiling_index(i, j); | |
122 tiles_[key] = tile; | 121 tiles_[key] = tile; |
122 } | |
123 return tile.get(); | 123 return tile.get(); |
124 } | 124 } |
125 | 125 |
126 void PictureLayerTiling::CreateMissingTilesInLiveTilesRect() { | 126 Tile* PictureLayerTiling::GetOrCreateTileAt(int i, int j) { |
127 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | 127 Tile* existing_tile = TileAt(i, j); |
128 bool include_borders = true; | 128 if (existing_tile) |
129 for (TilingData::Iterator iter( | 129 return existing_tile; |
130 &tiling_data_, live_tiles_rect_, include_borders); | 130 return CreateTile(i, j, client_->GetTwinTiling(this)); |
131 iter; | |
132 ++iter) { | |
133 TileMapKey key = iter.index(); | |
134 TileMap::iterator find = tiles_.find(key); | |
135 if (find != tiles_.end()) | |
136 continue; | |
137 CreateTile(key.first, key.second, twin_tiling); | |
138 } | |
139 } | 131 } |
140 | 132 |
141 void PictureLayerTiling::SetLayerBounds(const gfx::Size& layer_bounds) { | 133 void PictureLayerTiling::SetLayerBounds(const gfx::Size& layer_bounds) { |
142 if (layer_bounds_ == layer_bounds) | 134 if (layer_bounds_ == layer_bounds) |
143 return; | 135 return; |
144 | 136 |
145 DCHECK(!layer_bounds.IsEmpty()); | 137 DCHECK(!layer_bounds.IsEmpty()); |
146 | 138 |
147 gfx::Size old_layer_bounds = layer_bounds_; | 139 gfx::Size old_layer_bounds = layer_bounds_; |
148 layer_bounds_ = layer_bounds; | 140 layer_bounds_ = layer_bounds; |
(...skipping 13 matching lines...) Expand all Loading... | |
162 bounded_live_tiles_rect.Intersect(gfx::Rect(content_bounds)); | 154 bounded_live_tiles_rect.Intersect(gfx::Rect(content_bounds)); |
163 SetLiveTilesRect(bounded_live_tiles_rect); | 155 SetLiveTilesRect(bounded_live_tiles_rect); |
164 tiling_data_.SetTilingRect(gfx::Rect(content_bounds)); | 156 tiling_data_.SetTilingRect(gfx::Rect(content_bounds)); |
165 | 157 |
166 // Create tiles for newly exposed areas. | 158 // Create tiles for newly exposed areas. |
167 Region layer_region((gfx::Rect(layer_bounds_))); | 159 Region layer_region((gfx::Rect(layer_bounds_))); |
168 layer_region.Subtract(gfx::Rect(old_layer_bounds)); | 160 layer_region.Subtract(gfx::Rect(old_layer_bounds)); |
169 Invalidate(layer_region); | 161 Invalidate(layer_region); |
170 } | 162 } |
171 | 163 |
172 void PictureLayerTiling::RemoveTilesInRegion(const Region& layer_region) { | |
173 DoInvalidate(layer_region, false /* recreate_tiles */); | |
174 } | |
175 | |
176 void PictureLayerTiling::Invalidate(const Region& layer_region) { | 164 void PictureLayerTiling::Invalidate(const Region& layer_region) { |
177 DoInvalidate(layer_region, true /* recreate_tiles */); | |
178 } | |
179 | |
180 void PictureLayerTiling::DoInvalidate(const Region& layer_region, | |
181 bool recreate_tiles) { | |
182 std::vector<TileMapKey> new_tile_keys; | |
183 gfx::Rect expanded_live_tiles_rect( | 165 gfx::Rect expanded_live_tiles_rect( |
184 tiling_data_.ExpandRectToTileBoundsWithBorders(live_tiles_rect_)); | 166 tiling_data_.ExpandRectToTileBoundsWithBorders(live_tiles_rect_)); |
185 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { | 167 for (Region::Iterator iter(layer_region); iter.has_rect(); iter.next()) { |
186 gfx::Rect layer_rect = iter.rect(); | 168 gfx::Rect layer_rect = iter.rect(); |
187 gfx::Rect content_rect = | 169 gfx::Rect content_rect = |
188 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); | 170 gfx::ScaleToEnclosingRect(layer_rect, contents_scale_); |
189 // Avoid needless work by not bothering to invalidate where there aren't | 171 // Avoid needless work by not bothering to invalidate where there aren't |
190 // tiles. | 172 // tiles. |
191 content_rect.Intersect(expanded_live_tiles_rect); | 173 content_rect.Intersect(expanded_live_tiles_rect); |
192 if (content_rect.IsEmpty()) | 174 if (content_rect.IsEmpty()) |
193 continue; | 175 continue; |
194 bool include_borders = true; | 176 bool include_borders = true; |
195 for (TilingData::Iterator iter( | 177 for (TilingData::Iterator iter( |
196 &tiling_data_, content_rect, include_borders); | 178 &tiling_data_, content_rect, include_borders); |
197 iter; | 179 iter; |
198 ++iter) { | 180 ++iter) { |
199 TileMapKey key(iter.index()); | 181 TileMapKey key(iter.index()); |
200 TileMap::iterator find = tiles_.find(key); | 182 TileMap::iterator find = tiles_.find(key); |
201 if (find == tiles_.end()) | 183 if (find == tiles_.end()) |
202 continue; | 184 continue; |
203 tiles_.erase(find); | 185 tiles_.erase(find); |
204 if (recreate_tiles) | |
205 new_tile_keys.push_back(key); | |
206 } | 186 } |
207 } | 187 } |
208 | |
209 if (recreate_tiles) { | |
210 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
211 for (size_t i = 0; i < new_tile_keys.size(); ++i) | |
212 CreateTile(new_tile_keys[i].first, new_tile_keys[i].second, twin_tiling); | |
213 } | |
214 } | 188 } |
215 | 189 |
190 void PictureLayerTiling::UpdateTileOcclusion(Tile* tile) { | |
191 if (!tile) | |
192 return; | |
193 | |
194 bool is_occluded = occlusion_set_.count(std::make_pair( | |
195 tile->tiling_i_index(), tile->tiling_j_index())) != 0; | |
196 tile->set_is_occluded(is_occluded); | |
197 } | |
198 | |
199 bool PictureLayerTiling::IsTileRequiredForActivation(Tile* tile) const { | |
vmpstr
2014/07/02 23:51:29
I tried my best to capture what the previous thing
| |
200 if (tile->is_occluded()) | |
201 return false; | |
202 | |
203 if (resolution_ != HIGH_RESOLUTION) | |
204 return false; | |
205 | |
206 WhichTree tree = client_->GetTree(); | |
207 if (tree != PENDING_TREE) | |
208 return false; | |
209 | |
210 if (client_->RequiresHighResToDraw()) | |
211 return true; | |
212 | |
213 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
214 if (twin_tiling) { | |
215 if (twin_tiling->layer_bounds() != layer_bounds()) | |
216 return true; | |
217 | |
218 Tile* twin_tile = | |
219 twin_tiling->TileAt(tile->tiling_i_index(), tile->tiling_j_index()); | |
220 if (!twin_tile || twin_tile == tile) | |
221 return false; | |
222 } | |
223 return true; | |
224 } | |
225 | |
216 PictureLayerTiling::CoverageIterator::CoverageIterator() | 226 PictureLayerTiling::CoverageIterator::CoverageIterator() |
217 : tiling_(NULL), | 227 : tiling_(NULL), |
218 current_tile_(NULL), | 228 current_tile_(NULL), |
219 tile_i_(0), | 229 tile_i_(0), |
220 tile_j_(0), | 230 tile_j_(0), |
221 left_(0), | 231 left_(0), |
222 top_(0), | 232 top_(0), |
223 right_(-1), | 233 right_(-1), |
224 bottom_(-1) { | 234 bottom_(-1) { |
225 } | 235 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 DCHECK(eventually_rect.IsEmpty() || TilingRect().Contains(eventually_rect)); | 468 DCHECK(eventually_rect.IsEmpty() || TilingRect().Contains(eventually_rect)); |
459 | 469 |
460 SetLiveTilesRect(eventually_rect); | 470 SetLiveTilesRect(eventually_rect); |
461 | 471 |
462 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; | 472 last_impl_frame_time_in_seconds_ = current_frame_time_in_seconds; |
463 last_visible_rect_in_content_space_ = visible_rect_in_content_space; | 473 last_visible_rect_in_content_space_ = visible_rect_in_content_space; |
464 | 474 |
465 current_visible_rect_in_content_space_ = visible_rect_in_content_space; | 475 current_visible_rect_in_content_space_ = visible_rect_in_content_space; |
466 current_skewport_ = skewport; | 476 current_skewport_ = skewport; |
467 current_eventually_rect_ = eventually_rect; | 477 current_eventually_rect_ = eventually_rect; |
468 eviction_tiles_cache_valid_ = false; | 478 content_to_screen_scale_ = 1.0f / (contents_scale_ * layer_contents_scale); |
469 | 479 |
470 TilePriority now_priority(resolution_, TilePriority::NOW, 0); | 480 current_soon_border_rect_ = visible_rect_in_content_space; |
471 float content_to_screen_scale = | 481 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale_; |
472 1.0f / (contents_scale_ * layer_contents_scale); | 482 current_soon_border_rect_.Inset(-border, -border, -border, -border); |
473 | 483 |
474 // Assign now priority to all visible tiles. | 484 // Compute occluded indecies. |
enne (OOO)
2014/07/07 19:41:59
I'm not buying the occlusion_set_. Why can't Upda
vmpstr
2014/07/07 23:24:47
From my understanding of occlusion, we can only re
| |
475 bool include_borders = true; | 485 occlusion_set_.clear(); |
476 for (TilingData::Iterator iter( | 486 if (occlusion_tracker) { |
477 &tiling_data_, visible_rect_in_content_space, include_borders); | 487 bool include_borders = true; |
478 iter; | 488 for (TilingData::Iterator iter( |
479 ++iter) { | 489 &tiling_data_, visible_rect_in_content_space, include_borders); |
480 TileMap::iterator find = tiles_.find(iter.index()); | 490 iter; |
481 if (find == tiles_.end()) | 491 ++iter) { |
482 continue; | 492 gfx::Rect paint_rect = |
483 Tile* tile = find->second.get(); | 493 tiling_data_.TileBoundsWithBorder(iter.index_x(), iter.index_y()); |
494 gfx::Rect tile_rect = paint_rect; | |
495 tile_rect.set_size(tiling_data_.max_texture_size()); | |
496 gfx::Rect tile_query_rect = ScaleToEnclosingRect( | |
497 IntersectRects(tile_rect, visible_rect_in_content_space), | |
498 1.0f / contents_scale_); | |
499 bool is_occluded = occlusion_tracker->Occluded( | |
500 render_target, tile_query_rect, draw_transform); | |
501 if (!is_occluded) | |
502 continue; | |
484 | 503 |
485 tile->SetPriority(tree, now_priority); | 504 occlusion_set_.insert(iter.index()); |
486 | |
487 // Set whether tile is occluded or not. | |
488 bool is_occluded = false; | |
489 if (occlusion_tracker) { | |
490 gfx::Rect tile_query_rect = ScaleToEnclosingRect( | |
491 IntersectRects(tile->content_rect(), visible_rect_in_content_space), | |
492 1.0f / contents_scale_); | |
493 // TODO(vmpstr): Remove render_target and draw_transform from the | |
494 // parameters so they can be hidden from the tiling. | |
495 is_occluded = occlusion_tracker->Occluded( | |
496 render_target, tile_query_rect, draw_transform); | |
497 } | 505 } |
498 tile->set_is_occluded(is_occluded); | |
499 } | |
500 | |
501 // Assign soon priority to skewport tiles. | |
502 for (TilingData::DifferenceIterator iter( | |
503 &tiling_data_, skewport, visible_rect_in_content_space); | |
504 iter; | |
505 ++iter) { | |
506 TileMap::iterator find = tiles_.find(iter.index()); | |
507 if (find == tiles_.end()) | |
508 continue; | |
509 Tile* tile = find->second.get(); | |
510 | |
511 gfx::Rect tile_bounds = | |
512 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | |
513 | |
514 float distance_to_visible = | |
515 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * | |
516 content_to_screen_scale; | |
517 | |
518 TilePriority priority(resolution_, TilePriority::SOON, distance_to_visible); | |
519 tile->SetPriority(tree, priority); | |
520 } | |
521 | |
522 // Assign eventually priority to interest rect tiles. | |
523 for (TilingData::DifferenceIterator iter( | |
524 &tiling_data_, eventually_rect, skewport); | |
525 iter; | |
526 ++iter) { | |
527 TileMap::iterator find = tiles_.find(iter.index()); | |
528 if (find == tiles_.end()) | |
529 continue; | |
530 Tile* tile = find->second.get(); | |
531 | |
532 gfx::Rect tile_bounds = | |
533 tiling_data_.TileBounds(iter.index_x(), iter.index_y()); | |
534 | |
535 float distance_to_visible = | |
536 visible_rect_in_content_space.ManhattanInternalDistance(tile_bounds) * | |
537 content_to_screen_scale; | |
538 TilePriority priority( | |
539 resolution_, TilePriority::EVENTUALLY, distance_to_visible); | |
540 tile->SetPriority(tree, priority); | |
541 } | |
542 | |
543 // Upgrade the priority on border tiles to be SOON. | |
544 current_soon_border_rect_ = visible_rect_in_content_space; | |
545 float border = kSoonBorderDistanceInScreenPixels / content_to_screen_scale; | |
546 current_soon_border_rect_.Inset(-border, -border, -border, -border); | |
547 for (TilingData::DifferenceIterator iter( | |
548 &tiling_data_, current_soon_border_rect_, skewport); | |
549 iter; | |
550 ++iter) { | |
551 TileMap::iterator find = tiles_.find(iter.index()); | |
552 if (find == tiles_.end()) | |
553 continue; | |
554 Tile* tile = find->second.get(); | |
555 | |
556 TilePriority priority(resolution_, | |
557 TilePriority::SOON, | |
558 tile->priority(tree).distance_to_visible); | |
559 tile->SetPriority(tree, priority); | |
560 } | 506 } |
561 } | 507 } |
562 | 508 |
509 void PictureLayerTiling::SetTilePriority(Tile* tile, bool include_twin) const { | |
510 // First update the twin if required. | |
511 if (include_twin) { | |
512 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
513 if (twin_tiling) | |
514 twin_tiling->SetTilePriority(tile, false); | |
515 } | |
516 | |
517 WhichTree tree = client_->GetTree(); | |
518 | |
519 // If we're on the pending tree, start by clearing out the required for | |
520 // activation flag. | |
521 if (tree == PENDING_TREE) | |
522 tile->UnsetRequiredForActivation(); | |
523 | |
524 // If this tiling doesn't have the given tile, then set default priority. | |
525 if (TileAt(tile->tiling_i_index(), tile->tiling_j_index()) != tile) { | |
526 tile->SetPriority(tree, TilePriority()); | |
527 return; | |
528 } | |
529 | |
530 gfx::Rect tile_bounds = tiling_data_.TileBoundsWithBorder( | |
531 tile->tiling_i_index(), tile->tiling_j_index()); | |
532 | |
533 // If we're in the now bin, set the priority and return. | |
534 if (current_visible_rect_in_content_space_.Intersects(tile_bounds)) { | |
535 tile->SetPriority(tree, TilePriority(resolution_, TilePriority::NOW, 0)); | |
536 | |
537 // If necessary, mark this visible tile as required for activation. | |
538 if (IsTileRequiredForActivation(tile)) | |
539 tile->MarkRequiredForActivation(); | |
enne (OOO)
2014/07/07 19:41:59
Does it matter that this can mark active tree only
vmpstr
2014/07/07 23:24:47
IsTileRequiredForActivation has a tree check that
| |
540 return; | |
541 } | |
542 | |
543 // For non-now bin, we'll need to know distance to visible. | |
544 float distance_to_visible = | |
545 current_visible_rect_in_content_space_.ManhattanInternalDistance( | |
546 tile_bounds) * | |
547 content_to_screen_scale_; | |
548 | |
549 // Soon border and skewport tiles get SOON bin, otherwise they get EVENTUALLY | |
550 // bin. | |
551 if (current_soon_border_rect_.Intersects(tile_bounds) || | |
552 current_skewport_.Intersects(tile_bounds)) { | |
553 tile->SetPriority( | |
554 tree, | |
555 TilePriority(resolution_, TilePriority::SOON, distance_to_visible)); | |
556 return; | |
557 } | |
558 | |
559 tile->SetPriority( | |
560 tree, | |
561 TilePriority(resolution_, TilePriority::EVENTUALLY, distance_to_visible)); | |
562 } | |
563 | |
563 void PictureLayerTiling::SetLiveTilesRect( | 564 void PictureLayerTiling::SetLiveTilesRect( |
564 const gfx::Rect& new_live_tiles_rect) { | 565 const gfx::Rect& new_live_tiles_rect) { |
565 DCHECK(new_live_tiles_rect.IsEmpty() || | 566 DCHECK(new_live_tiles_rect.IsEmpty() || |
566 TilingRect().Contains(new_live_tiles_rect)); | 567 TilingRect().Contains(new_live_tiles_rect)); |
567 if (live_tiles_rect_ == new_live_tiles_rect) | 568 if (live_tiles_rect_ == new_live_tiles_rect) |
568 return; | 569 return; |
569 | 570 |
570 // Iterate to delete all tiles outside of our new live_tiles rect. | 571 // Iterate to delete all tiles outside of our new live_tiles rect. |
571 for (TilingData::DifferenceIterator iter(&tiling_data_, | 572 for (TilingData::DifferenceIterator iter(&tiling_data_, |
572 live_tiles_rect_, | 573 live_tiles_rect_, |
573 new_live_tiles_rect); | 574 new_live_tiles_rect); |
574 iter; | 575 iter; |
575 ++iter) { | 576 ++iter) { |
576 TileMapKey key(iter.index()); | 577 TileMapKey key(iter.index()); |
577 TileMap::iterator found = tiles_.find(key); | 578 TileMap::iterator found = tiles_.find(key); |
578 // If the tile was outside of the recorded region, it won't exist even | 579 // If the tile was outside of the recorded region, it won't exist even |
579 // though it was in the live rect. | 580 // though it was in the live rect. |
580 if (found != tiles_.end()) | 581 if (found != tiles_.end()) |
581 tiles_.erase(found); | 582 tiles_.erase(found); |
582 } | 583 } |
583 | 584 |
584 const PictureLayerTiling* twin_tiling = client_->GetTwinTiling(this); | |
585 | |
586 // Iterate to allocate new tiles for all regions with newly exposed area. | |
587 for (TilingData::DifferenceIterator iter(&tiling_data_, | |
588 new_live_tiles_rect, | |
589 live_tiles_rect_); | |
590 iter; | |
591 ++iter) { | |
592 TileMapKey key(iter.index()); | |
593 CreateTile(key.first, key.second, twin_tiling); | |
594 } | |
595 | |
596 live_tiles_rect_ = new_live_tiles_rect; | 585 live_tiles_rect_ = new_live_tiles_rect; |
597 } | 586 } |
598 | 587 |
599 void PictureLayerTiling::DidBecomeRecycled() { | |
600 // DidBecomeActive below will set the active priority for tiles that are | |
601 // still in the tree. Calling this first on an active tiling that is becoming | |
602 // recycled takes care of tiles that are no longer in the active tree (eg. | |
603 // due to a pending invalidation). | |
604 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | |
605 it->second->SetPriority(ACTIVE_TREE, TilePriority()); | |
606 } | |
607 } | |
608 | |
609 void PictureLayerTiling::DidBecomeActive() { | 588 void PictureLayerTiling::DidBecomeActive() { |
610 PicturePileImpl* active_pile = client_->GetPile(); | 589 PicturePileImpl* active_pile = client_->GetPile(); |
611 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 590 for (TileMap::const_iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
591 it->second->UnsetRequiredForActivation(); | |
612 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); | 592 it->second->SetPriority(ACTIVE_TREE, it->second->priority(PENDING_TREE)); |
613 it->second->SetPriority(PENDING_TREE, TilePriority()); | |
614 | 593 |
615 // Tile holds a ref onto a picture pile. If the tile never gets invalidated | 594 // Tile holds a ref onto a picture pile. If the tile never gets invalidated |
616 // and recreated, then that picture pile ref could exist indefinitely. To | 595 // and recreated, then that picture pile ref could exist indefinitely. To |
617 // prevent this, ask the client to update the pile to its own ref. This | 596 // prevent this, ask the client to update the pile to its own ref. This |
618 // will cause PicturePileImpls and their clones to get deleted once the | 597 // will cause PicturePileImpls and their clones to get deleted once the |
619 // corresponding PictureLayerImpl and any in flight raster jobs go out of | 598 // corresponding PictureLayerImpl and any in flight raster jobs go out of |
620 // scope. | 599 // scope. |
621 it->second->set_picture_pile(active_pile); | 600 it->second->set_picture_pile(active_pile); |
622 } | 601 } |
623 } | 602 } |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
790 } | 769 } |
791 | 770 |
792 gfx::Rect result(origin_x, origin_y, width, height); | 771 gfx::Rect result(origin_x, origin_y, width, height); |
793 if (cache) | 772 if (cache) |
794 cache->previous_result = result; | 773 cache->previous_result = result; |
795 return result; | 774 return result; |
796 } | 775 } |
797 | 776 |
798 void PictureLayerTiling::UpdateEvictionCacheIfNeeded( | 777 void PictureLayerTiling::UpdateEvictionCacheIfNeeded( |
799 TreePriority tree_priority) { | 778 TreePriority tree_priority) { |
800 if (eviction_tiles_cache_valid_ && | |
801 eviction_cache_tree_priority_ == tree_priority) | |
802 return; | |
803 | 779 |
804 eviction_tiles_cache_.clear(); | 780 eviction_tiles_cache_.clear(); |
805 eviction_tiles_cache_.reserve(tiles_.size()); | 781 eviction_tiles_cache_.reserve(tiles_.size()); |
806 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { | 782 for (TileMap::iterator it = tiles_.begin(); it != tiles_.end(); ++it) { |
807 // TODO(vmpstr): This should update the priority if UpdateTilePriorities | 783 UpdateTileOcclusion(it->second); |
enne (OOO)
2014/07/07 19:41:59
I feel like there are a lot of paired UpdateTileOc
vmpstr
2014/07/07 23:24:47
It's possible... I just feel like priority calcula
| |
808 // changes not to do this. | 784 SetTilePriority(it->second, true); |
enne (OOO)
2014/07/07 19:41:59
The boolean parameter is hard to read. I think ca
vmpstr
2014/07/07 23:24:46
Done.
| |
809 eviction_tiles_cache_.push_back(it->second); | 785 eviction_tiles_cache_.push_back(it->second); |
810 } | 786 } |
811 | 787 |
812 std::sort(eviction_tiles_cache_.begin(), | 788 std::sort(eviction_tiles_cache_.begin(), |
813 eviction_tiles_cache_.end(), | 789 eviction_tiles_cache_.end(), |
814 TileEvictionOrder(tree_priority)); | 790 TileEvictionOrder(tree_priority)); |
815 eviction_tiles_cache_valid_ = true; | |
816 eviction_cache_tree_priority_ = tree_priority; | |
817 } | 791 } |
818 | 792 |
819 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator() | 793 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator() |
820 : tiling_(NULL), current_tile_(NULL) {} | 794 : tiling_(NULL), current_tile_(NULL) {} |
821 | 795 |
822 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator( | 796 PictureLayerTiling::TilingRasterTileIterator::TilingRasterTileIterator( |
823 PictureLayerTiling* tiling, | 797 PictureLayerTiling* tiling, |
824 WhichTree tree) | 798 WhichTree tree) |
825 : tiling_(tiling), | 799 : tiling_(tiling), |
826 type_(TilePriority::NOW), | 800 type_(TilePriority::NOW), |
(...skipping 10 matching lines...) Expand all Loading... | |
837 spiral_iterator_(&tiling->tiling_data_, | 811 spiral_iterator_(&tiling->tiling_data_, |
838 skewport_in_content_space_, | 812 skewport_in_content_space_, |
839 visible_rect_in_content_space_, | 813 visible_rect_in_content_space_, |
840 visible_rect_in_content_space_), | 814 visible_rect_in_content_space_), |
841 skewport_processed_(false) { | 815 skewport_processed_(false) { |
842 if (!visible_iterator_) { | 816 if (!visible_iterator_) { |
843 AdvancePhase(); | 817 AdvancePhase(); |
844 return; | 818 return; |
845 } | 819 } |
846 | 820 |
847 current_tile_ = | 821 current_tile_ = tiling_->GetOrCreateTileAt(visible_iterator_.index_x(), |
848 tiling_->TileAt(visible_iterator_.index_x(), visible_iterator_.index_y()); | 822 visible_iterator_.index_y()); |
823 tiling_->UpdateTileOcclusion(current_tile_); | |
enne (OOO)
2014/07/07 19:41:59
Does this need to get wrapped by !current_tile_ to
vmpstr
2014/07/07 23:24:47
Whoops.
| |
849 if (!current_tile_ || !TileNeedsRaster(current_tile_)) | 824 if (!current_tile_ || !TileNeedsRaster(current_tile_)) |
850 ++(*this); | 825 ++(*this); |
826 else | |
827 tiling_->SetTilePriority(current_tile_, true); | |
851 } | 828 } |
852 | 829 |
853 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} | 830 PictureLayerTiling::TilingRasterTileIterator::~TilingRasterTileIterator() {} |
854 | 831 |
855 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { | 832 void PictureLayerTiling::TilingRasterTileIterator::AdvancePhase() { |
856 DCHECK_LT(type_, TilePriority::EVENTUALLY); | 833 DCHECK_LT(type_, TilePriority::EVENTUALLY); |
857 | 834 |
858 do { | 835 do { |
859 type_ = static_cast<TilePriority::PriorityBin>(type_ + 1); | 836 type_ = static_cast<TilePriority::PriorityBin>(type_ + 1); |
860 if (type_ == TilePriority::EVENTUALLY) { | 837 if (type_ == TilePriority::EVENTUALLY) { |
861 spiral_iterator_ = TilingData::SpiralDifferenceIterator( | 838 spiral_iterator_ = TilingData::SpiralDifferenceIterator( |
862 &tiling_->tiling_data_, | 839 &tiling_->tiling_data_, |
863 eventually_rect_in_content_space_, | 840 eventually_rect_in_content_space_, |
864 skewport_in_content_space_, | 841 skewport_in_content_space_, |
865 visible_rect_in_content_space_); | 842 visible_rect_in_content_space_); |
866 } | 843 } |
867 | 844 |
868 while (spiral_iterator_) { | 845 while (spiral_iterator_) { |
869 current_tile_ = tiling_->TileAt(spiral_iterator_.index_x(), | 846 current_tile_ = tiling_->GetOrCreateTileAt(spiral_iterator_.index_x(), |
870 spiral_iterator_.index_y()); | 847 spiral_iterator_.index_y()); |
848 tiling_->UpdateTileOcclusion(current_tile_); | |
871 if (current_tile_ && TileNeedsRaster(current_tile_)) | 849 if (current_tile_ && TileNeedsRaster(current_tile_)) |
872 break; | 850 break; |
873 ++spiral_iterator_; | 851 ++spiral_iterator_; |
874 } | 852 } |
875 | 853 |
876 if (!spiral_iterator_ && type_ == TilePriority::EVENTUALLY) { | 854 if (!spiral_iterator_ && type_ == TilePriority::EVENTUALLY) { |
877 current_tile_ = NULL; | 855 current_tile_ = NULL; |
878 break; | 856 break; |
879 } | 857 } |
880 } while (!spiral_iterator_); | 858 } while (!spiral_iterator_); |
859 | |
860 if (current_tile_) | |
861 tiling_->SetTilePriority(current_tile_, true); | |
881 } | 862 } |
882 | 863 |
883 PictureLayerTiling::TilingRasterTileIterator& | 864 PictureLayerTiling::TilingRasterTileIterator& |
884 PictureLayerTiling::TilingRasterTileIterator:: | 865 PictureLayerTiling::TilingRasterTileIterator:: |
885 operator++() { | 866 operator++() { |
886 current_tile_ = NULL; | 867 current_tile_ = NULL; |
887 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { | 868 while (!current_tile_ || !TileNeedsRaster(current_tile_)) { |
888 std::pair<int, int> next_index; | 869 std::pair<int, int> next_index; |
889 switch (type_) { | 870 switch (type_) { |
890 case TilePriority::NOW: | 871 case TilePriority::NOW: |
(...skipping 26 matching lines...) Expand all Loading... | |
917 break; | 898 break; |
918 case TilePriority::EVENTUALLY: | 899 case TilePriority::EVENTUALLY: |
919 ++spiral_iterator_; | 900 ++spiral_iterator_; |
920 if (!spiral_iterator_) { | 901 if (!spiral_iterator_) { |
921 current_tile_ = NULL; | 902 current_tile_ = NULL; |
922 return *this; | 903 return *this; |
923 } | 904 } |
924 next_index = spiral_iterator_.index(); | 905 next_index = spiral_iterator_.index(); |
925 break; | 906 break; |
926 } | 907 } |
927 current_tile_ = tiling_->TileAt(next_index.first, next_index.second); | 908 current_tile_ = |
909 tiling_->GetOrCreateTileAt(next_index.first, next_index.second); | |
910 tiling_->UpdateTileOcclusion(current_tile_); | |
928 } | 911 } |
912 | |
913 if (current_tile_) | |
914 tiling_->SetTilePriority(current_tile_, true); | |
929 return *this; | 915 return *this; |
930 } | 916 } |
931 | 917 |
932 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator() | 918 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator() |
933 : is_valid_(false), tiling_(NULL) {} | 919 : is_valid_(false), tiling_(NULL) {} |
934 | 920 |
935 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator( | 921 PictureLayerTiling::TilingEvictionTileIterator::TilingEvictionTileIterator( |
936 PictureLayerTiling* tiling, | 922 PictureLayerTiling* tiling, |
937 TreePriority tree_priority) | 923 TreePriority tree_priority) |
938 : is_valid_(false), tiling_(tiling), tree_priority_(tree_priority) {} | 924 : is_valid_(false), tiling_(tiling), tree_priority_(tree_priority) {} |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); | 959 tiling_->UpdateEvictionCacheIfNeeded(tree_priority_); |
974 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); | 960 tile_iterator_ = tiling_->eviction_tiles_cache_.begin(); |
975 is_valid_ = true; | 961 is_valid_ = true; |
976 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && | 962 if (tile_iterator_ != tiling_->eviction_tiles_cache_.end() && |
977 !(*tile_iterator_)->HasResources()) { | 963 !(*tile_iterator_)->HasResources()) { |
978 ++(*this); | 964 ++(*this); |
979 } | 965 } |
980 } | 966 } |
981 | 967 |
982 } // namespace cc | 968 } // namespace cc |
OLD | NEW |