diff options
author | vmpstr <vmpstr@chromium.org> | 2015-08-13 16:24:51 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-13 23:25:27 +0000 |
commit | ff62e3c023e3814065f284a0cccf486c2da6bf08 (patch) | |
tree | 8d204eb6f01602c0244ca883f6d216d87b0e3d1f | |
parent | 4b30ffe83c342e62be5682a1d96576367802511f (diff) | |
download | chromium_src-ff62e3c023e3814065f284a0cccf486c2da6bf08.zip chromium_src-ff62e3c023e3814065f284a0cccf486c2da6bf08.tar.gz chromium_src-ff62e3c023e3814065f284a0cccf486c2da6bf08.tar.bz2 |
cc: Don't mark any tilings low resolution during animation/pinch.
This patch ensures that while we're animating or pinching, we not only
not create low resolution tilings (which was already the case), but we
also don't mark any existing tilings as low resolution.
If we do, this can cause checker flashes when low res becomes high res
again, since we have to reset it due to low quality filters that might
have been applied.
BUG=517749
R=danakj, enne
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1296453002
Cr-Commit-Position: refs/heads/master@{#343299}
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 8 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 33 |
2 files changed, 37 insertions, 4 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 4966180..ed7c17f 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -902,11 +902,11 @@ void PictureLayerImpl::AddLowResolutionTilingIfNeeded() { // res tiling during a pinch or a CSS animation. bool is_pinching = layer_tree_impl()->PinchGestureActive(); bool is_animating = draw_properties().screen_space_transform_is_animating; - if (!low_res && !is_pinching && !is_animating) - low_res = AddTiling(low_res_raster_contents_scale_); - - if (low_res) + if (!is_pinching && !is_animating) { + if (!low_res) + low_res = AddTiling(low_res_raster_contents_scale_); low_res->set_resolution(LOW_RESOLUTION); + } } void PictureLayerImpl::RecalculateRasterScales() { diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 5460e4a..fe27db6 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -983,6 +983,9 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { EXPECT_EQ(active_layer_->tilings()->tiling_at(0)->contents_scale(), 2.f); EXPECT_EQ(active_layer_->tilings()->tiling_at(1)->contents_scale(), 2.f * low_res_factor); + // One of the tilings has to be a low resolution one. + EXPECT_EQ(LOW_RESOLUTION, + active_layer_->tilings()->tiling_at(1)->resolution()); // Ensure UpdateTiles won't remove any tilings. active_layer_->MarkAllTilingsUsed(); @@ -1000,6 +1003,9 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { active_layer_->tilings()->tiling_at(1)->contents_scale()); EXPECT_FLOAT_EQ(2.0f * low_res_factor, active_layer_->tilings()->tiling_at(2)->contents_scale()); + // Since we're pinching, we shouldn't create a low resolution tiling. + EXPECT_FALSE( + active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); // Ensure UpdateTiles won't remove any tilings. active_layer_->MarkAllTilingsUsed(); @@ -1009,6 +1015,8 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { SetContentsScaleOnBothLayers(low_res_factor * 2.1f, 1.0f, low_res_factor * 2.1f, 1.0f, 0.f, false); EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); + EXPECT_FALSE( + active_layer_->tilings()->FindTilingWithResolution(LOW_RESOLUTION)); // Zoom in a lot now. Since we increase by increments of // kMaxScaleRatioDuringPinch, this will create a new tiling at 4.0. @@ -1016,6 +1024,31 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); EXPECT_FLOAT_EQ(4.0f, active_layer_->tilings()->tiling_at(0)->contents_scale()); + // Although one of the tilings matches the low resolution scale, it still + // shouldn't be marked as low resolution since we're pinching. + auto* low_res_tiling = + active_layer_->tilings()->FindTilingWithScale(4.f * low_res_factor); + EXPECT_TRUE(low_res_tiling); + EXPECT_NE(LOW_RESOLUTION, low_res_tiling->resolution()); + + // Stop a pinch gesture. + host_impl_.PinchGestureEnd(); + + // Ensure UpdateTiles won't remove any tilings. + active_layer_->MarkAllTilingsUsed(); + + // After pinch ends, set the scale to what the raster scale was updated to + // (checked above). + SetContentsScaleOnBothLayers(4.0f, 1.0f, 4.0f, 1.f, 0.f, false); + EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); + EXPECT_FLOAT_EQ(4.0f, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + // Now that we stopped pinching, the low resolution tiling that existed should + // now be marked as low resolution. + low_res_tiling = + active_layer_->tilings()->FindTilingWithScale(4.f * low_res_factor); + EXPECT_TRUE(low_res_tiling); + EXPECT_EQ(LOW_RESOLUTION, low_res_tiling->resolution()); } TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |