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 d6144890f39da9631f0192e786cb5e0798378cc6..f2d5e6007db01576a4a45d1a2bd504db30721bcb 100644 |
--- a/cc/layers/picture_layer_impl_unittest.cc |
+++ b/cc/layers/picture_layer_impl_unittest.cc |
@@ -154,25 +154,26 @@ class PictureLayerImplTest : public testing::Test { |
void SetContentsScaleOnBothLayers(float contents_scale, |
float device_scale_factor, |
float page_scale_factor, |
+ float maximum_animation_contents_scale, |
bool animating_transform) { |
float result_scale_x, result_scale_y; |
gfx::Size result_bounds; |
- pending_layer_->CalculateContentsScale( |
- contents_scale, |
- device_scale_factor, |
- page_scale_factor, |
- animating_transform, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
- active_layer_->CalculateContentsScale( |
- contents_scale, |
- device_scale_factor, |
- page_scale_factor, |
- animating_transform, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ pending_layer_->CalculateContentsScale(contents_scale, |
+ device_scale_factor, |
+ page_scale_factor, |
+ maximum_animation_contents_scale, |
+ animating_transform, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
+ active_layer_->CalculateContentsScale(contents_scale, |
+ device_scale_factor, |
+ page_scale_factor, |
+ maximum_animation_contents_scale, |
+ animating_transform, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
} |
void ResetTilingsAndRasterScales() { |
@@ -211,8 +212,14 @@ class PictureLayerImplTest : public testing::Test { |
float result_scale_x, result_scale_y; |
gfx::Size result_bounds; |
- active_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ active_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
// Add 1x1 rects at the centers of each tile, then re-record pile contents |
active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -313,6 +320,7 @@ TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { |
active_layer_->CalculateContentsScale(1.f, |
1.f, |
1.f, |
+ 1.f, |
false, |
&dummy_contents_scale_x, |
&dummy_contents_scale_y, |
@@ -322,6 +330,7 @@ TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { |
pending_layer_->CalculateContentsScale(1.f, |
1.f, |
1.f, |
+ 1.f, |
false, |
&dummy_contents_scale_x, |
&dummy_contents_scale_y, |
@@ -346,6 +355,7 @@ TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { |
active_layer_->CalculateContentsScale(1.f, |
1.f, |
1.f, |
+ 1.f, |
false, |
&dummy_contents_scale_x, |
&dummy_contents_scale_y, |
@@ -355,6 +365,7 @@ TEST_F(PictureLayerImplTest, TileManagerRegisterUnregister) { |
pending_layer_->CalculateContentsScale(1.f, |
1.f, |
1.f, |
+ 1.f, |
false, |
&dummy_contents_scale_x, |
&dummy_contents_scale_y, |
@@ -389,6 +400,7 @@ TEST_F(PictureLayerImplTest, SuppressUpdateTilePriorities) { |
active_layer_->CalculateContentsScale(1.f, |
1.f, |
1.f, |
+ 1.f, |
false, |
&dummy_contents_scale_x, |
&dummy_contents_scale_y, |
@@ -601,8 +613,14 @@ TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { |
SetupTrees(pending_pile, active_pile); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
} |
@@ -627,7 +645,8 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
1.7f, // device scale |
- 3.2f, // page cale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -644,7 +663,8 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
// tilings. |
pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale |
1.7f, // device scale |
- 3.2f, // page cale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -660,7 +680,8 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
// If we change the page scale factor, then we should get new tilings. |
pending_layer_->CalculateContentsScale(1.8f, // ideal contents scale |
1.7f, // device scale |
- 2.2f, // page cale |
+ 2.2f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -676,7 +697,8 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
// If we change the device scale factor, then we should get new tilings. |
pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale |
1.4f, // device scale |
- 2.2f, // page cale |
+ 2.2f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -693,7 +715,8 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
// factor somehow, then we don't get new tilings. |
pending_layer_->CalculateContentsScale(1.9f, // ideal contents scale |
2.2f, // device scale |
- 1.4f, // page cale |
+ 1.4f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -726,6 +749,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
float low_res_scale = high_res_scale * low_res_factor; |
float device_scale = 1.7f; |
float page_scale = 3.2f; |
+ float maximum_animation_scale = 1.f; |
float result_scale_x, result_scale_y; |
gfx::Size result_bounds; |
@@ -733,6 +757,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
pending_layer_->CalculateContentsScale(high_res_scale, |
device_scale, |
page_scale, |
+ maximum_animation_scale, |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -748,6 +773,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
pending_layer_->CalculateContentsScale(high_res_scale, |
device_scale, |
page_scale, |
+ maximum_animation_scale, |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -759,6 +785,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
active_layer_->CalculateContentsScale(high_res_scale, |
device_scale, |
page_scale, |
+ maximum_animation_scale, |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -769,6 +796,7 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
pending_layer_->CalculateContentsScale(high_res_scale, |
device_scale, |
page_scale, |
+ maximum_animation_scale, |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -793,10 +821,10 @@ TEST_F(PictureLayerImplTest, ZoomOutCrash) { |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, active_layer_->tilings()->num_tilings()); |
- SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, false); |
+ SetContentsScaleOnBothLayers(32.0f, 1.0f, 32.0f, 1.0f, false); |
host_impl_.PinchGestureBegin(); |
- SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); |
- SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, false); |
+ SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
+ SetContentsScaleOnBothLayers(1.0f, 1.0f, 1.0f, 1.0f, false); |
EXPECT_EQ(active_layer_->tilings()->NumHighResTilings(), 1); |
} |
@@ -812,7 +840,7 @@ 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, false); |
+ SetContentsScaleOnBothLayers(1.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( |
@@ -827,7 +855,7 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
// 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); |
+ SetContentsScaleOnBothLayers(0.90f, 1.0f, 0.9f, 1.0f, false); |
EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ( |
1.0f, |
@@ -841,17 +869,18 @@ TEST_F(PictureLayerImplTest, PinchGestureTilings) { |
// 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, false); |
+ SetContentsScaleOnBothLayers( |
+ low_res_factor, 1.0f, low_res_factor, 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, false); |
+ SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); |
EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
- SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false); |
+ SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); |
EXPECT_EQ(3u, active_layer_->tilings()->num_tilings()); |
- SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, false); |
+ SetContentsScaleOnBothLayers(2.1f, 1.0f, 2.1f, 1.f, false); |
EXPECT_EQ(4u, active_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ( |
2.0f, |
@@ -880,7 +909,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
float device_scale = 1.7f; |
float page_scale = 3.2f; |
- SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, false); |
+ SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
// We only have ideal tilings, so they aren't removed. |
@@ -889,7 +918,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
// Changing the ideal but not creating new tilings. |
- SetContentsScaleOnBothLayers(1.5f, device_scale, page_scale, false); |
+ SetContentsScaleOnBothLayers(1.5f, device_scale, page_scale, 1.f, false); |
ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
// The tilings are still our target scale, so they aren't removed. |
@@ -899,7 +928,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
// Create a 1.2 scale tiling. Now we have 1.0 and 1.2 tilings. Ideal = 1.2. |
page_scale = 1.2f; |
- SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, false); |
+ SetContentsScaleOnBothLayers(1.2f, device_scale, page_scale, 1.f, false); |
ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ( |
1.f, |
@@ -916,7 +945,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
// Now move the ideal scale to 0.5. Our target stays 1.2. |
- SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, false); |
+ SetContentsScaleOnBothLayers(0.5f, device_scale, page_scale, 1.f, false); |
// The high resolution tiling is between target and ideal, so is not |
// removed. The low res tiling for the old ideal=1.0 scale is removed. |
@@ -925,7 +954,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
// Now move the ideal scale to 1.0. Our target stays 1.2. |
- SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, false); |
+ SetContentsScaleOnBothLayers(1.f, device_scale, page_scale, 1.f, false); |
// All the tilings are between are target and the ideal, so they are not |
// removed. |
@@ -937,6 +966,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
active_layer_->CalculateContentsScale(1.1f, |
device_scale, |
page_scale, |
+ 1.f, |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -953,6 +983,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
pending_layer_->CalculateContentsScale(1.1f, |
device_scale, |
page_scale, |
+ 1.f, |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -992,18 +1023,25 @@ TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
float contents_scale = 1.f; |
float device_scale = 1.f; |
float page_scale = 1.f; |
+ float maximum_animation_scale = 1.f; |
bool animating_transform = true; |
// Animating, so don't create low res even if there isn't one already. |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
EXPECT_BOTH_EQ(num_tilings(), 1u); |
// Stop animating, low res gets created. |
animating_transform = false; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
EXPECT_BOTH_EQ(num_tilings(), 2u); |
@@ -1012,16 +1050,22 @@ TEST_F(PictureLayerImplTest, DontAddLowResDuringAnimation) { |
contents_scale = 2.f; |
page_scale = 2.f; |
animating_transform = true; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), low_res_factor); |
EXPECT_BOTH_EQ(num_tilings(), 3u); |
// Stop animating, new low res gets created for final page scale. |
animating_transform = false; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), 2.f * low_res_factor); |
EXPECT_BOTH_EQ(num_tilings(), 4u); |
@@ -1034,12 +1078,16 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
float device_scale = 1.f; |
float page_scale = 1.f; |
+ float maximum_animation_scale = 1.f; |
bool animating_transform = false; |
// Contents exactly fit on one tile at scale 1, no low res. |
float contents_scale = 1.f; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
EXPECT_BOTH_EQ(num_tilings(), 1u); |
@@ -1047,8 +1095,11 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
// Contents that are smaller than one tile, no low res. |
contents_scale = 0.123f; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
EXPECT_BOTH_EQ(num_tilings(), 1u); |
@@ -1057,8 +1108,11 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
// Any content bounds that would create more than one tile will |
// generate a low res tiling. |
contents_scale = 2.5f; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
EXPECT_BOTH_EQ(LowResTiling()->contents_scale(), |
contents_scale * low_res_factor); |
@@ -1069,8 +1123,11 @@ TEST_F(PictureLayerImplTest, DontAddLowResForSmallLayers) { |
// Mask layers dont create low res since they always fit on one tile. |
pending_layer_->SetIsMask(true); |
active_layer_->SetIsMask(true); |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), contents_scale); |
EXPECT_BOTH_EQ(num_tilings(), 1u); |
} |
@@ -1092,7 +1149,8 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { |
pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
2.7f, // device scale |
- 3.2f, // page cale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -1108,7 +1166,8 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { |
// This should create new tilings. |
pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
2.7f, // device scale |
- 3.2f, // page cale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
false, |
&result_scale_x, |
&result_scale_y, |
@@ -1132,8 +1191,14 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1156,8 +1221,14 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
context.Pass()).PassAs<OutputSurface>()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1184,8 +1255,14 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1208,8 +1285,14 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
context.Pass()).PassAs<OutputSurface>()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1512,8 +1595,14 @@ TEST_F(PictureLayerImplTest, TilingWithoutGpuRasterization) { |
SetupDefaultTrees(layer_bounds); |
EXPECT_FALSE(pending_layer_->ShouldUseGpuRasterization()); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
// Should have a low-res and a high-res tiling. |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
} |
@@ -1521,7 +1610,7 @@ TEST_F(PictureLayerImplTest, TilingWithoutGpuRasterization) { |
TEST_F(PictureLayerImplTest, NoTilingIfDoesNotDrawContent) { |
// Set up layers with tilings. |
SetupDefaultTrees(gfx::Size(10, 10)); |
- SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, false); |
+ SetContentsScaleOnBothLayers(1.f, 1.f, 1.f, 1.f, false); |
pending_layer_->PushPropertiesTo(active_layer_); |
EXPECT_TRUE(pending_layer_->DrawsContent()); |
EXPECT_TRUE(pending_layer_->CanHaveTilings()); |
@@ -1542,7 +1631,7 @@ TEST_F(PictureLayerImplTest, FirstTilingDuringPinch) { |
SetupDefaultTrees(gfx::Size(10, 10)); |
host_impl_.PinchGestureBegin(); |
float high_res_scale = 2.3f; |
- SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, false); |
+ SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); |
ASSERT_GE(pending_layer_->num_tilings(), 0u); |
EXPECT_FLOAT_EQ(high_res_scale, |
@@ -1555,7 +1644,7 @@ TEST_F(PictureLayerImplTest, FirstTilingTooSmall) { |
float high_res_scale = 0.0001f; |
EXPECT_GT(pending_layer_->MinimumContentsScale(), high_res_scale); |
- SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, false); |
+ SetContentsScaleOnBothLayers(high_res_scale, 1.f, 1.f, 1.f, false); |
ASSERT_GE(pending_layer_->num_tilings(), 0u); |
EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
@@ -1566,7 +1655,7 @@ TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
SetupDefaultTrees(gfx::Size(10, 10)); |
float contents_scale = 0.15f; |
- SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, false); |
+ SetContentsScaleOnBothLayers(contents_scale, 1.f, 1.f, 1.f, false); |
ASSERT_GE(pending_layer_->num_tilings(), 0u); |
EXPECT_FLOAT_EQ(contents_scale, |
@@ -1578,8 +1667,7 @@ TEST_F(PictureLayerImplTest, PinchingTooSmall) { |
EXPECT_LT(page_scale * contents_scale, |
pending_layer_->MinimumContentsScale()); |
- |
- SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, false); |
+ SetContentsScaleOnBothLayers(contents_scale, 1.f, page_scale, 1.f, false); |
ASSERT_GE(pending_layer_->num_tilings(), 0u); |
EXPECT_FLOAT_EQ(pending_layer_->MinimumContentsScale(), |
pending_layer_->HighResTiling()->contents_scale()); |
@@ -1647,16 +1735,28 @@ TEST_F(HybridRasterizationPictureLayerImplTest, Tiling) { |
SetupDefaultTrees(layer_bounds); |
EXPECT_FALSE(pending_layer_->ShouldUseGpuRasterization()); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
// Should have a low-res and a high-res tiling. |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->SetHasGpuRasterizationHint(true); |
EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
// Should only have the high-res tiling. |
ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
} |
@@ -1671,26 +1771,85 @@ TEST_F(HybridRasterizationPictureLayerImplTest, |
float contents_scale = 1.f; |
float device_scale = 1.f; |
enne (OOO)
2014/04/08 20:37:01
Can you change this to device and page scale to be
ajuma
2014/04/08 20:54:56
Done.
|
float page_scale = 1.f; |
+ float maximum_animation_scale = 1.f; |
bool animating_transform = false; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
- // Changing contents scale shouldn't affect tiling resolution during the |
- // animation, since we're CPU-rasterizing. |
+ // Since we're CPU-rasterizing, starting an animation should cause tiling |
+ // resolution to get set to the maximum animation scale factor. |
animating_transform = true; |
+ maximum_animation_scale = 3.f; |
contents_scale = 2.f; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
- EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
+ |
+ // Further changes to scale during the animation should not cause a new |
+ // high-res tiling to get created. |
+ contents_scale = 4.f; |
+ maximum_animation_scale = 5.f; |
+ |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 3.f); |
// Once we stop animating, a new high-res tiling should be created. |
animating_transform = false; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
+ |
+ // When animating with an unknown maximum animation scale factor, a new |
+ // high-res tiling should be created at the animation's initial scale. |
+ animating_transform = true; |
+ contents_scale = 2.f; |
+ maximum_animation_scale = 0.f; |
+ |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
+ |
+ // Further changes to scale during the animation should not cause a new |
+ // high-res tiling to get created. |
+ contents_scale = 3.f; |
+ |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
+ |
+ // Once we stop animating, a new high-res tiling should be created. |
+ animating_transform = false; |
+ contents_scale = 4.f; |
+ |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
+ EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
} |
TEST_F(HybridRasterizationPictureLayerImplTest, |
@@ -1703,33 +1862,48 @@ TEST_F(HybridRasterizationPictureLayerImplTest, |
float contents_scale = 1.f; |
float device_scale = 1.f; |
float page_scale = 1.f; |
+ float maximum_animation_scale = 1.f; |
bool animating_transform = false; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 1.f); |
// Changing contents scale during an animation should cause tiling resolution |
- // to change, since we're GPU-rasterizing. |
+ // to change, since we're GPU-rasterizing. The maximum animation scale should |
+ // not have any effect. |
animating_transform = true; |
contents_scale = 2.f; |
+ maximum_animation_scale = 4.f; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 2.f); |
// Since we're re-rasterizing during the animation, scales smaller than 1 |
// should be respected. |
contents_scale = 0.5f; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 0.5f); |
// Tiling resolution should also update once we stop animating. |
contents_scale = 4.f; |
animating_transform = false; |
- SetContentsScaleOnBothLayers( |
- contents_scale, device_scale, page_scale, animating_transform); |
+ SetContentsScaleOnBothLayers(contents_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ animating_transform); |
EXPECT_BOTH_EQ(HighResTiling()->contents_scale(), 4.f); |
} |
@@ -1750,8 +1924,14 @@ TEST_F(GpuRasterizationPictureLayerImplTest, Tiling) { |
pending_layer_->SetHasGpuRasterizationHint(true); |
EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
// Should only have the high-res tiling. |
ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
@@ -1759,8 +1939,14 @@ TEST_F(GpuRasterizationPictureLayerImplTest, Tiling) { |
EXPECT_TRUE(pending_layer_->ShouldUseGpuRasterization()); |
// Should still have the high-res tiling. |
EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale( |
- 1.f, 1.f, 1.f, false, &result_scale_x, &result_scale_y, &result_bounds); |
+ pending_layer_->CalculateContentsScale(1.f, |
+ 1.f, |
+ 1.f, |
+ 1.f, |
+ false, |
+ &result_scale_x, |
+ &result_scale_y, |
+ &result_bounds); |
// Should still only have the high-res tiling. |
ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
} |