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

Unified Diff: third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp

Issue 2821323002: Optimize offscreen animation: don't update paint properties/visual rects (Closed)
Patch Set: Add unit test Created 3 years, 8 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
Index: third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp b/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp
index 324131bdaa23627b2b0a615d0ab29786c4256c25..9ee783cdc4f08ddabd513c80f20101fc9e42d092 100644
--- a/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp
@@ -6,6 +6,8 @@
#include "core/layout/LayoutTestHelper.h"
#include "core/layout/LayoutView.h"
#include "core/paint/PaintLayer.h"
+#include "platform/graphics/GraphicsLayer.h"
+#include "platform/graphics/paint/RasterInvalidationTracking.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,6 +22,15 @@ class PaintInvalidationTest : public ::testing::WithParamInterface<bool>,
PaintInvalidationTest()
: ScopedRootLayerScrollingForTest(GetParam()),
RenderingTest(SingleChildLocalFrameClient::Create()) {}
+
+ protected:
+ const RasterInvalidationTracking* GetRasterInvalidationTracking() const {
+ // TODO(wangxianzhu): Test SPv2.
+ return GetLayoutView()
+ .Layer()
+ ->GraphicsLayerBacking()
+ ->GetRasterInvalidationTracking();
+ }
};
INSTANTIATE_TEST_CASE_P(All, PaintInvalidationTest, ::testing::Bool());
@@ -153,6 +164,43 @@ TEST_P(PaintInvalidationTest, InvisibleTransformUnderFixedOnScroll) {
GetDocument().View()->UpdateAllLifecyclePhases();
}
+TEST_P(PaintInvalidationTest, DelayedFullPaintInvalidation) {
+ EnableCompositing();
+ SetBodyInnerHTML(
+ "<style>body { margin: 0 }</style>"
+ "<div style='height: 4000px'></div>"
+ "<div id='target' style='width: 100px; height: 100px; background: blue'>"
+ "</div>");
+
+ auto* target = GetLayoutObjectByElementId("target");
+ target->SetShouldDoFullPaintInvalidationWithoutGeometryChange(
+ kPaintInvalidationDelayedFull);
+ EXPECT_EQ(kPaintInvalidationDelayedFull,
+ target->FullPaintInvalidationReason());
+ EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate());
+
+ GetDocument().View()->SetTracksPaintInvalidations(true);
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ EXPECT_EQ(nullptr, GetRasterInvalidationTracking());
+ EXPECT_EQ(kPaintInvalidationDelayedFull,
+ target->FullPaintInvalidationReason());
+ EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate());
+ GetDocument().View()->SetTracksPaintInvalidations(false);
+
+ GetDocument().View()->SetTracksPaintInvalidations(true);
+ // Scroll target into view.
+ GetDocument().domWindow()->scrollTo(0, 4000);
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ const auto& raster_invalidations =
+ GetRasterInvalidationTracking()->tracked_raster_invalidations;
+ ASSERT_EQ(1u, raster_invalidations.size());
+ EXPECT_EQ(kPaintInvalidationNone, target->FullPaintInvalidationReason());
+ EXPECT_EQ(IntRect(0, 4000, 100, 100), raster_invalidations[0].rect);
+ EXPECT_EQ(kPaintInvalidationFull, raster_invalidations[0].reason);
+ EXPECT_FALSE(target->NeedsPaintOffsetAndVisualRectUpdate());
+ GetDocument().View()->SetTracksPaintInvalidations(false);
+};
+
} // namespace
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutImage.cpp ('k') | third_party/WebKit/Source/core/paint/PaintInvalidator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698