Skip to content

Commit

Permalink
[CompositeAfterPaint] Don't composite during printing
Browse files Browse the repository at this point in the history
This avoid unnecessary over-painting for composited layers (with cull
rects expanded by thousands of pixels) during printing.

This CL avoids some printing/ test failures due to expanded cull rects
when CullRectUpdate is enabled.

Bug: 1046544
Change-Id: I2f1582dcaf8a8ba91b9aa700ae459cf51a5dc935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2724848
Reviewed-by: Philip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#859064}
  • Loading branch information
wangxianzhu authored and Chromium LUCI CQ committed Mar 2, 2021
1 parent 6fc89cf commit 18eecd4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ static CompositingReasons BackfaceInvisibility3DAncestorReason(

CompositingReasons CompositingReasonFinder::DirectReasonsForPaintProperties(
const LayoutObject& object) {
if (object.GetDocument().Printing())
return CompositingReason::kNone;

// TODO(wangxianzhu): Don't depend on PaintLayer for CompositeAfterPaint.
if (!object.HasLayer()) {
if (object.IsSVGChild())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5849,15 +5849,28 @@ TEST_P(PaintPropertyTreeBuilderTest, RepeatingFixedPositionInPagedMedia) {
EXPECT_EQ(3u, NumFragments(fixed));
for (int i = 0; i < 3; i++) {
const auto& fragment = FragmentAt(fixed, i);
EXPECT_EQ(PhysicalOffset(0, 0), fragment.PaintOffset());
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
// In CompositeAfterPaint, we don't composite and create
// PaintOffsetTranslation for the fixed-position element during printing.
EXPECT_EQ(PhysicalOffset(20, 400 * i - 180), fragment.PaintOffset());
EXPECT_FALSE(fragment.PaintProperties());
} else {
// In pre-CompositeAfterPaint, we create PaintOffsetTranslation because
// the fixed-position element is currently composited.
EXPECT_EQ(PhysicalOffset(0, 0), fragment.PaintOffset());
EXPECT_EQ(FloatSize(20, 400 * i - 180), fragment.PaintProperties()
->PaintOffsetTranslation()
->Translation2D());
}
EXPECT_EQ(LayoutUnit(400 * i), fragment.LogicalTopInFlowThread());
}

EXPECT_FALSE(fixed_child->IsFixedPositionObjectInPagedMedia());
EXPECT_EQ(3u, NumFragments(fixed_child));
for (int i = 0; i < 3; i++) {
const auto& fragment = FragmentAt(fixed_child, i);
EXPECT_EQ(PhysicalOffset(0, 10), fragment.PaintOffset());
EXPECT_EQ(FragmentAt(fixed, i).PaintOffset() + PhysicalOffset(0, 10),
fragment.PaintOffset());
EXPECT_EQ(LayoutUnit(i * 400), fragment.LogicalTopInFlowThread());
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 18eecd4

Please sign in to comment.