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 <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 | 965 |
966 // If we're not re-rasterizing during animation, rasterize at the maximum | 966 // If we're not re-rasterizing during animation, rasterize at the maximum |
967 // scale that will occur during the animation, if the maximum scale is | 967 // scale that will occur during the animation, if the maximum scale is |
968 // known. However we want to avoid excessive memory use. If the scale is | 968 // known. However we want to avoid excessive memory use. If the scale is |
969 // smaller than what we would choose otherwise, then it's always better off | 969 // smaller than what we would choose otherwise, then it's always better off |
970 // for us memory-wise. But otherwise, we don't choose a scale at which this | 970 // for us memory-wise. But otherwise, we don't choose a scale at which this |
971 // layer's rastered content would become larger than the viewport. | 971 // layer's rastered content would become larger than the viewport. |
972 if (draw_properties().screen_space_transform_is_animating && | 972 if (draw_properties().screen_space_transform_is_animating && |
973 !ShouldAdjustRasterScaleDuringScaleAnimations()) { | 973 !ShouldAdjustRasterScaleDuringScaleAnimations()) { |
974 bool can_raster_at_maximum_scale = false; | 974 bool can_raster_at_maximum_scale = false; |
975 // TODO(ajuma): If we need to deal with scale-down animations starting right | 975 bool should_raster_at_starting_scale = false; |
976 // as a layer gets promoted, then we'd want to have the | |
977 // |starting_animation_contents_scale| passed in here as a separate draw | |
978 // property so we could try use that when the max is too large. | |
979 // See crbug.com/422341. | |
980 float maximum_scale = draw_properties().maximum_animation_contents_scale; | 976 float maximum_scale = draw_properties().maximum_animation_contents_scale; |
| 977 float starting_scale = draw_properties().starting_animation_contents_scale; |
981 if (maximum_scale) { | 978 if (maximum_scale) { |
982 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize( | 979 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize( |
983 gfx::ScaleSize(raster_source_->GetSize(), maximum_scale)); | 980 gfx::ScaleSize(raster_source_->GetSize(), maximum_scale)); |
984 int64 maximum_area = static_cast<int64>(bounds_at_maximum_scale.width()) * | 981 int64 maximum_area = static_cast<int64>(bounds_at_maximum_scale.width()) * |
985 static_cast<int64>(bounds_at_maximum_scale.height()); | 982 static_cast<int64>(bounds_at_maximum_scale.height()); |
986 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); | 983 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); |
987 int64 viewport_area = static_cast<int64>(viewport.width()) * | 984 int64 viewport_area = static_cast<int64>(viewport.width()) * |
988 static_cast<int64>(viewport.height()); | 985 static_cast<int64>(viewport.height()); |
989 if (maximum_area <= viewport_area) | 986 if (maximum_area <= viewport_area) |
990 can_raster_at_maximum_scale = true; | 987 can_raster_at_maximum_scale = true; |
991 } | 988 } |
| 989 if (starting_scale && starting_scale > maximum_scale) { |
| 990 gfx::Size bounds_at_starting_scale = gfx::ToCeiledSize( |
| 991 gfx::ScaleSize(raster_source_->GetSize(), starting_scale)); |
| 992 int64 start_area = static_cast<int64>(bounds_at_starting_scale.width()) * |
| 993 static_cast<int64>(bounds_at_starting_scale.height()); |
| 994 gfx::Size viewport = layer_tree_impl()->device_viewport_size(); |
| 995 int64 viewport_area = static_cast<int64>(viewport.width()) * |
| 996 static_cast<int64>(viewport.height()); |
| 997 if (start_area <= viewport_area) |
| 998 should_raster_at_starting_scale = true; |
| 999 } |
992 // Use the computed scales for the raster scale directly, do not try to use | 1000 // Use the computed scales for the raster scale directly, do not try to use |
993 // the ideal scale here. The current ideal scale may be way too large in the | 1001 // the ideal scale here. The current ideal scale may be way too large in the |
994 // case of an animation with scale, and will be constantly changing. | 1002 // case of an animation with scale, and will be constantly changing. |
995 if (can_raster_at_maximum_scale) | 1003 if (should_raster_at_starting_scale) |
| 1004 raster_contents_scale_ = starting_scale; |
| 1005 else if (can_raster_at_maximum_scale) |
996 raster_contents_scale_ = maximum_scale; | 1006 raster_contents_scale_ = maximum_scale; |
997 else | 1007 else |
998 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; | 1008 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_; |
999 } | 1009 } |
1000 | 1010 |
1001 raster_contents_scale_ = | 1011 raster_contents_scale_ = |
1002 std::max(raster_contents_scale_, MinimumContentsScale()); | 1012 std::max(raster_contents_scale_, MinimumContentsScale()); |
1003 raster_contents_scale_ = | 1013 raster_contents_scale_ = |
1004 std::min(raster_contents_scale_, MaximumContentsScale()); | 1014 std::min(raster_contents_scale_, MaximumContentsScale()); |
1005 DCHECK_GE(raster_contents_scale_, MinimumContentsScale()); | 1015 DCHECK_GE(raster_contents_scale_, MinimumContentsScale()); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 | 1262 |
1253 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { | 1263 bool PictureLayerImpl::IsOnActiveOrPendingTree() const { |
1254 return !layer_tree_impl()->IsRecycleTree(); | 1264 return !layer_tree_impl()->IsRecycleTree(); |
1255 } | 1265 } |
1256 | 1266 |
1257 bool PictureLayerImpl::HasValidTilePriorities() const { | 1267 bool PictureLayerImpl::HasValidTilePriorities() const { |
1258 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); | 1268 return IsOnActiveOrPendingTree() && IsDrawnRenderSurfaceLayerListMember(); |
1259 } | 1269 } |
1260 | 1270 |
1261 } // namespace cc | 1271 } // namespace cc |
OLD | NEW |