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

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: scaledownstillcheckssize 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
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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // TODO(ajuma): If we need to deal with scale-down animations starting right
1174 gfx::Size bounds_at_maximum_scale = gfx::ToCeiledSize(gfx::ScaleSize( 1176 // as a layer gets promoted, then we'd want to have the
1175 bounds(), draw_properties().maximum_animation_contents_scale)); 1177 // |starting_animation_contents_scale| passed in here as a separate draw
1178 // property so we could try use that when the max is too large.
1179 // See crbug.com/422341.
1180 float maximum_scale = draw_properties().maximum_animation_contents_scale;
1181 if (maximum_scale) {
1182 gfx::Size bounds_at_maximum_scale =
1183 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), maximum_scale));
1176 if (bounds_at_maximum_scale.GetArea() <= 1184 if (bounds_at_maximum_scale.GetArea() <=
1177 layer_tree_impl()->device_viewport_size().GetArea()) 1185 layer_tree_impl()->device_viewport_size().GetArea())
1178 can_raster_at_maximum_scale = true; 1186 can_raster_at_maximum_scale = true;
1179 } 1187 }
1180 if (can_raster_at_maximum_scale) { 1188 // Use the computed scales for the raster scale directly, do not try to use
1181 raster_contents_scale_ = 1189 // the ideal scale here. The current ideal scale may be way too large in the
1182 std::max(raster_contents_scale_, 1190 // case of an animation with scale, and will be constantly changing.
1183 draw_properties().maximum_animation_contents_scale); 1191 if (can_raster_at_maximum_scale)
1184 } else { 1192 raster_contents_scale_ = maximum_scale;
1185 raster_contents_scale_ = 1193 else
1186 std::max(raster_contents_scale_, 1194 raster_contents_scale_ = 1.f * ideal_page_scale_ * ideal_device_scale_;
danakj 2014/10/10 15:15:52 I do find this else case a little odd, and wonder
1187 1.f * ideal_page_scale_ * ideal_device_scale_);
1188 }
1189 } 1195 }
1190 1196
1191 // If this layer would create zero or one tiles at this content scale, 1197 // If this layer would create zero or one tiles at this content scale,
1192 // don't create a low res tiling. 1198 // don't create a low res tiling.
1193 gfx::Size content_bounds = 1199 gfx::Size content_bounds =
1194 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_)); 1200 gfx::ToCeiledSize(gfx::ScaleSize(bounds(), raster_contents_scale_));
1195 gfx::Size tile_size = CalculateTileSize(content_bounds); 1201 gfx::Size tile_size = CalculateTileSize(content_bounds);
1196 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() && 1202 bool tile_covers_bounds = tile_size.width() >= content_bounds.width() &&
1197 tile_size.height() >= content_bounds.height(); 1203 tile_size.height() >= content_bounds.height();
1198 if (tile_size.IsEmpty() || tile_covers_bounds) { 1204 if (tile_size.IsEmpty() || tile_covers_bounds) {
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange(); 1789 PictureLayerTilingSet::TilingRange tiling_range = CurrentTilingRange();
1784 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start; 1790 size_t current_tiling_range_offset = current_tiling_ - tiling_range.start;
1785 return tiling_range.end - 1 - current_tiling_range_offset; 1791 return tiling_range.end - 1 - current_tiling_range_offset;
1786 } 1792 }
1787 } 1793 }
1788 NOTREACHED(); 1794 NOTREACHED();
1789 return 0; 1795 return 0;
1790 } 1796 }
1791 1797
1792 } // namespace cc 1798 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698