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
parent af77ce62
...@@ -392,6 +392,7 @@ Zheng Chuang <zhengchuangscu@gmail.com> ...@@ -392,6 +392,7 @@ Zheng Chuang <zhengchuangscu@gmail.com>
Zhenyu Liang <zhenyu.liang@intel.com> Zhenyu Liang <zhenyu.liang@intel.com>
Zhenyu Shan <zhenyu.shan@intel.com> Zhenyu Shan <zhenyu.shan@intel.com>
Ziran Sun <ziran.sun@samsung.com> Ziran Sun <ziran.sun@samsung.com>
Yongha Lee <yongha78.lee@samsung.com>
方觉 (Fang Jue) <fangjue23303@gmail.com> 方觉 (Fang Jue) <fangjue23303@gmail.com>
Yupei Wang <perryuwang@tencent.com> Yupei Wang <perryuwang@tencent.com>
......
...@@ -31,7 +31,7 @@ const float kMaxScaleRatioDuringPinch = 2.0f; ...@@ -31,7 +31,7 @@ const float kMaxScaleRatioDuringPinch = 2.0f;
// When creating a new tiling during pinch, snap to an existing // When creating a new tiling during pinch, snap to an existing
// tiling's scale if the desired scale is within this ratio. // 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. // Estimate skewport 60 frames ahead for pre-rasterization on the CPU.
const float kCpuSkewportTargetTimeInFrames = 60.0f; const float kCpuSkewportTargetTimeInFrames = 60.0f;
......
...@@ -909,6 +909,50 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { ...@@ -909,6 +909,50 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) {
active_layer_->tilings()->tiling_at(0)->contents_scale()); 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) { TEST_F(PictureLayerImplTest, CleanUpTilings) {
gfx::Size tile_size(400, 400); gfx::Size tile_size(400, 400);
gfx::Size layer_bounds(1300, 1900); gfx::Size layer_bounds(1300, 1900);
......
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