From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Xianzhu Wang Date: Thu, 6 Dec 2018 02:00:06 +0000 Subject: Backport dedab04b5256f88ec4dbbbae9492941e8cf1221a which fixes compilation error for the test files. This patch can be removed after updating to Chrome 73. diff --git a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc index 97ffe553cd1e620152126639a1589621abaad00e..771392a0137b3eeb465651a228201e4fa5fa7b8f 100644 --- a/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/display_item_raster_invalidator_test.cc @@ -8,13 +8,15 @@ #include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller_test.h" #include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h" +#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/test_paint_artifact.h" namespace blink { using ::testing::UnorderedElementsAre; -class DisplayItemRasterInvalidatorTest : public PaintControllerTestBase { +class DisplayItemRasterInvalidatorTest : public PaintControllerTestBase, + public PaintTestConfigurations { protected: DisplayItemRasterInvalidatorTest() : invalidator_([](const IntRect&) {}) {} @@ -26,6 +28,10 @@ class DisplayItemRasterInvalidatorTest : public PaintControllerTestBase { // invalidation rects. IntRect(0, 0, 20000, 20000), PropertyTreeState::Root()); GetPaintController().FinishCycle(); + if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) { + GetPaintController().ClearPropertyTreeChangedStateTo( + PropertyTreeState::Root()); + } if (invalidator_.GetTracking()) return invalidator_.GetTracking()->Invalidations(); @@ -37,7 +43,9 @@ class DisplayItemRasterInvalidatorTest : public PaintControllerTestBase { RasterInvalidator invalidator_; }; -TEST_F(DisplayItemRasterInvalidatorTest, RemoveItemInMiddle) { +INSTANTIATE_PAINT_TEST_CASE_P(DisplayItemRasterInvalidatorTest); + +TEST_P(DisplayItemRasterInvalidatorTest, RemoveItemInMiddle) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 300, 300)); FakeDisplayItemClient second("second", LayoutRect(100, 100, 200, 200)); GraphicsContext context(GetPaintController()); @@ -60,7 +68,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, RemoveItemInMiddle) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrder) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrder) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); @@ -91,7 +99,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrder) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateFirst) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateFirst) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); @@ -117,7 +125,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateFirst) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateSecond) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateSecond) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); @@ -143,7 +151,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderAndInvalidateSecond) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderWithIncrementalInvalidation) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderWithIncrementalInvalidation) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); FakeDisplayItemClient unaffected("unaffected", LayoutRect(300, 300, 10, 10)); @@ -171,7 +179,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderWithIncrementalInvalidation) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, NewItemInMiddle) { +TEST_P(DisplayItemRasterInvalidatorTest, NewItemInMiddle) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient second("second", LayoutRect(100, 100, 50, 200)); FakeDisplayItemClient third("third", LayoutRect(125, 100, 200, 50)); @@ -195,7 +203,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, NewItemInMiddle) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, Incremental) { +TEST_P(DisplayItemRasterInvalidatorTest, Incremental) { LayoutRect initial_rect(100, 100, 100, 100); std::unique_ptr clients[6]; for (size_t i = 0; i < base::size(clients); i++) { @@ -259,7 +267,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, Incremental) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, AddRemoveFirstAndInvalidateSecond) { +TEST_P(DisplayItemRasterInvalidatorTest, AddRemoveFirstAndInvalidateSecond) { FakeDisplayItemClient chunk("chunk"); FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); @@ -304,7 +312,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, AddRemoveFirstAndInvalidateSecond) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, InvalidateFirstAndAddRemoveSecond) { +TEST_P(DisplayItemRasterInvalidatorTest, InvalidateFirstAndAddRemoveSecond) { FakeDisplayItemClient first("first", LayoutRect(100, 100, 150, 150)); FakeDisplayItemClient second("second", LayoutRect(200, 200, 50, 50)); GraphicsContext context(GetPaintController()); @@ -351,7 +359,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, InvalidateFirstAndAddRemoveSecond) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderWithChildren) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderWithChildren) { FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); @@ -395,7 +403,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderWithChildren) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderWithChildrenAndInvalidation) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderWithChildrenAndInvalidation) { FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); @@ -443,7 +451,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderWithChildrenAndInvalidation) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderCrossingChunks) { +TEST_P(DisplayItemRasterInvalidatorTest, SwapOrderCrossingChunks) { FakeDisplayItemClient container1("container1", LayoutRect(100, 100, 100, 100)); FakeDisplayItemClient content1("content1", LayoutRect(100, 100, 50, 200)); @@ -492,7 +500,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SwapOrderCrossingChunks) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, SkipCache) { +TEST_P(DisplayItemRasterInvalidatorTest, SkipCache) { FakeDisplayItemClient multicol("multicol", LayoutRect(100, 100, 200, 200)); FakeDisplayItemClient content("content", LayoutRect(100, 100, 100, 100)); GraphicsContext context(GetPaintController()); @@ -549,7 +557,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, SkipCache) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, PartialSkipCache) { +TEST_P(DisplayItemRasterInvalidatorTest, PartialSkipCache) { FakeDisplayItemClient content("content", LayoutRect(100, 100, 250, 250)); GraphicsContext context(GetPaintController()); @@ -581,7 +589,7 @@ TEST_F(DisplayItemRasterInvalidatorTest, PartialSkipCache) { invalidator_.SetTracksRasterInvalidations(false); } -TEST_F(DisplayItemRasterInvalidatorTest, Partial) { +TEST_P(DisplayItemRasterInvalidatorTest, Partial) { FakeDisplayItemClient client("client", LayoutRect(100, 100, 300, 300)); GraphicsContext context(GetPaintController()); diff --git a/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc b/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc index 13cbaaab2ea04726d0a2461fbd8e78e865443ce4..6a7e25139ad4848e14cb1548105eff2cdfdb94a1 100644 --- a/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc +++ b/third_party/blink/renderer/platform/graphics/paint/raster_invalidator_test.cc @@ -8,13 +8,15 @@ #include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_artifact.h" #include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h" +#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/test_paint_artifact.h" namespace blink { static const IntRect kDefaultLayerBounds(-9999, -7777, 18888, 16666); -class RasterInvalidatorTest : public testing::Test { +class RasterInvalidatorTest : public testing::Test, + public PaintTestConfigurations { public: static PropertyTreeState DefaultPropertyTreeState() { return PropertyTreeState::Root(); @@ -31,6 +33,11 @@ class RasterInvalidatorTest : public testing::Test { void FinishCycle(PaintArtifact& artifact) { artifact.FinishCycle(); ClearGeometryMapperCache(); + if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled()) { + // See PaintArtifact::FinishCycle() for the reason of doing this. + for (auto& chunk : artifact.PaintChunks()) + chunk.properties.ClearChangedToRoot(); + } } static const Vector TrackedRasterInvalidations( @@ -54,6 +61,8 @@ class RasterInvalidatorTest : public testing::Test { [](const IntRect& rect) {}; }; +INSTANTIATE_PAINT_TEST_CASE_P(RasterInvalidatorTest); + #define EXPECT_CHUNK_INVALIDATION_CUSTOM( \ invalidations, index, chunk, expected_reason, layer_offset, mapper) \ do { \ @@ -78,7 +87,7 @@ class RasterInvalidatorTest : public testing::Test { EXPECT_EQ(PaintInvalidationReason::kIncremental, info.reason); \ } while (false) -TEST_F(RasterInvalidatorTest, ImplicitFullLayerInvalidation) { +TEST_P(RasterInvalidatorTest, ImplicitFullLayerInvalidation) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Build(); @@ -94,7 +103,7 @@ TEST_F(RasterInvalidatorTest, ImplicitFullLayerInvalidation) { invalidator.SetTracksRasterInvalidations(false); } -TEST_F(RasterInvalidatorTest, LayerBounds) { +TEST_P(RasterInvalidatorTest, LayerBounds) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Build(); @@ -122,7 +131,7 @@ TEST_F(RasterInvalidatorTest, LayerBounds) { FinishCycle(*artifact); } -TEST_F(RasterInvalidatorTest, ReorderChunks) { +TEST_P(RasterInvalidatorTest, ReorderChunks) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Build(); invalidator.Generate(artifact, kDefaultLayerBounds, @@ -150,7 +159,7 @@ TEST_F(RasterInvalidatorTest, ReorderChunks) { FinishCycle(*new_artifact); } -TEST_F(RasterInvalidatorTest, ReorderChunkSubsequences) { +TEST_P(RasterInvalidatorTest, ReorderChunkSubsequences) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Chunk(3).Chunk(4).Build(); @@ -185,7 +194,7 @@ TEST_F(RasterInvalidatorTest, ReorderChunkSubsequences) { FinishCycle(*new_artifact); } -TEST_F(RasterInvalidatorTest, ChunkAppearAndDisappear) { +TEST_P(RasterInvalidatorTest, ChunkAppearAndDisappear) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Chunk(2).Build(); invalidator.Generate(artifact, kDefaultLayerBounds, @@ -210,7 +219,7 @@ TEST_F(RasterInvalidatorTest, ChunkAppearAndDisappear) { FinishCycle(*new_artifact); } -TEST_F(RasterInvalidatorTest, ChunkAppearAtEnd) { +TEST_P(RasterInvalidatorTest, ChunkAppearAtEnd) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Build(); invalidator.Generate(artifact, kDefaultLayerBounds, @@ -230,7 +239,7 @@ TEST_F(RasterInvalidatorTest, ChunkAppearAtEnd) { FinishCycle(*new_artifact); } -TEST_F(RasterInvalidatorTest, UncacheableChunks) { +TEST_P(RasterInvalidatorTest, UncacheableChunks) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto artifact = TestPaintArtifact().Chunk(0).Chunk(1).Uncacheable().Chunk(2).Build(); @@ -254,7 +263,7 @@ TEST_F(RasterInvalidatorTest, UncacheableChunks) { } // Tests the path based on ClipPaintPropertyNode::Changed(). -TEST_F(RasterInvalidatorTest, ClipPropertyChangeRounded) { +TEST_P(RasterInvalidatorTest, ClipPropertyChangeRounded) { RasterInvalidator invalidator(kNoopRasterInvalidation); FloatRoundedRect::Radii radii(FloatSize(1, 2), FloatSize(2, 3), FloatSize(3, 4), FloatSize(4, 5)); @@ -316,7 +325,7 @@ TEST_F(RasterInvalidatorTest, ClipPropertyChangeRounded) { } // Tests the path detecting change of PaintChunkInfo::chunk_to_layer_clip. -TEST_F(RasterInvalidatorTest, ClipPropertyChangeSimple) { +TEST_P(RasterInvalidatorTest, ClipPropertyChangeSimple) { RasterInvalidator invalidator(kNoopRasterInvalidation); FloatRoundedRect clip_rect(-1000, -1000, 2000, 2000); auto clip0 = CreateClip(c0(), &t0(), clip_rect); @@ -385,7 +394,7 @@ TEST_F(RasterInvalidatorTest, ClipPropertyChangeSimple) { FinishCycle(*artifact); } -TEST_F(RasterInvalidatorTest, ClipLocalTransformSpaceChange) { +TEST_P(RasterInvalidatorTest, ClipLocalTransformSpaceChange) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto t1 = CreateTransform(t0(), TransformationMatrix()); @@ -422,7 +431,7 @@ TEST_F(RasterInvalidatorTest, ClipLocalTransformSpaceChange) { // This is based on ClipLocalTransformSpaceChange, but tests the no-invalidation // path by letting the clip's LocalTransformSpace be the same as the chunk's // transform. -TEST_F(RasterInvalidatorTest, ClipLocalTransformSpaceChangeNoInvalidation) { +TEST_P(RasterInvalidatorTest, ClipLocalTransformSpaceChangeNoInvalidation) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto t1 = CreateTransform(t0(), TransformationMatrix()); @@ -453,7 +462,7 @@ TEST_F(RasterInvalidatorTest, ClipLocalTransformSpaceChangeNoInvalidation) { FinishCycle(*artifact); } -TEST_F(RasterInvalidatorTest, TransformPropertyChange) { +TEST_P(RasterInvalidatorTest, TransformPropertyChange) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto layer_transform = CreateTransform(t0(), TransformationMatrix().Scale(5)); @@ -534,7 +543,7 @@ TEST_F(RasterInvalidatorTest, TransformPropertyChange) { FinishCycle(*artifact); } -TEST_F(RasterInvalidatorTest, TransformPropertyTinyChange) { +TEST_P(RasterInvalidatorTest, TransformPropertyTinyChange) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto layer_transform = CreateTransform(t0(), TransformationMatrix().Scale(5)); @@ -580,7 +589,7 @@ TEST_F(RasterInvalidatorTest, TransformPropertyTinyChange) { EXPECT_TRUE(invalidated); } -TEST_F(RasterInvalidatorTest, TransformPropertyTinyChangeScale) { +TEST_P(RasterInvalidatorTest, TransformPropertyTinyChangeScale) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto layer_transform = CreateTransform(t0(), TransformationMatrix().Scale(5)); @@ -621,7 +630,7 @@ TEST_F(RasterInvalidatorTest, TransformPropertyTinyChangeScale) { FinishCycle(*artifact); } -TEST_F(RasterInvalidatorTest, EffectLocalTransformSpaceChange) { +TEST_P(RasterInvalidatorTest, EffectLocalTransformSpaceChange) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto t1 = CreateTransform(t0(), TransformationMatrix()); @@ -659,7 +668,7 @@ TEST_F(RasterInvalidatorTest, EffectLocalTransformSpaceChange) { // This is based on EffectLocalTransformSpaceChange, but tests the no- // invalidation path by letting the effect's LocalTransformSpace be the same as // the chunk's transform. -TEST_F(RasterInvalidatorTest, EffectLocalTransformSpaceChangeNoInvalidation) { +TEST_P(RasterInvalidatorTest, EffectLocalTransformSpaceChangeNoInvalidation) { RasterInvalidator invalidator(kNoopRasterInvalidation); auto t1 = CreateTransform(t0(), TransformationMatrix());