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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 | 736 |
737 raster_page_scale_ = other->raster_page_scale_; | 737 raster_page_scale_ = other->raster_page_scale_; |
738 raster_device_scale_ = other->raster_device_scale_; | 738 raster_device_scale_ = other->raster_device_scale_; |
739 raster_source_scale_ = other->raster_source_scale_; | 739 raster_source_scale_ = other->raster_source_scale_; |
740 raster_contents_scale_ = other->raster_contents_scale_; | 740 raster_contents_scale_ = other->raster_contents_scale_; |
741 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; | 741 low_res_raster_contents_scale_ = other->low_res_raster_contents_scale_; |
742 | 742 |
743 bool synced_high_res_tiling = false; | 743 bool synced_high_res_tiling = false; |
744 if (CanHaveTilings()) { | 744 if (CanHaveTilings()) { |
745 synced_high_res_tiling = tilings_->SyncTilings( | 745 synced_high_res_tiling = tilings_->SyncTilings( |
746 *other->tilings_, bounds(), invalidation_, MinimumContentsScale()); | 746 *other->tilings_, |
| 747 gfx::ToCeiledSize(bounds()), |
| 748 invalidation_, |
| 749 MinimumContentsScale()); |
747 } else { | 750 } else { |
748 RemoveAllTilings(); | 751 RemoveAllTilings(); |
749 } | 752 } |
750 | 753 |
751 // If our MinimumContentsScale has changed to prevent the twin's high res | 754 // If our MinimumContentsScale has changed to prevent the twin's high res |
752 // tiling from being synced, we should reset the raster scale and let it be | 755 // tiling from being synced, we should reset the raster scale and let it be |
753 // recalculated (1) again. This can happen if our bounds shrink to the point | 756 // recalculated (1) again. This can happen if our bounds shrink to the point |
754 // where min contents scale grows. | 757 // where min contents scale grows. |
755 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we | 758 // (1) - TODO(vmpstr) Instead of hoping that this will be recalculated, we |
756 // should refactor this code a little bit and actually recalculate this. | 759 // should refactor this code a little bit and actually recalculate this. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 tile->MarkRequiredForActivation(); | 957 tile->MarkRequiredForActivation(); |
955 } | 958 } |
956 return twin_had_missing_tile; | 959 return twin_had_missing_tile; |
957 } | 960 } |
958 | 961 |
959 void PictureLayerImpl::DoPostCommitInitialization() { | 962 void PictureLayerImpl::DoPostCommitInitialization() { |
960 DCHECK(needs_post_commit_initialization_); | 963 DCHECK(needs_post_commit_initialization_); |
961 DCHECK(layer_tree_impl()->IsPendingTree()); | 964 DCHECK(layer_tree_impl()->IsPendingTree()); |
962 | 965 |
963 if (!tilings_) | 966 if (!tilings_) |
964 tilings_.reset(new PictureLayerTilingSet(this, bounds())); | 967 tilings_.reset(new PictureLayerTilingSet(this, |
| 968 gfx::ToCeiledSize(bounds()))); |
965 | 969 |
966 DCHECK(!twin_layer_); | 970 DCHECK(!twin_layer_); |
967 twin_layer_ = static_cast<PictureLayerImpl*>( | 971 twin_layer_ = static_cast<PictureLayerImpl*>( |
968 layer_tree_impl()->FindActiveTreeLayerById(id())); | 972 layer_tree_impl()->FindActiveTreeLayerById(id())); |
969 if (twin_layer_) { | 973 if (twin_layer_) { |
970 DCHECK(!twin_layer_->twin_layer_); | 974 DCHECK(!twin_layer_->twin_layer_); |
971 twin_layer_->twin_layer_ = this; | 975 twin_layer_->twin_layer_ = this; |
972 // If the twin has never been pushed to, do not sync from it. | 976 // If the twin has never been pushed to, do not sync from it. |
973 // This can happen if this function is called during activation. | 977 // This can happen if this function is called during activation. |
974 if (!twin_layer_->needs_post_commit_initialization_) | 978 if (!twin_layer_->needs_post_commit_initialization_) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 SanityCheckTilingState(); | 1299 SanityCheckTilingState(); |
1296 } | 1300 } |
1297 | 1301 |
1298 float PictureLayerImpl::MinimumContentsScale() const { | 1302 float PictureLayerImpl::MinimumContentsScale() const { |
1299 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; | 1303 float setting_min = layer_tree_impl()->settings().minimum_contents_scale; |
1300 | 1304 |
1301 // If the contents scale is less than 1 / width (also for height), | 1305 // If the contents scale is less than 1 / width (also for height), |
1302 // then it will end up having less than one pixel of content in that | 1306 // then it will end up having less than one pixel of content in that |
1303 // dimension. Bump the minimum contents scale up in this case to prevent | 1307 // dimension. Bump the minimum contents scale up in this case to prevent |
1304 // this from happening. | 1308 // this from happening. |
1305 int min_dimension = std::min(bounds().width(), bounds().height()); | 1309 float min_dimension = std::min(bounds().width(), bounds().height()); |
1306 if (!min_dimension) | 1310 if (!min_dimension) |
1307 return setting_min; | 1311 return setting_min; |
1308 | 1312 |
1309 return std::max(1.f / min_dimension, setting_min); | 1313 return std::max(1.f / min_dimension, setting_min); |
1310 } | 1314 } |
1311 | 1315 |
1312 void PictureLayerImpl::ResetRasterScale() { | 1316 void PictureLayerImpl::ResetRasterScale() { |
1313 raster_page_scale_ = 0.f; | 1317 raster_page_scale_ = 0.f; |
1314 raster_device_scale_ = 0.f; | 1318 raster_device_scale_ = 0.f; |
1315 raster_source_scale_ = 0.f; | 1319 raster_source_scale_ = 0.f; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1794 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1798 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1795 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1799 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1796 return tiling_range.end - 1 - current_tiling_range_offset; | 1800 return tiling_range.end - 1 - current_tiling_range_offset; |
1797 } | 1801 } |
1798 } | 1802 } |
1799 NOTREACHED(); | 1803 NOTREACHED(); |
1800 return 0; | 1804 return 0; |
1801 } | 1805 } |
1802 | 1806 |
1803 } // namespace cc | 1807 } // namespace cc |
OLD | NEW |