| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ideal_device_scale_(0.f), | 75 ideal_device_scale_(0.f), |
| 76 ideal_source_scale_(0.f), | 76 ideal_source_scale_(0.f), |
| 77 ideal_contents_scale_(0.f), | 77 ideal_contents_scale_(0.f), |
| 78 raster_page_scale_(0.f), | 78 raster_page_scale_(0.f), |
| 79 raster_device_scale_(0.f), | 79 raster_device_scale_(0.f), |
| 80 raster_source_scale_(0.f), | 80 raster_source_scale_(0.f), |
| 81 raster_contents_scale_(0.f), | 81 raster_contents_scale_(0.f), |
| 82 low_res_raster_contents_scale_(0.f), | 82 low_res_raster_contents_scale_(0.f), |
| 83 raster_source_scale_is_fixed_(false), | 83 raster_source_scale_is_fixed_(false), |
| 84 was_screen_space_transform_animating_(false), | 84 was_screen_space_transform_animating_(false), |
| 85 should_update_tile_priorities_(false), | |
| 86 only_used_low_res_last_append_quads_(false), | 85 only_used_low_res_last_append_quads_(false), |
| 87 is_mask_(is_mask), | 86 is_mask_(is_mask), |
| 88 nearest_neighbor_(false) { | 87 nearest_neighbor_(false) { |
| 89 layer_tree_impl()->RegisterPictureLayerImpl(this); | 88 layer_tree_impl()->RegisterPictureLayerImpl(this); |
| 90 } | 89 } |
| 91 | 90 |
| 92 PictureLayerImpl::~PictureLayerImpl() { | 91 PictureLayerImpl::~PictureLayerImpl() { |
| 93 if (twin_layer_) | 92 if (twin_layer_) |
| 94 twin_layer_->twin_layer_ = nullptr; | 93 twin_layer_->twin_layer_ = nullptr; |
| 95 layer_tree_impl()->UnregisterPictureLayerImpl(this); | 94 layer_tree_impl()->UnregisterPictureLayerImpl(this); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 DCHECK(raster_source_scale_); | 454 DCHECK(raster_source_scale_); |
| 456 DCHECK(raster_contents_scale_); | 455 DCHECK(raster_contents_scale_); |
| 457 DCHECK(low_res_raster_contents_scale_); | 456 DCHECK(low_res_raster_contents_scale_); |
| 458 | 457 |
| 459 was_screen_space_transform_animating_ = | 458 was_screen_space_transform_animating_ = |
| 460 draw_properties().screen_space_transform_is_animating; | 459 draw_properties().screen_space_transform_is_animating; |
| 461 | 460 |
| 462 if (draw_transform_is_animating()) | 461 if (draw_transform_is_animating()) |
| 463 raster_source_->SetShouldAttemptToUseDistanceFieldText(); | 462 raster_source_->SetShouldAttemptToUseDistanceFieldText(); |
| 464 | 463 |
| 465 should_update_tile_priorities_ = true; | |
| 466 | |
| 467 return UpdateTilePriorities(occlusion_in_content_space); | 464 return UpdateTilePriorities(occlusion_in_content_space); |
| 468 } | 465 } |
| 469 | 466 |
| 470 bool PictureLayerImpl::UpdateTilePriorities( | 467 bool PictureLayerImpl::UpdateTilePriorities( |
| 471 const Occlusion& occlusion_in_content_space) { | 468 const Occlusion& occlusion_in_content_space) { |
| 472 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); | 469 DCHECK_IMPLIES(raster_source_->IsSolidColor(), tilings_->num_tilings() == 0); |
| 473 | 470 |
| 474 double current_frame_time_in_seconds = | 471 double current_frame_time_in_seconds = |
| 475 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - | 472 (layer_tree_impl()->CurrentBeginFrameArgs().frame_time - |
| 476 base::TimeTicks()).InSecondsF(); | 473 base::TimeTicks()).InSecondsF(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 // first frame. | 547 // first frame. |
| 551 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); | 548 bool could_have_tilings = raster_source_.get() && CanHaveTilings(); |
| 552 raster_source_.swap(raster_source); | 549 raster_source_.swap(raster_source); |
| 553 | 550 |
| 554 // The |new_invalidation| must be cleared before updating tilings since they | 551 // The |new_invalidation| must be cleared before updating tilings since they |
| 555 // access the invalidation through the PictureLayerTilingClient interface. | 552 // access the invalidation through the PictureLayerTilingClient interface. |
| 556 invalidation_.Clear(); | 553 invalidation_.Clear(); |
| 557 invalidation_.Swap(new_invalidation); | 554 invalidation_.Swap(new_invalidation); |
| 558 | 555 |
| 559 bool can_have_tilings = CanHaveTilings(); | 556 bool can_have_tilings = CanHaveTilings(); |
| 557 DCHECK_IMPLIES( |
| 558 pending_set, |
| 559 can_have_tilings == GetPendingOrActiveTwinLayer()->CanHaveTilings()); |
| 560 | 560 |
| 561 // Need to call UpdateTiles again if CanHaveTilings changed. | 561 // Need to call UpdateTiles again if CanHaveTilings changed. |
| 562 if (could_have_tilings != can_have_tilings) | 562 if (could_have_tilings != can_have_tilings) |
| 563 layer_tree_impl()->set_needs_update_draw_properties(); | 563 layer_tree_impl()->set_needs_update_draw_properties(); |
| 564 | 564 |
| 565 if (!can_have_tilings) { | 565 if (!can_have_tilings) { |
| 566 RemoveAllTilings(); | 566 RemoveAllTilings(); |
| 567 return; | 567 return; |
| 568 } | 568 } |
| 569 | 569 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 582 AddDamageRect(layer_damage_rect); | 582 AddDamageRect(layer_damage_rect); |
| 583 } | 583 } |
| 584 } | 584 } |
| 585 | 585 |
| 586 void PictureLayerImpl::DidBeginTracing() { | 586 void PictureLayerImpl::DidBeginTracing() { |
| 587 raster_source_->DidBeginTracing(); | 587 raster_source_->DidBeginTracing(); |
| 588 } | 588 } |
| 589 | 589 |
| 590 void PictureLayerImpl::ReleaseResources() { | 590 void PictureLayerImpl::ReleaseResources() { |
| 591 // Recreate tilings with new settings, since some of those might change when | 591 // Recreate tilings with new settings, since some of those might change when |
| 592 // we release resources. If tilings_ is null, then leave it as null. | 592 // we release resources. |
| 593 if (tilings_) | 593 tilings_ = CreatePictureLayerTilingSet(); |
| 594 tilings_ = CreatePictureLayerTilingSet(); | |
| 595 ResetRasterScale(); | 594 ResetRasterScale(); |
| 596 | 595 |
| 597 // To avoid an edge case after lost context where the tree is up to date but | 596 // To avoid an edge case after lost context where the tree is up to date but |
| 598 // the tilings have not been managed, request an update draw properties | 597 // the tilings have not been managed, request an update draw properties |
| 599 // to force tilings to get managed. | 598 // to force tilings to get managed. |
| 600 layer_tree_impl()->set_needs_update_draw_properties(); | 599 layer_tree_impl()->set_needs_update_draw_properties(); |
| 601 } | 600 } |
| 602 | 601 |
| 603 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { | 602 skia::RefPtr<SkPicture> PictureLayerImpl::GetPicture() { |
| 604 return raster_source_->GetFlattenedPicture(); | 603 return raster_source_->GetFlattenedPicture(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 | 776 |
| 778 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { | 777 PictureLayerTiling* PictureLayerImpl::AddTiling(float contents_scale) { |
| 779 DCHECK(CanHaveTilings()); | 778 DCHECK(CanHaveTilings()); |
| 780 DCHECK_GE(contents_scale, MinimumContentsScale()); | 779 DCHECK_GE(contents_scale, MinimumContentsScale()); |
| 781 DCHECK_LE(contents_scale, MaximumContentsScale()); | 780 DCHECK_LE(contents_scale, MaximumContentsScale()); |
| 782 DCHECK(raster_source_->HasRecordings()); | 781 DCHECK(raster_source_->HasRecordings()); |
| 783 return tilings_->AddTiling(contents_scale, raster_source_); | 782 return tilings_->AddTiling(contents_scale, raster_source_); |
| 784 } | 783 } |
| 785 | 784 |
| 786 void PictureLayerImpl::RemoveAllTilings() { | 785 void PictureLayerImpl::RemoveAllTilings() { |
| 787 if (tilings_) | 786 tilings_->RemoveAllTilings(); |
| 788 tilings_->RemoveAllTilings(); | |
| 789 // If there are no tilings, then raster scales are no longer meaningful. | 787 // If there are no tilings, then raster scales are no longer meaningful. |
| 790 ResetRasterScale(); | 788 ResetRasterScale(); |
| 791 } | 789 } |
| 792 | 790 |
| 793 void PictureLayerImpl::AddTilingsForRasterScale() { | 791 void PictureLayerImpl::AddTilingsForRasterScale() { |
| 794 // Reset all resolution enums on tilings, we'll be setting new values in this | 792 // Reset all resolution enums on tilings, we'll be setting new values in this |
| 795 // function. | 793 // function. |
| 796 tilings_->MarkAllTilingsNonIdeal(); | 794 tilings_->MarkAllTilingsNonIdeal(); |
| 797 | 795 |
| 798 PictureLayerTiling* high_res = | 796 PictureLayerTiling* high_res = |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 return nextafterf(max_scale, 0.f); | 1067 return nextafterf(max_scale, 0.f); |
| 1070 } | 1068 } |
| 1071 | 1069 |
| 1072 void PictureLayerImpl::ResetRasterScale() { | 1070 void PictureLayerImpl::ResetRasterScale() { |
| 1073 raster_page_scale_ = 0.f; | 1071 raster_page_scale_ = 0.f; |
| 1074 raster_device_scale_ = 0.f; | 1072 raster_device_scale_ = 0.f; |
| 1075 raster_source_scale_ = 0.f; | 1073 raster_source_scale_ = 0.f; |
| 1076 raster_contents_scale_ = 0.f; | 1074 raster_contents_scale_ = 0.f; |
| 1077 low_res_raster_contents_scale_ = 0.f; | 1075 low_res_raster_contents_scale_ = 0.f; |
| 1078 raster_source_scale_is_fixed_ = false; | 1076 raster_source_scale_is_fixed_ = false; |
| 1079 | |
| 1080 // When raster scales aren't valid, don't update tile priorities until | |
| 1081 // this layer has been updated via UpdateDrawProperties. | |
| 1082 should_update_tile_priorities_ = false; | |
| 1083 } | 1077 } |
| 1084 | 1078 |
| 1085 bool PictureLayerImpl::CanHaveTilings() const { | 1079 bool PictureLayerImpl::CanHaveTilings() const { |
| 1086 if (raster_source_->IsSolidColor()) | 1080 if (raster_source_->IsSolidColor()) |
| 1087 return false; | 1081 return false; |
| 1088 if (!DrawsContent()) | 1082 if (!DrawsContent()) |
| 1089 return false; | 1083 return false; |
| 1090 if (!raster_source_->HasRecordings()) | 1084 if (!raster_source_->HasRecordings()) |
| 1091 return false; | 1085 return false; |
| 1092 // If the |raster_source_| has a recording it should have non-empty bounds. | 1086 // If the |raster_source_| has a recording it should have non-empty bounds. |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 | 1280 |
| 1287 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { | 1281 bool PictureLayerImpl::AllTilesRequiredForDrawAreReadyToDraw() const { |
| 1288 if (!layer_tree_impl()->IsActiveTree()) | 1282 if (!layer_tree_impl()->IsActiveTree()) |
| 1289 return true; | 1283 return true; |
| 1290 | 1284 |
| 1291 return AllTilesRequiredAreReadyToDraw( | 1285 return AllTilesRequiredAreReadyToDraw( |
| 1292 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); | 1286 &PictureLayerTiling::IsTileRequiredForDrawIfVisible); |
| 1293 } | 1287 } |
| 1294 | 1288 |
| 1295 } // namespace cc | 1289 } // namespace cc |
| OLD | NEW |