Chromium Code Reviews| 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 68b304a6784af82ab456c2b3431c39c2014c608f..81a5f704516137458b6129c6033c85edaea8b3d1 100644 |
| --- a/cc/layers/picture_layer_impl_unittest.cc |
| +++ b/cc/layers/picture_layer_impl_unittest.cc |
| @@ -417,7 +417,8 @@ TEST_F(PictureLayerImplTest, ClonePartialInvalidation) { |
| Region()); |
| ActivateTree(); |
| // Add a unique tiling on the active tree. |
| - PictureLayerTiling* tiling = active_layer()->AddTiling(3.f); |
| + PictureLayerTiling* tiling = |
| + active_layer()->AddTiling(ScaleTranslate2d(3.f, gfx::Vector2dF())); |
| tiling->set_resolution(HIGH_RESOLUTION); |
| tiling->CreateAllTilesForTesting(); |
| @@ -3929,11 +3930,21 @@ TEST_F(OcclusionTrackingPictureLayerImplTest, OcclusionForDifferentScales) { |
| pending_layer()->tilings()->RemoveAllTilings(); |
| float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
| - pending_layer()->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); |
| - pending_layer()->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); |
| - pending_layer()->AddTiling(0.7f)->set_resolution(HIGH_RESOLUTION); |
| - pending_layer()->AddTiling(1.0f)->set_resolution(HIGH_RESOLUTION); |
| - pending_layer()->AddTiling(2.0f)->set_resolution(HIGH_RESOLUTION); |
| + pending_layer() |
| + ->AddTiling(ScaleTranslate2d(low_res_factor, gfx::Vector2dF())) |
| + ->set_resolution(LOW_RESOLUTION); |
| + pending_layer() |
| + ->AddTiling(ScaleTranslate2d(0.3f, gfx::Vector2dF())) |
| + ->set_resolution(HIGH_RESOLUTION); |
| + pending_layer() |
| + ->AddTiling(ScaleTranslate2d(0.7f, gfx::Vector2dF())) |
| + ->set_resolution(HIGH_RESOLUTION); |
| + pending_layer() |
| + ->AddTiling(ScaleTranslate2d(1.0f, gfx::Vector2dF())) |
| + ->set_resolution(HIGH_RESOLUTION); |
| + pending_layer() |
| + ->AddTiling(ScaleTranslate2d(2.0f, gfx::Vector2dF())) |
| + ->set_resolution(HIGH_RESOLUTION); |
| RebuildPropertyTreesOnPendingTree(); |
| host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
| @@ -4975,5 +4986,131 @@ TEST_F(PictureLayerImplTest, CompositedImageRasterScaleChanges) { |
| } |
| } |
| +TEST_F(PictureLayerImplTest, ChangeRasterTranslationNukePendingLayerTiles) { |
| + gfx::Size layer_bounds(200, 200); |
| + gfx::Size tile_size(256, 256); |
| + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| + pending_layer()->SetUseTransformedRasterization(true); |
| + |
| + // Start with scale & translation of * 2.25 + (0.25, 0.5). |
| + SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); |
| + gfx::Transform translate1; |
| + translate1.Translate(0.25f, 0.5f); |
| + pending_layer()->draw_properties().screen_space_transform.ConcatTransform( |
| + translate1); |
| + pending_layer()->draw_properties().target_space_transform = |
| + pending_layer()->draw_properties().screen_space_transform; |
| + pending_layer()->UpdateTiles(); |
| + ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| + { |
| + PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); |
| + EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.25f, 0.5f)), |
| + tiling->raster_transform()); |
| + EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| + // Mark some arbitrary flags on the tiles for later checking. |
|
enne (OOO)
2017/03/29 13:28:59
Are you trying to make sure that these tiles are t
trchen
2017/03/30 21:48:47
Yes. Okay I'll try if I can inject some fingerprin
trchen
2017/03/30 22:40:47
Actually the tiles remember its raster transform a
|
| + for (auto* tile : tiling->AllTilesForTesting()) |
| + tile->set_solid_color_analysis_performed(true); |
| + } |
| + |
| + // Change to scale & translation of * 2.25 + (0.75, 0.25). |
| + // Verifies there is a hysteresis that simple layer movement doesn't update |
| + // raster translation. |
| + SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); |
| + gfx::Transform translate2; |
| + translate2.Translate(0.75f, 0.25f); |
| + pending_layer()->draw_properties().screen_space_transform.ConcatTransform( |
| + translate2); |
| + pending_layer()->draw_properties().target_space_transform = |
| + pending_layer()->draw_properties().screen_space_transform; |
| + pending_layer()->UpdateTiles(); |
| + ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| + { |
| + PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); |
| + EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.25f, 0.5f)), |
| + tiling->raster_transform()); |
| + EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| + for (auto* tile : tiling->AllTilesForTesting()) |
| + EXPECT_TRUE(tile->is_solid_color_analysis_performed()); |
| + } |
| + |
| + // Now change the device scale factor but keep the same total scale. |
| + // Verifies the old tiles get evicted due to slot conflict. |
|
enne (OOO)
2017/03/29 13:28:59
What does this mean?
trchen
2017/03/30 21:48:47
The layer property change is significant enough to
trchen
2017/03/30 22:40:47
Done.
|
| + SetupDrawProperties(pending_layer(), 2.25f, 1.0f, 1.f, 2.25f, 2.25f, false); |
| + pending_layer()->draw_properties().screen_space_transform.ConcatTransform( |
| + translate2); |
| + pending_layer()->draw_properties().target_space_transform = |
| + pending_layer()->draw_properties().screen_space_transform; |
| + pending_layer()->UpdateTiles(); |
| + ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| + { |
| + PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); |
| + EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), |
| + tiling->raster_transform()); |
| + EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| + for (auto* tile : tiling->AllTilesForTesting()) |
| + EXPECT_FALSE(tile->is_solid_color_analysis_performed()); |
| + } |
| +} |
| + |
| +TEST_F(PictureLayerImplTest, ChangeRasterTranslationNukeActiveLayerTiles) { |
| + gfx::Size layer_bounds(200, 200); |
| + gfx::Size tile_size(256, 256); |
| + SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); |
| + active_layer()->SetUseTransformedRasterization(true); |
| + pending_layer()->SetUseTransformedRasterization(true); |
| + |
| + // Start with scale & translation of * 2.25 + (0.25, 0.5) on the active layer. |
| + SetupDrawProperties(active_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); |
| + gfx::Transform translate1; |
| + translate1.Translate(0.25f, 0.5f); |
| + active_layer()->draw_properties().screen_space_transform.ConcatTransform( |
| + translate1); |
| + active_layer()->draw_properties().target_space_transform = |
| + active_layer()->draw_properties().screen_space_transform; |
| + active_layer()->UpdateTiles(); |
| + ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| + { |
| + PictureLayerTiling* tiling = |
| + active_layer()->tilings()->FindTilingWithScaleKey(2.25f); |
| + EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.25f, 0.5f)), |
| + tiling->raster_transform()); |
| + EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| + // Mark some arbitrary flags on the tiles for later checking. |
| + for (auto* tile : tiling->AllTilesForTesting()) |
| + tile->set_solid_color_analysis_performed(true); |
| + } |
| + |
| + // Create a pending layer with the same scale but different translation. |
| + SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); |
| + gfx::Transform translate2; |
| + translate2.Translate(0.75f, 0.25f); |
| + pending_layer()->draw_properties().screen_space_transform.ConcatTransform( |
| + translate2); |
| + pending_layer()->draw_properties().target_space_transform = |
| + pending_layer()->draw_properties().screen_space_transform; |
| + pending_layer()->UpdateTiles(); |
| + ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); |
| + { |
| + PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); |
| + EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), |
| + tiling->raster_transform()); |
| + EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| + } |
| + |
| + // Now push to the active layer. |
| + // Verifies the active tiles get evicted due to slot conflict. |
|
enne (OOO)
2017/03/29 13:28:59
I'm a little unclear what the behavior is here. I
trchen
2017/03/30 21:48:47
The general goal is to make indirectly composited
enne (OOO)
2017/03/30 21:55:23
Thanks for the reminder that this is indirectly co
enne (OOO)
2017/03/30 21:55:23
Thanks for the reminder that this is indirectly co
trchen
2017/03/30 22:40:47
Done.
|
| + host_impl()->ActivateSyncTree(); |
| + ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); |
| + { |
| + PictureLayerTiling* tiling = |
| + active_layer()->tilings()->FindTilingWithScaleKey(2.25f); |
| + EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), |
| + tiling->raster_transform()); |
| + EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); |
| + for (auto* tile : tiling->AllTilesForTesting()) |
| + EXPECT_FALSE(tile->is_solid_color_analysis_performed()); |
| + } |
| +} |
| + |
| } // namespace |
| } // namespace cc |