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 cb4486ba82fc0b811e02157aafc4c117ae55d45f..40028de6f143267a1b6cff071dd8ca0a58f2340d 100644 |
--- a/cc/layers/picture_layer_impl_unittest.cc |
+++ b/cc/layers/picture_layer_impl_unittest.cc |
@@ -26,6 +26,7 @@ |
#include "cc/trees/layer_tree_impl.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/gfx/rect_conversions.h" |
+#include "ui/gfx/size_conversions.h" |
namespace cc { |
namespace { |
@@ -139,6 +140,23 @@ class PictureLayerImplTest : public testing::Test { |
pending_layer_->DoPostCommitInitializationIfNeeded(); |
} |
+ void SetupDrawPropertiesAndManageTilings( |
+ FakePictureLayerImpl* layer, |
+ float ideal_contents_scale, |
+ float device_scale_factor, |
+ float page_scale_factor, |
+ float maximum_animation_contents_scale, |
+ bool animating_transform_to_screen) { |
+ layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
+ layer->draw_properties().device_scale_factor = device_scale_factor; |
+ layer->draw_properties().page_scale_factor = page_scale_factor; |
+ layer->draw_properties().maximum_animation_contents_scale = |
+ maximum_animation_contents_scale; |
+ layer->draw_properties().screen_space_transform_is_animating = |
+ animating_transform_to_screen; |
+ layer->ScaleAndManageTilings(animating_transform_to_screen, |
+ maximum_animation_contents_scale); |
+ } |
static void VerifyAllTilesExistAndHavePile( |
const PictureLayerTiling* tiling, |
PicturePileImpl* pile) { |
@@ -156,24 +174,19 @@ class PictureLayerImplTest : public testing::Test { |
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, |
- 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); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ contents_scale, |
+ device_scale_factor, |
+ page_scale_factor, |
+ maximum_animation_contents_scale, |
+ animating_transform); |
+ |
+ SetupDrawPropertiesAndManageTilings(active_layer_, |
+ contents_scale, |
+ device_scale_factor, |
+ page_scale_factor, |
+ maximum_animation_contents_scale, |
+ animating_transform); |
} |
void ResetTilingsAndRasterScales() { |
@@ -210,16 +223,8 @@ class PictureLayerImplTest : public testing::Test { |
SetupTrees(pending_pile, active_pile); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- active_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
// Add 1x1 rects at the centers of each tile, then re-record pile contents |
active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -314,17 +319,7 @@ TEST_F(PictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
Region invalidation; |
AddDefaultTilingsWithInvalidation(invalidation); |
- float dummy_contents_scale_x; |
- float dummy_contents_scale_y; |
- gfx::Size dummy_content_bounds; |
- active_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &dummy_contents_scale_x, |
- &dummy_contents_scale_y, |
- &dummy_content_bounds); |
+ SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
// UpdateTilePriorities with valid viewport. Should update tile viewport. |
bool valid_for_tile_management = true; |
@@ -581,19 +576,10 @@ TEST_F(PictureLayerImplTest, ManageTilingsWithNoRecording) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateEmptyPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
} |
@@ -607,23 +593,18 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
EXPECT_LT(low_res_factor, 1.f); |
- pending_layer_->CalculateContentsScale(6.f, // ideal contents scale |
- 3.f, // device scale |
- 2.f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 6.f, // ideal contents scale |
+ 3.f, // device scale |
+ 2.f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(6.f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
@@ -631,14 +612,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
pending_layer_->tilings()->tiling_at(1)->contents_scale()); |
// If we change the page scale factor, then we should get new tilings. |
- pending_layer_->CalculateContentsScale(6.6f, // ideal contents scale |
- 3.f, // device scale |
- 2.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 6.6f, // ideal contents scale |
+ 3.f, // device scale |
+ 2.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(6.6f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
@@ -646,14 +625,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
pending_layer_->tilings()->tiling_at(2)->contents_scale()); |
// If we change the device scale factor, then we should get new tilings. |
- pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale |
- 3.3f, // device scale |
- 2.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 7.26f, // ideal contents scale |
+ 3.3f, // device scale |
+ 2.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(7.26f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
@@ -662,14 +639,12 @@ TEST_F(PictureLayerImplTest, ManageTilingsCreatesTilings) { |
// If we change the device scale factor, but end up at the same total scale |
// factor somehow, then we don't get new tilings. |
- pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale |
- 2.2f, // device scale |
- 3.3f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 7.26f, // ideal contents scale |
+ 2.2f, // device scale |
+ 3.3f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(7.26f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
@@ -697,18 +672,14 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
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; |
SetupPendingTree(valid_pile); |
- pending_layer_->CalculateContentsScale(high_res_scale, |
- device_scale, |
- page_scale, |
- maximum_animation_scale, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ high_res_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ false); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(high_res_scale, |
pending_layer_->HighResTiling()->contents_scale()); |
@@ -717,37 +688,31 @@ TEST_F(PictureLayerImplTest, CreateTilingsEvenIfTwinHasNone) { |
ActivateTree(); |
SetupPendingTree(empty_pile); |
- pending_layer_->CalculateContentsScale(high_res_scale, |
- device_scale, |
- page_scale, |
- maximum_animation_scale, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ high_res_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ false); |
ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
ActivateTree(); |
- active_layer_->CalculateContentsScale(high_res_scale, |
- device_scale, |
- page_scale, |
- maximum_animation_scale, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(active_layer_, |
+ high_res_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ false); |
ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
SetupPendingTree(valid_pile); |
- pending_layer_->CalculateContentsScale(high_res_scale, |
- device_scale, |
- page_scale, |
- maximum_animation_scale, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ high_res_scale, |
+ device_scale, |
+ page_scale, |
+ maximum_animation_scale, |
+ false); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
ASSERT_EQ(0u, active_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(high_res_scale, |
@@ -881,8 +846,6 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
std::vector<PictureLayerTiling*> used_tilings; |
SetupTrees(pending_pile, active_pile); |
@@ -956,14 +919,8 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
ASSERT_EQ(3u, active_layer_->tilings()->num_tilings()); |
// Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
- active_layer_->CalculateContentsScale(1.1f, |
- device_scale, |
- page_scale, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ active_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
// Because the pending layer's ideal scale is still 1.0, our tilings fall |
// in the range [1.0,1.2] and are kept. |
@@ -973,14 +930,8 @@ TEST_F(PictureLayerImplTest, CleanUpTilings) { |
// Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
// 1.2 still. |
- pending_layer_->CalculateContentsScale(1.1f, |
- device_scale, |
- page_scale, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
// Our 1.0 tiling now falls outside the range between our ideal scale and our |
// target raster scale. But it is in our used tilings set, so nothing is |
@@ -1134,20 +1085,15 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
- 2.7f, // device scale |
- 3.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 1.3f, // ideal contents scale |
+ 2.7f, // device scale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
// All tilings should be removed when losing output surface. |
@@ -1157,14 +1103,12 @@ TEST_F(PictureLayerImplTest, ReleaseResources) { |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
// This should create new tilings. |
- pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
- 2.7f, // device scale |
- 3.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 1.3f, // ideal contents scale |
+ 2.7f, // device scale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
} |
@@ -1178,20 +1122,11 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1214,14 +1149,8 @@ TEST_F(PictureLayerImplTest, ClampTilesToToMaxTileSize) { |
host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
context.Pass()).PassAs<OutputSurface>()); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1242,20 +1171,11 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1278,14 +1198,8 @@ TEST_F(PictureLayerImplTest, ClampSingleTileToToMaxTileSize) { |
host_impl_.InitializeRenderer(FakeOutputSurface::Create3d( |
context.Pass()).PassAs<OutputSurface>()); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
ASSERT_LE(1u, pending_layer_->tilings()->num_tilings()); |
pending_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting(); |
@@ -1314,7 +1228,6 @@ TEST_F(PictureLayerImplTest, DisallowTileDrawQuads) { |
SetupTrees(pending_pile, active_pile); |
- active_layer_->SetContentBounds(layer_bounds); |
active_layer_->draw_properties().visible_content_rect = |
gfx::Rect(layer_bounds); |
@@ -1679,17 +1592,8 @@ TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) { |
host_impl_.active_tree()->UpdateDrawProperties(); |
EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties()); |
- float result_scale_x; |
- float result_scale_y; |
- gfx::Size result_bounds; |
- active_layer_->CalculateContentsScale(0.5f, |
- 0.5f, |
- 0.5f, |
- 0.5f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false); |
active_layer_->tilings()->RemoveAllTilings(); |
PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f); |
active_layer_->tilings()->AddTiling(1.5f); |
@@ -1732,20 +1636,12 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
gfx::Size default_tile_size(host_impl_.settings().default_tile_size); |
gfx::Size layer_bounds(default_tile_size.width() * 4, |
default_tile_size.height() * 4); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
SetupDefaultTrees(layer_bounds); |
EXPECT_FALSE(host_impl_.use_gpu_rasterization()); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
// Should have a low-res and a high-res tiling. |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
@@ -1753,14 +1649,9 @@ TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) { |
host_impl_.SetUseGpuRasterization(true); |
EXPECT_TRUE(host_impl_.use_gpu_rasterization()); |
- pending_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.f, 1.f, 1.f, 1.f, false); |
+ |
// Should only have the high-res tiling. |
ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
} |
@@ -2386,63 +2277,52 @@ TEST_F(NoLowResPictureLayerImplTest, ManageTilingsCreatesTilings) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
EXPECT_LT(low_res_factor, 1.f); |
- pending_layer_->CalculateContentsScale(6.f, // ideal contents scale |
- 3.f, // device scale |
- 2.f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 6.f, // ideal contents scale |
+ 3.f, // device scale |
+ 2.f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(6.f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
// If we change the page scale factor, then we should get new tilings. |
- pending_layer_->CalculateContentsScale(6.6f, // ideal contents scale |
- 3.f, // device scale |
- 2.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 6.6f, // ideal contents scale |
+ 3.f, // device scale |
+ 2.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(6.6f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
// If we change the device scale factor, then we should get new tilings. |
- pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale |
- 3.3f, // device scale |
- 2.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 7.26f, // ideal contents scale |
+ 3.3f, // device scale |
+ 2.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(7.26f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
// If we change the device scale factor, but end up at the same total scale |
// factor somehow, then we don't get new tilings. |
- pending_layer_->CalculateContentsScale(7.26f, // ideal contents scale |
- 2.2f, // device scale |
- 3.3f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 7.26f, // ideal contents scale |
+ 2.2f, // device scale |
+ 3.3f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings()); |
EXPECT_FLOAT_EQ(7.26f, |
pending_layer_->tilings()->tiling_at(0)->contents_scale()); |
@@ -2537,17 +2417,7 @@ TEST_F(NoLowResPictureLayerImplTest, InvalidViewportForPrioritizingTiles) { |
Region invalidation; |
AddDefaultTilingsWithInvalidation(invalidation); |
- float dummy_contents_scale_x; |
- float dummy_contents_scale_y; |
- gfx::Size dummy_content_bounds; |
- active_layer_->CalculateContentsScale(1.f, |
- 1.f, |
- 1.f, |
- 1.f, |
- false, |
- &dummy_contents_scale_x, |
- &dummy_contents_scale_y, |
- &dummy_content_bounds); |
+ SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false); |
// UpdateTilePriorities with valid viewport. Should update tile viewport. |
bool valid_for_tile_management = true; |
@@ -2646,8 +2516,6 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
std::vector<PictureLayerTiling*> used_tilings; |
SetupTrees(pending_pile, active_pile); |
@@ -2716,14 +2584,8 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { |
ASSERT_EQ(2u, active_layer_->tilings()->num_tilings()); |
// Now move the ideal scale to 1.1 on the active layer. Our target stays 1.2. |
- active_layer_->CalculateContentsScale(1.1f, |
- device_scale, |
- page_scale, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ active_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
// Because the pending layer's ideal scale is still 1.0, our tilings fall |
// in the range [1.0,1.2] and are kept. |
@@ -2733,14 +2595,8 @@ TEST_F(NoLowResPictureLayerImplTest, CleanUpTilings) { |
// Move the ideal scale on the pending layer to 1.1 as well. Our target stays |
// 1.2 still. |
- pending_layer_->CalculateContentsScale(1.1f, |
- device_scale, |
- page_scale, |
- 1.f, |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 1.1f, device_scale, page_scale, 1.f, false); |
// Our 1.0 tiling now falls outside the range between our ideal scale and our |
// target raster scale. But it is in our used tilings set, so nothing is |
@@ -2766,8 +2622,6 @@ TEST_F(PictureLayerImplTest, ScaleCollision) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
std::vector<PictureLayerTiling*> used_tilings; |
SetupTrees(pending_pile, active_pile); |
@@ -2783,22 +2637,18 @@ TEST_F(PictureLayerImplTest, ScaleCollision) { |
float low_res_factor = host_impl_.settings().low_res_contents_scale_factor; |
EXPECT_LT(low_res_factor, 1.f); |
- pending_layer_->CalculateContentsScale(pending_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(active_contents_scale, |
- device_scale_factor, |
- page_scale_factor, |
- maximum_animation_contents_scale, |
- animating_transform, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ pending_contents_scale, |
+ device_scale_factor, |
+ page_scale_factor, |
+ maximum_animation_contents_scale, |
+ animating_transform); |
+ SetupDrawPropertiesAndManageTilings(active_layer_, |
+ active_contents_scale, |
+ device_scale_factor, |
+ page_scale_factor, |
+ maximum_animation_contents_scale, |
+ animating_transform); |
ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings()); |
ASSERT_EQ(4u, active_layer_->tilings()->num_tilings()); |
@@ -2846,20 +2696,15 @@ TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { |
scoped_refptr<FakePicturePileImpl> active_pile = |
FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
- float result_scale_x, result_scale_y; |
- gfx::Size result_bounds; |
- |
SetupTrees(pending_pile, active_pile); |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
- pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
- 2.7f, // device scale |
- 3.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 1.3f, // ideal contents scale |
+ 2.7f, // device scale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
// All tilings should be removed when losing output surface. |
@@ -2869,16 +2714,61 @@ TEST_F(NoLowResPictureLayerImplTest, ReleaseResources) { |
EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings()); |
// This should create new tilings. |
- pending_layer_->CalculateContentsScale(1.3f, // ideal contents scale |
- 2.7f, // device scale |
- 3.2f, // page scale |
- 1.f, // maximum animation scale |
- false, |
- &result_scale_x, |
- &result_scale_y, |
- &result_bounds); |
+ SetupDrawPropertiesAndManageTilings(pending_layer_, |
+ 1.3f, // ideal contents scale |
+ 2.7f, // device scale |
+ 3.2f, // page scale |
+ 1.f, // maximum animation scale |
+ false); |
EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings()); |
} |
+TEST_F(PictureLayerImplTest, SharedQuadStateContainsMaxTilingScale) { |
+ MockQuadCuller quad_culler; |
+ |
+ gfx::Size tile_size(400, 400); |
+ gfx::Size layer_bounds(1000, 2000); |
+ |
+ scoped_refptr<FakePicturePileImpl> pending_pile = |
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
+ scoped_refptr<FakePicturePileImpl> active_pile = |
+ FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds); |
+ |
+ SetupTrees(pending_pile, active_pile); |
+ |
+ SetupDrawPropertiesAndManageTilings( |
+ pending_layer_, 2.5f, 1.f, 1.f, 1.f, false); |
+ host_impl_.pending_tree()->UpdateDrawProperties(); |
+ |
+ active_layer_->draw_properties().visible_content_rect = |
+ gfx::Rect(layer_bounds); |
+ host_impl_.active_tree()->UpdateDrawProperties(); |
+ |
+ float max_contents_scale = active_layer_->MaximumTilingContentsScale(); |
+ gfx::Transform scaled_draw_transform = active_layer_->draw_transform(); |
+ scaled_draw_transform.Scale(SK_MScalar1 / max_contents_scale, |
+ SK_MScalar1 / max_contents_scale); |
+ |
+ AppendQuadsData data; |
+ active_layer_->AppendQuads(&quad_culler, &data); |
+ |
+ // SharedQuadState should have be of size 1, as we are doing AppenQuad once. |
+ EXPECT_EQ(1u, quad_culler.shared_quad_state_list().size()); |
+ // The content_to_target_transform should be scaled by the |
+ // MaximumTilingContentsScale on the layer. |
+ EXPECT_EQ(scaled_draw_transform.ToString(), |
+ quad_culler.shared_quad_state_list()[0] |
+ ->content_to_target_transform.ToString()); |
+ // The content_bounds should be scaled by the |
+ // MaximumTilingContentsScale on the layer. |
+ EXPECT_EQ(gfx::Size(2500u, 5000u).ToString(), |
+ quad_culler.shared_quad_state_list()[0]->content_bounds.ToString()); |
+ // The visible_content_rect should be scaled by the |
+ // MaximumTilingContentsScale on the layer. |
+ EXPECT_EQ( |
+ gfx::Rect(0u, 0u, 2500u, 5000u).ToString(), |
+ quad_culler.shared_quad_state_list()[0]->visible_content_rect.ToString()); |
+} |
+ |
} // namespace |
} // namespace cc |