diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/chromium/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc b/chromium/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc index ad5dbd0444a..349d4e820f4 100644 --- a/chromium/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc +++ b/chromium/third_party/blink/renderer/platform/graphics/paint/paint_chunker_test.cc @@ -11,6 +11,7 @@ #include "third_party/blink/renderer/platform/graphics/paint/drawing_display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/foreign_layer_display_item.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller_test.h" +#include "third_party/blink/renderer/platform/graphics/paint/paint_recorder.h" #include "third_party/blink/renderer/platform/testing/fake_display_item_client.h" #include "third_party/blink/renderer/platform/testing/paint_property_test_helpers.h" #include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h" @@ -39,18 +40,33 @@ class TestChunkerDisplayItem : public DrawingDisplayItem { const DisplayItemClient& client, DisplayItem::Type type = DisplayItem::kDrawingFirst, const IntRect& visual_rect = IntRect()) - : DrawingDisplayItem(client, type, visual_rect, nullptr) {} + : DrawingDisplayItem(client, + type, + visual_rect, + nullptr, + client.GetPaintInvalidationReason()) {} }; +sk_sp<const PaintRecord> OpaquePaintRecord(const IntRect& visual_rect) { + PaintRecorder recorder; + auto* canvas = recorder.beginRecording(visual_rect); + PaintFlags flags; + flags.setColor(SK_ColorBLACK); + canvas->drawRect(visual_rect, flags); + return recorder.finishRecordingAsPicture(); +} + class TestChunkerOpaqueDisplayItem : public DrawingDisplayItem { public: explicit TestChunkerOpaqueDisplayItem( const DisplayItemClient& client, DisplayItem::Type type = DisplayItem::kDrawingFirst, const IntRect& visual_rect = IntRect()) - : DrawingDisplayItem(client, type, visual_rect, nullptr) { - SetKnownToBeOpaqueForTesting(); - } + : DrawingDisplayItem(client, + type, + visual_rect, + OpaquePaintRecord(visual_rect), + client.GetPaintInvalidationReason()) {} }; class TestDisplayItemRequiringSeparateChunk : public ForeignLayerDisplayItem { @@ -60,7 +76,8 @@ class TestDisplayItemRequiringSeparateChunk : public ForeignLayerDisplayItem { : ForeignLayerDisplayItem(client, DisplayItem::kForeignLayerPlugin, cc::Layer::Create(), - IntPoint()) {} + IntPoint(), + client.GetPaintInvalidationReason()) {} }; TEST_F(PaintChunkerTest, Empty) { @@ -136,6 +153,7 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithSinglePropertyChanging) { chunker.UpdateCurrentPaintChunkProperties(&id3, another_transform); chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem(client_)); + chunker.ResetChunks(nullptr); EXPECT_THAT(chunks, ElementsAre(IsPaintChunk(0, 2, id1, DefaultPaintChunkProperties()), IsPaintChunk(2, 3, id2, simple_transform), @@ -191,6 +209,7 @@ TEST_F(PaintChunkerTest, BuildMultipleChunksWithDifferentPropertyChanges) { chunker.IncrementDisplayItemIndex(item_after_restore); chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem(client_)); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre( @@ -234,6 +253,7 @@ TEST_F(PaintChunkerTest, BuildChunksFromNestedTransforms) { TestChunkerDisplayItem item_after_restore(client_, DisplayItemType(10)); chunker.IncrementDisplayItemIndex(item_after_restore); + chunker.ResetChunks(nullptr); EXPECT_THAT(chunks, ElementsAre(IsPaintChunk(0, 1, id1, DefaultPaintChunkProperties()), IsPaintChunk(1, 3, id2, simple_transform), @@ -265,6 +285,8 @@ TEST_F(PaintChunkerTest, ChangingPropertiesWithoutItems) { chunker.UpdateCurrentPaintChunkProperties(&id3, second_transform); chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem(client_)); + + chunker.ResetChunks(nullptr); EXPECT_THAT(chunks, ElementsAre(IsPaintChunk(0, 1, id1, DefaultPaintChunkProperties()), IsPaintChunk(1, 2, id3, second_transform))); @@ -295,6 +317,7 @@ TEST_F(PaintChunkerTest, CreatesSeparateChunksWhenRequested) { DefaultPaintChunkProperties()); chunker.IncrementDisplayItemIndex(i3); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre( @@ -341,6 +364,7 @@ TEST_F(PaintChunkerTest, ForceNewChunkWithNewId) { EXPECT_FALSE(chunker.WillForceNewChunk()); chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem(client_)); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre(IsPaintChunk(0, 2, id0, DefaultPaintChunkProperties()), @@ -384,6 +408,7 @@ TEST_F(PaintChunkerTest, ForceNewChunkWithoutNewId) { chunker.IncrementDisplayItemIndex( TestChunkerDisplayItem(client_, DisplayItemType(4))); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre(IsPaintChunk(0, 2, id0, DefaultPaintChunkProperties()), @@ -412,8 +437,9 @@ TEST_F(PaintChunkerTest, SetAndImmediatelyUnSetWillForceNewChunk) { EXPECT_FALSE(chunker.WillForceNewChunk()); chunker.IncrementDisplayItemIndex( TestChunkerDisplayItem(client_, DisplayItemType(1))); - EXPECT_EQ(1u, chunks.size()); + chunker.ResetChunks(nullptr); + EXPECT_EQ(1u, chunks.size()); EXPECT_THAT(chunks, ElementsAre(IsPaintChunk(0, 3, id0, DefaultPaintChunkProperties()))); } @@ -438,6 +464,7 @@ TEST_F(PaintChunkerTest, NoNewChunkForSamePropertyDifferentIds) { chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem(client_)); chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem(client_)); + chunker.ResetChunks(nullptr); EXPECT_THAT(chunks, ElementsAre(IsPaintChunk(0, 6, id0, DefaultPaintChunkProperties()))); } @@ -466,6 +493,7 @@ TEST_F(PaintChunkerTest, ChunksFollowingForcedChunk) { chunker.IncrementDisplayItemIndex(after_forced1); chunker.IncrementDisplayItemIndex(after_forced2); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre( @@ -511,6 +539,7 @@ TEST_F(PaintChunkerTest, ChunkIdsSkippingCache) { TestChunkerDisplayItem after_restore(client_, DisplayItemType(4)); chunker.IncrementDisplayItemIndex(after_restore); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre( @@ -557,6 +586,7 @@ TEST_F(PaintChunkerTest, AddHitTestDataToCurrentChunk) { chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem( client_, DisplayItemType(5), IntRect(0, 0, 10, 10))); + chunker.ResetChunks(nullptr); HitTestData hit_test_data; hit_test_data.touch_action_rects = { {IntRect(20, 30, 40, 50), TouchAction::kPan}}; @@ -615,6 +645,7 @@ TEST_F(PaintChunkerTest, AddHitTestDataToCurrentChunkWheelRegionsEnabled) { chunker.IncrementDisplayItemIndex(TestChunkerDisplayItem( client_, DisplayItemType(5), IntRect(0, 0, 10, 10))); + chunker.ResetChunks(nullptr); HitTestData hit_test_data; hit_test_data.touch_action_rects = { {IntRect(20, 30, 40, 50), TouchAction::kPan}}; @@ -667,6 +698,7 @@ TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueAllOpaqueItems) { chunker.IncrementDisplayItemIndex(TestChunkerOpaqueDisplayItem( client3, DisplayItemType(4), IntRect(50, 50, 100, 100))); + chunker.ResetChunks(nullptr); EXPECT_THAT( chunks, ElementsAre( @@ -677,9 +709,9 @@ TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueAllOpaqueItems) { IsPaintChunk(3, 5, PaintChunk::Id(client1, DisplayItemType(3)), properties, nullptr, IntRect(0, 0, 150, 150)))); ASSERT_EQ(3u, chunks.size()); - EXPECT_TRUE(chunks[0].known_to_be_opaque); - EXPECT_TRUE(chunks[1].known_to_be_opaque); - EXPECT_FALSE(chunks[2].known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[0].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 150), chunks[1].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[2].rect_known_to_be_opaque); } TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueWithHitTest) { @@ -719,6 +751,8 @@ TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueWithHitTest) { PaintChunk::Id(client1, DisplayItemType(6)), IntRect(0, 100, 200, 100), TouchAction::kAuto, false); + chunker.ResetChunks(nullptr); + EXPECT_THAT( chunks, ElementsAre( @@ -731,10 +765,10 @@ TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueWithHitTest) { IsPaintChunk(2, 3, PaintChunk::Id(client1, DisplayItemType(5)), properties, nullptr, IntRect(0, 0, 200, 200)))); ASSERT_EQ(4u, chunks.size()); - EXPECT_FALSE(chunks[0].known_to_be_opaque); - EXPECT_TRUE(chunks[1].known_to_be_opaque); - EXPECT_TRUE(chunks[2].known_to_be_opaque); - EXPECT_FALSE(chunks[3].known_to_be_opaque); + EXPECT_EQ(IntRect(), chunks[0].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[1].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[2].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[3].rect_known_to_be_opaque); } TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueMixedOpaquenessItems) { @@ -773,7 +807,6 @@ TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueMixedOpaquenessItems) { TestChunkerDisplayItem(client2, DisplayItemType(7), visual_rect2)); chunker.ResetChunks(nullptr); - EXPECT_THAT( chunks, ElementsAre( @@ -786,10 +819,10 @@ TEST_F(PaintChunkerTest, ChunkBoundsAndKnownToBeOpaqueMixedOpaquenessItems) { IsPaintChunk(5, 7, PaintChunk::Id(client1, DisplayItemType(6)), properties, nullptr, IntRect(0, 0, 100, 100)))); ASSERT_EQ(4u, chunks.size()); - EXPECT_FALSE(chunks[0].known_to_be_opaque); - EXPECT_FALSE(chunks[1].known_to_be_opaque); - EXPECT_TRUE(chunks[2].known_to_be_opaque); - EXPECT_TRUE(chunks[3].known_to_be_opaque); + EXPECT_EQ(IntRect(), chunks[0].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(50, 50, 50, 50), chunks[1].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[2].rect_known_to_be_opaque); + EXPECT_EQ(IntRect(0, 0, 100, 100), chunks[3].rect_known_to_be_opaque); } } // namespace |