OLD | NEW |
---|---|
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/ClipPathDisplayItem.h" | 9 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
10 #include "platform/graphics/paint/ClipPathRecorder.h" | 10 #include "platform/graphics/paint/ClipPathRecorder.h" |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
821 TestDisplayItem(multicol, backgroundDrawingType), | 821 TestDisplayItem(multicol, backgroundDrawingType), |
822 TestDisplayItem(content, foregroundDrawingType), | 822 TestDisplayItem(content, foregroundDrawingType), |
823 TestDisplayItem(content, foregroundDrawingType), | 823 TestDisplayItem(content, foregroundDrawingType), |
824 TestDisplayItem(content, foregroundDrawingType)); | 824 TestDisplayItem(content, foregroundDrawingType)); |
825 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); | 825 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[1]).picture()); |
826 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); | 826 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().newDisplayItemList()[2]).picture()); |
827 | 827 |
828 getPaintController().commitNewDisplayItems(); | 828 getPaintController().commitNewDisplayItems(); |
829 } | 829 } |
830 | 830 |
831 TEST_F(PaintControllerTest, PartialSkipCache) | |
832 { | |
833 FakeDisplayItemClient content("content"); | |
834 GraphicsContext context(getPaintController()); | |
835 | |
836 FloatRect rect1(100, 100, 50, 50); | |
837 FloatRect rect2(150, 100, 50, 50); | |
838 FloatRect rect3(200, 100, 50, 50); | |
839 | |
840 drawRect(context, content, backgroundDrawingType, rect1); | |
841 getPaintController().beginSkippingCache(); | |
842 drawRect(context, content, foregroundDrawingType, rect2); | |
843 getPaintController().endSkippingCache(); | |
844 drawRect(context, content, foregroundDrawingType, rect3); | |
845 | |
846 getPaintController().commitNewDisplayItems(); | |
847 | |
848 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | |
849 TestDisplayItem(content, backgroundDrawingType), | |
850 TestDisplayItem(content, foregroundDrawingType), | |
851 TestDisplayItem(content, foregroundDrawingType)); | |
852 RefPtr<const SkPicture> picture0 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[0]).picture(); | |
853 RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[1]).picture(); | |
854 RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(ge tPaintController().getDisplayItemList()[2]).picture(); | |
855 EXPECT_NE(picture1, picture2); | |
856 | |
857 // Draw again with nothing invalidated. | |
858 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); | |
chrishtr
2016/07/27 20:14:57
Add a comment that it's not valid because at least
Xianzhu
2016/07/27 20:40:34
Done.
| |
859 | |
860 drawRect(context, content, backgroundDrawingType, rect1); | |
861 getPaintController().beginSkippingCache(); | |
862 drawRect(context, content, foregroundDrawingType, rect2); | |
863 getPaintController().endSkippingCache(); | |
864 drawRect(context, content, foregroundDrawingType, rect3); | |
865 | |
866 EXPECT_EQ(0, numCachedNewItems()); | |
867 #if DCHECK_IS_ON() | |
868 EXPECT_EQ(0, numSequentialMatches()); | |
869 EXPECT_EQ(0, numOutOfOrderMatches()); | |
870 EXPECT_EQ(0, numIndexedItems()); | |
871 #endif | |
872 | |
873 getPaintController().commitNewDisplayItems(); | |
874 | |
875 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, | |
876 TestDisplayItem(content, backgroundDrawingType), | |
877 TestDisplayItem(content, foregroundDrawingType), | |
878 TestDisplayItem(content, foregroundDrawingType)); | |
879 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[0]).picture()); | |
880 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[1]).picture()); | |
881 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle r().getDisplayItemList()[2]).picture()); | |
882 } | |
883 | |
831 TEST_F(PaintControllerTest, OptimizeNoopPairs) | 884 TEST_F(PaintControllerTest, OptimizeNoopPairs) |
832 { | 885 { |
833 FakeDisplayItemClient first("first"); | 886 FakeDisplayItemClient first("first"); |
834 FakeDisplayItemClient second("second"); | 887 FakeDisplayItemClient second("second"); |
835 FakeDisplayItemClient third("third"); | 888 FakeDisplayItemClient third("third"); |
836 | 889 |
837 GraphicsContext context(getPaintController()); | 890 GraphicsContext context(getPaintController()); |
838 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 891 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
839 { | 892 { |
840 ClipPathRecorder clipRecorder(context, second, Path()); | 893 ClipPathRecorder clipRecorder(context, second, Path()); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1051 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path); | 1104 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien t, path); |
1052 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); | 1105 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10 0)); |
1053 for (int j = 0; j < 50; ++j) | 1106 for (int j = 0; j < 50; ++j) |
1054 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ; | 1107 getPaintController().createAndAppend<EndClipPathDisplayItem>(client) ; |
1055 getPaintController().commitNewDisplayItems(LayoutSize()); | 1108 getPaintController().commitNewDisplayItems(LayoutSize()); |
1056 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); | 1109 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster ization()); |
1057 } | 1110 } |
1058 } | 1111 } |
1059 | 1112 |
1060 } // namespace blink | 1113 } // namespace blink |
OLD | NEW |