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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 | 725 |
726 raster_page_scale_ = other->raster_page_scale_; | 726 raster_page_scale_ = other->raster_page_scale_; |
727 raster_device_scale_ = other->raster_device_scale_; | 727 raster_device_scale_ = other->raster_device_scale_; |
728 raster_source_scale_ = other->raster_source_scale_; | 728 raster_source_scale_ = other->raster_source_scale_; |
729 raster_contents_scale_ = other->raster_contents_scale_; | 729 raster_contents_scale_ = other->raster_contents_scale_; |
730 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 730 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
731 | 731 |
732 bool synced_high_res_tiling = false; | 732 bool synced_high_res_tiling = false; |
733 if (CanHaveTilings()) { | 733 if (CanHaveTilings()) { |
734 synced_high_res_tiling = tilings_->SyncTilings( | 734 synced_high_res_tiling = tilings_->SyncTilings( |
735 *other->tilings_, | 735 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); |
736 gfx::ToCeiledSize(bounds()), | |
737 invalidation_, | |
738 MinimumContentsScale()); | |
739 } else { | 736 } else { |
740 RemoveAllTilings(); | 737 RemoveAllTilings(); |
741 } | 738 } |
742 | 739 |
743 // If our MinimumContentsScale has changed to prevent the twin's high res | 740 // If our MinimumContentsScale has changed to prevent the twin's high res |
744 // tiling from being synced, we should reset the raster scale and let it be | 741 // tiling from being synced, we should reset the raster scale and let it be |
745 // recalculated (1) again. This can happen if our bounds shrink to the point | 742 // recalculated (1) again. This can happen if our bounds shrink to the point |
746 // where min contents scale grows. | 743 // where min contents scale grows. |
747 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we | 744 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we |
748 // should refactor this code a little bit and actually recalculate this. | 745 // should refactor this code a little bit and actually recalculate this. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 tile->MarkRequiredForActivation(); | 943 tile->MarkRequiredForActivation(); |
947 } | 944 } |
948 return twin_had_missing_tile; | 945 return twin_had_missing_tile; |
949 } | 946 } |
950 | 947 |
951 void PictureLayerImpl::DoPostCommitInitialization() { | 948 void PictureLayerImpl::DoPostCommitInitialization() { |
952 DCHECK(needs_post_commit_initialization_); | 949 DCHECK(needs_post_commit_initialization_); |
953 DCHECK(layer_tree_impl()->IsPendingTree()); | 950 DCHECK(layer_tree_impl()->IsPendingTree()); |
954 | 951 |
955 if (!tilings_) | 952 if (!tilings_) |
956 tilings_.reset(new PictureLayerTilingSet(this, | 953 tilings_.reset(new PictureLayerTilingSet(this, bounds())); |
957 gfx::ToCeiledSize(bounds()))); | |
958 | 954 |
959 DCHECK(!twin_layer_); | 955 DCHECK(!twin_layer_); |
960 twin_layer_ = static_cast<PictureLayerImpl*>( | 956 twin_layer_ = static_cast<PictureLayerImpl*>( |
961 layer_tree_impl()->FindActiveTreeLayerById(id())); | 957 layer_tree_impl()->FindActiveTreeLayerById(id())); |
962 if (twin_layer_) { | 958 if (twin_layer_) { |
963 DCHECK(!twin_layer_->twin_layer_); | 959 DCHECK(!twin_layer_->twin_layer_); |
964 twin_layer_->twin_layer_ = this; | 960 twin_layer_->twin_layer_ = this; |
965 // If the twin has never been pushed to, do not sync from it. | 961 // If the twin has never been pushed to, do not sync from it. |
966 // This can happen if this function is called during activation. | 962 // This can happen if this function is called during activation. |
967 if (!twin_layer_->needs_post_commit_initialization_) | 963 if (!twin_layer_->needs_post_commit_initialization_) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 SanityCheckTilingState(); | 1284 SanityCheckTilingState(); |
1289 } | 1285 } |
1290 | 1286 |
1291 float PictureLayerImpl::MinimumContentsScale() const { | 1287 float PictureLayerImpl::MinimumContentsScale() const { |
1292 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1288 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
1293 | 1289 |
1294 // If the contents scale is less than 1 / width (also for height), | 1290 // If the contents scale is less than 1 / width (also for height), |
1295 // then it will end up having less than one pixel of content in that | 1291 // then it will end up having less than one pixel of content in that |
1296 // dimension. Bump the minimum contents scale up in this case to prevent | 1292 // dimension. Bump the minimum contents scale up in this case to prevent |
1297 // this from happening. | 1293 // this from happening. |
1298 float min_dimension = std::min(bounds().width(), bounds().height()); | 1294 int min_dimension = std::min(bounds().width(), bounds().height()); |
1299 if (!min_dimension) | 1295 if (!min_dimension) |
1300 return setting_min; | 1296 return setting_min; |
1301 | 1297 |
1302 return std::max(1.f / min_dimension, setting_min); | 1298 return std::max(1.f / min_dimension, setting_min); |
1303 } | 1299 } |
1304 | 1300 |
1305 void PictureLayerImpl::ResetRasterScale() { | 1301 void PictureLayerImpl::ResetRasterScale() { |
1306 raster_page_scale_ = 0.f; | 1302 raster_page_scale_ = 0.f; |
1307 raster_device_scale_ = 0.f; | 1303 raster_device_scale_ = 0.f; |
1308 raster_source_scale_ = 0.f; | 1304 raster_source_scale_ = 0.f; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1783 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1788 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1784 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1789 return tiling_range.end - 1 - current_tiling_range_offset; | 1785 return tiling_range.end - 1 - current_tiling_range_offset; |
1790 } | 1786 } |
1791 } | 1787 } |
1792 NOTREACHED(); | 1788 NOTREACHED(); |
1793 return 0; | 1789 return 0; |
1794 } | 1790 } |
1795 | 1791 |
1796 } // namespace cc | 1792 } // namespace cc |
OLD | NEW |