diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-01 20:01:29 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-01 20:01:29 +0000 |
commit | 637569218a06afb8da415d27f62c70c25c719ff7 (patch) | |
tree | 301ad18c0002ea8a0e9ab43be09f720a985fbfa2 /cc | |
parent | 87d449de81afe5d7ee73d7ea9e0ce193788d762a (diff) | |
download | chromium_src-637569218a06afb8da415d27f62c70c25c719ff7.zip chromium_src-637569218a06afb8da415d27f62c70c25c719ff7.tar.gz chromium_src-637569218a06afb8da415d27f62c70c25c719ff7.tar.bz2 |
cc: Take the source scale into account when picking tilings in pinch.
The page scale is the contents scale / device scale / source scale.
Updated the unit test to fail without the source scale being present.
R=enne
Review URL: https://codereview.chromium.org/264743002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layers/picture_layer_impl.cc | 3 | ||||
-rw-r--r-- | cc/layers/picture_layer_impl_unittest.cc | 48 |
2 files changed, 23 insertions, 28 deletions
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index 15dc02e..36e754f 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc @@ -1118,7 +1118,8 @@ void PictureLayerImpl::RecalculateRasterScales( zooming_out ? old_raster_contents_scale / kMaxScaleRatioDuringPinch : old_raster_contents_scale * kMaxScaleRatioDuringPinch; raster_contents_scale_ = SnappedContentsScale(desired_contents_scale); - raster_page_scale_ = raster_contents_scale_ / raster_device_scale_; + raster_page_scale_ = + raster_contents_scale_ / raster_device_scale_ / raster_source_scale_; } raster_contents_scale_ = diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc index 6c5b2c7..114c8a9 100644 --- a/cc/layers/picture_layer_impl_unittest.cc +++ b/cc/layers/picture_layer_impl_unittest.cc @@ -868,51 +868,45 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { // 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, 1.0f, false); + SetContentsScaleOnBothLayers(2.0f, 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()); + EXPECT_FLOAT_EQ(2.0f, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_FLOAT_EQ(2.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, 1.0f, false); + // the scale (2/kMaxScaleRatioDuringPinch). + SetContentsScaleOnBothLayers(1.8f, 1.0f, 0.9f, 1.0f, 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()); + EXPECT_FLOAT_EQ(2.0f, + active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_FLOAT_EQ(1.0f, + active_layer_->tilings()->tiling_at(1)->contents_scale()); + EXPECT_FLOAT_EQ(2.0f * low_res_factor, + 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( - low_res_factor, 1.0f, low_res_factor, 1.0f, false); + low_res_factor, 1.0f, low_res_factor / 2.0f, 1.0f, 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, 1.f, false); + // kMaxScaleRatioDuringPinch, this will first use 1.0, then 2.0 + // and then finally create a new tiling at 4.0. + SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); - SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); + SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); - SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); + SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); - EXPECT_FLOAT_EQ( - 2.0f, - active_layer_->tilings()->tiling_at(0)->contents_scale()); + EXPECT_FLOAT_EQ(4.0f, + active_layer_->tilings()->tiling_at(0)->contents_scale()); } TEST_F(PictureLayerImplTest, CleanUpTilings) { |