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 // Content's cache is invalid because it has display items skipped cache. |
| 858 EXPECT_FALSE(getPaintController().clientCacheIsValid(content)); |
| 859 EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason()); |
| 860 |
| 861 // Draw again with nothing invalidated. |
| 862 drawRect(context, content, backgroundDrawingType, rect1); |
| 863 getPaintController().beginSkippingCache(); |
| 864 drawRect(context, content, foregroundDrawingType, rect2); |
| 865 getPaintController().endSkippingCache(); |
| 866 drawRect(context, content, foregroundDrawingType, rect3); |
| 867 |
| 868 EXPECT_EQ(0, numCachedNewItems()); |
| 869 #if DCHECK_IS_ON() |
| 870 EXPECT_EQ(0, numSequentialMatches()); |
| 871 EXPECT_EQ(0, numOutOfOrderMatches()); |
| 872 EXPECT_EQ(0, numIndexedItems()); |
| 873 #endif |
| 874 |
| 875 getPaintController().commitNewDisplayItems(); |
| 876 |
| 877 EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| 878 TestDisplayItem(content, backgroundDrawingType), |
| 879 TestDisplayItem(content, foregroundDrawingType), |
| 880 TestDisplayItem(content, foregroundDrawingType)); |
| 881 EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[0]).picture()); |
| 882 EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[1]).picture()); |
| 883 EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintControlle
r().getDisplayItemList()[2]).picture()); |
| 884 } |
| 885 |
831 TEST_F(PaintControllerTest, OptimizeNoopPairs) | 886 TEST_F(PaintControllerTest, OptimizeNoopPairs) |
832 { | 887 { |
833 FakeDisplayItemClient first("first"); | 888 FakeDisplayItemClient first("first"); |
834 FakeDisplayItemClient second("second"); | 889 FakeDisplayItemClient second("second"); |
835 FakeDisplayItemClient third("third"); | 890 FakeDisplayItemClient third("third"); |
836 | 891 |
837 GraphicsContext context(getPaintController()); | 892 GraphicsContext context(getPaintController()); |
838 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); | 893 drawRect(context, first, backgroundDrawingType, FloatRect(0, 0, 100, 100)); |
839 { | 894 { |
840 ClipPathRecorder clipRecorder(context, second, Path()); | 895 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); | 1106 getPaintController().createAndAppend<BeginClipPathDisplayItem>(clien
t, path); |
1052 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); | 1107 drawRect(context, client, backgroundDrawingType, FloatRect(0, 0, 100, 10
0)); |
1053 for (int j = 0; j < 50; ++j) | 1108 for (int j = 0; j < 50; ++j) |
1054 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; | 1109 getPaintController().createAndAppend<EndClipPathDisplayItem>(client)
; |
1055 getPaintController().commitNewDisplayItems(LayoutSize()); | 1110 getPaintController().commitNewDisplayItems(LayoutSize()); |
1056 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); | 1111 EXPECT_FALSE(getPaintController().paintArtifact().isSuitableForGpuRaster
ization()); |
1057 } | 1112 } |
1058 } | 1113 } |
1059 | 1114 |
1060 } // namespace blink | 1115 } // namespace blink |
OLD | NEW |