Chromium Code Reviews| 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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); | 1158 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); |
| 1159 raster_page_scale_ = | 1159 raster_page_scale_ = |
| 1160 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; | 1160 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 raster_contents_scale_ = | 1163 raster_contents_scale_ = |
| 1164 std::max(raster_contents_scale_, MinimumContentsScale()); | 1164 std::max(raster_contents_scale_, MinimumContentsScale()); |
| 1165 | 1165 |
| 1166 // If we're not re-rasterizing during animation, rasterize at the maximum | 1166 // If we're not re-rasterizing during animation, rasterize at the maximum |
| 1167 // scale that will occur during the animation, if the maximum scale is | 1167 // scale that will occur during the animation, if the maximum scale is |
| 1168 // known. However, to avoid excessive memory use, don't rasterize at a scale | 1168 // known. However we want to avoid excessive memory use. If the scale is |
| 1169 // at which this layer would become larger than the viewport. | 1169 // smaller than what we would choose otherwise, then it's always better off |
| 1170 // for us memory-wise. But otherwise, we don't choose a scale at which this | |
| 1171 // layer's rastered content would become larger than the viewport. | |
| 1170 if (draw_properties().screen_space_transform_is_animating && | 1172 if (draw_properties().screen_space_transform_is_animating && |
| 1171 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | 1173 !ShouldAdjustRasterScaleDuringScaleAnimations()) { |
| 1172 bool can_raster_at_maximum_scale = false; | 1174 bool can_raster_at_maximum_scale = false; |
| 1173 if (draw_properties().maximum_animation_contents_scale > 0.f) { | 1175 float maximum_scale = draw_properties().maximum_animation_contents_scale; |
| 1174 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize(gfx::ScaleSize( | 1176 if (maximum_scale) { |
| 1175 bounds(), draw_properties().maximum_animation_contents_scale)); | 1177 if (maximum_scale < raster_contents_scale_) { |
|
ajuma
2014/10/10 13:43:07
What if raster_contents_scale is huge, maximum_sca
danakj
2014/10/10 15:14:45
Ya.. that's a good point. Uhhh. This function real
| |
| 1176 if (bounds_at_maximum_scale.GetArea() <= | |
| 1177 layer_tree_impl()->device_viewport_size().GetArea()) | |
| 1178 can_raster_at_maximum_scale = true; | 1178 can_raster_at_maximum_scale = true; |
| 1179 } else { | |
| 1180 gfx::Size bounds_at_maximum_scale = | |
| 1181 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), maximum_scale)); | |
| 1182 if (bounds_at_maximum_scale.GetArea() <= | |
| 1183 layer_tree_impl()->device_viewport_size().GetArea()) | |
| 1184 can_raster_at_maximum_scale = true; | |
| 1185 } | |
| 1179 } | 1186 } |
| 1180 if (can_raster_at_maximum_scale) { | 1187 // Use the computed scales for the raster scale directly, do not try to use |
| 1181 raster_contents_scale_ = | 1188 // the ideal scale here. The current ideal scale may be way too large in the |
| 1182 std::max(raster_contents_scale_, | 1189 // case of an animation with scale, and will be constantly changing. |
| 1183 draw_properties().maximum_animation_contents_scale); | 1190 if (can_raster_at_maximum_scale) |
| 1184 } else { | 1191 raster_contents_scale_ = maximum_scale; |
| 1185 raster_contents_scale_ = | 1192 else |
| 1186 std::max(raster_contents_scale_, | 1193 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; |
| 1187 1.f * ideal_page_scale_ * ideal_device_scale_); | |
| 1188 } | |
| 1189 } | 1194 } |
| 1190 | 1195 |
| 1191 // If this layer would create zero or one tiles at this content scale, | 1196 // If this layer would create zero or one tiles at this content scale, |
| 1192 // don't create a low res tiling. | 1197 // don't create a low res tiling. |
| 1193 gfx::Size content_bounds = | 1198 gfx::Size content_bounds = |
| 1194 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_)); | 1199 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_)); |
| 1195 gfx::Size tile_size = CalculateTileSize(content_bounds); | 1200 gfx::Size tile_size = CalculateTileSize(content_bounds); |
| 1196 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() && | 1201 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() && |
| 1197 tile_size.height() >= content_bounds.height(); | 1202 tile_size.height() >= content_bounds.height(); |
| 1198 if (tile_size.IsEmpty() || tile_covers_bounds) { | 1203 if (tile_size.IsEmpty() || tile_covers_bounds) { |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1783 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); | 1788 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); |
| 1784 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; | 1789 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; |
| 1785 return tiling_range.end - 1 - current_tiling_range_offset; | 1790 return tiling_range.end - 1 - current_tiling_range_offset; |
| 1786 } | 1791 } |
| 1787 } | 1792 } |
| 1788 NOTREACHED(); | 1793 NOTREACHED(); |
| 1789 return 0; | 1794 return 0; |
| 1790 } | 1795 } |
| 1791 | 1796 |
| 1792 } // namespace cc | 1797 } // namespace cc |
| OLD | NEW |