| 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 40028de6f143267a1b6cff071dd8ca0a58f2340d..cb4486ba82fc0b811e02157aafc4c117ae55d45f 100644
|
| --- a/cc/layers/picture_layer_impl_unittest.cc
|
| +++ b/cc/layers/picture_layer_impl_unittest.cc
|
| @@ -26,7 +26,6 @@
|
| #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 {
|
| @@ -140,23 +139,6 @@
|
| 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) {
|
| @@ -174,19 +156,24 @@
|
| float page_scale_factor,
|
| float maximum_animation_contents_scale,
|
| bool animating_transform) {
|
| - 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);
|
| + 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);
|
| }
|
|
|
| void ResetTilingsAndRasterScales() {
|
| @@ -223,8 +210,16 @@
|
|
|
| SetupTrees(pending_pile, active_pile);
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - active_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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);
|
|
|
| // Add 1x1 rects at the centers of each tile, then re-record pile contents
|
| active_layer_->tilings()->tiling_at(0)->CreateAllTilesForTesting();
|
| @@ -319,7 +314,17 @@
|
|
|
| Region invalidation;
|
| AddDefaultTilingsWithInvalidation(invalidation);
|
| - SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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);
|
|
|
| // UpdateTilePriorities with valid viewport. Should update tile viewport.
|
| bool valid_for_tile_management = true;
|
| @@ -576,10 +581,19 @@
|
| 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);
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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());
|
| }
|
| @@ -593,18 +607,23 @@
|
| 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);
|
|
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 6.f, // ideal contents scale
|
| - 3.f, // device scale
|
| - 2.f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(6.f,
|
| pending_layer_->tilings()->tiling_at(0)->contents_scale());
|
| @@ -612,12 +631,14 @@
|
| pending_layer_->tilings()->tiling_at(1)->contents_scale());
|
|
|
| // If we change the page scale factor, then we should get new tilings.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 6.6f, // ideal contents scale
|
| - 3.f, // device scale
|
| - 2.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(6.6f,
|
| pending_layer_->tilings()->tiling_at(0)->contents_scale());
|
| @@ -625,12 +646,14 @@
|
| pending_layer_->tilings()->tiling_at(2)->contents_scale());
|
|
|
| // If we change the device scale factor, then we should get new tilings.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 7.26f, // ideal contents scale
|
| - 3.3f, // device scale
|
| - 2.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(7.26f,
|
| pending_layer_->tilings()->tiling_at(0)->contents_scale());
|
| @@ -639,12 +662,14 @@
|
|
|
| // If we change the device scale factor, but end up at the same total scale
|
| // factor somehow, then we don't get new tilings.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 7.26f, // ideal contents scale
|
| - 2.2f, // device scale
|
| - 3.3f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| ASSERT_EQ(6u, pending_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(7.26f,
|
| pending_layer_->tilings()->tiling_at(0)->contents_scale());
|
| @@ -672,14 +697,18 @@
|
| 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);
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - high_res_scale,
|
| - device_scale,
|
| - page_scale,
|
| - maximum_animation_scale,
|
| - false);
|
| + pending_layer_->CalculateContentsScale(high_res_scale,
|
| + device_scale,
|
| + page_scale,
|
| + maximum_animation_scale,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
| ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(high_res_scale,
|
| pending_layer_->HighResTiling()->contents_scale());
|
| @@ -688,31 +717,37 @@
|
|
|
| ActivateTree();
|
| SetupPendingTree(empty_pile);
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - high_res_scale,
|
| - device_scale,
|
| - page_scale,
|
| - maximum_animation_scale,
|
| - false);
|
| + pending_layer_->CalculateContentsScale(high_res_scale,
|
| + device_scale,
|
| + page_scale,
|
| + maximum_animation_scale,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
| ASSERT_EQ(2u, active_layer_->tilings()->num_tilings());
|
| ASSERT_EQ(0u, pending_layer_->tilings()->num_tilings());
|
|
|
| ActivateTree();
|
| - SetupDrawPropertiesAndManageTilings(active_layer_,
|
| - high_res_scale,
|
| - device_scale,
|
| - page_scale,
|
| - maximum_animation_scale,
|
| - false);
|
| + active_layer_->CalculateContentsScale(high_res_scale,
|
| + device_scale,
|
| + page_scale,
|
| + maximum_animation_scale,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
| ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
|
|
|
| SetupPendingTree(valid_pile);
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - high_res_scale,
|
| - device_scale,
|
| - page_scale,
|
| - maximum_animation_scale,
|
| - false);
|
| + pending_layer_->CalculateContentsScale(high_res_scale,
|
| + device_scale,
|
| + page_scale,
|
| + maximum_animation_scale,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
| ASSERT_EQ(2u, pending_layer_->tilings()->num_tilings());
|
| ASSERT_EQ(0u, active_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(high_res_scale,
|
| @@ -846,6 +881,8 @@
|
| 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);
|
| @@ -919,8 +956,14 @@
|
| 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.
|
| - SetupDrawPropertiesAndManageTilings(
|
| - active_layer_, 1.1f, device_scale, page_scale, 1.f, false);
|
| + active_layer_->CalculateContentsScale(1.1f,
|
| + device_scale,
|
| + page_scale,
|
| + 1.f,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
|
|
| // Because the pending layer's ideal scale is still 1.0, our tilings fall
|
| // in the range [1.0,1.2] and are kept.
|
| @@ -930,8 +973,14 @@
|
|
|
| // Move the ideal scale on the pending layer to 1.1 as well. Our target stays
|
| // 1.2 still.
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.1f, device_scale, page_scale, 1.f, false);
|
| + pending_layer_->CalculateContentsScale(1.1f,
|
| + device_scale,
|
| + page_scale,
|
| + 1.f,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
|
|
| // 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
|
| @@ -1085,15 +1134,20 @@
|
| 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());
|
|
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 1.3f, // ideal contents scale
|
| - 2.7f, // device scale
|
| - 3.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
|
|
|
| // All tilings should be removed when losing output surface.
|
| @@ -1103,12 +1157,14 @@
|
| EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
|
|
|
| // This should create new tilings.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 1.3f, // ideal contents scale
|
| - 2.7f, // device scale
|
| - 3.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
|
| }
|
|
|
| @@ -1122,11 +1178,20 @@
|
| 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());
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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();
|
| @@ -1149,8 +1214,14 @@
|
| host_impl_.InitializeRenderer(FakeOutputSurface::Create3d(
|
| context.Pass()).PassAs<OutputSurface>());
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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();
|
| @@ -1171,11 +1242,20 @@
|
| 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());
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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();
|
| @@ -1198,8 +1278,14 @@
|
| host_impl_.InitializeRenderer(FakeOutputSurface::Create3d(
|
| context.Pass()).PassAs<OutputSurface>());
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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();
|
| @@ -1228,6 +1314,7 @@
|
|
|
| SetupTrees(pending_pile, active_pile);
|
|
|
| + active_layer_->SetContentBounds(layer_bounds);
|
| active_layer_->draw_properties().visible_content_rect =
|
| gfx::Rect(layer_bounds);
|
|
|
| @@ -1592,8 +1679,17 @@
|
| host_impl_.active_tree()->UpdateDrawProperties();
|
| EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties());
|
|
|
| - SetupDrawPropertiesAndManageTilings(
|
| - active_layer_, 0.5f, 0.5f, 0.5f, 0.5f, false);
|
| + 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);
|
| active_layer_->tilings()->RemoveAllTilings();
|
| PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f);
|
| active_layer_->tilings()->AddTiling(1.5f);
|
| @@ -1636,12 +1732,20 @@
|
| 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());
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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());
|
|
|
| @@ -1649,9 +1753,14 @@
|
|
|
| host_impl_.SetUseGpuRasterization(true);
|
| EXPECT_TRUE(host_impl_.use_gpu_rasterization());
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| -
|
| + 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());
|
| }
|
| @@ -2277,52 +2386,63 @@
|
| 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);
|
|
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 6.f, // ideal contents scale
|
| - 3.f, // device scale
|
| - 2.f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| 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.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 6.6f, // ideal contents scale
|
| - 3.f, // device scale
|
| - 2.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| 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.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 7.26f, // ideal contents scale
|
| - 3.3f, // device scale
|
| - 2.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| 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.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 7.26f, // ideal contents scale
|
| - 2.2f, // device scale
|
| - 3.3f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| ASSERT_EQ(3u, pending_layer_->tilings()->num_tilings());
|
| EXPECT_FLOAT_EQ(7.26f,
|
| pending_layer_->tilings()->tiling_at(0)->contents_scale());
|
| @@ -2417,7 +2537,17 @@
|
|
|
| Region invalidation;
|
| AddDefaultTilingsWithInvalidation(invalidation);
|
| - SetupDrawPropertiesAndManageTilings(active_layer_, 1.f, 1.f, 1.f, 1.f, false);
|
| + 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);
|
|
|
| // UpdateTilePriorities with valid viewport. Should update tile viewport.
|
| bool valid_for_tile_management = true;
|
| @@ -2516,6 +2646,8 @@
|
| 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);
|
| @@ -2584,8 +2716,14 @@
|
| 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.
|
| - SetupDrawPropertiesAndManageTilings(
|
| - active_layer_, 1.1f, device_scale, page_scale, 1.f, false);
|
| + active_layer_->CalculateContentsScale(1.1f,
|
| + device_scale,
|
| + page_scale,
|
| + 1.f,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
|
|
| // Because the pending layer's ideal scale is still 1.0, our tilings fall
|
| // in the range [1.0,1.2] and are kept.
|
| @@ -2595,8 +2733,14 @@
|
|
|
| // Move the ideal scale on the pending layer to 1.1 as well. Our target stays
|
| // 1.2 still.
|
| - SetupDrawPropertiesAndManageTilings(
|
| - pending_layer_, 1.1f, device_scale, page_scale, 1.f, false);
|
| + pending_layer_->CalculateContentsScale(1.1f,
|
| + device_scale,
|
| + page_scale,
|
| + 1.f,
|
| + false,
|
| + &result_scale_x,
|
| + &result_scale_y,
|
| + &result_bounds);
|
|
|
| // 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
|
| @@ -2622,6 +2766,8 @@
|
| 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);
|
| @@ -2637,18 +2783,22 @@
|
| float low_res_factor = host_impl_.settings().low_res_contents_scale_factor;
|
| EXPECT_LT(low_res_factor, 1.f);
|
|
|
| - 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);
|
| + 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);
|
|
|
| ASSERT_EQ(4u, pending_layer_->tilings()->num_tilings());
|
| ASSERT_EQ(4u, active_layer_->tilings()->num_tilings());
|
| @@ -2696,15 +2846,20 @@
|
| 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());
|
|
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 1.3f, // ideal contents scale
|
| - 2.7f, // device scale
|
| - 3.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| EXPECT_EQ(1u, pending_layer_->tilings()->num_tilings());
|
|
|
| // All tilings should be removed when losing output surface.
|
| @@ -2714,60 +2869,15 @@
|
| EXPECT_EQ(0u, pending_layer_->tilings()->num_tilings());
|
|
|
| // This should create new tilings.
|
| - SetupDrawPropertiesAndManageTilings(pending_layer_,
|
| - 1.3f, // ideal contents scale
|
| - 2.7f, // device scale
|
| - 3.2f, // page scale
|
| - 1.f, // maximum animation scale
|
| - false);
|
| + 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);
|
| 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
|
|
|