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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. | 1080 // - When zooming in, approximate ideal using multiple of kMaxScaleRatio. |
1081 bool zooming_out = old_raster_page_scale > ideal_page_scale_; | 1081 bool zooming_out = old_raster_page_scale > ideal_page_scale_; |
1082 float desired_contents_scale = | 1082 float desired_contents_scale = |
1083 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch | 1083 zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch |
1084 : old_raster_contents_scale * kMaxScaleRatioDuringPinch; | 1084 : old_raster_contents_scale * kMaxScaleRatioDuringPinch; |
1085 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); | 1085 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); |
1086 raster_page_scale_ = | 1086 raster_page_scale_ = |
1087 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; | 1087 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; |
1088 } | 1088 } |
1089 | 1089 |
1090 raster_contents_scale_ = | |
1091 std::max(raster_contents_scale_, MinimumContentsScale()); | |
1092 | |
1093 // If we're not re-rasterizing during animation, rasterize at the maximum | 1090 // If we're not re-rasterizing during animation, rasterize at the maximum |
1094 // scale that will occur during the animation, if the maximum scale is | 1091 // scale that will occur during the animation, if the maximum scale is |
1095 // known. However we want to avoid excessive memory use. If the scale is | 1092 // known. However we want to avoid excessive memory use. If the scale is |
1096 // smaller than what we would choose otherwise, then it's always better off | 1093 // smaller than what we would choose otherwise, then it's always better off |
1097 // for us memory-wise. But otherwise, we don't choose a scale at which this | 1094 // for us memory-wise. But otherwise, we don't choose a scale at which this |
1098 // layer's rastered content would become larger than the viewport. | 1095 // layer's rastered content would become larger than the viewport. |
1099 if (draw_properties().screen_space_transform_is_animating && | 1096 if (draw_properties().screen_space_transform_is_animating && |
1100 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | 1097 !ShouldAdjustRasterScaleDuringScaleAnimations()) { |
1101 bool can_raster_at_maximum_scale = false; | 1098 bool can_raster_at_maximum_scale = false; |
1102 // TODO(ajuma): If we need to deal with scale-down animations starting right | 1099 // TODO(ajuma): If we need to deal with scale-down animations starting right |
(...skipping 11 matching lines...) Expand all Loading... |
1114 } | 1111 } |
1115 // Use the computed scales for the raster scale directly, do not try to use | 1112 // Use the computed scales for the raster scale directly, do not try to use |
1116 // the ideal scale here. The current ideal scale may be way too large in the | 1113 // the ideal scale here. The current ideal scale may be way too large in the |
1117 // case of an animation with scale, and will be constantly changing. | 1114 // case of an animation with scale, and will be constantly changing. |
1118 if (can_raster_at_maximum_scale) | 1115 if (can_raster_at_maximum_scale) |
1119 raster_contents_scale_ = maximum_scale; | 1116 raster_contents_scale_ = maximum_scale; |
1120 else | 1117 else |
1121 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; | 1118 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; |
1122 } | 1119 } |
1123 | 1120 |
| 1121 raster_contents_scale_ = |
| 1122 std::max(raster_contents_scale_, MinimumContentsScale()); |
| 1123 |
1124 // If this layer would create zero or one tiles at this content scale, | 1124 // If this layer would create zero or one tiles at this content scale, |
1125 // don't create a low res tiling. | 1125 // don't create a low res tiling. |
1126 gfx::Size raster_bounds = gfx::ToCeiledSize( | 1126 gfx::Size raster_bounds = gfx::ToCeiledSize( |
1127 gfx::ScaleSize(pile_->tiling_size(), raster_contents_scale_)); | 1127 gfx::ScaleSize(pile_->tiling_size(), raster_contents_scale_)); |
1128 gfx::Size tile_size = CalculateTileSize(raster_bounds); | 1128 gfx::Size tile_size = CalculateTileSize(raster_bounds); |
1129 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && | 1129 bool tile_covers_bounds = tile_size.width() >= raster_bounds.width() && |
1130 tile_size.height() >= raster_bounds.height(); | 1130 tile_size.height() >= raster_bounds.height(); |
1131 if (tile_size.IsEmpty() || tile_covers_bounds) { | 1131 if (tile_size.IsEmpty() || tile_covers_bounds) { |
1132 low_res_raster_contents_scale_ = raster_contents_scale_; | 1132 low_res_raster_contents_scale_ = raster_contents_scale_; |
1133 return; | 1133 return; |
1134 } | 1134 } |
1135 | 1135 |
1136 float low_res_factor = | 1136 float low_res_factor = |
1137 layer_tree_impl()->settings().low_res_contents_scale_factor; | 1137 layer_tree_impl()->settings().low_res_contents_scale_factor; |
1138 low_res_raster_contents_scale_ = std::max( | 1138 low_res_raster_contents_scale_ = std::max( |
1139 raster_contents_scale_ * low_res_factor, | 1139 raster_contents_scale_ * low_res_factor, |
1140 MinimumContentsScale()); | 1140 MinimumContentsScale()); |
| 1141 DCHECK_LE(low_res_raster_contents_scale_, raster_contents_scale_); |
| 1142 DCHECK_GE(low_res_raster_contents_scale_, MinimumContentsScale()); |
1141 } | 1143 } |
1142 | 1144 |
1143 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( | 1145 void PictureLayerImpl::CleanUpTilingsOnActiveLayer( |
1144 std::vector<PictureLayerTiling*> used_tilings) { | 1146 std::vector<PictureLayerTiling*> used_tilings) { |
1145 DCHECK(layer_tree_impl()->IsActiveTree()); | 1147 DCHECK(layer_tree_impl()->IsActiveTree()); |
1146 if (tilings_->num_tilings() == 0) | 1148 if (tilings_->num_tilings() == 0) |
1147 return; | 1149 return; |
1148 | 1150 |
1149 float min_acceptable_high_res_scale = std::min( | 1151 float min_acceptable_high_res_scale = std::min( |
1150 raster_contents_scale_, ideal_contents_scale_); | 1152 raster_contents_scale_, ideal_contents_scale_); |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1724 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
1723 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1725 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
1724 return tiling_range.end - 1 - current_tiling_range_offset; | 1726 return tiling_range.end - 1 - current_tiling_range_offset; |
1725 } | 1727 } |
1726 } | 1728 } |
1727 NOTREACHED(); | 1729 NOTREACHED(); |
1728 return 0; | 1730 return 0; |
1729 } | 1731 } |
1730 | 1732 |
1731 } // namespace cc | 1733 } // namespace cc |
OLD | NEW |