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

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

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

Powered by Google App Engine
This is Rietveld 408576698