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

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

Issue 1018053003: Remove blink::RuntimeEnabledFeatures::slimmingPaintDisplayItemCache (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 9 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/SubtreeRecorder.cpp ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | 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 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/LayoutText.h" 8 #include "core/layout/LayoutText.h"
9 #include "core/layout/LayoutView.h" 9 #include "core/layout/LayoutView.h"
10 #include "core/layout/line/InlineTextBox.h" 10 #include "core/layout/line/InlineTextBox.h"
11 #include "core/page/FocusController.h" 11 #include "core/page/FocusController.h"
12 #include "core/paint/DeprecatedPaintLayer.h" 12 #include "core/paint/DeprecatedPaintLayer.h"
13 #include "core/paint/DeprecatedPaintLayerPainter.h" 13 #include "core/paint/DeprecatedPaintLayerPainter.h"
14 #include "core/paint/LayerClipRecorder.h" 14 #include "core/paint/LayerClipRecorder.h"
15 #include "core/paint/LayoutObjectDrawingRecorder.h" 15 #include "core/paint/LayoutObjectDrawingRecorder.h"
16 #include "core/paint/ScopeRecorder.h" 16 #include "core/paint/ScopeRecorder.h"
17 #include "core/paint/SubtreeRecorder.h" 17 #include "core/paint/SubtreeRecorder.h"
18 #include "platform/graphics/GraphicsContext.h" 18 #include "platform/graphics/GraphicsContext.h"
19 #include "platform/graphics/GraphicsLayer.h" 19 #include "platform/graphics/GraphicsLayer.h"
20 #include "platform/graphics/paint/DisplayItemList.h" 20 #include "platform/graphics/paint/DisplayItemList.h"
21 #include "platform/graphics/paint/DrawingDisplayItem.h" 21 #include "platform/graphics/paint/DrawingDisplayItem.h"
22 #include "third_party/skia/include/core/SkCanvas.h" 22 #include "third_party/skia/include/core/SkCanvas.h"
23 #include <gtest/gtest.h> 23 #include <gtest/gtest.h>
24 24
25 namespace blink { 25 namespace blink {
26 26
27 class ViewDisplayListTest : public RenderingTest { 27 class ViewDisplayListTest : public RenderingTest {
28 public: 28 public:
29 ViewDisplayListTest() 29 ViewDisplayListTest()
30 : m_layoutView(nullptr) 30 : m_layoutView(nullptr) { }
31 , m_originalDisplayItemCacheEnabled(false) { }
32 31
33 protected: 32 protected:
34 LayoutView* layoutView() { return m_layoutView; } 33 LayoutView* layoutView() { return m_layoutView; }
35 DisplayItemList& rootDisplayItemList() { return *layoutView()->layer()->grap hicsLayerBacking()->displayItemList(); } 34 DisplayItemList& rootDisplayItemList() { return *layoutView()->layer()->grap hicsLayerBacking()->displayItemList(); }
36 const Vector<OwnPtr<DisplayItem>>& newPaintListBeforeUpdate() { return rootD isplayItemList().m_newPaints; } 35 const Vector<OwnPtr<DisplayItem>>& newPaintListBeforeUpdate() { return rootD isplayItemList().m_newPaints; }
37 36
38 private: 37 private:
39 virtual void SetUp() override 38 virtual void SetUp() override
40 { 39 {
41 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true); 40 RuntimeEnabledFeatures::setSlimmingPaintEnabled(true);
42 m_originalDisplayItemCacheEnabled = RuntimeEnabledFeatures::slimmingPain tDisplayItemCacheEnabled();
43 41
44 RenderingTest::SetUp(); 42 RenderingTest::SetUp();
45 enableCompositing(); 43 enableCompositing();
46 44
47 m_layoutView = document().view()->layoutView(); 45 m_layoutView = document().view()->layoutView();
48 ASSERT_TRUE(m_layoutView); 46 ASSERT_TRUE(m_layoutView);
49 } 47 }
50 48
51 virtual void TearDown() override 49 virtual void TearDown() override
52 { 50 {
53 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false); 51 RuntimeEnabledFeatures::setSlimmingPaintEnabled(false);
54 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(m_origin alDisplayItemCacheEnabled);
55 } 52 }
56 53
57 LayoutView* m_layoutView; 54 LayoutView* m_layoutView;
58 bool m_originalDisplayItemCacheEnabled;
59 }; 55 };
60 56
61 class TestDisplayItem : public DisplayItem { 57 class TestDisplayItem : public DisplayItem {
62 public: 58 public:
63 TestDisplayItem(const LayoutObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } 59 TestDisplayItem(const LayoutObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { }
64 TestDisplayItem(DisplayItemClient displayItemClient, Type type) : DisplayIte m(displayItemClient, type) { } 60 TestDisplayItem(DisplayItemClient displayItemClient, Type type) : DisplayIte m(displayItemClient, type) { }
65 61
66 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } 62 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
67 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); } 63 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); }
68 }; 64 };
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 371
376 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 372 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
377 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain tPhaseBlockBackground)), 373 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain tPhaseBlockBackground)),
378 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), 374 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground),
379 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai ntPhaseBlockBackground)), 375 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai ntPhaseBlockBackground)),
380 TestDisplayItem(secondRenderer, DisplayItem::clipTypeToEndClipType(Displ ayItem::ClipLayerForeground))); 376 TestDisplayItem(secondRenderer, DisplayItem::clipTypeToEndClipType(Displ ayItem::ClipLayerForeground)));
381 } 377 }
382 378
383 TEST_F(ViewDisplayListTest, CachedDisplayItems) 379 TEST_F(ViewDisplayListTest, CachedDisplayItems)
384 { 380 {
385 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
386
387 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); 381 setBodyInnerHTML("<div id='first'><div id='second'></div></div>");
388 LayoutBoxModelObject* firstRenderer = toLayoutBoxModelObject(document().body ()->firstChild()->layoutObject()); 382 LayoutBoxModelObject* firstRenderer = toLayoutBoxModelObject(document().body ()->firstChild()->layoutObject());
389 LayoutBoxModelObject* secondRenderer = toLayoutBoxModelObject(document().bod y()->firstChild()->firstChild()->layoutObject()); 383 LayoutBoxModelObject* secondRenderer = toLayoutBoxModelObject(document().bod y()->firstChild()->firstChild()->layoutObject());
390 GraphicsContext context(nullptr, &rootDisplayItemList()); 384 GraphicsContext context(nullptr, &rootDisplayItemList());
391 385
392 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 386 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
393 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150)); 387 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100, 100, 150, 150));
394 rootDisplayItemList().endNewPaints(); 388 rootDisplayItemList().endNewPaints();
395 389
396 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, 390 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
(...skipping 20 matching lines...) Expand all
417 // The second display item should be cached. 411 // The second display item should be cached.
418 EXPECT_EQ(secondDisplayItem, rootDisplayItemList().paintList()[1].get()); 412 EXPECT_EQ(secondDisplayItem, rootDisplayItemList().paintList()[1].get());
419 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient())); 413 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient()));
420 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient())); 414 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient()));
421 415
422 rootDisplayItemList().invalidateAll(); 416 rootDisplayItemList().invalidateAll();
423 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient())); 417 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient()));
424 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient())); 418 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient()));
425 } 419 }
426 420
427 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret_CacheDisabled) 421 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
428 { 422 {
429 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(false);
430
431 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>"); 423 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
432 document().page()->focusController().setActive(true); 424 document().page()->focusController().setActive(true);
433 document().page()->focusController().setFocused(true); 425 document().page()->focusController().setFocused(true);
434 LayoutView* layoutView = document().layoutView();
435 DeprecatedPaintLayer* rootLayer = layoutView->layer();
436 LayoutObject* htmlRenderer = document().documentElement()->layoutObject();
437 Element* div = toElement(document().body()->firstChild());
438 LayoutObject* divRenderer = document().body()->firstChild()->layoutObject();
439 InlineTextBox* textInlineBox = toLayoutText(div->firstChild()->layoutObject( ))->firstTextBox();
440
441 SkCanvas canvas(800, 600);
442 GraphicsContext context(&canvas, &rootDisplayItemList());
443 DeprecatedPaintLayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 80 0, 600), PaintBehaviorNormal, LayoutSize());
444 DeprecatedPaintLayerPainter(*rootLayer).paintLayerContents(&context, paintin gInfo, PaintLayerPaintingCompositingAllPhases);
445 rootDisplayItemList().endNewPaints();
446
447 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
448 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground),
449 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)));
450
451 div->focus();
452 document().view()->updateLayoutAndStyleForPainting();
453 DeprecatedPaintLayerPainter(*rootLayer).paintLayerContents(&context, paintin gInfo, PaintLayerPaintingCompositingAllPhases);
454 rootDisplayItemList().endNewPaints();
455
456 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
457 TestDisplayItem(htmlRenderer, DisplayItem::BoxDecorationBackground),
458 TestDisplayItem(textInlineBox->displayItemClient(), DisplayItem::paintPh aseToDrawingType(PaintPhaseForeground)),
459 TestDisplayItem(divRenderer, DisplayItem::Caret));
460 }
461
462 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret_CacheEnabled)
463 {
464 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
465
466 setBodyInnerHTML("<div id='div' contentEditable='true' style='outline:none'> XYZ</div>");
467 document().page()->focusController().setActive(true);
468 document().page()->focusController().setFocused(true);
469 LayoutView* layoutView = document().layoutView(); 426 LayoutView* layoutView = document().layoutView();
470 DeprecatedPaintLayer* rootLayer = layoutView->layer(); 427 DeprecatedPaintLayer* rootLayer = layoutView->layer();
471 LayoutObject* htmlRenderer = document().documentElement()->layoutObject(); 428 LayoutObject* htmlRenderer = document().documentElement()->layoutObject();
472 LayoutObject* bodyRenderer = document().body()->layoutObject(); 429 LayoutObject* bodyRenderer = document().body()->layoutObject();
473 Element* div = toElement(document().body()->firstChild()); 430 Element* div = toElement(document().body()->firstChild());
474 LayoutObject* divRenderer = document().body()->firstChild()->layoutObject(); 431 LayoutObject* divRenderer = document().body()->firstChild()->layoutObject();
475 InlineTextBox* textInlineBox = toLayoutText(div->firstChild()->layoutObject( ))->firstTextBox(); 432 InlineTextBox* textInlineBox = toLayoutText(div->firstChild()->layoutObject( ))->firstTextBox();
476 433
477 SkCanvas canvas(800, 600); 434 SkCanvas canvas(800, 600);
478 GraphicsContext context(&canvas, &rootDisplayItemList()); 435 GraphicsContext context(&canvas, &rootDisplayItemList());
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)), 522 TestDisplayItem(container2, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
566 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)), 523 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseBlockBackground)),
567 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)), 524 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
568 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)), 525 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
569 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground))); 526 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)));
570 } 527 }
571 528
572 // Enable this when cached subtree flags are ready. 529 // Enable this when cached subtree flags are ready.
573 TEST_F(ViewDisplayListTest, DISABLED_CachedSubtreeSwapOrder) 530 TEST_F(ViewDisplayListTest, DISABLED_CachedSubtreeSwapOrder)
574 { 531 {
575 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
576
577 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>" 532 setBodyInnerHTML("<div id='container1'><div id='content1'></div></div>"
578 "<div id='container2'><div id='content2'></div></div>"); 533 "<div id='container2'><div id='content2'></div></div>");
579 LayoutObject* container1 = document().body()->firstChild()->layoutObject(); 534 LayoutObject* container1 = document().body()->firstChild()->layoutObject();
580 LayoutObject* content1 = document().body()->firstChild()->firstChild()->layo utObject(); 535 LayoutObject* content1 = document().body()->firstChild()->firstChild()->layo utObject();
581 LayoutObject* container2 = document().body()->firstChild()->nextSibling()->l ayoutObject(); 536 LayoutObject* container2 = document().body()->firstChild()->nextSibling()->l ayoutObject();
582 LayoutObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->layoutObject(); 537 LayoutObject* content2 = document().body()->firstChild()->nextSibling()->fir stChild()->layoutObject();
583 GraphicsContext context(nullptr, &rootDisplayItemList()); 538 GraphicsContext context(nullptr, &rootDisplayItemList());
584 539
585 { 540 {
586 SubtreeRecorder r(&context, *container1, PaintPhaseBlockBackground); 541 SubtreeRecorder r(&context, *container1, PaintPhaseBlockBackground);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseBlockBackground)), 626 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseBlockBackground)),
672 627
673 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseForeground)), 628 TestDisplayItem(container1, DisplayItem::paintPhaseToBeginSubtreeType(Pa intPhaseForeground)),
674 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)), 629 TestDisplayItem(content1, DisplayItem::paintPhaseToDrawingType(PaintPhas eForeground)),
675 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)), 630 TestDisplayItem(container1, DisplayItem::paintPhaseToDrawingType(PaintPh aseForeground)),
676 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseForeground))); 631 TestDisplayItem(container1, DisplayItem::paintPhaseToEndSubtreeType(Pain tPhaseForeground)));
677 } 632 }
678 633
679 TEST_F(ViewDisplayListTest, Scope) 634 TEST_F(ViewDisplayListTest, Scope)
680 { 635 {
681 RuntimeEnabledFeatures::setSlimmingPaintDisplayItemCacheEnabled(true);
682
683 setBodyInnerHTML("<div id='multicol'><div id='content'></div></div>"); 636 setBodyInnerHTML("<div id='multicol'><div id='content'></div></div>");
684 637
685 LayoutObject* multicol = document().body()->firstChild()->layoutObject(); 638 LayoutObject* multicol = document().body()->firstChild()->layoutObject();
686 LayoutObject* content = document().body()->firstChild()->firstChild()->layou tObject(); 639 LayoutObject* content = document().body()->firstChild()->firstChild()->layou tObject();
687 GraphicsContext context(nullptr, &rootDisplayItemList()); 640 GraphicsContext context(nullptr, &rootDisplayItemList());
688 641
689 FloatRect rect1(100, 100, 50, 50); 642 FloatRect rect1(100, 100, 50, 50);
690 FloatRect rect2(150, 100, 50, 50); 643 FloatRect rect2(150, 100, 50, 50);
691 FloatRect rect3(200, 100, 50, 50); 644 FloatRect rect3(200, 100, 50, 50);
692 drawRect(&context, multicol, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100)); 645 drawRect(&context, multicol, PaintPhaseBlockBackground, FloatRect(100, 200, 100, 100));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, 706 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4,
754 TestDisplayItem(multicol, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)), 707 TestDisplayItem(multicol, DisplayItem::paintPhaseToDrawingType(PaintPhas eBlockBackground)),
755 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase Foreground)), 708 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase Foreground)),
756 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase Foreground)), 709 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase Foreground)),
757 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase Foreground))); 710 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase Foreground)));
758 EXPECT_NE(picture1, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p aintList()[1].get())->picture()); 711 EXPECT_NE(picture1, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p aintList()[1].get())->picture());
759 EXPECT_NE(picture2, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p aintList()[2].get())->picture()); 712 EXPECT_NE(picture2, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p aintList()[2].get())->picture());
760 } 713 }
761 714
762 } // namespace blink 715 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/SubtreeRecorder.cpp ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698