diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-16 11:45:35 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-07-17 08:59:23 +0000 |
commit | 552906b0f222c5d5dd11b9fd73829d510980461a (patch) | |
tree | 3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc | |
parent | 1b05827804eaf047779b597718c03e7d38344261 (diff) | |
download | qtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz |
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc | 189 |
1 files changed, 101 insertions, 88 deletions
diff --git a/chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc b/chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc index 098e3f3182e..cacaa2c7a95 100644 --- a/chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc +++ b/chromium/third_party/blink/renderer/platform/graphics/paint/paint_controller_test.cc @@ -565,7 +565,7 @@ TEST_P(PaintControllerTest, CachedSubsequenceForcePaintChunk) { FakeDisplayItemClient root("root"); auto root_properties = DefaultPaintChunkProperties(); PaintChunk::Id root_id(root, DisplayItem::kCaret); - GetPaintController().UpdateCurrentPaintChunkProperties(root_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&root_id, root_properties); DrawRect(context, root, kBackgroundType, FloatRect(100, 100, 100, 100)); @@ -575,7 +575,7 @@ TEST_P(PaintControllerTest, CachedSubsequenceForcePaintChunk) { { SubsequenceRecorder r(context, container); GetPaintController().UpdateCurrentPaintChunkProperties( - container_id, container_properties); + &container_id, container_properties); DrawRect(context, container, kBackgroundType, FloatRect(100, 100, 100, 100)); DrawRect(context, container, kForegroundType, @@ -595,7 +595,7 @@ TEST_P(PaintControllerTest, CachedSubsequenceForcePaintChunk) { IsPaintChunk(3, 4, PaintChunk::Id(root, kForegroundType), root_properties))); - GetPaintController().UpdateCurrentPaintChunkProperties(root_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&root_id, root_properties); DrawRect(context, root, kBackgroundType, FloatRect(100, 100, 100, 100)); EXPECT_TRUE(GetPaintController().UseCachedSubsequenceIfPossible(container)); @@ -631,7 +631,7 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { { GetPaintController().UpdateCurrentPaintChunkProperties( - container1_id, container1_properties); + &container1_id, container1_properties); SubsequenceRecorder r(context, container1); DrawRect(context, container1, kBackgroundType, @@ -643,7 +643,7 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { } { GetPaintController().UpdateCurrentPaintChunkProperties( - container2_id, container2_properties); + &container2_id, container2_properties); SubsequenceRecorder r(context, container2); DrawRect(context, container2, kBackgroundType, @@ -666,15 +666,10 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { IsSameId(&content2, kForegroundType), IsSameId(&container2, kForegroundType))); - auto* markers = GetSubsequenceMarkers(container1); - CHECK(markers); - EXPECT_EQ(0u, markers->start); - EXPECT_EQ(4u, markers->end); - - markers = GetSubsequenceMarkers(container2); - CHECK(markers); - EXPECT_EQ(4u, markers->start); - EXPECT_EQ(8u, markers->end); + EXPECT_SUBSEQUENCE(container1, 0, 1); + EXPECT_NO_SUBSEQUENCE(content1); + EXPECT_SUBSEQUENCE(container2, 1, 2); + EXPECT_NO_SUBSEQUENCE(content2); EXPECT_THAT( GetPaintController().PaintChunks(), @@ -685,13 +680,13 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { // than that of |container2|. if (RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled()) { // When under-invalidation-checking is enabled, - // useCachedSubsequenceIfPossible is forced off, and the client is expected + // UseCachedSubsequenceIfPossible is forced off, and the client is expected // to create the same painting as in the previous paint. EXPECT_FALSE(SubsequenceRecorder::UseCachedSubsequenceIfPossible( context, container2)); { GetPaintController().UpdateCurrentPaintChunkProperties( - container2_id, container2_properties); + &container2_id, container2_properties); SubsequenceRecorder r(context, container2); DrawRect(context, container2, kBackgroundType, @@ -707,7 +702,7 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { context, container1)); { GetPaintController().UpdateCurrentPaintChunkProperties( - container1_id, container1_properties); + &container1_id, container1_properties); SubsequenceRecorder r(context, container1); DrawRect(context, container1, kBackgroundType, @@ -746,15 +741,10 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { IsSameId(&content1, kForegroundType), IsSameId(&container1, kForegroundType))); - markers = GetSubsequenceMarkers(container2); - CHECK(markers); - EXPECT_EQ(0u, markers->start); - EXPECT_EQ(4u, markers->end); - - markers = GetSubsequenceMarkers(container1); - CHECK(markers); - EXPECT_EQ(4u, markers->start); - EXPECT_EQ(8u, markers->end); + EXPECT_SUBSEQUENCE(container1, 1, 2); + EXPECT_NO_SUBSEQUENCE(content1); + EXPECT_SUBSEQUENCE(container2, 0, 1); + EXPECT_NO_SUBSEQUENCE(content2); EXPECT_THAT( GetPaintController().PaintChunks(), @@ -763,12 +753,15 @@ TEST_P(PaintControllerTest, CachedSubsequenceSwapOrder) { } TEST_P(PaintControllerTest, CachedSubsequenceAndDisplayItemsSwapOrder) { - FakeDisplayItemClient root("root", IntRect(0, 0, 300, 300)); FakeDisplayItemClient content1("content1", IntRect(100, 100, 50, 200)); FakeDisplayItemClient container2("container2", IntRect(100, 200, 100, 100)); FakeDisplayItemClient content2("content2", IntRect(100, 200, 50, 200)); GraphicsContext context(GetPaintController()); + PaintChunk::Id content1_id(content1, kBackgroundType); + PaintChunk::Id container2_id(container2, kBackgroundType); + PaintChunk::Id content2_id(content2, kBackgroundType); + InitRootChunk(); DrawRect(context, content1, kBackgroundType, FloatRect(100, 100, 50, 200)); @@ -792,17 +785,26 @@ TEST_P(PaintControllerTest, CachedSubsequenceAndDisplayItemsSwapOrder) { IsSameId(&container2, kForegroundType), IsSameId(&content1, kForegroundType))); - auto* markers = GetSubsequenceMarkers(container2); - CHECK(markers); - EXPECT_EQ(1u, markers->start); - EXPECT_EQ(5u, markers->end); + EXPECT_NO_SUBSEQUENCE(content1); + EXPECT_SUBSEQUENCE(container2, 1, 2); + EXPECT_NO_SUBSEQUENCE(content2); + + EXPECT_THAT( + GetPaintController().PaintChunks(), + ElementsAre( + IsPaintChunk(0, 1, DefaultRootChunkId(), + DefaultPaintChunkProperties()), + IsPaintChunk(1, 5, PaintChunk::Id(container2, kBackgroundType), + DefaultPaintChunkProperties()), + IsPaintChunk(5, 6, PaintChunk::Id(content1, kForegroundType), + DefaultPaintChunkProperties()))); // Simulate the situation when |container2| gets a z-index that is smaller // than that of |content1|. InitRootChunk(); if (RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled()) { // When under-invalidation-checking is enabled, - // useCachedSubsequenceIfPossible is forced off, and the client is expected + // UseCachedSubsequenceIfPossible is forced off, and the client is expected // to create the same painting as in the previous paint. EXPECT_FALSE(SubsequenceRecorder::UseCachedSubsequenceIfPossible( context, container2)); @@ -846,22 +848,29 @@ TEST_P(PaintControllerTest, CachedSubsequenceAndDisplayItemsSwapOrder) { IsSameId(&content1, kBackgroundType), IsSameId(&content1, kForegroundType))); - markers = GetSubsequenceMarkers(container2); - CHECK(markers); - EXPECT_EQ(0u, markers->start); - EXPECT_EQ(4u, markers->end); + EXPECT_NO_SUBSEQUENCE(content1); + EXPECT_SUBSEQUENCE(container2, 0, 1); + EXPECT_NO_SUBSEQUENCE(content2); + + EXPECT_THAT( + GetPaintController().PaintChunks(), + ElementsAre( + IsPaintChunk(0, 4, PaintChunk::Id(container2, kBackgroundType), + DefaultPaintChunkProperties()), + IsPaintChunk(4, 6, PaintChunk::Id(content1, kBackgroundType), + DefaultPaintChunkProperties()))); } TEST_P(PaintControllerTest, CachedSubsequenceContainingFragments) { GraphicsContext context(GetPaintController()); FakeDisplayItemClient root("root"); - constexpr size_t kFragmentCount = 3; + constexpr wtf_size_t kFragmentCount = 3; FakeDisplayItemClient container("container"); // The first paint. auto paint_container = [this, &context, &container]() { SubsequenceRecorder r(context, container); - for (size_t i = 0; i < kFragmentCount; ++i) { + for (wtf_size_t i = 0; i < kFragmentCount; ++i) { ScopedDisplayItemFragment scoped_fragment(context, i); ScopedPaintChunkProperties content_chunk_properties( GetPaintController(), DefaultPaintChunkProperties(), container, @@ -936,11 +945,11 @@ TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) { auto container2_properties = DefaultPaintChunkProperties(); container2_properties.SetEffect(*container2_effect); - GetPaintController().UpdateCurrentPaintChunkProperties(container1_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&container1_id, container1_properties); DrawRect(context, container1, kBackgroundType, FloatRect(100, 100, 100, 100)); DrawRect(context, content1, kBackgroundType, FloatRect(100, 100, 50, 200)); - GetPaintController().UpdateCurrentPaintChunkProperties(container2_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&container2_id, container2_properties); DrawRect(context, container2, kBackgroundType, FloatRect(100, 200, 100, 100)); DrawRect(context, content2, kBackgroundType, FloatRect(100, 200, 50, 200)); @@ -958,12 +967,12 @@ TEST_P(PaintControllerTest, UpdateSwapOrderCrossingChunks) { IsPaintChunk(2, 4, container2_id, container2_properties))); // Move content2 into container1, without invalidation. - GetPaintController().UpdateCurrentPaintChunkProperties(container1_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&container1_id, container1_properties); DrawRect(context, container1, kBackgroundType, FloatRect(100, 100, 100, 100)); DrawRect(context, content1, kBackgroundType, FloatRect(100, 100, 50, 200)); DrawRect(context, content2, kBackgroundType, FloatRect(100, 200, 50, 200)); - GetPaintController().UpdateCurrentPaintChunkProperties(container2_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&container2_id, container2_properties); DrawRect(context, container2, kBackgroundType, FloatRect(100, 200, 100, 100)); @@ -1051,34 +1060,34 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { { SubsequenceRecorder r(context, container1); GetPaintController().UpdateCurrentPaintChunkProperties( - container1_background_id, container1_background_properties); + &container1_background_id, container1_background_properties); DrawRect(context, container1, kBackgroundType, FloatRect(100, 100, 100, 100)); { SubsequenceRecorder r(context, content1); GetPaintController().UpdateCurrentPaintChunkProperties( - content1_id, content1_properties); + &content1_id, content1_properties); DrawRect(context, content1, kBackgroundType, FloatRect(100, 100, 50, 200)); DrawRect(context, content1, kForegroundType, FloatRect(100, 100, 50, 200)); } GetPaintController().UpdateCurrentPaintChunkProperties( - container1_foreground_id, container1_foreground_properties); + &container1_foreground_id, container1_foreground_properties); DrawRect(context, container1, kForegroundType, FloatRect(100, 100, 100, 100)); } { SubsequenceRecorder r(context, container2); GetPaintController().UpdateCurrentPaintChunkProperties( - container2_background_id, container2_background_properties); + &container2_background_id, container2_background_properties); DrawRect(context, container2, kBackgroundType, FloatRect(100, 200, 100, 100)); { SubsequenceRecorder r(context, content2); GetPaintController().UpdateCurrentPaintChunkProperties( - content2_id, content2_properties); + &content2_id, content2_properties); DrawRect(context, content2, kBackgroundType, FloatRect(100, 200, 50, 200)); } @@ -1093,25 +1102,10 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { IsSameId(&container2, kBackgroundType), IsSameId(&content2, kBackgroundType))); - auto* markers = GetSubsequenceMarkers(container1); - CHECK(markers); - EXPECT_EQ(0u, markers->start); - EXPECT_EQ(4u, markers->end); - - markers = GetSubsequenceMarkers(content1); - CHECK(markers); - EXPECT_EQ(1u, markers->start); - EXPECT_EQ(3u, markers->end); - - markers = GetSubsequenceMarkers(container2); - CHECK(markers); - EXPECT_EQ(4u, markers->start); - EXPECT_EQ(6u, markers->end); - - markers = GetSubsequenceMarkers(content2); - CHECK(markers); - EXPECT_EQ(5u, markers->start); - EXPECT_EQ(6u, markers->end); + EXPECT_SUBSEQUENCE(container1, 0, 3); + EXPECT_SUBSEQUENCE(content1, 1, 2); + EXPECT_SUBSEQUENCE(container2, 3, 5); + EXPECT_SUBSEQUENCE(content2, 4, 5); EXPECT_THAT( GetPaintController().PaintChunks(), @@ -1139,7 +1133,7 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { // Content2 now outputs foreground only. { SubsequenceRecorder r(context, content2); - GetPaintController().UpdateCurrentPaintChunkProperties(content2_id, + GetPaintController().UpdateCurrentPaintChunkProperties(&content2_id, content2_properties); DrawRect(context, content2, kForegroundType, FloatRect(100, 200, 50, 200)); } @@ -1151,13 +1145,13 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { // Use cached subsequence of content1. if (RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled()) { // When under-invalidation-checking is enabled, - // useCachedSubsequenceIfPossible is forced off, and the client is + // UseCachedSubsequenceIfPossible is forced off, and the client is // expected to create the same painting as in the previous paint. EXPECT_FALSE(SubsequenceRecorder::UseCachedSubsequenceIfPossible( context, content1)); SubsequenceRecorder r(context, content1); GetPaintController().UpdateCurrentPaintChunkProperties( - content1_id, content1_properties); + &content1_id, content1_properties); DrawRect(context, content1, kBackgroundType, FloatRect(100, 100, 50, 200)); DrawRect(context, content1, kForegroundType, @@ -1167,7 +1161,7 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { context, content1)); } GetPaintController().UpdateCurrentPaintChunkProperties( - container1_foreground_id, container1_foreground_properties); + &container1_foreground_id, container1_foreground_properties); DrawRect(context, container1, kForegroundType, FloatRect(100, 100, 100, 100)); } @@ -1188,20 +1182,10 @@ TEST_P(PaintControllerTest, CachedNestedSubsequenceUpdate) { IsSameId(&content1, kForegroundType), IsSameId(&container1, kForegroundType))); - markers = GetSubsequenceMarkers(content2); - CHECK(markers); - EXPECT_EQ(0u, markers->start); - EXPECT_EQ(1u, markers->end); - - markers = GetSubsequenceMarkers(container1); - CHECK(markers); - EXPECT_EQ(1u, markers->start); - EXPECT_EQ(4u, markers->end); - - markers = GetSubsequenceMarkers(content1); - CHECK(markers); - EXPECT_EQ(1u, markers->start); - EXPECT_EQ(3u, markers->end); + EXPECT_NO_SUBSEQUENCE(container2); + EXPECT_SUBSEQUENCE(content2, 0, 1); + EXPECT_SUBSEQUENCE(container1, 1, 3); + EXPECT_SUBSEQUENCE(content1, 1, 2); EXPECT_THAT(GetPaintController().PaintChunks(), ElementsAre(IsPaintChunk(0, 1, content2_id, content2_properties), @@ -1637,9 +1621,7 @@ TEST_P(PaintControllerTest, DuplicatedSubsequences) { #if DCHECK_IS_ON() EXPECT_DEATH(paint_duplicated_subsequences(), "Multiple subsequences for client: \"test\""); - return; -#endif - +#else // The following is for non-DCHECK path. No security CHECK should trigger. paint_duplicated_subsequences(); // Paint again. @@ -1658,6 +1640,37 @@ TEST_P(PaintControllerTest, DuplicatedSubsequences) { DrawRect(context, client, kForegroundType, FloatRect(100, 100, 100, 100)); } CommitAndFinishCycle(); +#endif +} + +TEST_P(PaintControllerTest, DeletedClientInUnderInvaldiatedSubsequence) { + if (RuntimeEnabledFeatures::PaintUnderInvalidationCheckingEnabled()) + return; + + FakeDisplayItemClient container("container"); + auto content = std::make_unique<FakeDisplayItemClient>("content"); + GraphicsContext context(GetPaintController()); + + InitRootChunk(); + { + SubsequenceRecorder r(context, container); + DrawRect(context, *content, kBackgroundType, FloatRect(100, 100, 300, 300)); + } + CommitAndFinishCycle(); + + content = nullptr; + InitRootChunk(); + // Leave container not invalidated. +#if DCHECK_IS_ON() + ASSERT_DEATH( + SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container), + ""); +#else + // This should not crash. + EXPECT_TRUE( + SubsequenceRecorder::UseCachedSubsequenceIfPossible(context, container)); + CommitAndFinishCycle(); +#endif } class PaintControllerUnderInvalidationTest @@ -1863,7 +1876,7 @@ TEST_F(PaintControllerUnderInvalidationTest, MoreDrawingInSubsequence) { TEST_F(PaintControllerUnderInvalidationTest, LessDrawingInSubsequence) { EXPECT_DEATH(TestLessDrawingInSubsequence(), "In cached subsequence for first.*" - "under-invalidation: new subsequence wrong length"); + "under-invalidation: chunk changed"); } TEST_F(PaintControllerUnderInvalidationTest, InvalidationInSubsequence) { |