Commit b2515c5c authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Reland "[PE] Change CHECK to LOG(WARNING) in PaintController::FindOutOfOrderCachedItemForward"

This is a reland of 8bc8a796

Updated unit tests, and add comments to
DisplayItemClient::SetDisplayItemsUncached()
and PaintController::ClientCacheIsValid() (also made private).

Original change's description:
> [PE] Change CHECK to LOG(WARNING) in PaintController::FindOutOfOrderCachedItemForward
>
> The situation doesn't cause corrupted rendering but just slightly
> affects performance. It's fine not to DCHECK given that the situation
> is rare.
>
> Bug: 805024
> Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
> Change-Id: Iac8cd617d5df51da2516fc6a9df1308a0daaedd0
> Reviewed-on: https://chromium-review.googlesource.com/990074
> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
> Reviewed-by: Philip Rogers <pdr@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#547923}

Bug: 805024
Change-Id: Ibcd443972c41b03cf03ea946da3c499987ad3b59
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Reviewed-on: https://chromium-review.googlesource.com/994339Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548177}
parent a4ace033
......@@ -121,9 +121,9 @@ TEST_P(PaintControllerPaintTestForNonSPv1, ChunkIdClientCacheFlag) {
EXPECT_FALSE(div.Layer()->IsJustCreated());
// Client used by only paint chunks and non-cachaeable display items but not
// by any cacheable display items won't be marked as validly cached.
EXPECT_TRUE(RootPaintController().ClientCacheIsValid(*div.Layer()));
EXPECT_FALSE(RootPaintController().ClientCacheIsValid(div));
EXPECT_TRUE(RootPaintController().ClientCacheIsValid(sub_div));
EXPECT_TRUE(ClientCacheIsValid(*div.Layer()));
EXPECT_FALSE(ClientCacheIsValid(div));
EXPECT_TRUE(ClientCacheIsValid(sub_div));
}
TEST_P(PaintControllerPaintTestForNonSPv1, CompositingNoFold) {
......
......@@ -108,6 +108,10 @@ class PaintControllerPaintTestBase : public RenderingTest {
void InvalidateAll(PaintController& paint_controller) {
paint_controller.InvalidateAllForTesting();
}
bool ClientCacheIsValid(const DisplayItemClient& client) {
return RootPaintController().ClientCacheIsValid(client);
}
};
class PaintControllerPaintTest : public PaintTestConfigurations,
......
......@@ -68,6 +68,11 @@ class PLATFORM_EXPORT DisplayItemClient {
return false;
}
// Indicates that the client will paint display items different from the ones
// cached by PaintController. However, PaintController allows a client to
// paint new display items that are not cached or to no longer paint some
// cached display items without calling this method.
// See PaintController::ClientCacheIsValid() for more details.
void SetDisplayItemsUncached(
PaintInvalidationReason reason = PaintInvalidationReason::kFull) const {
cache_generation_or_invalidation_reason_.Invalidate(reason);
......
......@@ -480,7 +480,7 @@ size_t PaintController::FindOutOfOrderCachedItemForward(
#endif
// Ensure our paint invalidation tests don't trigger the less performant
// situation which should be rare.
CHECK(false) << "Can't find cached display item: " << id.client.DebugName()
LOG(WARNING) << "Can't find cached display item: " << id.client.DebugName()
<< " " << id.ToString();
}
return kNotFound;
......
......@@ -173,8 +173,6 @@ class PLATFORM_EXPORT PaintController {
return GetPaintArtifact().PaintChunks();
}
bool ClientCacheIsValid(const DisplayItemClient&) const;
// For micro benchmarking of record time.
bool DisplayItemConstructionIsDisabled() const {
return construction_disabled_;
......@@ -249,6 +247,18 @@ class PLATFORM_EXPORT PaintController {
friend class PaintControllerTestBase;
friend class PaintControllerPaintTestBase;
// True if all display items associated with the client are validly cached.
// However, the current algorithm allows the following situations even if
// ClientCacheIsValid() is true for a client during painting:
// 1. The client paints a new display item that is not cached:
// UseCachedDrawingIfPossible() returns false for the display item and the
// newly painted display item will be added into the cache. This situation
// has slight performance hit (see FindOutOfOrderCachedItemForward()) so we
// print a warning in the situation and should keep it rare.
// 2. the client no longer paints a display item that is cached: the cached
// display item will be removed. This doesn't affect performance.
bool ClientCacheIsValid(const DisplayItemClient&) const;
void InvalidateAllForTesting() { InvalidateAllInternal(); }
void InvalidateAllInternal();
......
......@@ -74,6 +74,15 @@ class PaintControllerTestBase : public testing::Test {
return paint_controller_->GetSubsequenceMarkers(client);
}
static bool ClientCacheIsValid(const PaintController& paint_controller,
const DisplayItemClient& client) {
return paint_controller.ClientCacheIsValid(client);
}
bool ClientCacheIsValid(const DisplayItemClient& client) const {
return ClientCacheIsValid(*paint_controller_, client);
}
private:
FakeDisplayItemClient root_paint_property_client_;
PaintChunk::Id root_paint_chunk_id_;
......
......@@ -20,7 +20,7 @@ TEST_F(PaintRecordBuilderTest, TransientPaintController) {
FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20));
DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20));
DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10));
EXPECT_FALSE(context.GetPaintController().ClientCacheIsValid(client));
EXPECT_FALSE(ClientCacheIsValid(context.GetPaintController(), client));
MockPaintCanvas canvas;
PaintFlags flags;
......@@ -30,7 +30,7 @@ TEST_F(PaintRecordBuilderTest, TransientPaintController) {
EXPECT_DISPLAY_LIST(context.GetPaintController().GetDisplayItemList(), 2,
TestDisplayItem(client, kBackgroundType),
TestDisplayItem(client, kForegroundType));
EXPECT_FALSE(context.GetPaintController().ClientCacheIsValid(client));
EXPECT_FALSE(ClientCacheIsValid(context.GetPaintController(), client));
}
TEST_F(PaintRecordBuilderTest, LastingPaintController) {
......@@ -46,13 +46,13 @@ TEST_F(PaintRecordBuilderTest, LastingPaintController) {
FakeDisplayItemClient client("client", LayoutRect(10, 10, 20, 20));
DrawRect(context, client, kBackgroundType, FloatRect(10, 10, 20, 20));
DrawRect(context, client, kForegroundType, FloatRect(15, 15, 10, 10));
EXPECT_FALSE(GetPaintController().ClientCacheIsValid(client));
EXPECT_FALSE(ClientCacheIsValid(client));
MockPaintCanvas canvas;
PaintFlags flags;
EXPECT_CALL(canvas, drawPicture(_)).Times(1);
builder.EndRecording(canvas);
EXPECT_TRUE(GetPaintController().ClientCacheIsValid(client));
EXPECT_TRUE(ClientCacheIsValid(client));
EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 2,
TestDisplayItem(client, kBackgroundType),
......@@ -73,7 +73,7 @@ TEST_F(PaintRecordBuilderTest, LastingPaintController) {
EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 2,
TestDisplayItem(client, kBackgroundType),
TestDisplayItem(client, kForegroundType));
EXPECT_TRUE(GetPaintController().ClientCacheIsValid(client));
EXPECT_TRUE(ClientCacheIsValid(client));
}
TEST_F(PaintRecordBuilderTest, TransientAndAnotherPaintController) {
......@@ -87,7 +87,7 @@ TEST_F(PaintRecordBuilderTest, TransientAndAnotherPaintController) {
EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 2,
TestDisplayItem(client, kBackgroundType),
TestDisplayItem(client, kForegroundType));
EXPECT_TRUE(GetPaintController().ClientCacheIsValid(client));
EXPECT_TRUE(ClientCacheIsValid(client));
PaintRecordBuilder builder;
EXPECT_NE(&builder.Context().GetPaintController(), &GetPaintController());
......@@ -97,9 +97,9 @@ TEST_F(PaintRecordBuilderTest, TransientAndAnotherPaintController) {
// The transient PaintController in PaintRecordBuilder doesn't affect the
// client's cache status in another PaintController.
EXPECT_TRUE(GetPaintController().ClientCacheIsValid(client));
EXPECT_TRUE(ClientCacheIsValid(client));
EXPECT_FALSE(
builder.Context().GetPaintController().ClientCacheIsValid(client));
ClientCacheIsValid(builder.Context().GetPaintController(), client));
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment