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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp

Issue 2022563002: Remove display item scope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 "platform/graphics/paint/PaintController.h" 5 #include "platform/graphics/paint/PaintController.h"
6 6
7 #include "platform/RuntimeEnabledFeatures.h" 7 #include "platform/RuntimeEnabledFeatures.h"
8 #include "platform/graphics/GraphicsContext.h" 8 #include "platform/graphics/GraphicsContext.h"
9 #include "platform/graphics/paint/CachedDisplayItem.h" 9 #include "platform/graphics/paint/CachedDisplayItem.h"
10 #include "platform/graphics/paint/ClipPathDisplayItem.h" 10 #include "platform/graphics/paint/ClipPathDisplayItem.h"
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 615
616 TestDisplayItem(container1, DisplayItem::Subsequence), 616 TestDisplayItem(container1, DisplayItem::Subsequence),
617 TestDisplayItem(content1, DisplayItem::Subsequence), 617 TestDisplayItem(content1, DisplayItem::Subsequence),
618 TestDisplayItem(content1, backgroundDrawingType), 618 TestDisplayItem(content1, backgroundDrawingType),
619 TestDisplayItem(content1, foregroundDrawingType), 619 TestDisplayItem(content1, foregroundDrawingType),
620 TestDisplayItem(content1, DisplayItem::EndSubsequence), 620 TestDisplayItem(content1, DisplayItem::EndSubsequence),
621 TestDisplayItem(container1, foregroundDrawingType), 621 TestDisplayItem(container1, foregroundDrawingType),
622 TestDisplayItem(container1, DisplayItem::EndSubsequence)); 622 TestDisplayItem(container1, DisplayItem::EndSubsequence));
623 } 623 }
624 624
625 TEST_F(PaintControllerTest, Scope) 625 TEST_F(PaintControllerTest, SkipCache)
626 { 626 {
627 FakeDisplayItemClient multicol("multicol"); 627 FakeDisplayItemClient multicol("multicol");
628 FakeDisplayItemClient content("content"); 628 FakeDisplayItemClient content("content");
629 GraphicsContext context(getPaintController()); 629 GraphicsContext context(getPaintController());
630 630
631 FloatRect rect1(100, 100, 50, 50); 631 FloatRect rect1(100, 100, 50, 50);
632 FloatRect rect2(150, 100, 50, 50); 632 FloatRect rect2(150, 100, 50, 50);
633 FloatRect rect3(200, 100, 50, 50); 633 FloatRect rect3(200, 100, 50, 50);
634 634
635 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 635 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100));
636 636
637 getPaintController().beginScope(); 637 getPaintController().beginSkippingCache();
638 drawRect(context, content, foregroundDrawingType, rect1); 638 drawRect(context, content, foregroundDrawingType, rect1);
639 getPaintController().endScope(); 639 drawRect(context, content, foregroundDrawingType, rect2);
640 getPaintController().endSkippingCache();
640 641
641 getPaintController().beginScope();
642 drawRect(context, content, foregroundDrawingType, rect2);
643 getPaintController().endScope();
644 getPaintController().commitNewDisplayItems(); 642 getPaintController().commitNewDisplayItems();
645 643
646 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 644 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
647 TestDisplayItem(multicol, backgroundDrawingType), 645 TestDisplayItem(multicol, backgroundDrawingType),
648 TestDisplayItem(content, foregroundDrawingType), 646 TestDisplayItem(content, foregroundDrawingType),
649 TestDisplayItem(content, foregroundDrawingType)); 647 TestDisplayItem(content, foregroundDrawingType));
650 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); 648 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture();
651 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); 649 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture();
652 EXPECT_NE(picture1, picture2); 650 EXPECT_NE(picture1, picture2);
653 651
654 // Draw again with nothing invalidated. 652 // Draw again with nothing invalidated.
655 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol)); 653 EXPECT_TRUE(getPaintController().clientCacheIsValid(multicol));
656 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100)); 654 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 200, 100, 100));
657 getPaintController().beginScope(); 655
656 getPaintController().beginSkippingCache();
658 drawRect(context, content, foregroundDrawingType, rect1); 657 drawRect(context, content, foregroundDrawingType, rect1);
659 getPaintController().endScope();
660
661 getPaintController().beginScope();
662 drawRect(context, content, foregroundDrawingType, rect2); 658 drawRect(context, content, foregroundDrawingType, rect2);
663 getPaintController().endScope(); 659 getPaintController().endSkippingCache();
664 660
665 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 3, 661 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 3,
666 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba ckgroundDrawingType)), 662 TestDisplayItem(multicol, DisplayItem::drawingTypeToCachedDrawingType(ba ckgroundDrawingType)),
667 TestDisplayItem(content, foregroundDrawingType), 663 TestDisplayItem(content, foregroundDrawingType),
668 TestDisplayItem(content, foregroundDrawingType)); 664 TestDisplayItem(content, foregroundDrawingType));
669 665
670 getPaintController().commitNewDisplayItems(); 666 getPaintController().commitNewDisplayItems();
671 667
672 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, 668 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3,
673 TestDisplayItem(multicol, backgroundDrawingType), 669 TestDisplayItem(multicol, backgroundDrawingType),
674 TestDisplayItem(content, foregroundDrawingType), 670 TestDisplayItem(content, foregroundDrawingType),
675 TestDisplayItem(content, foregroundDrawingType)); 671 TestDisplayItem(content, foregroundDrawingType));
676 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); 672 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture());
677 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); 673 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture());
678 674
679 // Now the multicol becomes 3 columns and repaints. 675 // Now the multicol becomes 3 columns and repaints.
680 multicol.setDisplayItemsUncached(); 676 multicol.setDisplayItemsUncached();
681 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100)); 677 drawRect(context, multicol, backgroundDrawingType, FloatRect(100, 100, 100, 100));
682 678
683 getPaintController().beginScope(); 679 getPaintController().beginSkippingCache();
684 drawRect(context, content, foregroundDrawingType, rect1); 680 drawRect(context, content, foregroundDrawingType, rect1);
685 getPaintController().endScope();
686
687 getPaintController().beginScope();
688 drawRect(context, content, foregroundDrawingType, rect2); 681 drawRect(context, content, foregroundDrawingType, rect2);
689 getPaintController().endScope();
690
691 getPaintController().beginScope();
692 drawRect(context, content, foregroundDrawingType, rect3); 682 drawRect(context, content, foregroundDrawingType, rect3);
693 getPaintController().endScope(); 683 getPaintController().endSkippingCache();
694 684
695 // We should repaint everything on invalidation of the scope container. 685 // We should repaint everything on invalidation of the scope container.
696 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4, 686 EXPECT_DISPLAY_LIST(getPaintController().newDisplayItemList(), 4,
697 TestDisplayItem(multicol, backgroundDrawingType), 687 TestDisplayItem(multicol, backgroundDrawingType),
698 TestDisplayItem(content, foregroundDrawingType), 688 TestDisplayItem(content, foregroundDrawingType),
699 TestDisplayItem(content, foregroundDrawingType), 689 TestDisplayItem(content, foregroundDrawingType),
700 TestDisplayItem(content, foregroundDrawingType)); 690 TestDisplayItem(content, foregroundDrawingType));
701 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); 691 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture());
702 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); 692 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture());
703 693
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 820
831 drawPath(context, client, backgroundDrawingType, 50); 821 drawPath(context, client, backgroundDrawingType, 50);
832 getPaintController().commitNewDisplayItems(LayoutSize()); 822 getPaintController().commitNewDisplayItems(LayoutSize());
833 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 823 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
834 } 824 }
835 825
836 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicturesSing lePathEach) 826 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationMultiplePicturesSing lePathEach)
837 { 827 {
838 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 828 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
839 GraphicsContext context(getPaintController()); 829 GraphicsContext context(getPaintController());
830 getPaintController().beginSkippingCache();
840 831
841 for (int i = 0; i < 50; ++i) { 832 for (int i = 0; i < 50; ++i)
842 getPaintController().beginScope();
843 drawPath(context, client, backgroundDrawingType, 50); 833 drawPath(context, client, backgroundDrawingType, 50);
844 getPaintController().endScope();
845 }
846 834
835 getPaintController().endSkippingCache();
847 getPaintController().commitNewDisplayItems(LayoutSize()); 836 getPaintController().commitNewDisplayItems(LayoutSize());
848 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion()); 837 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRasterizat ion());
849 } 838 }
850 839
851 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsTwoPaints) 840 TEST_F(PaintControllerTest, IsNotSuitableForGpuRasterizationSinglePictureManyPat hsTwoPaints)
852 { 841 {
853 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100)); 842 FakeDisplayItemClient client("test client", LayoutRect(0, 0, 200, 100));
854 843
855 { 844 {
856 GraphicsContext context(getPaintController()); 845 GraphicsContext context(getPaintController());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path); 912 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path);
924 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); 913 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0));
925 for (int j = 0; j < 50; ++j) 914 for (int j = 0; j < 50; ++j)
926 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ; 915 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ;
927 getPaintController().commitNewDisplayItems(LayoutSize()); 916 getPaintController().commitNewDisplayItems(LayoutSize());
928 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); 917 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization());
929 } 918 }
930 } 919 }
931 920
932 } // namespace blink 921 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698