OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/picture_layer_impl.h" | 5 #include "cc/layers/picture_layer_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <limits> | 10 #include <limits> |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 FakeRasterSource::CreateFilled(layer_bounds); | 410 FakeRasterSource::CreateFilled(layer_bounds); |
411 scoped_refptr<FakeRasterSource> active_raster_source = | 411 scoped_refptr<FakeRasterSource> active_raster_source = |
412 FakeRasterSource::CreateFilled(layer_bounds); | 412 FakeRasterSource::CreateFilled(layer_bounds); |
413 scoped_refptr<FakeRasterSource> lost_raster_source = | 413 scoped_refptr<FakeRasterSource> lost_raster_source = |
414 FakeRasterSource::CreateFilled(layer_bounds); | 414 FakeRasterSource::CreateFilled(layer_bounds); |
415 | 415 |
416 SetupPendingTreeWithFixedTileSize(lost_raster_source, gfx::Size(50, 50), | 416 SetupPendingTreeWithFixedTileSize(lost_raster_source, gfx::Size(50, 50), |
417 Region()); | 417 Region()); |
418 ActivateTree(); | 418 ActivateTree(); |
419 // Add a unique tiling on the active tree. | 419 // Add a unique tiling on the active tree. |
420 PictureLayerTiling* tiling = active_layer()->AddTiling(3.f); | 420 PictureLayerTiling* tiling = |
421 active_layer()->AddTiling(ScaleTranslate2d(3.f, gfx::Vector2dF())); | |
421 tiling->set_resolution(HIGH_RESOLUTION); | 422 tiling->set_resolution(HIGH_RESOLUTION); |
422 tiling->CreateAllTilesForTesting(); | 423 tiling->CreateAllTilesForTesting(); |
423 | 424 |
424 // Ensure UpdateTiles won't remove any tilings. | 425 // Ensure UpdateTiles won't remove any tilings. |
425 active_layer()->MarkAllTilingsUsed(); | 426 active_layer()->MarkAllTilingsUsed(); |
426 | 427 |
427 // Then setup a new pending tree and activate it. | 428 // Then setup a new pending tree and activate it. |
428 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, | 429 SetupTreesWithFixedTileSize(pending_raster_source, active_raster_source, |
429 gfx::Size(50, 50), layer_invalidation); | 430 gfx::Size(50, 50), layer_invalidation); |
430 | 431 |
(...skipping 3491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3922 pending_layer()->test_properties()->AddChild( | 3923 pending_layer()->test_properties()->AddChild( |
3923 LayerImpl::Create(host_impl()->pending_tree(), 1)); | 3924 LayerImpl::Create(host_impl()->pending_tree(), 1)); |
3924 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; | 3925 LayerImpl* layer1 = pending_layer()->test_properties()->children[0]; |
3925 layer1->SetBounds(layer_bounds); | 3926 layer1->SetBounds(layer_bounds); |
3926 layer1->SetDrawsContent(true); | 3927 layer1->SetDrawsContent(true); |
3927 layer1->SetContentsOpaque(true); | 3928 layer1->SetContentsOpaque(true); |
3928 layer1->SetPosition(occluding_layer_position); | 3929 layer1->SetPosition(occluding_layer_position); |
3929 | 3930 |
3930 pending_layer()->tilings()->RemoveAllTilings(); | 3931 pending_layer()->tilings()->RemoveAllTilings(); |
3931 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; | 3932 float low_res_factor = host_impl()->settings().low_res_contents_scale_factor; |
3932 pending_layer()->AddTiling(low_res_factor)->set_resolution(LOW_RESOLUTION); | 3933 pending_layer() |
3933 pending_layer()->AddTiling(0.3f)->set_resolution(HIGH_RESOLUTION); | 3934 ->AddTiling(ScaleTranslate2d(low_res_factor, gfx::Vector2dF())) |
3934 pending_layer()->AddTiling(0.7f)->set_resolution(HIGH_RESOLUTION); | 3935 ->set_resolution(LOW_RESOLUTION); |
3935 pending_layer()->AddTiling(1.0f)->set_resolution(HIGH_RESOLUTION); | 3936 pending_layer() |
3936 pending_layer()->AddTiling(2.0f)->set_resolution(HIGH_RESOLUTION); | 3937 ->AddTiling(ScaleTranslate2d(0.3f, gfx::Vector2dF())) |
3938 ->set_resolution(HIGH_RESOLUTION); | |
3939 pending_layer() | |
3940 ->AddTiling(ScaleTranslate2d(0.7f, gfx::Vector2dF())) | |
3941 ->set_resolution(HIGH_RESOLUTION); | |
3942 pending_layer() | |
3943 ->AddTiling(ScaleTranslate2d(1.0f, gfx::Vector2dF())) | |
3944 ->set_resolution(HIGH_RESOLUTION); | |
3945 pending_layer() | |
3946 ->AddTiling(ScaleTranslate2d(2.0f, gfx::Vector2dF())) | |
3947 ->set_resolution(HIGH_RESOLUTION); | |
3937 | 3948 |
3938 RebuildPropertyTreesOnPendingTree(); | 3949 RebuildPropertyTreesOnPendingTree(); |
3939 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); | 3950 host_impl()->AdvanceToNextFrame(base::TimeDelta::FromMilliseconds(1)); |
3940 // UpdateDrawProperties with the occluding layer. | 3951 // UpdateDrawProperties with the occluding layer. |
3941 bool update_lcd_text = false; | 3952 bool update_lcd_text = false; |
3942 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); | 3953 host_impl()->pending_tree()->UpdateDrawProperties(update_lcd_text); |
3943 | 3954 |
3944 EXPECT_EQ(5u, pending_layer()->num_tilings()); | 3955 EXPECT_EQ(5u, pending_layer()->num_tilings()); |
3945 | 3956 |
3946 int occluded_tile_count = 0; | 3957 int occluded_tile_count = 0; |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4968 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, | 4979 SetupDrawPropertiesAndUpdateTiles(pending_layer_ptr, ideal_contents_scale, |
4969 1.f, 1.f, 1.f, 1.f, false); | 4980 1.f, 1.f, 1.f, 1.f, false); |
4970 EXPECT_FLOAT_EQ(expected_contents_scale, | 4981 EXPECT_FLOAT_EQ(expected_contents_scale, |
4971 pending_layer_ptr->picture_layer_tiling_set() | 4982 pending_layer_ptr->picture_layer_tiling_set() |
4972 ->FindTilingWithResolution(HIGH_RESOLUTION) | 4983 ->FindTilingWithResolution(HIGH_RESOLUTION) |
4973 ->contents_scale_key()) | 4984 ->contents_scale_key()) |
4974 << "ideal_contents_scale: " << ideal_contents_scale; | 4985 << "ideal_contents_scale: " << ideal_contents_scale; |
4975 } | 4986 } |
4976 } | 4987 } |
4977 | 4988 |
4989 TEST_F(PictureLayerImplTest, ChangeRasterTranslationNukePendingLayerTiles) { | |
4990 gfx::Size layer_bounds(200, 200); | |
4991 gfx::Size tile_size(256, 256); | |
4992 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | |
4993 pending_layer()->SetUseTransformedRasterization(true); | |
4994 | |
4995 // Start with scale & translation of * 2.25 + (0.25, 0.5). | |
4996 SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); | |
4997 gfx::Transform translate1; | |
4998 translate1.Translate(0.25f, 0.5f); | |
4999 pending_layer()->draw_properties().screen_space_transform.ConcatTransform( | |
5000 translate1); | |
5001 pending_layer()->draw_properties().target_space_transform = | |
5002 pending_layer()->draw_properties().screen_space_transform; | |
5003 pending_layer()->UpdateTiles(); | |
5004 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | |
5005 { | |
5006 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); | |
5007 EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.25f, 0.5f)), | |
5008 tiling->raster_transform()); | |
5009 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | |
5010 // 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
| |
5011 for (auto* tile : tiling->AllTilesForTesting()) | |
5012 tile->set_solid_color_analysis_performed(true); | |
5013 } | |
5014 | |
5015 // Change to scale & translation of * 2.25 + (0.75, 0.25). | |
5016 // Verifies there is a hysteresis that simple layer movement doesn't update | |
5017 // raster translation. | |
5018 SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); | |
5019 gfx::Transform translate2; | |
5020 translate2.Translate(0.75f, 0.25f); | |
5021 pending_layer()->draw_properties().screen_space_transform.ConcatTransform( | |
5022 translate2); | |
5023 pending_layer()->draw_properties().target_space_transform = | |
5024 pending_layer()->draw_properties().screen_space_transform; | |
5025 pending_layer()->UpdateTiles(); | |
5026 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | |
5027 { | |
5028 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); | |
5029 EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.25f, 0.5f)), | |
5030 tiling->raster_transform()); | |
5031 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | |
5032 for (auto* tile : tiling->AllTilesForTesting()) | |
5033 EXPECT_TRUE(tile->is_solid_color_analysis_performed()); | |
5034 } | |
5035 | |
5036 // Now change the device scale factor but keep the same total scale. | |
5037 // 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.
| |
5038 SetupDrawProperties(pending_layer(), 2.25f, 1.0f, 1.f, 2.25f, 2.25f, false); | |
5039 pending_layer()->draw_properties().screen_space_transform.ConcatTransform( | |
5040 translate2); | |
5041 pending_layer()->draw_properties().target_space_transform = | |
5042 pending_layer()->draw_properties().screen_space_transform; | |
5043 pending_layer()->UpdateTiles(); | |
5044 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | |
5045 { | |
5046 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); | |
5047 EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), | |
5048 tiling->raster_transform()); | |
5049 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | |
5050 for (auto* tile : tiling->AllTilesForTesting()) | |
5051 EXPECT_FALSE(tile->is_solid_color_analysis_performed()); | |
5052 } | |
5053 } | |
5054 | |
5055 TEST_F(PictureLayerImplTest, ChangeRasterTranslationNukeActiveLayerTiles) { | |
5056 gfx::Size layer_bounds(200, 200); | |
5057 gfx::Size tile_size(256, 256); | |
5058 SetupDefaultTreesWithFixedTileSize(layer_bounds, tile_size, Region()); | |
5059 active_layer()->SetUseTransformedRasterization(true); | |
5060 pending_layer()->SetUseTransformedRasterization(true); | |
5061 | |
5062 // Start with scale & translation of * 2.25 + (0.25, 0.5) on the active layer. | |
5063 SetupDrawProperties(active_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); | |
5064 gfx::Transform translate1; | |
5065 translate1.Translate(0.25f, 0.5f); | |
5066 active_layer()->draw_properties().screen_space_transform.ConcatTransform( | |
5067 translate1); | |
5068 active_layer()->draw_properties().target_space_transform = | |
5069 active_layer()->draw_properties().screen_space_transform; | |
5070 active_layer()->UpdateTiles(); | |
5071 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | |
5072 { | |
5073 PictureLayerTiling* tiling = | |
5074 active_layer()->tilings()->FindTilingWithScaleKey(2.25f); | |
5075 EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.25f, 0.5f)), | |
5076 tiling->raster_transform()); | |
5077 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | |
5078 // Mark some arbitrary flags on the tiles for later checking. | |
5079 for (auto* tile : tiling->AllTilesForTesting()) | |
5080 tile->set_solid_color_analysis_performed(true); | |
5081 } | |
5082 | |
5083 // Create a pending layer with the same scale but different translation. | |
5084 SetupDrawProperties(pending_layer(), 2.25f, 1.5f, 1.f, 2.25f, 2.25f, false); | |
5085 gfx::Transform translate2; | |
5086 translate2.Translate(0.75f, 0.25f); | |
5087 pending_layer()->draw_properties().screen_space_transform.ConcatTransform( | |
5088 translate2); | |
5089 pending_layer()->draw_properties().target_space_transform = | |
5090 pending_layer()->draw_properties().screen_space_transform; | |
5091 pending_layer()->UpdateTiles(); | |
5092 ASSERT_EQ(1u, pending_layer()->tilings()->num_tilings()); | |
5093 { | |
5094 PictureLayerTiling* tiling = pending_layer()->tilings()->tiling_at(0); | |
5095 EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), | |
5096 tiling->raster_transform()); | |
5097 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | |
5098 } | |
5099 | |
5100 // Now push to the active layer. | |
5101 // 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.
| |
5102 host_impl()->ActivateSyncTree(); | |
5103 ASSERT_EQ(3u, active_layer()->tilings()->num_tilings()); | |
5104 { | |
5105 PictureLayerTiling* tiling = | |
5106 active_layer()->tilings()->FindTilingWithScaleKey(2.25f); | |
5107 EXPECT_EQ(ScaleTranslate2d(2.25f, gfx::Vector2dF(0.75f, 0.25f)), | |
5108 tiling->raster_transform()); | |
5109 EXPECT_EQ(4u, tiling->AllTilesForTesting().size()); | |
5110 for (auto* tile : tiling->AllTilesForTesting()) | |
5111 EXPECT_FALSE(tile->is_solid_color_analysis_performed()); | |
5112 } | |
5113 } | |
5114 | |
4978 } // namespace | 5115 } // namespace |
4979 } // namespace cc | 5116 } // namespace cc |
OLD | NEW |