diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 10:22:43 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:36:28 +0000 |
commit | 271a6c3487a14599023a9106329505597638d793 (patch) | |
tree | e040d58ffc86c1480b79ca8528020ca9ec919bf8 /chromium/cc/trees/layer_tree_impl_unittest.cc | |
parent | 7b2ffa587235a47d4094787d72f38102089f402a (diff) |
BASELINE: Update Chromium to 77.0.3865.59
Change-Id: I1e89a5f3b009a9519a6705102ad65c92fe736f21
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/cc/trees/layer_tree_impl_unittest.cc')
-rw-r--r-- | chromium/cc/trees/layer_tree_impl_unittest.cc | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/chromium/cc/trees/layer_tree_impl_unittest.cc b/chromium/cc/trees/layer_tree_impl_unittest.cc index 4dc46346a58..11d6bbc38d7 100644 --- a/chromium/cc/trees/layer_tree_impl_unittest.cc +++ b/chromium/cc/trees/layer_tree_impl_unittest.cc @@ -6,6 +6,7 @@ #include "cc/layers/heads_up_display_layer_impl.h" #include "cc/test/fake_layer_tree_host_impl.h" +#include "cc/test/fake_raster_source.h" #include "cc/test/geometry_test_utils.h" #include "cc/test/layer_test_common.h" #include "cc/trees/clip_node.h" @@ -18,17 +19,10 @@ namespace cc { namespace { -class LayerTreeImplTestSettings : public LayerTreeSettings { - public: - LayerTreeImplTestSettings() { - layer_transforms_should_scale_layer_contents = true; - } -}; - class LayerTreeImplTest : public testing::Test { public: - LayerTreeImplTest( - const LayerTreeSettings& settings = LayerTreeImplTestSettings()) + explicit LayerTreeImplTest( + const LayerTreeSettings& settings = LayerTreeSettings()) : impl_test_(settings) {} FakeLayerTreeHostImpl& host_impl() const { return *impl_test_.host_impl(); } @@ -47,7 +41,6 @@ class LayerTreeImplTest : public testing::Test { render_surface_list_impl_.clear(); LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( root_layer, root_layer->bounds(), &render_surface_list_impl_); - inputs.can_adjust_raster_scales = true; LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); } @@ -2468,6 +2461,61 @@ TEST_F(LayerTreeImplTest, NotPersistentSwapPromisesAreDroppedWhenSwapFails) { } } +TEST_F(LayerTreeImplTest, TrackPictureLayersWithPaintWorklets) { + host_impl().CreatePendingTree(); + LayerTreeImpl* pending_tree = host_impl().pending_tree(); + + // Initially there are no layers in the set. + EXPECT_EQ(pending_tree->picture_layers_with_paint_worklets().size(), 0u); + + // Add three layers; two with PaintWorklets and one without. + std::unique_ptr<PictureLayerImpl> child1_owned = + PictureLayerImpl::Create(pending_tree, 2, Layer::LayerMaskType::NOT_MASK); + child1_owned->SetBounds(gfx::Size(100, 100)); + std::unique_ptr<PictureLayerImpl> child2_owned = + PictureLayerImpl::Create(pending_tree, 3, Layer::LayerMaskType::NOT_MASK); + child2_owned->SetBounds(gfx::Size(100, 100)); + std::unique_ptr<PictureLayerImpl> child3_owned = + PictureLayerImpl::Create(pending_tree, 4, Layer::LayerMaskType::NOT_MASK); + child3_owned->SetBounds(gfx::Size(100, 100)); + + PictureLayerImpl* child1 = child1_owned.get(); + PictureLayerImpl* child3 = child3_owned.get(); + + root_layer()->test_properties()->AddChild(std::move(child1_owned)); + root_layer()->test_properties()->AddChild(std::move(child2_owned)); + root_layer()->test_properties()->AddChild(std::move(child3_owned)); + + Region empty_invalidation; + scoped_refptr<RasterSource> raster_source1( + FakeRasterSource::CreateFilledWithPaintWorklet(child1->bounds())); + child1->UpdateRasterSource(raster_source1, &empty_invalidation, nullptr, + nullptr); + scoped_refptr<RasterSource> raster_source3( + FakeRasterSource::CreateFilledWithPaintWorklet(child3->bounds())); + child3->UpdateRasterSource(raster_source3, &empty_invalidation, nullptr, + nullptr); + + // The set should correctly track which layers are in it. + const base::flat_set<PictureLayerImpl*>& layers = + pending_tree->picture_layers_with_paint_worklets(); + EXPECT_EQ(layers.size(), 2u); + EXPECT_TRUE(layers.contains(child1)); + EXPECT_TRUE(layers.contains(child3)); + + // Test explicitly removing a layer from the set. + scoped_refptr<RasterSource> empty_raster_source( + FakeRasterSource::CreateFilled(child1->bounds())); + child1->UpdateRasterSource(empty_raster_source, &empty_invalidation, nullptr, + nullptr); + EXPECT_EQ(layers.size(), 1u); + EXPECT_FALSE(layers.contains(child1)); + + // Deleting a layer should also cause it to be removed from the set. + root_layer()->test_properties()->RemoveChild(child3); + EXPECT_EQ(layers.size(), 0u); +} + namespace { class CommitToPendingTreeLayerTreeImplTestSettings : public LayerTreeSettings { public: |