| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 return true; | 919 return true; |
| 920 if (raster_source_scale_ > 4 * ideal_source_scale_) | 920 if (raster_source_scale_ > 4 * ideal_source_scale_) |
| 921 return true; | 921 return true; |
| 922 return false; | 922 return false; |
| 923 } | 923 } |
| 924 | 924 |
| 925 if (was_screen_space_transform_animating_ != | 925 if (was_screen_space_transform_animating_ != |
| 926 draw_properties().screen_space_transform_is_animating) | 926 draw_properties().screen_space_transform_is_animating) |
| 927 return true; | 927 return true; |
| 928 | 928 |
| 929 if (draw_properties().screen_space_transform_is_animating && | |
| 930 raster_contents_scale_ != ideal_contents_scale_ && | |
| 931 ShouldAdjustRasterScaleDuringScaleAnimations()) | |
| 932 return true; | |
| 933 | |
| 934 bool is_pinching = layer_tree_impl()->PinchGestureActive(); | 929 bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
| 935 if (is_pinching && raster_page_scale_) { | 930 if (is_pinching && raster_page_scale_) { |
| 936 // We change our raster scale when it is: | 931 // We change our raster scale when it is: |
| 937 // - Higher than ideal (need a lower-res tiling available) | 932 // - Higher than ideal (need a lower-res tiling available) |
| 938 // - Too far from ideal (need a higher-res tiling available) | 933 // - Too far from ideal (need a higher-res tiling available) |
| 939 float ratio = ideal_page_scale_ / raster_page_scale_; | 934 float ratio = ideal_page_scale_ / raster_page_scale_; |
| 940 if (raster_page_scale_ > ideal_page_scale_ || | 935 if (raster_page_scale_ > ideal_page_scale_ || |
| 941 ratio > kMaxScaleRatioDuringPinch) | 936 ratio > kMaxScaleRatioDuringPinch) |
| 942 return true; | 937 return true; |
| 943 } | 938 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 } else { | 1042 } else { |
| 1048 while (desired_contents_scale < ideal_contents_scale_) | 1043 while (desired_contents_scale < ideal_contents_scale_) |
| 1049 desired_contents_scale *= kMaxScaleRatioDuringPinch; | 1044 desired_contents_scale *= kMaxScaleRatioDuringPinch; |
| 1050 } | 1045 } |
| 1051 raster_contents_scale_ = tilings_->GetSnappedContentsScale( | 1046 raster_contents_scale_ = tilings_->GetSnappedContentsScale( |
| 1052 desired_contents_scale, kSnapToExistingTilingRatio); | 1047 desired_contents_scale, kSnapToExistingTilingRatio); |
| 1053 raster_page_scale_ = | 1048 raster_page_scale_ = |
| 1054 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; | 1049 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; |
| 1055 } | 1050 } |
| 1056 | 1051 |
| 1057 // If we're not re-rasterizing during animation, rasterize at the maximum | 1052 // We rasterize at the maximum scale that will occur during the animation, if |
| 1058 // scale that will occur during the animation, if the maximum scale is | 1053 // the maximum scale is known. However we want to avoid excessive memory use. |
| 1059 // known. However we want to avoid excessive memory use. If the scale is | 1054 // If the scale is smaller than what we would choose otherwise, then it's |
| 1060 // smaller than what we would choose otherwise, then it's always better off | 1055 // always better off for us memory-wise. But otherwise, we don't choose a |
| 1061 // for us memory-wise. But otherwise, we don't choose a scale at which this | 1056 // scale at which this layer's rastered content would become larger than the |
| 1062 // layer's rastered content would become larger than the viewport. | 1057 // viewport. |
| 1063 if (draw_properties().screen_space_transform_is_animating && | 1058 if (draw_properties().screen_space_transform_is_animating) { |
| 1064 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | |
| 1065 bool can_raster_at_maximum_scale = false; | 1059 bool can_raster_at_maximum_scale = false; |
| 1066 bool should_raster_at_starting_scale = false; | 1060 bool should_raster_at_starting_scale = false; |
| 1067 CombinedAnimationScale animation_scales = | 1061 CombinedAnimationScale animation_scales = |
| 1068 layer_tree_impl()->property_trees()->GetAnimationScales( | 1062 layer_tree_impl()->property_trees()->GetAnimationScales( |
| 1069 transform_tree_index(), layer_tree_impl()); | 1063 transform_tree_index(), layer_tree_impl()); |
| 1070 float maximum_scale = animation_scales.maximum_animation_scale; | 1064 float maximum_scale = animation_scales.maximum_animation_scale; |
| 1071 float starting_scale = animation_scales.starting_animation_scale; | 1065 float starting_scale = animation_scales.starting_animation_scale; |
| 1072 if (maximum_scale) { | 1066 if (maximum_scale) { |
| 1073 gfx::Size bounds_at_maximum_scale = | 1067 gfx::Size bounds_at_maximum_scale = |
| 1074 gfx::ScaleToCeiledSize(raster_source_->GetSize(), maximum_scale); | 1068 gfx::ScaleToCeiledSize(raster_source_->GetSize(), maximum_scale); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 return; | 1222 return; |
| 1229 } | 1223 } |
| 1230 if (tilings_->num_tilings() == 0) | 1224 if (tilings_->num_tilings() == 0) |
| 1231 return; | 1225 return; |
| 1232 | 1226 |
| 1233 // We should only have one high res tiling. | 1227 // We should only have one high res tiling. |
| 1234 DCHECK_EQ(1, tilings_->NumHighResTilings()); | 1228 DCHECK_EQ(1, tilings_->NumHighResTilings()); |
| 1235 #endif | 1229 #endif |
| 1236 } | 1230 } |
| 1237 | 1231 |
| 1238 bool PictureLayerImpl::ShouldAdjustRasterScaleDuringScaleAnimations() const { | |
| 1239 return layer_tree_impl()->use_gpu_rasterization(); | |
| 1240 } | |
| 1241 | |
| 1242 float PictureLayerImpl::MaximumTilingContentsScale() const { | 1232 float PictureLayerImpl::MaximumTilingContentsScale() const { |
| 1243 float max_contents_scale = tilings_->GetMaximumContentsScale(); | 1233 float max_contents_scale = tilings_->GetMaximumContentsScale(); |
| 1244 return std::max(max_contents_scale, MinimumContentsScale()); | 1234 return std::max(max_contents_scale, MinimumContentsScale()); |
| 1245 } | 1235 } |
| 1246 | 1236 |
| 1247 std::unique_ptr<PictureLayerTilingSet> | 1237 std::unique_ptr<PictureLayerTilingSet> |
| 1248 PictureLayerImpl::CreatePictureLayerTilingSet() { | 1238 PictureLayerImpl::CreatePictureLayerTilingSet() { |
| 1249 const LayerTreeSettings& settings = layer_tree_impl()->settings(); | 1239 const LayerTreeSettings& settings = layer_tree_impl()->settings(); |
| 1250 return PictureLayerTilingSet::Create( | 1240 return PictureLayerTilingSet::Create( |
| 1251 GetTree(), this, settings.tiling_interest_area_padding, | 1241 GetTree(), this, settings.tiling_interest_area_padding, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1347 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1337 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
| 1348 return !layer_tree_impl()->IsRecycleTree(); | 1338 return !layer_tree_impl()->IsRecycleTree(); |
| 1349 } | 1339 } |
| 1350 | 1340 |
| 1351 bool PictureLayerImpl::HasValidTilePriorities() const { | 1341 bool PictureLayerImpl::HasValidTilePriorities() const { |
| 1352 return IsOnActiveOrPendingTree() && | 1342 return IsOnActiveOrPendingTree() && |
| 1353 is_drawn_render_surface_layer_list_member(); | 1343 is_drawn_render_surface_layer_list_member(); |
| 1354 } | 1344 } |
| 1355 | 1345 |
| 1356 } // namespace cc | 1346 } // namespace cc |
| OLD | NEW |