Chromium Code Reviews| 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/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 PictureLayerImpl* pending_layer) | 66 PictureLayerImpl* pending_layer) |
| 67 : active(active_layer), pending(pending_layer) { | 67 : active(active_layer), pending(pending_layer) { |
| 68 } | 68 } |
| 69 | 69 |
| 70 PictureLayerImpl::Pair::~Pair() { | 70 PictureLayerImpl::Pair::~Pair() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) | 73 PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, int id) |
| 74 : LayerImpl(tree_impl, id), | 74 : LayerImpl(tree_impl, id), |
| 75 twin_layer_(nullptr), | 75 twin_layer_(nullptr), |
| 76 tilings_(PictureLayerTilingSet::Create(this)), | |
| 77 // TODO(danakj): Can this be null to start? | |
|
enne (OOO)
2014/12/01 22:08:17
I think it could be. PushPropertiesTo happens bef
danakj
2014/12/05 22:30:44
Cool. It crashes a lot of unit tests and I'm not s
enne (OOO)
2014/12/05 23:02:02
Sounds good to me.
| |
| 76 raster_source_(PicturePileImpl::Create()), | 78 raster_source_(PicturePileImpl::Create()), |
| 77 ideal_page_scale_(0.f), | 79 ideal_page_scale_(0.f), |
| 78 ideal_device_scale_(0.f), | 80 ideal_device_scale_(0.f), |
| 79 ideal_source_scale_(0.f), | 81 ideal_source_scale_(0.f), |
| 80 ideal_contents_scale_(0.f), | 82 ideal_contents_scale_(0.f), |
| 81 raster_page_scale_(0.f), | 83 raster_page_scale_(0.f), |
| 82 raster_device_scale_(0.f), | 84 raster_device_scale_(0.f), |
| 83 raster_source_scale_(0.f), | 85 raster_source_scale_(0.f), |
| 84 raster_contents_scale_(0.f), | 86 raster_contents_scale_(0.f), |
| 85 low_res_raster_contents_scale_(0.f), | 87 low_res_raster_contents_scale_(0.f), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 // Twin relationships should never change once established. | 128 // Twin relationships should never change once established. |
| 127 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); | 129 DCHECK_IMPLIES(twin_layer_, twin_layer_ == layer_impl); |
| 128 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); | 130 DCHECK_IMPLIES(twin_layer_, layer_impl->twin_layer_ == this); |
| 129 // The twin relationship does not need to exist before the first | 131 // The twin relationship does not need to exist before the first |
| 130 // PushPropertiesTo from pending to active layer since before that the active | 132 // PushPropertiesTo from pending to active layer since before that the active |
| 131 // layer can not have a pile or tilings, it has only been created and inserted | 133 // layer can not have a pile or tilings, it has only been created and inserted |
| 132 // into the tree at that point. | 134 // into the tree at that point. |
| 133 twin_layer_ = layer_impl; | 135 twin_layer_ = layer_impl; |
| 134 layer_impl->twin_layer_ = this; | 136 layer_impl->twin_layer_ = this; |
| 135 | 137 |
| 136 layer_impl->set_is_mask(is_mask_); | 138 // Solid color layers have no tilings. |
| 137 layer_impl->UpdateRasterSource(raster_source_); | 139 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); |
| 140 // The pending tree should only have a high res (and possibly low res) tiling. | |
| 141 DCHECK_LE(tilings_->num_tilings(), | |
| 142 layer_tree_impl()->create_low_res_tiling() ? 2u : 1u); | |
| 138 | 143 |
| 139 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); | 144 layer_impl->UpdateRasterSource(raster_source_, &invalidation_, is_mask_, |
| 140 // Tilings would be expensive to push, so we swap. | 145 tilings_.get()); |
| 141 layer_impl->tilings_.swap(tilings_); | 146 DCHECK(invalidation_.IsEmpty()); |
| 142 layer_impl->tilings_->SetClient(layer_impl); | |
| 143 if (tilings_) | |
| 144 tilings_->SetClient(this); | |
| 145 | 147 |
| 146 // Ensure that the recycle tree doesn't have any unshared tiles. | 148 // After syncing a solid color layer, the active layer has no tilings. |
| 147 if (tilings_ && raster_source_->IsSolidColor()) | 149 DCHECK_IMPLIES(raster_source_->IsSolidColor(), |
| 148 tilings_->RemoveAllTilings(); | 150 !layer_impl->tilings_->num_tilings()); |
| 149 | |
| 150 // Remove invalidated tiles from what will become a recycle tree. | |
| 151 if (tilings_) | |
| 152 tilings_->RemoveTilesInRegion(invalidation_); | |
| 153 | 151 |
| 154 layer_impl->raster_page_scale_ = raster_page_scale_; | 152 layer_impl->raster_page_scale_ = raster_page_scale_; |
| 155 layer_impl->raster_device_scale_ = raster_device_scale_; | 153 layer_impl->raster_device_scale_ = raster_device_scale_; |
| 156 layer_impl->raster_source_scale_ = raster_source_scale_; | 154 layer_impl->raster_source_scale_ = raster_source_scale_; |
| 157 layer_impl->raster_contents_scale_ = raster_contents_scale_; | 155 layer_impl->raster_contents_scale_ = raster_contents_scale_; |
| 158 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; | 156 layer_impl->low_res_raster_contents_scale_ = low_res_raster_contents_scale_; |
| 157 | |
| 158 layer_impl->SanityCheckTilingState(); | |
| 159 | |
| 159 layer_impl->needs_post_commit_initialization_ = false; | 160 layer_impl->needs_post_commit_initialization_ = false; |
| 160 | |
| 161 // The invalidation on this soon-to-be-recycled layer must be cleared to | |
| 162 // mirror clearing the invalidation in PictureLayer's version of this function | |
| 163 // in case push properties is skipped. | |
| 164 layer_impl->invalidation_.Swap(&invalidation_); | |
| 165 invalidation_.Clear(); | |
| 166 needs_post_commit_initialization_ = true; | 161 needs_post_commit_initialization_ = true; |
| 167 | 162 |
| 168 // We always need to push properties. | 163 // We always need to push properties. |
| 169 // See http://crbug.com/303943 | 164 // See http://crbug.com/303943 |
| 165 // TODO(danakj): Stop always pushing properties since we don't swap tilings. | |
|
enne (OOO)
2014/12/01 22:08:17
\o/
| |
| 170 needs_push_properties_ = true; | 166 needs_push_properties_ = true; |
| 171 } | 167 } |
| 172 | 168 |
| 173 void PictureLayerImpl::UpdateRasterSource( | |
| 174 scoped_refptr<RasterSource> raster_source) { | |
| 175 bool could_have_tilings = CanHaveTilings(); | |
| 176 raster_source_.swap(raster_source); | |
| 177 | |
| 178 // Need to call UpdateTiles again if CanHaveTilings changed. | |
| 179 if (could_have_tilings != CanHaveTilings()) { | |
| 180 layer_tree_impl()->set_needs_update_draw_properties(); | |
| 181 } | |
| 182 } | |
| 183 | |
| 184 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, | 169 void PictureLayerImpl::AppendQuads(RenderPass* render_pass, |
| 185 const Occlusion& occlusion_in_content_space, | 170 const Occlusion& occlusion_in_content_space, |
| 186 AppendQuadsData* append_quads_data) { | 171 AppendQuadsData* append_quads_data) { |
| 187 DCHECK(!needs_post_commit_initialization_); | 172 DCHECK(!needs_post_commit_initialization_); |
| 188 // The bounds and the pile size may differ if the pile wasn't updated (ie. | 173 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
| 189 // PictureLayer::Update didn't happen). In that case the pile will be empty. | 174 // PictureLayer::Update didn't happen). In that case the pile will be empty. |
| 190 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), | 175 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), |
| 191 bounds() == raster_source_->GetSize()) | 176 bounds() == raster_source_->GetSize()) |
| 192 << " bounds " << bounds().ToString() << " pile " | 177 << " bounds " << bounds().ToString() << " pile " |
| 193 << raster_source_->GetSize().ToString(); | 178 << raster_source_->GetSize().ToString(); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 ideal_page_scale_ = 0.f; | 462 ideal_page_scale_ = 0.f; |
| 478 ideal_device_scale_ = 0.f; | 463 ideal_device_scale_ = 0.f; |
| 479 ideal_contents_scale_ = 0.f; | 464 ideal_contents_scale_ = 0.f; |
| 480 ideal_source_scale_ = 0.f; | 465 ideal_source_scale_ = 0.f; |
| 481 SanityCheckTilingState(); | 466 SanityCheckTilingState(); |
| 482 return; | 467 return; |
| 483 } | 468 } |
| 484 | 469 |
| 485 UpdateIdealScales(); | 470 UpdateIdealScales(); |
| 486 | 471 |
| 487 DCHECK_IMPLIES(tilings_->num_tilings() == 0, raster_contents_scale_ == 0.f) | |
| 488 << "A layer with no tilings shouldn't have valid raster scales"; | |
| 489 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { | 472 if (!raster_contents_scale_ || ShouldAdjustRasterScale()) { |
| 490 RecalculateRasterScales(); | 473 RecalculateRasterScales(); |
| 491 AddTilingsForRasterScale(); | 474 AddTilingsForRasterScale(); |
| 492 } | 475 } |
| 493 | 476 |
| 494 DCHECK(raster_page_scale_); | 477 DCHECK(raster_page_scale_); |
| 495 DCHECK(raster_device_scale_); | 478 DCHECK(raster_device_scale_); |
| 496 DCHECK(raster_source_scale_); | 479 DCHECK(raster_source_scale_); |
| 497 DCHECK(raster_contents_scale_); | 480 DCHECK(raster_contents_scale_); |
| 498 DCHECK(low_res_raster_contents_scale_); | 481 DCHECK(low_res_raster_contents_scale_); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 573 return nullptr; | 556 return nullptr; |
| 574 return twin_layer_; | 557 return twin_layer_; |
| 575 } | 558 } |
| 576 | 559 |
| 577 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { | 560 PictureLayerImpl* PictureLayerImpl::GetRecycledTwinLayer() const { |
| 578 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) | 561 if (!twin_layer_ || twin_layer_->IsOnActiveOrPendingTree()) |
| 579 return nullptr; | 562 return nullptr; |
| 580 return twin_layer_; | 563 return twin_layer_; |
| 581 } | 564 } |
| 582 | 565 |
| 566 void PictureLayerImpl::UpdateRasterSource( | |
|
enne (OOO)
2014/12/01 22:08:17
I'm handwaving a bit, but my perspective here is t
danakj
2014/12/05 22:30:44
Yes, vlad said similar thing in PLTS and I've dete
| |
| 567 scoped_refptr<RasterSource> raster_source, | |
| 568 Region* new_invalidation, | |
| 569 bool is_mask, | |
| 570 const PictureLayerTilingSet* pending_set) { | |
| 571 // The bounds and the pile size may differ if the pile wasn't updated (ie. | |
| 572 // PictureLayer::Update didn't happen). In that case the pile will be empty. | |
| 573 DCHECK_IMPLIES(!raster_source->GetSize().IsEmpty(), | |
| 574 bounds() == raster_source->GetSize()) | |
| 575 << " bounds " << bounds().ToString() << " pile " | |
| 576 << raster_source->GetSize().ToString(); | |
| 577 | |
| 578 bool could_have_tilings = CanHaveTilings(); | |
| 579 raster_source_.swap(raster_source); | |
| 580 | |
| 581 // The |new_invalidation| must be cleared before updating tilings since they | |
|
vmpstr
2014/12/01 22:38:03
nit: It's unclear to me what this comment is sayin
danakj
2014/12/05 22:30:43
The |new_invalidation| is a pointer to the invalid
| |
| 582 // access the invalidation through the PictureLayerTilingClient interface. | |
| 583 invalidation_.Clear(); | |
|
enne (OOO)
2014/12/01 22:08:17
This dance is a bit more awkward when it has to be
danakj
2014/12/05 22:30:43
ya..
| |
| 584 invalidation_.Swap(new_invalidation); | |
| 585 | |
| 586 is_mask_ = is_mask; | |
| 587 | |
| 588 // Need to call UpdateTiles again if CanHaveTilings changed. | |
| 589 if (could_have_tilings != CanHaveTilings()) | |
|
vmpstr
2014/12/01 22:38:03
nit: save CanHaveTilings() into a local before thi
danakj
2014/12/05 22:30:43
Done.
| |
| 590 layer_tree_impl()->set_needs_update_draw_properties(); | |
| 591 | |
| 592 if (!CanHaveTilings()) { | |
| 593 RemoveAllTilings(); | |
| 594 return; | |
| 595 } | |
| 596 | |
| 597 // TODO(danakj): Should this happen after doing UpdateTiles so we can avoid | |
|
enne (OOO)
2014/12/01 22:08:17
I'm a little torn. Doing after does seem like it
danakj
2014/12/05 22:30:44
Sure.
| |
| 598 // doing this for tilings that will just go away on the pending tree? (What | |
| 599 // about commit to active tree?) | |
| 600 // TODO(danakj): Just pass along the pile to this function instead of using | |
|
enne (OOO)
2014/12/01 22:08:17
Maybe, yeah? The client API made a lot more sense
vmpstr
2014/12/01 22:38:03
Isn't that what we're doing? maybe? Or am I missin
danakj
2014/12/05 22:30:44
It's passing the size also, more or less. It was p
| |
| 601 // the client API? | |
| 602 // TODO(danakj): What I mean here is IsSyncTree, for the commit to active | |
| 603 // case. | |
| 604 if (layer_tree_impl()->IsPendingTree()) { | |
| 605 tilings_->UpdateTilingsToCurrentRasterSource( | |
| 606 raster_source_.get(), raster_source_->GetSize(), | |
| 607 raster_source_->IsSolidColor(), invalidation_, MinimumContentsScale()); | |
| 608 } else { | |
| 609 tilings_->UpdateTilingsFromPending( | |
|
vmpstr
2014/12/01 22:38:03
Maybe ShareFromOther? I've been trying to make PLT
danakj
2014/12/05 22:30:44
This function does a bit more than that.
For tili
| |
| 610 raster_source_.get(), *pending_set, raster_source_->GetSize(), | |
| 611 raster_source_->IsSolidColor(), invalidation_, MinimumContentsScale()); | |
| 612 } | |
| 613 } | |
| 614 | |
| 583 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { | 615 void PictureLayerImpl::NotifyTileStateChanged(const Tile* tile) { |
| 584 if (layer_tree_impl()->IsActiveTree()) { | 616 if (layer_tree_impl()->IsActiveTree()) { |
| 585 gfx::RectF layer_damage_rect = | 617 gfx::RectF layer_damage_rect = |
| 586 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); | 618 gfx::ScaleRect(tile->content_rect(), 1.f / tile->contents_scale()); |
| 587 AddDamageRect(layer_damage_rect); | 619 AddDamageRect(layer_damage_rect); |
| 588 } | 620 } |
| 589 } | 621 } |
| 590 | 622 |
| 591 void PictureLayerImpl::DidBecomeActive() { | 623 void PictureLayerImpl::DidBecomeActive() { |
| 592 LayerImpl::DidBecomeActive(); | 624 LayerImpl::DidBecomeActive(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 644 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 676 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
| 645 return &twin_layer->invalidation_; | 677 return &twin_layer->invalidation_; |
| 646 return nullptr; | 678 return nullptr; |
| 647 } | 679 } |
| 648 | 680 |
| 649 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( | 681 const PictureLayerTiling* PictureLayerImpl::GetPendingOrActiveTwinTiling( |
| 650 const PictureLayerTiling* tiling) const { | 682 const PictureLayerTiling* tiling) const { |
| 651 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | 683 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); |
| 652 if (!twin_layer) | 684 if (!twin_layer) |
| 653 return nullptr; | 685 return nullptr; |
| 654 // TODO(danakj): Remove this when no longer swapping tilings. | |
| 655 if (!twin_layer->tilings_) | |
| 656 return nullptr; | |
| 657 return twin_layer->tilings_->FindTilingWithScale(tiling->contents_scale()); | 686 return twin_layer->tilings_->FindTilingWithScale(tiling->contents_scale()); |
| 658 } | 687 } |
| 659 | 688 |
| 660 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( | 689 PictureLayerTiling* PictureLayerImpl::GetRecycledTwinTiling( |
| 661 const PictureLayerTiling* tiling) { | 690 const PictureLayerTiling* tiling) { |
| 662 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); | 691 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); |
| 663 if (!recycled_twin || !recycled_twin->tilings_) | 692 if (!recycled_twin || !recycled_twin->tilings_) |
| 664 return nullptr; | 693 return nullptr; |
| 665 return recycled_twin->tilings_->FindTilingWithScale(tiling->contents_scale()); | 694 return recycled_twin->tilings_->FindTilingWithScale(tiling->contents_scale()); |
| 666 } | 695 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 765 tile_height = RoundUp(tile_height, kTileRoundUp); | 794 tile_height = RoundUp(tile_height, kTileRoundUp); |
| 766 tile_height = std::min(tile_height, default_tile_height); | 795 tile_height = std::min(tile_height, default_tile_height); |
| 767 } | 796 } |
| 768 | 797 |
| 769 // Under no circumstance should we be larger than the max texture size. | 798 // Under no circumstance should we be larger than the max texture size. |
| 770 tile_width = std::min(tile_width, max_texture_size); | 799 tile_width = std::min(tile_width, max_texture_size); |
| 771 tile_height = std::min(tile_height, max_texture_size); | 800 tile_height = std::min(tile_height, max_texture_size); |
| 772 return gfx::Size(tile_width, tile_height); | 801 return gfx::Size(tile_width, tile_height); |
| 773 } | 802 } |
| 774 | 803 |
| 775 void PictureLayerImpl::SyncFromActiveLayer(const PictureLayerImpl* other) { | |
| 776 DCHECK(!other->needs_post_commit_initialization_); | |
| 777 DCHECK(other->tilings_); | |
| 778 | |
| 779 if (!DrawsContent()) { | |
| 780 RemoveAllTilings(); | |
| 781 return; | |
| 782 } | |
| 783 | |
| 784 raster_page_scale_ = other->raster_page_scale_; | |
| 785 raster_device_scale_ = other->raster_device_scale_; | |
| 786 raster_source_scale_ = other->raster_source_scale_; | |
| 787 raster_contents_scale_ = other->raster_contents_scale_; | |
| 788 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | |
| 789 | |
| 790 bool synced_high_res_tiling = false; | |
| 791 if (CanHaveTilings()) { | |
| 792 synced_high_res_tiling = tilings_->SyncTilings( | |
| 793 *other->tilings_, raster_source_->GetSize(), invalidation_, | |
| 794 MinimumContentsScale(), raster_source_.get()); | |
| 795 } else { | |
| 796 RemoveAllTilings(); | |
| 797 } | |
| 798 | |
| 799 // If our MinimumContentsScale has changed to prevent the twin's high res | |
| 800 // tiling from being synced, we should reset the raster scale and let it be | |
| 801 // recalculated (1) again. This can happen if our bounds shrink to the point | |
| 802 // where min contents scale grows. | |
| 803 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we | |
| 804 // should refactor this code a little bit and actually recalculate this. | |
| 805 // However, this is a larger undertaking, so this will work for now. | |
| 806 if (!synced_high_res_tiling) | |
| 807 ResetRasterScale(); | |
| 808 else | |
| 809 SanityCheckTilingState(); | |
| 810 } | |
| 811 | |
| 812 void PictureLayerImpl::SyncTiling( | |
| 813 const PictureLayerTiling* tiling) { | |
| 814 if (!tilings_) | |
| 815 return; | |
| 816 if (!CanHaveTilingWithScale(tiling->contents_scale())) | |
| 817 return; | |
| 818 tilings_->AddTiling(tiling->contents_scale(), raster_source_->GetSize()); | |
| 819 | |
| 820 // If this tree needs update draw properties, then the tiling will | |
| 821 // get updated prior to drawing or activation. If this tree does not | |
| 822 // need update draw properties, then its transforms are up to date and | |
| 823 // we can create tiles for this tiling immediately. | |
| 824 if (!layer_tree_impl()->needs_update_draw_properties() && | |
| 825 should_update_tile_priorities_) { | |
| 826 // TODO(danakj): Add a DCHECK() that we are not using occlusion tracking | |
| 827 // when we stop using the pending tree in the browser compositor. If we want | |
| 828 // to support occlusion tracking here, we need to dirty the draw properties | |
| 829 // or save occlusion as a draw property. | |
| 830 UpdateTilePriorities(Occlusion()); | |
| 831 } | |
| 832 } | |
| 833 | |
| 834 void PictureLayerImpl::GetContentsResourceId( | 804 void PictureLayerImpl::GetContentsResourceId( |
| 835 ResourceProvider::ResourceId* resource_id, | 805 ResourceProvider::ResourceId* resource_id, |
| 836 gfx::Size* resource_size) const { | 806 gfx::Size* resource_size) const { |
| 837 DCHECK_EQ(bounds().ToString(), raster_source_->GetSize().ToString()); | 807 // The bounds and the pile size may differ if the pile wasn't updated (ie. |
| 808 // PictureLayer::Update didn't happen). In that case the pile will be empty. | |
| 809 DCHECK_IMPLIES(!raster_source_->GetSize().IsEmpty(), | |
| 810 bounds() == raster_source_->GetSize()) | |
| 811 << " bounds " << bounds().ToString() << " pile " | |
| 812 << raster_source_->GetSize().ToString(); | |
| 838 gfx::Rect content_rect(bounds()); | 813 gfx::Rect content_rect(bounds()); |
| 839 PictureLayerTilingSet::CoverageIterator iter( | 814 PictureLayerTilingSet::CoverageIterator iter( |
| 840 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); | 815 tilings_.get(), 1.f, content_rect, ideal_contents_scale_); |
| 841 | 816 |
| 842 // Mask resource not ready yet. | 817 // Mask resource not ready yet. |
| 843 if (!iter || !*iter) { | 818 if (!iter || !*iter) { |
| 844 *resource_id = 0; | 819 *resource_id = 0; |
| 845 return; | 820 return; |
| 846 } | 821 } |
| 847 | 822 |
| 848 // Masks only supported if they fit on exactly one tile. | 823 // Masks only supported if they fit on exactly one tile. |
| 849 DCHECK(iter.geometry_rect() == content_rect) | 824 DCHECK(iter.geometry_rect() == content_rect) |
| 850 << "iter rect " << iter.geometry_rect().ToString() << " content rect " | 825 << "iter rect " << iter.geometry_rect().ToString() << " content rect " |
| 851 << content_rect.ToString(); | 826 << content_rect.ToString(); |
| 852 | 827 |
| 853 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); | 828 const ManagedTileState::DrawInfo& draw_info = iter->draw_info(); |
| 854 if (!draw_info.IsReadyToDraw() || | 829 if (!draw_info.IsReadyToDraw() || |
| 855 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { | 830 draw_info.mode() != ManagedTileState::DrawInfo::RESOURCE_MODE) { |
| 856 *resource_id = 0; | 831 *resource_id = 0; |
| 857 return; | 832 return; |
| 858 } | 833 } |
| 859 | 834 |
| 860 *resource_id = draw_info.get_resource_id(); | 835 *resource_id = draw_info.get_resource_id(); |
| 861 *resource_size = iter.texture_size(); | 836 *resource_size = iter.texture_size(); |
| 862 } | 837 } |
| 863 | 838 |
| 864 void PictureLayerImpl::DoPostCommitInitialization() { | 839 void PictureLayerImpl::DoPostCommitInitialization() { |
| 840 // TODO(danakj): Remove this. | |
|
enne (OOO)
2014/12/01 22:08:17
\o/
| |
| 865 DCHECK(needs_post_commit_initialization_); | 841 DCHECK(needs_post_commit_initialization_); |
| 866 DCHECK(layer_tree_impl()->IsPendingTree()); | 842 DCHECK(layer_tree_impl()->IsPendingTree()); |
| 867 | |
| 868 if (!tilings_) | |
| 869 tilings_ = PictureLayerTilingSet::Create(this); | |
| 870 | |
| 871 PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer(); | |
| 872 if (twin_layer) { | |
| 873 // If the twin has never been pushed to, do not sync from it. | |
| 874 // This can happen if this function is called during activation. | |
| 875 if (!twin_layer->needs_post_commit_initialization_) | |
| 876 SyncFromActiveLayer(twin_layer); | |
| 877 } | |
| 878 | |
| 879 needs_post_commit_initialization_ = false; | 843 needs_post_commit_initialization_ = false; |
| 880 } | 844 } |
| 881 | 845 |
| 882 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 846 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 883 DCHECK(CanHaveTilingWithScale(contents_scale)) << | 847 DCHECK(CanHaveTilingWithScale(contents_scale)) << |
| 884 "contents_scale: " << contents_scale; | 848 "contents_scale: " << contents_scale; |
| 885 | 849 |
| 886 PictureLayerTiling* tiling = | 850 PictureLayerTiling* tiling = |
| 887 tilings_->AddTiling(contents_scale, raster_source_->GetSize()); | 851 tilings_->AddTiling(contents_scale, raster_source_->GetSize()); |
| 888 | 852 |
| 889 DCHECK(raster_source_->HasRecordings()); | 853 DCHECK(raster_source_->HasRecordings()); |
| 890 | 854 |
| 891 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | |
| 892 twin_layer->SyncTiling(tiling); | |
|
enne (OOO)
2014/12/01 22:08:17
Just to make sure I understand, this is no longer
danakj
2014/12/05 22:30:43
This is no longer needed because when the active t
| |
| 893 | |
| 894 return tiling; | 855 return tiling; |
| 895 } | 856 } |
| 896 | 857 |
| 897 void PictureLayerImpl::RemoveAllTilings() { | 858 void PictureLayerImpl::RemoveAllTilings() { |
| 898 if (tilings_) | 859 if (tilings_) |
| 899 tilings_->RemoveAllTilings(); | 860 tilings_->RemoveAllTilings(); |
| 900 // If there are no tilings, then raster scales are no longer meaningful. | 861 // If there are no tilings, then raster scales are no longer meaningful. |
| 901 ResetRasterScale(); | 862 ResetRasterScale(); |
| 902 } | 863 } |
| 903 | 864 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 929 if (can_have_low_res && needs_low_res && !is_pinching && !is_animating) | 890 if (can_have_low_res && needs_low_res && !is_pinching && !is_animating) |
| 930 low_res = AddTiling(low_res_raster_contents_scale_); | 891 low_res = AddTiling(low_res_raster_contents_scale_); |
| 931 | 892 |
| 932 // Set low-res if we have one. | 893 // Set low-res if we have one. |
| 933 if (low_res && low_res != high_res) | 894 if (low_res && low_res != high_res) |
| 934 low_res->set_resolution(LOW_RESOLUTION); | 895 low_res->set_resolution(LOW_RESOLUTION); |
| 935 | 896 |
| 936 // Make sure we always have one high-res (even if high == low). | 897 // Make sure we always have one high-res (even if high == low). |
| 937 high_res->set_resolution(HIGH_RESOLUTION); | 898 high_res->set_resolution(HIGH_RESOLUTION); |
| 938 | 899 |
| 900 if (layer_tree_impl()->IsPendingTree()) { | |
| 901 // On the pending tree, drop any tilings that are non-ideal since we don't | |
| 902 // need them to activate anyway. | |
| 903 tilings_->RemoveNonIdealTilings(); | |
| 904 } | |
| 905 | |
| 939 SanityCheckTilingState(); | 906 SanityCheckTilingState(); |
| 940 } | 907 } |
| 941 | 908 |
| 942 bool PictureLayerImpl::ShouldAdjustRasterScale() const { | 909 bool PictureLayerImpl::ShouldAdjustRasterScale() const { |
| 943 if (was_screen_space_transform_animating_ != | 910 if (was_screen_space_transform_animating_ != |
| 944 draw_properties().screen_space_transform_is_animating) | 911 draw_properties().screen_space_transform_is_animating) |
| 945 return true; | 912 return true; |
| 946 | 913 |
| 947 if (draw_properties().screen_space_transform_is_animating && | 914 if (draw_properties().screen_space_transform_is_animating && |
| 948 raster_contents_scale_ != ideal_contents_scale_ && | 915 raster_contents_scale_ != ideal_contents_scale_ && |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1109 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr; | 1076 PictureLayerTilingSet* twin_set = twin ? twin->tilings_.get() : nullptr; |
| 1110 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); | 1077 PictureLayerImpl* recycled_twin = GetRecycledTwinLayer(); |
| 1111 PictureLayerTilingSet* recycled_twin_set = | 1078 PictureLayerTilingSet* recycled_twin_set = |
| 1112 recycled_twin ? recycled_twin->tilings_.get() : nullptr; | 1079 recycled_twin ? recycled_twin->tilings_.get() : nullptr; |
| 1113 | 1080 |
| 1114 tilings_->CleanUpTilings(min_acceptable_high_res_scale, | 1081 tilings_->CleanUpTilings(min_acceptable_high_res_scale, |
| 1115 max_acceptable_high_res_scale, used_tilings, | 1082 max_acceptable_high_res_scale, used_tilings, |
| 1116 layer_tree_impl()->create_low_res_tiling(), twin_set, | 1083 layer_tree_impl()->create_low_res_tiling(), twin_set, |
| 1117 recycled_twin_set); | 1084 recycled_twin_set); |
| 1118 | 1085 |
| 1119 if (twin_set && twin_set->num_tilings() == 0) | |
| 1120 twin->ResetRasterScale(); | |
| 1121 | |
| 1122 if (recycled_twin_set && recycled_twin_set->num_tilings() == 0) | 1086 if (recycled_twin_set && recycled_twin_set->num_tilings() == 0) |
| 1123 recycled_twin->ResetRasterScale(); | 1087 recycled_twin->ResetRasterScale(); |
| 1124 | 1088 |
| 1125 DCHECK_GT(tilings_->num_tilings(), 0u); | 1089 DCHECK_GT(tilings_->num_tilings(), 0u); |
| 1126 SanityCheckTilingState(); | 1090 SanityCheckTilingState(); |
| 1127 } | 1091 } |
| 1128 | 1092 |
| 1129 float PictureLayerImpl::MinimumContentsScale() const { | 1093 float PictureLayerImpl::MinimumContentsScale() const { |
| 1130 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1094 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
| 1131 | 1095 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1477 IteratorType index = stages_[current_stage_].iterator_type; | 1441 IteratorType index = stages_[current_stage_].iterator_type; |
| 1478 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; | 1442 TilePriority::PriorityBin tile_type = stages_[current_stage_].tile_type; |
| 1479 | 1443 |
| 1480 if (iterators_[index] && iterators_[index].get_type() == tile_type) | 1444 if (iterators_[index] && iterators_[index].get_type() == tile_type) |
| 1481 break; | 1445 break; |
| 1482 ++current_stage_; | 1446 ++current_stage_; |
| 1483 } | 1447 } |
| 1484 } | 1448 } |
| 1485 | 1449 |
| 1486 } // namespace cc | 1450 } // namespace cc |
| OLD | NEW |