diff options
author | yongha78.lee@samsung.com <yongha78.lee@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 11:48:53 +0000 |
---|---|---|
committer | yongha78.lee@samsung.com <yongha78.lee@samsung.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-10 11:48:53 +0000 |
commit | f2d60f3f730fa460dd40ed67d07afed6391bfd54 (patch) | |
tree | 30975fc8c4a4df0c4c0d2ce0e4a6a22b9e20c147 /cc | |
parent | af77ce62e0b41163bda7852e6a68a5be8d31b619 (diff) | |
download | chromium_src-f2d60f3f730fa460dd40ed67d07afed6391bfd54.zip chromium_src-f2d60f3f730fa460dd40ed67d07afed6391bfd54.tar.gz chromium_src-f2d60f3f730fa460dd40ed67d07afed6391bfd54.tar.bz2 |
The snap ratio is wrong
Snapping which is intended to snap to existing scale during pinch
is not working. That is, because the snap ratio constant is wrong,
snapping logic do not work and might make extra tiling during pinch.
BUG=368203
Review URL: https://codereview.chromium.org/256343002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 2 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 44 |
2 files changed, 45 insertions, 1 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index bd3b9dc..6cfd913 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -31,7 +31,7 @@ const float kMaxScaleRatioDuringPinch = 2.0f; // When creating a new tiling during pinch, snap to an existing // tiling's scale if the desired scale is within this ratio. -const float kSnapToExistingTilingRatio = 0.2f; +const float kSnapToExistingTilingRatio = 1.2f; // Estimate skewport 60 frames ahead for pre-rasterization on the CPU. const float kCpuSkewportTargetTimeInFrames = 60.0f; diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 114c8a9..c23e364 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -909,6 +909,50 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { active_layer_->tilings()->tiling_at(0)->contents_scale()); } +TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { + gfx::Size tile_size(300, 300); + gfx::Size layer_bounds(2600, 3800); + + 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(0.24f, 1.0f, 0.24f, 1.0f, false); + EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); + EXPECT_FLOAT_EQ(0.24f, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_FLOAT_EQ(0.0625f, + 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.2f, 1.0f, 0.2f, 1.0f, false); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); + EXPECT_FLOAT_EQ(0.24f, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_FLOAT_EQ(0.12f, + active_layer_->tilings()->tiling_at(1)->contents_scale()); + EXPECT_FLOAT_EQ(0.0625, + active_layer_->tilings()->tiling_at(2)->contents_scale()); + + // Zoom out further, close to our low-res scale factor. We should + // use that tiling as high-res, and not create a new tiling. + SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); + + // Zoom in. 0.125(desired_scale) should be snapped to 0.12 during zoom-in + // because 0.125(desired_scale) is within the ratio(1.2) + SetContentsScaleOnBothLayers(0.5f, 1.0f, 0.5f, 1.0f, false); + EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); +} + TEST_F(PictureLayerImplTest, CleanUpTilings) { gfx::Size tile_size(400, 400); gfx::Size layer_bounds(1300, 1900); |