Commit 10056cdd authored by wangxianzhu's avatar wangxianzhu Committed by Commit bot

Optimize offscreen animation: don't update paint properties/visual rects

CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2821323002
Cr-Commit-Position: refs/heads/master@{#468081}
parent 89209614
...@@ -1756,7 +1756,7 @@ void LayoutBox::PaintMask(const PaintInfo& paint_info, ...@@ -1756,7 +1756,7 @@ void LayoutBox::PaintMask(const PaintInfo& paint_info,
} }
void LayoutBox::ImageChanged(WrappedImagePtr image, const IntRect*) { void LayoutBox::ImageChanged(WrappedImagePtr image, const IntRect*) {
// TODO(chrishtr): support PaintInvalidationDelayedFull for animated border // TODO(chrishtr): support kPaintInvalidationDelayedFull for animated border
// images. // images.
if ((StyleRef().BorderImage().GetImage() && if ((StyleRef().BorderImage().GetImage() &&
StyleRef().BorderImage().GetImage()->Data() == image) || StyleRef().BorderImage().GetImage()->Data() == image) ||
...@@ -1878,14 +1878,11 @@ void LayoutBox::EnsureIsReadyForPaintInvalidation() { ...@@ -1878,14 +1878,11 @@ void LayoutBox::EnsureIsReadyForPaintInvalidation() {
return; return;
// Do regular full paint invalidation if the object with // Do regular full paint invalidation if the object with
// PaintInvalidationDelayedFull is onscreen. // kPaintInvalidationDelayedFull is onscreen.
if (IntersectsVisibleViewport()) {
// Conservatively assume the delayed paint invalidation was caused by // Conservatively assume the delayed paint invalidation was caused by
// background image change. // background image change.
SetBackgroundChangedSinceLastPaintInvalidation(); SetBackgroundChangedSinceLastPaintInvalidation();
SetShouldDoFullPaintInvalidationWithoutGeometryChange( SetShouldDoFullPaintInvalidationWithoutGeometryChange(kPaintInvalidationFull);
kPaintInvalidationFull);
}
} }
PaintInvalidationReason LayoutBox::InvalidatePaint( PaintInvalidationReason LayoutBox::InvalidatePaint(
......
...@@ -170,10 +170,10 @@ void LayoutImage::InvalidatePaintAndMarkForLayoutIfNeeded() { ...@@ -170,10 +170,10 @@ void LayoutImage::InvalidatePaintAndMarkForLayoutIfNeeded() {
return; return;
} }
if (ImageResource() && ImageResource()->MaybeAnimated()) SetShouldDoFullPaintInvalidationWithoutGeometryChange(
SetShouldDoFullPaintInvalidation(kPaintInvalidationDelayedFull); ImageResource() && ImageResource()->MaybeAnimated()
else ? kPaintInvalidationDelayedFull
SetShouldDoFullPaintInvalidation(kPaintInvalidationFull); : kPaintInvalidationFull);
// Tell any potential compositing layers that the image needs updating. // Tell any potential compositing layers that the image needs updating.
ContentChanged(kImageChanged); ContentChanged(kImageChanged);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "core/layout/LayoutTestHelper.h" #include "core/layout/LayoutTestHelper.h"
#include "core/layout/LayoutView.h" #include "core/layout/LayoutView.h"
#include "core/paint/PaintLayer.h" #include "core/paint/PaintLayer.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/graphics/paint/RasterInvalidationTracking.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -20,6 +22,15 @@ class PaintInvalidationTest : public ::testing::WithParamInterface<bool>, ...@@ -20,6 +22,15 @@ class PaintInvalidationTest : public ::testing::WithParamInterface<bool>,
PaintInvalidationTest() PaintInvalidationTest()
: ScopedRootLayerScrollingForTest(GetParam()), : ScopedRootLayerScrollingForTest(GetParam()),
RenderingTest(SingleChildLocalFrameClient::Create()) {} 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()); INSTANTIATE_TEST_CASE_P(All, PaintInvalidationTest, ::testing::Bool());
...@@ -153,6 +164,43 @@ TEST_P(PaintInvalidationTest, InvisibleTransformUnderFixedOnScroll) { ...@@ -153,6 +164,43 @@ TEST_P(PaintInvalidationTest, InvisibleTransformUnderFixedOnScroll) {
GetDocument().View()->UpdateAllLifecyclePhases(); 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
} // namespace blink } // namespace blink
...@@ -510,7 +510,8 @@ void PaintInvalidator::InvalidatePaint(const LayoutObject& object, ...@@ -510,7 +510,8 @@ void PaintInvalidator::InvalidatePaint(const LayoutObject& object,
void PaintInvalidator::ProcessPendingDelayedPaintInvalidations() { void PaintInvalidator::ProcessPendingDelayedPaintInvalidations() {
for (auto target : pending_delayed_paint_invalidations_) { for (auto target : pending_delayed_paint_invalidations_) {
target->GetMutableForPainting().SetShouldDoFullPaintInvalidation( target->GetMutableForPainting()
.SetShouldDoFullPaintInvalidationWithoutGeometryChange(
kPaintInvalidationDelayedFull); kPaintInvalidationDelayedFull);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment