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

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

Issue 2185933003: Fix issues of display item client cache flags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2b8cff0b37d1028c059b10dd031f65cd7174ed61 100644
--- a/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/paint/PaintControllerTest.cpp
@@ -828,6 +828,61 @@ 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);
+
+ // Content's cache is invalid because it has display items skipped cache.
+ EXPECT_FALSE(getPaintController().clientCacheIsValid(content));
+ EXPECT_EQ(PaintInvalidationFull, content.getPaintInvalidationReason());
+
+ // Draw again with nothing invalidated.
+ 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");
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/paint/PaintController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698