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

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: Ready for review Created 5 years, 4 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
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& newPaintListBeforeUpdate() { return rootDisplayItemList( ).m_newDisplayItems; }
69 69
70 // Expose some document lifecycle steps.
71 void updateLifecyclePhasesToPaintForSlimmingPaintV2Clean() { document().view ()->updateLifecyclePhasesInternal(FrameView::OnlyUpToPaintForSlimmingPaintV2Clea n); }
72 void compositeForSlimmingPaintV2() { document().view()->compositeForSlimming PaintV2(); }
73
70 private: 74 private:
71 void SetUp() override 75 void SetUp() override
72 { 76 {
73 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled()); 77 ASSERT_TRUE(RuntimeEnabledFeatures::slimmingPaintEnabled());
74 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 78 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
75 79
76 RenderingTest::SetUp(); 80 RenderingTest::SetUp();
77 enableCompositing(); 81 enableCompositing();
78 82
79 m_layoutView = document().view()->layoutView(); 83 m_layoutView = document().view()->layoutView();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox(); 252 InlineTextBox& secondTextBox = *newText.firstTextBox()->nextTextBox();
249 253
250 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5, 254 EXPECT_DISPLAY_LIST_WITH_RED_FILL_IN_DEBUG(rootDisplayItemList().displayItem s(), 5,
251 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground), 255 TestDisplayItem(layoutView, DisplayItem::BoxDecorationBackground),
252 TestDisplayItem(divBlock, DisplayItem::paintPhaseToBeginSubtreeType(Pain tPhaseForeground)), 256 TestDisplayItem(divBlock, DisplayItem::paintPhaseToBeginSubtreeType(Pain tPhaseForeground)),
253 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)), 257 TestDisplayItem(newFirstTextBox, DisplayItem::paintPhaseToDrawingType(Pa intPhaseForeground)),
254 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)), 258 TestDisplayItem(secondTextBox, DisplayItem::paintPhaseToDrawingType(Pain tPhaseForeground)),
255 TestDisplayItem(divBlock, DisplayItem::paintPhaseToEndSubtreeType(PaintP haseForeground))); 259 TestDisplayItem(divBlock, DisplayItem::paintPhaseToEndSubtreeType(PaintP haseForeground)));
256 } 260 }
257 261
262 TEST_F(DisplayItemListPaintTestForSlimmingPaintV2, SubtreeCache)
263 {
264 setBodyInnerHTML(
265 "<div id='container1' style='width: 200px; height: 200px; background-col or: blue'>"
266 " <div id='content1a'>AAA</div>"
267 " <div id='content1b' style='width: 100px; height: 100px; background-co lor: red'>BBB</div>"
268 "</div>"
269 "<div id='container2' style='width: 200px; height: 200px; background-col or: blue'>"
270 " <div id='content2a'>CCC</div>"
271 " <div id='content2b' style='width: 100px; height: 100px; background-co lor: green'>DDD</div>"
272 "</div>");
273 document().view()->updateAllLifecyclePhases();
274
275 size_t displayItemCount = rootDisplayItemList().displayItems().size();
276
277 Element& content1b = *document().getElementById("content1b");
278 content1b.setAttribute(HTMLNames::styleAttr, "width: 100px; height: 100px; b ackground-color: green");
279
280 updateLifecyclePhasesToPaintForSlimmingPaintV2Clean();
281 const LayoutObject* container2 = document().getElementById("container2")->la youtObject();
282 int cachedSubtreeCount = 0;
283 for (auto& item : newPaintListBeforeUpdate()) {
284 if (item.isCachedSubtree()) {
285 ++cachedSubtreeCount;
286 EXPECT_EQ(container2->displayItemClient(), item.client());
287 if (cachedSubtreeCount == 1)
288 EXPECT_EQ(item.type(), DisplayItem::paintPhaseToCachedSubtreeTyp e(PaintPhaseChildBlockBackground));
289 else if (cachedSubtreeCount == 2)
290 EXPECT_EQ(item.type(), DisplayItem::paintPhaseToCachedSubtreeTyp e(PaintPhaseForeground));
291 }
292 }
293 EXPECT_EQ(2, cachedSubtreeCount);
294
295 compositeForSlimmingPaintV2();
296 EXPECT_EQ(displayItemCount, rootDisplayItemList().displayItems().size());
297 }
298
258 } // namespace blink 299 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698