| 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 <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 // To avoid an edge case after lost context where the tree is up to date but | 631 // To avoid an edge case after lost context where the tree is up to date but |
| 632 // the tilings have not been managed, request an update draw properties | 632 // the tilings have not been managed, request an update draw properties |
| 633 // to force tilings to get managed. | 633 // to force tilings to get managed. |
| 634 layer_tree_impl()->set_needs_update_draw_properties(); | 634 layer_tree_impl()->set_needs_update_draw_properties(); |
| 635 } | 635 } |
| 636 | 636 |
| 637 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 637 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 638 return raster_source_->GetFlattenedPicture(); | 638 return raster_source_->GetFlattenedPicture(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 scoped_refptr<Tile> PictureLayerImpl::CreateTile(PictureLayerTiling* tiling, | 641 scoped_refptr<Tile> PictureLayerImpl::CreateTile( |
| 642 const gfx::Rect& content_rect) { | 642 float contents_scale, |
| 643 DCHECK(!raster_source_->IsSolidColor()); | 643 const gfx::Rect& content_rect) { |
| 644 if (!raster_source_->CoversRect(content_rect, tiling->contents_scale())) | |
| 645 return scoped_refptr<Tile>(); | |
| 646 | |
| 647 int flags = 0; | 644 int flags = 0; |
| 648 | 645 |
| 649 // We don't handle solid color masks, so we shouldn't bother analyzing those. | 646 // We don't handle solid color masks, so we shouldn't bother analyzing those. |
| 650 // Otherwise, always analyze to maximize memory savings. | 647 // Otherwise, always analyze to maximize memory savings. |
| 651 if (!is_mask_) | 648 if (!is_mask_) |
| 652 flags = Tile::USE_PICTURE_ANALYSIS; | 649 flags = Tile::USE_PICTURE_ANALYSIS; |
| 653 | 650 |
| 654 return layer_tree_impl()->tile_manager()->CreateTile( | 651 return layer_tree_impl()->tile_manager()->CreateTile( |
| 655 raster_source_.get(), content_rect.size(), content_rect, | 652 raster_source_.get(), content_rect.size(), content_rect, contents_scale, |
| 656 tiling->contents_scale(), id(), layer_tree_impl()->source_frame_number(), | 653 id(), layer_tree_impl()->source_frame_number(), flags); |
| 657 flags); | |
| 658 } | 654 } |
| 659 | 655 |
| 660 const Region* PictureLayerImpl::GetPendingInvalidation() { | 656 const Region* PictureLayerImpl::GetPendingInvalidation() { |
| 661 if (layer_tree_impl()->IsPendingTree()) | 657 if (layer_tree_impl()->IsPendingTree()) |
| 662 return &invalidation_; | 658 return &invalidation_; |
| 663 if (layer_tree_impl()->IsRecycleTree()) | 659 if (layer_tree_impl()->IsRecycleTree()) |
| 664 return nullptr; | 660 return nullptr; |
| 665 DCHECK(layer_tree_impl()->IsActiveTree()); | 661 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 666 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) | 662 if (PictureLayerImpl* twin_layer = GetPendingOrActiveTwinLayer()) |
| 667 return &twin_layer->invalidation_; | 663 return &twin_layer->invalidation_; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 | 807 |
| 812 nearest_neighbor_ = nearest_neighbor; | 808 nearest_neighbor_ = nearest_neighbor; |
| 813 NoteLayerPropertyChanged(); | 809 NoteLayerPropertyChanged(); |
| 814 } | 810 } |
| 815 | 811 |
| 816 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 812 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 817 DCHECK(CanHaveTilings()); | 813 DCHECK(CanHaveTilings()); |
| 818 DCHECK_GE(contents_scale, MinimumContentsScale()); | 814 DCHECK_GE(contents_scale, MinimumContentsScale()); |
| 819 DCHECK_LE(contents_scale, MaximumContentsScale()); | 815 DCHECK_LE(contents_scale, MaximumContentsScale()); |
| 820 DCHECK(raster_source_->HasRecordings()); | 816 DCHECK(raster_source_->HasRecordings()); |
| 821 return tilings_->AddTiling(contents_scale, raster_source_->GetSize()); | 817 return tilings_->AddTiling(contents_scale, raster_source_); |
| 822 } | 818 } |
| 823 | 819 |
| 824 void PictureLayerImpl::RemoveAllTilings() { | 820 void PictureLayerImpl::RemoveAllTilings() { |
| 825 if (tilings_) | 821 if (tilings_) |
| 826 tilings_->RemoveAllTilings(); | 822 tilings_->RemoveAllTilings(); |
| 827 // If there are no tilings, then raster scales are no longer meaningful. | 823 // If there are no tilings, then raster scales are no longer meaningful. |
| 828 ResetRasterScale(); | 824 ResetRasterScale(); |
| 829 } | 825 } |
| 830 | 826 |
| 831 void PictureLayerImpl::AddTilingsForRasterScale() { | 827 void PictureLayerImpl::AddTilingsForRasterScale() { |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 | 1325 |
| 1330 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { | 1326 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { |
| 1331 if (!layer_tree_impl()->IsActiveTree()) | 1327 if (!layer_tree_impl()->IsActiveTree()) |
| 1332 return true; | 1328 return true; |
| 1333 | 1329 |
| 1334 return AllTilesRequiredAreReadyToDraw( | 1330 return AllTilesRequiredAreReadyToDraw( |
| 1335 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); | 1331 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
| 1336 } | 1332 } |
| 1337 | 1333 |
| 1338 } // namespace cc | 1334 } // namespace cc |
| OLD | NEW |