Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp b/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp |
| index bd10716d77e2343ef1af1ffa0330b93f40302682..a2fa2b1e4b66be20aaf43563008751f785338e47 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp |
| @@ -828,6 +828,59 @@ TEST_F(PaintControllerTest, SkipCache) |
| getPaintController().commitNewDisplayItems(); |
| } |
| +TEST_F(PaintControllerTest, PartialSkipCache) |
| +{ |
| + FakeDisplayItemClient content("content"); |
| + GraphicsContext context(getPaintController()); |
| + |
| + FloatRect rect1(100, 100, 50, 50); |
| + FloatRect rect2(150, 100, 50, 50); |
| + FloatRect rect3(200, 100, 50, 50); |
| + |
| + drawRect(context, content, backgroundDrawingType, rect1); |
| + getPaintController().beginSkippingCache(); |
| + drawRect(context, content, foregroundDrawingType, rect2); |
| + getPaintController().endSkippingCache(); |
| + drawRect(context, content, foregroundDrawingType, rect3); |
| + |
| + getPaintController().commitNewDisplayItems(); |
| + |
| + EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| + TestDisplayItem(content, backgroundDrawingType), |
| + TestDisplayItem(content, foregroundDrawingType), |
| + TestDisplayItem(content, foregroundDrawingType)); |
| + RefPtr<const SkPicture> picture0 = static_cast<const DrawingDisplayItem&>(getPaintController().getDisplayItemList()[0]).picture(); |
| + RefPtr<const SkPicture> picture1 = static_cast<const DrawingDisplayItem&>(getPaintController().getDisplayItemList()[1]).picture(); |
| + RefPtr<const SkPicture> picture2 = static_cast<const DrawingDisplayItem&>(getPaintController().getDisplayItemList()[2]).picture(); |
| + EXPECT_NE(picture1, picture2); |
| + |
| + // Draw again with nothing invalidated. |
| + 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.
|
| + |
| + drawRect(context, content, backgroundDrawingType, rect1); |
| + getPaintController().beginSkippingCache(); |
| + drawRect(context, content, foregroundDrawingType, rect2); |
| + getPaintController().endSkippingCache(); |
| + drawRect(context, content, foregroundDrawingType, rect3); |
| + |
| + EXPECT_EQ(0, numCachedNewItems()); |
| +#if DCHECK_IS_ON() |
| + EXPECT_EQ(0, numSequentialMatches()); |
| + EXPECT_EQ(0, numOutOfOrderMatches()); |
| + EXPECT_EQ(0, numIndexedItems()); |
| +#endif |
| + |
| + getPaintController().commitNewDisplayItems(); |
| + |
| + EXPECT_DISPLAY_LIST(getPaintController().getDisplayItemList(), 3, |
| + TestDisplayItem(content, backgroundDrawingType), |
| + TestDisplayItem(content, foregroundDrawingType), |
| + TestDisplayItem(content, foregroundDrawingType)); |
| + EXPECT_NE(picture0, static_cast<const DrawingDisplayItem&>(getPaintController().getDisplayItemList()[0]).picture()); |
| + EXPECT_NE(picture1, static_cast<const DrawingDisplayItem&>(getPaintController().getDisplayItemList()[1]).picture()); |
| + EXPECT_NE(picture2, static_cast<const DrawingDisplayItem&>(getPaintController().getDisplayItemList()[2]).picture()); |
| +} |
| + |
| TEST_F(PaintControllerTest, OptimizeNoopPairs) |
| { |
| FakeDisplayItemClient first("first"); |