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

Unified Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 81453002: Reland: CC: Adjust tiling creation triggers during pinch-zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@CC_soon_bin_optimization_REDUCE_ZOOM_OUT_MEMORY_V2
Patch Set: Crash fix. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« cc/layers/picture_layer_impl.cc ('K') | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_impl_unittest.cc
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index 716d50da7acf5253e54db054e0bed6d9b4629c21..00cf7996c35cd7d32e8a3be189326f2b2976c0a2 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -591,6 +591,83 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) {
pending_layer_->tilings()->tiling_at(3)->contents_scale());
}
+TEST_F(PictureLayerImplTest, ZoomOutCrash) {
+ gfx::Size tile_size(400, 400);
+ gfx::Size layer_bounds(1300, 1900);
+
+ // Set up the high and low res tilings before pinch zoom.
+ scoped_refptr<FakePicturePileImpl> pending_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ scoped_refptr<FakePicturePileImpl> active_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ SetupTrees(pending_pile, active_pile);
+ EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
+ SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, false);
+ host_impl_.PinchGestureBegin();
+ SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
+ SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
+ EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1);
+}
+
+TEST_F(PictureLayerImplTest, PinchGestureTilings) {
+ gfx::Size tile_size(400, 400);
+ gfx::Size layer_bounds(1300, 1900);
+
+ scoped_refptr<FakePicturePileImpl> pending_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+ scoped_refptr<FakePicturePileImpl> active_pile =
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
+
+ // Set up the high and low res tilings before pinch zoom.
+ SetupTrees(pending_pile, active_pile);
+ EXPECT_EQ(0u, active_layer_->tilings()->num_tilings());
+ SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false);
+ float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
+ EXPECT_EQ(2u, active_layer_->tilings()->num_tilings());
+ EXPECT_FLOAT_EQ(
+ 1.0f,
+ active_layer_->tilings()->tiling_at(0)->contents_scale());
+ EXPECT_FLOAT_EQ(
+ 1.0f * low_res_factor,
+ active_layer_->tilings()->tiling_at(1)->contents_scale());
+
+ // Start a pinch gesture.
+ host_impl_.PinchGestureBegin();
+
+ // Zoom out by a small amount. We should create a tiling at half
+ // the scale (1/kMaxScaleRatioDuringPinch).
+ SetContentsScaleOnBothLayers(0.90f, 1.0f, 0.9f, false);
+ EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
+ EXPECT_FLOAT_EQ(
+ 1.0f,
+ active_layer_->tilings()->tiling_at(0)->contents_scale());
+ EXPECT_FLOAT_EQ(
+ 0.5f,
+ active_layer_->tilings()->tiling_at(1)->contents_scale());
+ EXPECT_FLOAT_EQ(
+ 1.0f * low_res_factor,
+ active_layer_->tilings()->tiling_at(2)->contents_scale());
+
+ // Zoom out further, close to our old low-res scale factor. We should
+ // use that tiling as high-res, and not create a new tiling.
+ SetContentsScaleOnBothLayers(low_res_factor, 1.0f, low_res_factor, false);
+ EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
+
+ // Zoom in a lot now. Since we increase by increments of
+ // kMaxScaleRatioDuringPinch, this will first use 0.5, then 1.0
+ // and then finally create a new tiling at 2.0.
+ SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false);
+ EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
+ SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false);
+ EXPECT_EQ(3u, active_layer_->tilings()->num_tilings());
+ SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false);
+ EXPECT_EQ(4u, active_layer_->tilings()->num_tilings());
+ EXPECT_FLOAT_EQ(
+ 2.0f,
+ active_layer_->tilings()->tiling_at(0)->contents_scale());
+}
+
TEST_F(PictureLayerImplTest, CleanUpTilings) {
gfx::Size tile_size(400, 400);
gfx::Size layer_bounds(1300, 1900);
« cc/layers/picture_layer_impl.cc ('K') | « cc/layers/picture_layer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698