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

Side by Side Diff: Source/core/paint/DisplayItemListPaintTest.cpp

Issue 1294233004: Subtree caching implementation in blink-core (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't mark non-self-painting layers for needsRepaint Created 5 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerPainter.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/graphics/paint/DisplayItemList.h" 6 #include "platform/graphics/paint/DisplayItemList.h"
7 7
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/layout/LayoutText.h" 9 #include "core/layout/LayoutText.h"
10 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 13 matching lines...) Expand all
24 24
25 class DisplayItemListPaintTest : public RenderingTest { 25 class DisplayItemListPaintTest : public RenderingTest {
26 public: 26 public:
27 DisplayItemListPaintTest() 27 DisplayItemListPaintTest()
28 : m_layoutView(nullptr) 28 : m_layoutView(nullptr)
29 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn abled()) { } 29 , m_originalSlimmingPaintEnabled(RuntimeEnabledFeatures::slimmingPaintEn abled()) { }
30 30
31 protected: 31 protected:
32 LayoutView& layoutView() { return *m_layoutView; } 32 LayoutView& layoutView() { return *m_layoutView; }
33 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph icsLayerBacking()->displayItemList(); } 33 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph icsLayerBacking()->displayItemList(); }
34 const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList( ).m_newDisplayItems; } 34 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi st().m_newDisplayItems; }
35 35
36 private: 36 private:
37 void SetUp() override 37 void SetUp() override
38 { 38 {
39 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); 39 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
40 40
41 RenderingTest::SetUp(); 41 RenderingTest::SetUp();
42 enableCompositing(); 42 enableCompositing();
43 43
44 m_layoutView = document().view()->layoutView(); 44 m_layoutView = document().view()->layoutView();
(...skipping 13 matching lines...) Expand all
58 // class is used to test only v2 behavior while maintaining v1 test coverage. 58 // class is used to test only v2 behavior while maintaining v1 test coverage.
59 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest { 59 class DisplayItemListPaintTestForSlimmingPaintV2 : public RenderingTest {
60 public: 60 public:
61 DisplayItemListPaintTestForSlimmingPaintV2() 61 DisplayItemListPaintTestForSlimmingPaintV2()
62 : m_layoutView(nullptr) 62 : m_layoutView(nullptr)
63 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { } 63 , m_originalSlimmingPaintV2Enabled(RuntimeEnabledFeatures::slimmingPaint V2Enabled()) { }
64 64
65 protected: 65 protected:
66 LayoutView& layoutView() { return *m_layoutView; } 66 LayoutView& layoutView() { return *m_layoutView; }
67 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph icsLayerBacking()->displayItemList(); } 67 DisplayItemList& rootDisplayItemList() { return *layoutView().layer()->graph icsLayerBacking()->displayItemList(); }
68 const DisplayItems& newPaintListBeforeUpdate() { return rootDisplayItemList( ).m_newDisplayItems; } 68 const DisplayItems& newDisplayItemsBeforeUpdate() { return rootDisplayItemLi st().m_newDisplayItems; }
69
70 // Expose some document lifecycle steps for checking new display items befor e commiting.
71 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean()
72 {
73 document().view()->updateLifecyclePhasesInternal(FrameView::OnlyUpToComp ositingCleanPlusScrolling);
74 document().view()->invalidateTreeIfNeededRecursive();
75 document().view()->paintForSlimmingPaintV2();
76 }
77 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming PaintV2(); }
69 78
70 private: 79 private:
71 void SetUp() override 80 void SetUp() override
72 { 81 {
73 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); 82 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled());
74 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 83 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
75 84
76 RenderingTest::SetUp(); 85 RenderingTest::SetUp();
77 enableCompositing(); 86 enableCompositing();
78 87
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_EQ(expected[index].type(), actual[index].type()); \ 126 EXPECT_EQ(expected[index].type(), actual[index].type()); \
118 } \ 127 } \
119 } while (false); 128 } while (false);
120 129
121 #ifndef NDEBUG 130 #ifndef NDEBUG
122 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi ll, ...) \ 131 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(actual, expectedSizeWithoutFi ll, ...) \
123 EXPECT_DISPLAY_LIST_BASE( \ 132 EXPECT_DISPLAY_LIST_BASE( \
124 actual, expectedSizeWithoutFill + 1, \ 133 actual, expectedSizeWithoutFill + 1, \
125 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking( ), DisplayItem::DebugRedFill), \ 134 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking( ), DisplayItem::DebugRedFill), \
126 __VA_ARGS__) 135 __VA_ARGS__)
136 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(actual, expectedSizeWi thoutFill, ...) \
137 EXPECT_DISPLAY_LIST_BASE( \
138 actual, expectedSizeWithoutFill + 1, \
139 TestDisplayItem(*document().layoutView()->layer()->graphicsLayerBacking( ), DisplayItem::drawingTypeToCachedDrawingType(DisplayItem::DebugRedFill)), \
140 __VA_ARGS__)
127 #else 141 #else
128 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE 142 #define EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BASE
143 #define EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG EXPECT_DISPLAY_LIST_BA SE
129 #endif 144 #endif
130 145
131 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret) 146 TEST_F(DisplayItemListPaintTest, FullDocumentPaintingWithCaret)
132 { 147 {
133 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>"); 148 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
134 document().page()->focusController().setActive(true); 149 document().page()->focusController().setActive(true);
135 document().page()->focusController().setFocused(true); 150 document().page()->focusController().setFocused(true);
136 LayoutView& layoutView = *document().layoutView(); 151 LayoutView& layoutView = *document().layoutView();
137 DeprecatedPaintLayer& rootLayer = *layoutView.layer(); 152 DeprecatedPaintLayer& rootLayer = *layoutView.layer();
138 Element& div = *toElement(document().body()->firstChild()); 153 Element& div = *toElement(document().body()->firstChild());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 214 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
200 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground))); 215 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)));
201 } 216 }
202 217
203 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret ) 218 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, FullDocumentPaintingWithCaret )
204 { 219 {
205 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>"); 220 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
206 document().page()->focusController().setActive(true); 221 document().page()->focusController().setActive(true);
207 document().page()->focusController().setFocused(true); 222 document().page()->focusController().setFocused(true);
208 LayoutView& layoutView = *document().layoutView(); 223 LayoutView& layoutView = *document().layoutView();
224 LayoutObject& html = *document().documentElement()->layoutObject();
209 Element& div = *toElement(document().body()->firstChild()); 225 Element& div = *toElement(document().body()->firstChild());
210 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje ct(); 226 LayoutObject& divLayoutObject = *document().body()->firstChild()->layoutObje ct();
211 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject( ))->firstTextBox(); 227 InlineTextBox& textInlineBox = *toLayoutText(div.firstChild()->layoutObject( ))->firstTextBox();
212 228
213 document().view()->updateAllLifecyclePhases(); 229 document().view()->updateAllLifecyclePhases();
214 230
215 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 2, 231 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 4,
216 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 232 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
217 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground))); 233 TestDisplayItem(html, DisplayItem::BeginSubsequence),
234 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
235 TestDisplayItem(html, DisplayItem::EndSubsequence));
218 236
219 div.focus(); 237 div.focus();
220 document().view()->updateAllLifecyclePhases(); 238 document().view()->updateAllLifecyclePhases();
221 239
222 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 3, 240 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5,
223 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 241 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
242 TestDisplayItem(html, DisplayItem::BeginSubsequence),
224 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 243 TestDisplayItem(textInlineBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
225 TestDisplayItem(divLayoutObject, DisplayItem::Caret)); // New! 244 TestDisplayItem(divLayoutObject, DisplayItem::Caret), // New!
245 TestDisplayItem(html, DisplayItem::EndSubsequence));
226 } 246 }
227 247
228 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout) 248 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, InlineRelayout)
229 { 249 {
230 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>"); 250 setBodyInnerHTML("<div id='div' style='width:100px; height: 200px'>AAAAAAAAA A BBBBBBBBBB</div>");
231 LayoutView& layoutView = *document().layoutView(); 251 LayoutView& layoutView = *document().layoutView();
252 LayoutObject& html = *document().documentElement()->layoutObject();
232 Element& div = *toElement(document().body()->firstChild()); 253 Element& div = *toElement(document().body()->firstChild());
233 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject()); 254 LayoutBlock& divBlock = *toLayoutBlock(document().body()->firstChild()->layo utObject());
234 LayoutText& text = *toLayoutText(divBlock.firstChild()); 255 LayoutText& text = *toLayoutText(divBlock.firstChild());
235 InlineTextBox& firstTextBox = *text.firstTextBox(); 256 InlineTextBox& firstTextBox = *text.firstTextBox();
236 257
237 document().view()->updateAllLifecyclePhases(); 258 document().view()->updateAllLifecyclePhases();
238 259
239 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 2, 260 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 4,
240 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 261 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
241 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground))); 262 TestDisplayItem(html, DisplayItem::BeginSubsequence),
263 TestDisplayItem(firstTextBox, DisplayItem::paintPhaseToDrawingType(Paint PhaseForeground)),
264 TestDisplayItem(html, DisplayItem::EndSubsequence));
242 265
243 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px"); 266 div.setAttribute(HTMLNames::styleAttr, "width: 10px; height: 200px");
244 document().view()->updateAllLifecyclePhases(); 267 document().view()->updateAllLifecyclePhases();
245 268
246 LayoutText& newText = *toLayoutText(divBlock.firstChild()); 269 LayoutText& newText = *toLayoutText(divBlock.firstChild());
247 InlineTextBox& newFirstTextBox = *newText.firstTextBox(); 270 InlineTextBox& newFirstTextBox = *newText.firstTextBox();
248 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); 271 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
249 272
250 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 3, 273 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5,
251 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 274 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
275 TestDisplayItem(html, DisplayItem::BeginSubsequence),
252 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 276 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
253 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground))); 277 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
278 TestDisplayItem(html, DisplayItem::EndSubsequence));
279 }
280
281 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, CachedSubsequence)
282 {
283 setBodyInnerHTML(
284 "<div id='container1' style='position: relative; width: 200px; height: 2 00px; background-color: blue'>"
285 " <div id='content1' style='width: 100px; height: 100px; background-col or: red'></div>"
286 "</div>"
287 "<div id='container2' style='position: relative; width: 200px; height: 2 00px; background-color: blue'>"
288 " <div id='content2' style='width: 100px; height: 100px; background-col or: green'></div>"
289 "</div>");
290 document().view()->updateAllLifecyclePhases();
291
292 LayoutView& layoutView = *document().layoutView();
293 LayoutObject& html = *document().documentElement()->layoutObject();
294 LayoutObject& container1 = *document().getElementById("container1")->layoutO bject();
295 LayoutObject& content1 = *document().getElementById("content1")->layoutObjec t();
296 LayoutObject& container2 = *document().getElementById("container2")->layoutO bject();
297 LayoutObject& content2 = *document().getElementById("content2")->layoutObjec t();
298
299 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 11,
300 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
301 TestDisplayItem(html, DisplayItem::BeginSubsequence),
302 TestDisplayItem(container1, DisplayItem::BeginSubsequence),
303 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
304 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
305 TestDisplayItem(container1, DisplayItem::EndSubsequence),
306 TestDisplayItem(container2, DisplayItem::BeginSubsequence),
307 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
308 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
309 TestDisplayItem(container2, DisplayItem::EndSubsequence),
310 TestDisplayItem(html, DisplayItem::EndSubsequence));
311
312 toHTMLElement(content1.node())->setAttribute(HTMLNames::styleAttr, "width: 1 00px; height: 100px; background-color: green");
313 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
314
315 EXPECT_DISPLAY_LIST_WITH_CACHED_RED_FILL_IN_DEBUG(newDisplayItemsBeforeUpdat e(), 8,
316 TestDisplayItem(layoutView, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)),
317 TestDisplayItem(html, DisplayItem::BeginSubsequence),
318 TestDisplayItem(container1, DisplayItem::BeginSubsequence),
319 TestDisplayItem(container1, DisplayItem::drawingTypeToCachedDrawingType( DisplayItem::BoxDecorationBackground)),
320 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
321 TestDisplayItem(container1, DisplayItem::EndSubsequence),
322 TestDisplayItem(container2, DisplayItem::CachedSubsequence),
323 TestDisplayItem(html, DisplayItem::EndSubsequence));
324
325 compositeForSlimmingPaintV2();
326
327 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 11,
328 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
329 TestDisplayItem(html, DisplayItem::BeginSubsequence),
330 TestDisplayItem(container1, DisplayItem::BeginSubsequence),
331 TestDisplayItem(container1, DisplayItem::BoxDecorationBackground),
332 TestDisplayItem(content1, DisplayItem::BoxDecorationBackground),
333 TestDisplayItem(container1, DisplayItem::EndSubsequence),
334 TestDisplayItem(container2, DisplayItem::BeginSubsequence),
335 TestDisplayItem(container2, DisplayItem::BoxDecorationBackground),
336 TestDisplayItem(content2, DisplayItem::BoxDecorationBackground),
337 TestDisplayItem(container2, DisplayItem::EndSubsequence),
338 TestDisplayItem(html, DisplayItem::EndSubsequence));
254 } 339 }
255 340
256 } // namespace blink 341 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/DeprecatedPaintLayerPainter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698