Commit f3a6e6c9 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Avoid recreation of high res tiling during pinch gesture

This is like we avoid reraster for scale change during pinch gesture
unless the scale is too different.

Also allow recreation of high res tiling if it doesn't contain any
tile or we are going to invalidate the tiles.

This fixes performance regression of pinch perf tests caused by
crrev.com/c/2351164.

Bug: 1117479
Change-Id: Ifc7979af81aa76b0214fda7dc2340be76ae63046
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364583Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800205}
parent 76306c32
......@@ -1198,6 +1198,25 @@ void PictureLayerImpl::RemoveAllTilings() {
ResetRasterScale();
}
bool PictureLayerImpl::CanRecreateHighResTilingForLCDTextAndRasterTranslation(
const PictureLayerTiling& high_res) const {
// This is for the sync tree only to avoid flickering.
if (!layer_tree_impl()->IsSyncTree())
return false;
// We can recreate the tiling if we would invalidate all of its tiles.
if (high_res.may_contain_low_resolution_tiles())
return true;
// Keep the non-ideal raster translation unchanged for transform animations
// to avoid re-rasterization during animation.
if (draw_properties().screen_space_transform_is_animating ||
has_will_change_transform_hint())
return false;
// Also avoid re-rasterization during pinch-zoom.
if (layer_tree_impl()->PinchGestureActive())
return false;
return true;
}
void PictureLayerImpl::UpdateTilingsForRasterScaleAndTranslation(
bool has_adjusted_raster_scale) {
PictureLayerTiling* high_res =
......@@ -1211,15 +1230,9 @@ void PictureLayerImpl::UpdateTilingsForRasterScaleAndTranslation(
if (high_res) {
bool raster_translation_is_not_ideal =
high_res->raster_transform().translation() != raster_translation;
// We should recreate the high res tiling with the new raster translation
// and lcd text, which is for the sync tree only to avoid flickering.
bool should_recreate_high_res =
layer_tree_impl()->IsSyncTree() &&
(raster_translation_is_not_ideal || can_use_lcd_text_changed) &&
// Keep the non-ideal raster translation unchanged for transform
// animations to avoid re-rasterization during animation.
!draw_properties().screen_space_transform_is_animating &&
!has_will_change_transform_hint();
CanRecreateHighResTilingForLCDTextAndRasterTranslation(*high_res);
if (should_recreate_high_res) {
tilings_->Remove(high_res);
high_res = nullptr;
......
......@@ -171,6 +171,8 @@ class CC_EXPORT PictureLayerImpl
PictureLayerImpl(LayerTreeImpl* tree_impl, int id);
PictureLayerTiling* AddTiling(const gfx::AxisTransform2d& contents_transform);
void RemoveAllTilings();
bool CanRecreateHighResTilingForLCDTextAndRasterTranslation(
const PictureLayerTiling& high_res) const;
void UpdateTilingsForRasterScaleAndTranslation(bool adjusted_raster_scale);
void AddLowResolutionTilingIfNeeded();
bool ShouldAdjustRasterScale(float old_ideal_contents_scale) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment