Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1527)

Unified Diff: Source/core/paint/ViewDisplayListTest.cpp

Issue 860563003: Disable display item caching (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/paint/ViewDisplayListTest.cpp
diff --git a/Source/core/paint/ViewDisplayListTest.cpp b/Source/core/paint/ViewDisplayListTest.cpp
index eeca86223ee7deccbdb8d45deb4a35316b5dc2ca..3d52e8c047f1e380df1972b92a9c53821c33beb2 100644
--- a/Source/core/paint/ViewDisplayListTest.cpp
+++ b/Source/core/paint/ViewDisplayListTest.cpp
@@ -38,6 +38,12 @@ private:
ASSERT_TRUE(m_renderView);
}
+ virtual void TearDown() override
+ {
+ RuntimeEnabledFeatures::setSlimmingPaintEnabled(false);
+ RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false);
+ }
+
RenderView* m_renderView;
};
@@ -63,7 +69,7 @@ public:
#define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
EXPECT_EQ((size_t)expectedSize, actual.size()); \
const TestDisplayItem expected[] = { __VA_ARGS__ }; \
- for (size_t index = 0; index < expectedSize; index++) { \
+ for (size_t index = 0; index < std::min<size_t>(actual.size(), expectedSize); index++) { \
TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \
EXPECT_EQ(expected[index].client(), actual[index]->client()); \
EXPECT_EQ(expected[index].type(), actual[index]->type()); \
@@ -92,7 +98,9 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
GraphicsContext context(nullptr, &rootDisplayItemList());
FloatRect bound = renderView()->viewRect();
+ rootDisplayItemList().beginNewPaints();
drawClippedRect(&context, renderView(), PaintPhaseForeground, bound);
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
TestDisplayItem(renderView(), DisplayItem::ClipLayerForeground),
@@ -107,9 +115,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
RenderObject* second = document().body()->firstChild()->firstChild()->renderer();
GraphicsContext context(nullptr, &rootDisplayItemList());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
drawRect(&context, second, PaintPhaseChildBlockBackground, FloatRect(100, 100, 200, 200));
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -117,8 +127,10 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
rootDisplayItemList().invalidate(second->displayItemClient());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -133,9 +145,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
RenderObject* unaffected = document().body()->firstChild()->nextSibling()->renderer();
GraphicsContext context(nullptr, &rootDisplayItemList());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -143,8 +157,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
TestDisplayItem(unaffected, DisplayItem::DrawingPaintPhaseBlockBackground));
rootDisplayItemList().invalidate(second->displayItemClient());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+ drawRect(&context, unaffected, PaintPhaseBlockBackground, FloatRect(300, 300, 10, 10));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -160,17 +177,21 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
RenderObject* third = document().body()->firstChild()->firstChild()->firstChild()->renderer();
GraphicsContext context(nullptr, &rootDisplayItemList());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseBlockBackground));
rootDisplayItemList().invalidate(third->displayItemClient());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(125, 100, 200, 50));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -186,6 +207,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
RenderObject* third = document().body()->firstChild()->nextSibling()->renderer();
GraphicsContext context(nullptr, &rootDisplayItemList());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
@@ -195,6 +217,7 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
drawRect(&context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -208,12 +231,17 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
rootDisplayItemList().invalidate(second->displayItemClient());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, third, PaintPhaseBlockBackground, FloatRect(300, 100, 50, 50));
drawRect(&context, first, PaintPhaseForeground, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseForeground, FloatRect(100, 100, 50, 200));
+ drawRect(&context, third, PaintPhaseForeground, FloatRect(300, 100, 50, 50));
drawRect(&context, first, PaintPhaseOutline, FloatRect(100, 100, 100, 100));
drawRect(&context, second, PaintPhaseOutline, FloatRect(100, 100, 50, 200));
+ drawRect(&context, third, PaintPhaseOutline, FloatRect(300, 100, 50, 50));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 9,
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -226,6 +254,8 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
+ // The following is only applicable when we support incremental paint.
+#if 0
rootDisplayItemList().invalidate(second->displayItemClient());
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 6,
@@ -235,9 +265,11 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateInvalidationWithPhases)
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseForeground),
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline),
TestDisplayItem(third, DisplayItem::DrawingPaintPhaseOutline));
+#endif
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
+// This test is only applicable when we support incremental paint.
+TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstNoOverlap)
{
setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -268,7 +300,8 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstNoOverlap)
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
+// This test is only applicable when we support incremental paint.
+TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddFirstOverlap)
{
setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -304,7 +337,8 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddFirstOverlap)
TestDisplayItem(second, DisplayItem::DrawingPaintPhaseOutline));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
+// This test is only applicable when we support incremental paint.
+TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastNoOverlap)
{
setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -335,7 +369,8 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastNoOverlap)
TestDisplayItem(first, DisplayItem::DrawingPaintPhaseOutline));
}
-TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateAddLastOverlap)
+// This test is only applicable when we support incremental paint.
+TEST_F(ViewDisplayListTest, DISABLED_ViewDisplayListTest_UpdateAddLastOverlap)
{
setBodyInnerHTML("<div id='first'></div><div id='second'></div>");
RenderObject* first = document().body()->firstChild()->renderer();
@@ -379,12 +414,14 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document().body()->firstChild()->firstChild()->renderer());
GraphicsContext context(nullptr, &rootDisplayItemList());
+ rootDisplayItemList().beginNewPaints();
ClipRect firstClipRect(IntRect(1, 1, 2, 2));
{
LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags());
drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
}
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground),
@@ -393,20 +430,24 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
TestDisplayItem(firstRenderer, DisplayItem::EndClip));
rootDisplayItemList().invalidate(firstRenderer->displayItemClient());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
TestDisplayItem(secondRenderer, DisplayItem::DrawingPaintPhaseBlockBackground));
rootDisplayItemList().invalidate(secondRenderer->displayItemClient());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
ClipRect secondClipRect(IntRect(1, 1, 2, 2));
{
LayerClipRecorder layerClipRecorder(secondRenderer, &context, DisplayItem::ClipLayerForeground, secondClipRect, 0, LayoutPoint(), PaintLayerFlags());
drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
}
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -417,13 +458,17 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateClip)
TEST_F(ViewDisplayListTest, CachedDisplayItems)
{
+ RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
+
setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
RenderLayerModelObject* firstRenderer = toRenderLayerModelObject(document().body()->firstChild()->renderer());
RenderLayerModelObject* secondRenderer = toRenderLayerModelObject(document().body()->firstChild()->firstChild()->renderer());
GraphicsContext context(nullptr, &rootDisplayItemList());
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -437,8 +482,10 @@ TEST_F(ViewDisplayListTest, CachedDisplayItems)
EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayItemClient()));
EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displayItemClient()));
+ rootDisplayItemList().beginNewPaints();
drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(firstRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -468,7 +515,9 @@ TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
SkCanvas canvas(800, 600);
GraphicsContext context(&canvas, &rootDisplayItemList());
LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintBehaviorNormal, LayoutSize());
+ rootDisplayItemList().beginNewPaints();
LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),
@@ -476,7 +525,9 @@ TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
div->focus();
document().view()->updateLayoutAndStyleForPainting();
+ rootDisplayItemList().beginNewPaints();
LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLayerPaintingCompositingAllPhases);
+ rootDisplayItemList().endNewPaints();
EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackground),

Powered by Google App Engine
This is Rietveld 408576698