Index: cc/layers/picture_layer_impl.cc |
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc |
index cf2e36a209bdcb576c5ca138e6673b97955ed079..f8c726ebb8774863294953e611c24579d7a64f02 100644 |
--- a/cc/layers/picture_layer_impl.cc |
+++ b/cc/layers/picture_layer_impl.cc |
@@ -74,6 +74,7 @@ PictureLayerImpl::PictureLayerImpl(LayerTreeImpl* tree_impl, |
raster_source_scale_(0.f), |
raster_contents_scale_(0.f), |
low_res_raster_contents_scale_(0.f), |
+ source_scale_has_changed_(false), |
was_screen_space_transform_animating_(false), |
only_used_low_res_last_append_quads_(false), |
is_mask_(is_mask), |
@@ -545,6 +546,10 @@ void PictureLayerImpl::UpdateRasterSource( |
if (!pending_set) { |
raster_source_->SetImageDecodeController( |
layer_tree_impl()->image_decode_controller()); |
+ raster_source_->SetImageScalingOptimization( |
+ source_scale_has_changed_ |
+ ? DisplayListRasterSource::ImageScalingOptimization::Animation |
+ : DisplayListRasterSource::ImageScalingOptimization::Static); |
} |
// The |new_invalidation| must be cleared before updating tilings since they |
@@ -946,12 +951,23 @@ void PictureLayerImpl::AddLowResolutionTilingIfNeeded() { |
void PictureLayerImpl::RecalculateRasterScales() { |
const float old_raster_contents_scale = raster_contents_scale_; |
const float old_raster_page_scale = raster_page_scale_; |
+ const float old_raster_source_scale = raster_source_scale_; |
raster_device_scale_ = ideal_device_scale_; |
raster_page_scale_ = ideal_page_scale_; |
raster_source_scale_ = ideal_source_scale_; |
raster_contents_scale_ = ideal_contents_scale_; |
+ // If we're not animating, or leaving an animation, and the |
+ // ideal_source_scale_ changes, then things are unpredictable, and we |
+ // may need to tweak some source rasterization params. |
+ // TODO(fmalita): this should be generalized for screen transform changes. |
+ if (old_raster_source_scale && |
+ !draw_properties().screen_space_transform_is_animating && |
+ !was_screen_space_transform_animating_ && |
+ old_raster_source_scale != ideal_source_scale_) |
+ source_scale_has_changed_ = true; |
+ |
// During pinch we completely ignore the current ideal scale, and just use |
// a multiple of the previous scale. |
bool is_pinching = layer_tree_impl()->PinchGestureActive(); |
@@ -1122,6 +1138,7 @@ void PictureLayerImpl::ResetRasterScale() { |
raster_source_scale_ = 0.f; |
raster_contents_scale_ = 0.f; |
low_res_raster_contents_scale_ = 0.f; |
+ source_scale_has_changed_ = false; |
} |
bool PictureLayerImpl::CanHaveTilings() const { |
@@ -1207,6 +1224,7 @@ void PictureLayerImpl::AsValueInto( |
state->SetDouble("ideal_contents_scale", ideal_contents_scale_); |
state->SetDouble("raster_contents_scale", raster_contents_scale_); |
state->SetDouble("geometry_contents_scale", MaximumTilingContentsScale()); |
+ state->SetBoolean("source_scale_changed", source_scale_has_changed_); |
state->BeginArray("tilings"); |
tilings_->AsValueInto(state); |
state->EndArray(); |