Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1181)

Unified Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 226283004: Rasterize at maximum scale for scale animations on CPU-rasterized layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 5079c5eec59e15934ccfb7471a278088c5104c0c..12ffcc0717e3281c1ad2f8e2ee1197541e568c40 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -152,25 +152,26 @@ class PictureLayerImplTest : public testing::Test {
void SetContentsScaleOnBothLayers(float contents_scale,
float device_scale_factor,
float page_scale_factor,
+ float maximum_animation_scale_factor,
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_scale_factor,
+ animating_transform,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
+ active_layer_->CalculateContentsScale(contents_scale,
+ device_scale_factor,
+ page_scale_factor,
+ maximum_animation_scale_factor,
+ animating_transform,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
}
void ResetTilingsAndRasterScales() {
@@ -209,8 +210,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();
@@ -311,6 +318,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,
@@ -320,6 +328,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,
@@ -344,6 +353,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,
@@ -353,6 +363,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,
@@ -387,6 +398,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,
@@ -599,8 +611,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());
}
@@ -625,7 +643,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,
@@ -642,7 +661,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,
@@ -658,7 +678,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,
@@ -674,7 +695,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,
@@ -691,7 +713,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,
@@ -724,6 +747,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;
@@ -731,6 +755,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,
@@ -746,6 +771,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,
@@ -757,6 +783,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,
@@ -767,6 +794,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,
@@ -791,10 +819,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);
}
@@ -810,7 +838,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(
@@ -825,7 +853,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,
@@ -839,17 +867,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,
@@ -878,7 +907,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.
@@ -887,7 +916,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.
@@ -897,7 +926,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,
@@ -914,7 +943,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.
@@ -923,7 +952,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.
@@ -935,6 +964,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) {
active_layer_->CalculateContentsScale(1.1f,
device_scale,
page_scale,
+ 1.f,
false,
&result_scale_x,
&result_scale_y,
@@ -951,6 +981,7 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) {
pending_layer_->CalculateContentsScale(1.1f,
device_scale,
page_scale,
+ 1.f,
false,
&result_scale_x,
&result_scale_y,
@@ -990,18 +1021,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);
@@ -1010,16 +1048,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);
@@ -1032,12 +1076,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);
@@ -1045,8 +1093,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);
@@ -1055,8 +1106,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);
@@ -1067,8 +1121,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);
}
@@ -1090,7 +1147,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,
@@ -1106,7 +1164,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,
@@ -1130,8 +1189,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();
@@ -1154,8 +1219,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();
@@ -1182,8 +1253,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();
@@ -1206,8 +1283,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();
@@ -1510,8 +1593,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());
}
@@ -1519,7 +1608,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());
@@ -1540,7 +1629,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,
@@ -1553,7 +1642,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(),
@@ -1564,7 +1653,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,
@@ -1576,8 +1665,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());
@@ -1645,16 +1733,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());
}
@@ -1669,26 +1769,84 @@ 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 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 multiplied by 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(), 6.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(), 6.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(), 3.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,
@@ -1701,33 +1859,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);
}
@@ -1748,8 +1921,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());
@@ -1757,8 +1936,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());
}

Powered by Google App Engine
This is Rietveld 408576698