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

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

Issue 697543002: First implementation of the paint slimming update algorithm (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 5109af45539844d510bad3b26c674e267087b660..f4316175d465a081636b18beeb4842d1cc9ea3c2 100644
--- a/Source/core/paint/ViewDisplayListTest.cpp
+++ b/Source/core/paint/ViewDisplayListTest.cpp
@@ -37,19 +37,19 @@ private:
RenderView* m_renderView;
};
-void drawRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound)
+void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase, const FloatRect& bound)
{
DrawingRecorder drawingRecorder(context, renderer, phase, bound);
IntRect rect(0, 0, 10, 10);
context->drawRect(rect);
}
-void drawClippedRect(GraphicsContext* context, RenderView* renderer, PaintPhase phase, const FloatRect& bound)
+void drawClippedRect(GraphicsContext* context, RenderView* renderView, PaintPhase phase, const FloatRect& bound)
{
IntRect rect(1, 1, 9, 9);
ClipRect clipRect(rect);
- ClipRecorder clipRecorder(renderer->compositor()->rootRenderLayer(), context, DisplayItem::ClipLayerForeground, clipRect);
- drawRect(context, renderer, phase, bound);
+ ClipRecorder clipRecorder(renderView->compositor()->rootRenderLayer(), context, DisplayItem::ClipLayerForeground, clipRect);
+ drawRect(context, renderView, phase, bound);
}
TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
@@ -63,5 +63,82 @@ TEST_F(ViewDisplayListTest, ViewDisplayListTest_NestedRecorders)
// TODO(schenney): Check that the IDs are what we expect.
}
+TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateBasic)
+{
+ setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
+ RenderObject* first = document().body()->firstChild()->renderer();
+ RenderObject* second = document().body()->firstChild()->firstChild()->renderer();
+ GraphicsContext* context = new GraphicsContext(nullptr);
+
+ 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));
+
+ EXPECT_EQ((size_t)3, renderView()->viewDisplayList().paintList().size());
+
+ renderView()->viewDisplayList().invalidate(second);
+ drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 300, 300));
+ drawRect(context, first, PaintPhaseOutline, FloatRect(100, 100, 300, 300));
+ EXPECT_EQ((size_t)2, renderView()->viewDisplayList().paintList().size());
}
+
+TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateSwapOrder)
+{
+ setBodyInnerHTML("<div id='first'><div id='second'></div></div><div id='unaffected'></div>");
+ RenderObject* first = document().body()->firstChild()->renderer();
+ RenderObject* second = document().body()->firstChild()->firstChild()->renderer();
+ RenderObject* unaffected = document().body()->firstChild()->nextSibling()->renderer();
+ GraphicsContext* context = new GraphicsContext(nullptr);
+
+ 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));
+
+ const PaintList& firstList = renderView()->viewDisplayList().paintList();
+ EXPECT_EQ((size_t)3, firstList.size());
+ EXPECT_EQ(first, firstList[0]->renderer());
+ EXPECT_EQ(second, firstList[1]->renderer());
+ EXPECT_EQ(unaffected, firstList[2]->renderer());
+
+ renderView()->viewDisplayList().invalidate(second);
+ drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+ drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+
+ const PaintList& secondList = renderView()->viewDisplayList().paintList();
+ EXPECT_EQ((size_t)3, secondList.size());
+ EXPECT_EQ(second, secondList[0]->renderer());
+ EXPECT_EQ(first, secondList[1]->renderer());
+ EXPECT_EQ(unaffected, secondList[2]->renderer());
+}
+
+TEST_F(ViewDisplayListTest, ViewDisplayListTest_UpdateNewItemInMiddle)
+{
+ setBodyInnerHTML("<div id='first'><div id='second'><div id='third'></div></div></div>");
+ RenderObject* first = document().body()->firstChild()->renderer();
+ RenderObject* second = document().body()->firstChild()->firstChild()->renderer();
+ RenderObject* third = document().body()->firstChild()->firstChild()->firstChild()->renderer();
+ GraphicsContext* context = new GraphicsContext(nullptr);
+
+ drawRect(context, first, PaintPhaseBlockBackground, FloatRect(100, 100, 100, 100));
+ drawRect(context, second, PaintPhaseBlockBackground, FloatRect(100, 100, 50, 200));
+
+ const PaintList& firstList = renderView()->viewDisplayList().paintList();
+ EXPECT_EQ((size_t)2, firstList.size());
+ EXPECT_EQ(first, firstList[0]->renderer());
+ EXPECT_EQ(second, firstList[1]->renderer());
+
+ renderView()->viewDisplayList().invalidate(third);
+ 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));
+
+ const PaintList& secondList = renderView()->viewDisplayList().paintList();
+ EXPECT_EQ((size_t)3, secondList.size());
+ EXPECT_EQ(first, secondList[0]->renderer());
+ EXPECT_EQ(third, secondList[1]->renderer());
+ EXPECT_EQ(second, secondList[2]->renderer());
+}
+
+}
+
}
« Source/core/paint/ViewDisplayList.cpp ('K') | « Source/core/paint/ViewDisplayList.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698