Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: cc/layers/picture_layer_impl.cc

Issue 642983003: cc: Make PictureLayerImpl use a better choice for animated raster scale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: animationscale: fixtest Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/transform_operations_unittest.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); 1038 raster_contents_scale_ = SnappedContentsScale(desired_contents_scale);
1039 raster_page_scale_ = 1039 raster_page_scale_ =
1040 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; 1040 raster_contents_scale_ / raster_device_scale_ / raster_source_scale_;
1041 } 1041 }
1042 1042
1043 raster_contents_scale_ = 1043 raster_contents_scale_ =
1044 std::max(raster_contents_scale_, MinimumContentsScale()); 1044 std::max(raster_contents_scale_, MinimumContentsScale());
1045 1045
1046 // If we're not re-rasterizing during animation, rasterize at the maximum 1046 // If we're not re-rasterizing during animation, rasterize at the maximum
1047 // scale that will occur during the animation, if the maximum scale is 1047 // scale that will occur during the animation, if the maximum scale is
1048 // known. However, to avoid excessive memory use, don't rasterize at a scale 1048 // known. However we want to avoid excessive memory use. If the scale is
1049 // at which this layer would become larger than the viewport. 1049 // smaller than what we would choose otherwise, then it's always better off
1050 // for us memory-wise. But otherwise, we don't choose a scale at which this
1051 // layer's rastered content would become larger than the viewport.
1050 if (draw_properties().screen_space_transform_is_animating && 1052 if (draw_properties().screen_space_transform_is_animating &&
1051 !ShouldAdjustRasterScaleDuringScaleAnimations()) { 1053 !ShouldAdjustRasterScaleDuringScaleAnimations()) {
1052 bool can_raster_at_maximum_scale = false; 1054 bool can_raster_at_maximum_scale = false;
1053 if (draw_properties().maximum_animation_contents_scale > 0.f) { 1055 // TODO(ajuma): If we need to deal with scale-down animations starting right
1054 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize(gfx::ScaleSize( 1056 // as a layer gets promoted, then we'd want to have the
1055 bounds(), draw_properties().maximum_animation_contents_scale)); 1057 // |starting_animation_contents_scale| passed in here as a separate draw
1058 // property so we could try use that when the max is too large.
1059 // See crbug.com/422341.
1060 float maximum_scale = draw_properties().maximum_animation_contents_scale;
1061 if (maximum_scale) {
1062 gfx::Size bounds_at_maximum_scale =
1063 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), maximum_scale));
1056 if (bounds_at_maximum_scale.GetArea() <= 1064 if (bounds_at_maximum_scale.GetArea() <=
1057 layer_tree_impl()->device_viewport_size().GetArea()) 1065 layer_tree_impl()->device_viewport_size().GetArea())
1058 can_raster_at_maximum_scale = true; 1066 can_raster_at_maximum_scale = true;
1059 } 1067 }
1060 if (can_raster_at_maximum_scale) { 1068 // Use the computed scales for the raster scale directly, do not try to use
1061 raster_contents_scale_ = 1069 // the ideal scale here. The current ideal scale may be way too large in the
1062 std::max(raster_contents_scale_, 1070 // case of an animation with scale, and will be constantly changing.
1063 draw_properties().maximum_animation_contents_scale); 1071 if (can_raster_at_maximum_scale)
1064 } else { 1072 raster_contents_scale_ = maximum_scale;
1065 raster_contents_scale_ = 1073 else
1066 std::max(raster_contents_scale_, 1074 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_;
1067 1.f * ideal_page_scale_ * ideal_device_scale_);
1068 }
1069 } 1075 }
1070 1076
1071 // If this layer would create zero or one tiles at this content scale, 1077 // If this layer would create zero or one tiles at this content scale,
1072 // don't create a low res tiling. 1078 // don't create a low res tiling.
1073 gfx::Size content_bounds = 1079 gfx::Size content_bounds =
1074 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_)); 1080 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_));
1075 gfx::Size tile_size = CalculateTileSize(content_bounds); 1081 gfx::Size tile_size = CalculateTileSize(content_bounds);
1076 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() && 1082 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() &&
1077 tile_size.height() >= content_bounds.height(); 1083 tile_size.height() >= content_bounds.height();
1078 if (tile_size.IsEmpty() || tile_covers_bounds) { 1084 if (tile_size.IsEmpty() || tile_covers_bounds) {
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1672 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1667 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1673 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1668 return tiling_range.end - 1 - current_tiling_range_offset; 1674 return tiling_range.end - 1 - current_tiling_range_offset;
1669 } 1675 }
1670 } 1676 }
1671 NOTREACHED(); 1677 NOTREACHED();
1672 return 0; 1678 return 0;
1673 } 1679 }
1674 1680
1675 } // namespace cc 1681 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/transform_operations_unittest.cc ('k') | cc/layers/picture_layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698