| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); | 902 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); |
| 903 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 903 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 904 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); | 904 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); |
| 905 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); | 905 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 906 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); | 906 SetContentsScaleOnBothLayers(4.2f, 1.0f, 2.1f, 1.f, false); |
| 907 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); | 907 EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
| 908 EXPECT_FLOAT_EQ(4.0f, | 908 EXPECT_FLOAT_EQ(4.0f, |
| 909 active_layer_->tilings()->tiling_at(0)->contents_scale()); | 909 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 910 } | 910 } |
| 911 | 911 |
| 912 TEST_F(PictureLayerImplTest, SnappedTilingDuringZoom) { |
| 913 gfx::Size tile_size(300, 300); |
| 914 gfx::Size layer_bounds(2600, 3800); |
| 915 |
| 916 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 917 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 918 scoped_refptr<FakePicturePileImpl> active_pile = |
| 919 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 920 |
| 921 // Set up the high and low res tilings before pinch zoom. |
| 922 SetupTrees(pending_pile, active_pile); |
| 923 EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
| 924 SetContentsScaleOnBothLayers(0.24f, 1.0f, 0.24f, 1.0f, false); |
| 925 EXPECT_EQ(2u, active_layer_->tilings()->num_tilings()); |
| 926 EXPECT_FLOAT_EQ(0.24f, |
| 927 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 928 EXPECT_FLOAT_EQ(0.0625f, |
| 929 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 930 |
| 931 // Start a pinch gesture. |
| 932 host_impl_.PinchGestureBegin(); |
| 933 |
| 934 // Zoom out by a small amount. We should create a tiling at half |
| 935 // the scale (1/kMaxScaleRatioDuringPinch). |
| 936 SetContentsScaleOnBothLayers(0.2f, 1.0f, 0.2f, 1.0f, false); |
| 937 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 938 EXPECT_FLOAT_EQ(0.24f, |
| 939 active_layer_->tilings()->tiling_at(0)->contents_scale()); |
| 940 EXPECT_FLOAT_EQ(0.12f, |
| 941 active_layer_->tilings()->tiling_at(1)->contents_scale()); |
| 942 EXPECT_FLOAT_EQ(0.0625, |
| 943 active_layer_->tilings()->tiling_at(2)->contents_scale()); |
| 944 |
| 945 // Zoom out further, close to our low-res scale factor. We should |
| 946 // use that tiling as high-res, and not create a new tiling. |
| 947 SetContentsScaleOnBothLayers(0.1f, 1.0f, 0.1f, 1.0f, false); |
| 948 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 949 |
| 950 // Zoom in. 0.125(desired_scale) should be snapped to 0.12 during zoom-in |
| 951 // because 0.125(desired_scale) is within the ratio(1.2) |
| 952 SetContentsScaleOnBothLayers(0.5f, 1.0f, 0.5f, 1.0f, false); |
| 953 EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
| 954 } |
| 955 |
| 912 TEST_F(PictureLayerImplTest, CleanUpTilings) { | 956 TEST_F(PictureLayerImplTest, CleanUpTilings) { |
| 913 gfx::Size tile_size(400, 400); | 957 gfx::Size tile_size(400, 400); |
| 914 gfx::Size layer_bounds(1300, 1900); | 958 gfx::Size layer_bounds(1300, 1900); |
| 915 | 959 |
| 916 scoped_refptr<FakePicturePileImpl> pending_pile = | 960 scoped_refptr<FakePicturePileImpl> pending_pile = |
| 917 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 961 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 918 scoped_refptr<FakePicturePileImpl> active_pile = | 962 scoped_refptr<FakePicturePileImpl> active_pile = |
| 919 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); | 963 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
| 920 | 964 |
| 921 float result_scale_x, result_scale_y; | 965 float result_scale_x, result_scale_y; |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2292 SetContentsScaleOnBothLayers(contents_scale, | 2336 SetContentsScaleOnBothLayers(contents_scale, |
| 2293 device_scale, | 2337 device_scale, |
| 2294 page_scale, | 2338 page_scale, |
| 2295 maximum_animation_scale, | 2339 maximum_animation_scale, |
| 2296 animating_transform); | 2340 animating_transform); |
| 2297 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); | 2341 EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
| 2298 } | 2342 } |
| 2299 | 2343 |
| 2300 } // namespace | 2344 } // namespace |
| 2301 } // namespace cc | 2345 } // namespace cc |
| OLD | NEW |