Commit f0a8a428 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Re-land: [Fast compositing] Don't set any compositing reasons for non-self-painting PaintLayers.

This reverts commit 1a41279a.

virtual/threaded/animations/cancel-unattached-animation.html was failing because
PaintLayerCompositor::CanBeComposited has an early out if the LocalFrameView's IsVisible
bit is false. When that bit changes, compositing inputs need to re-computed, to get a correct
value for PaintLayer::DescendantHasDirectOrScrollingCompositingReason.

Bug: 859304,856808
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_slimming_paint_v2;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I4eb61112f3d396df1361486007c6efd2c6f7b339
Reviewed-on: https://chromium-review.googlesource.com/1123027Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572002}
parent 8d395ba0
......@@ -3821,6 +3821,16 @@ void LocalFrameView::SetParentVisible(bool visible) {
});
}
void LocalFrameView::SetSelfVisible(bool visible) {
if (visible != self_visible_) {
// Frame view visibility affects PLC::CanBeComposited, which in turn
// affects compositing inputs.
if (LayoutView* view = GetLayoutView())
view->Layer()->SetNeedsCompositingInputsUpdate();
}
self_visible_ = visible;
}
void LocalFrameView::Show() {
if (!IsSelfVisible()) {
SetSelfVisible(true);
......
......@@ -421,7 +421,7 @@ class CORE_EXPORT LocalFrameView final
return self_visible_ && parent_visible_;
} // Whether or not we are actually visible.
void SetParentVisible(bool) override;
void SetSelfVisible(bool v) { self_visible_ = v; }
void SetSelfVisible(bool);
void AttachToLayout() override;
void DetachFromLayout() override;
bool IsAttached() const override { return is_attached_; }
......
......@@ -190,6 +190,9 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
info.needs_reparent_scroll_for_fixed = false;
}
PaintLayerCompositor* compositor =
layer->GetLayoutObject().View()->Compositor();
// The sequence of updates to compositing triggers goes like this:
// 1. Apply all triggers from kComboAllDirectNonStyleDeterminedReasons for
// |layer|. This may depend on ancestor composited scrolling (i.e. step
......@@ -212,7 +215,7 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
if (layer->GetScrollableArea()) {
layer->GetScrollableArea()->UpdateNeedsCompositedScrolling(
layer->GetLayoutObject().View()->Compositor()->CanBeComposited(layer) &&
compositor->CanBeComposited(layer) &&
layer->DirectCompositingReasons());
layer->GetScrollableArea()->SetHasPaintLayerScrollChild(false);
}
......@@ -228,7 +231,9 @@ void CompositingInputsUpdater::UpdateRecursive(PaintLayer* layer,
UpdateRecursive(child, update_type, info);
descendant_has_direct_compositing_reason |=
child->DescendantHasDirectOrScrollingCompositingReason() ||
child->DirectCompositingReasons() || child->NeedsCompositedScrolling();
child->NeedsCompositedScrolling() ||
(compositor->CanBeComposited(child) &&
child->DirectCompositingReasons());
}
layer->SetDescendantHasDirectOrScrollingCompositingReason(
descendant_has_direct_compositing_reason);
......
......@@ -248,7 +248,8 @@ static void CheckSubtreeHasNoCompositing(PaintLayer* layer) {
kNegativeZOrderChildren | kNormalFlowChildren | kPositiveZOrderChildren);
while (PaintLayer* cur_layer = iterator.Next()) {
DCHECK(cur_layer->GetCompositingState() == kNotComposited);
DCHECK(!cur_layer->DirectCompositingReasons());
DCHECK(!cur_layer->DirectCompositingReasons() ||
!layer->Compositor()->CanBeComposited(cur_layer));
CheckSubtreeHasNoCompositing(cur_layer);
}
}
......@@ -287,8 +288,11 @@ void CompositingRequirementsUpdater::UpdateRecursive(
!current_recursion_data.compositing_ancestor_->IsRootLayer();
const bool ignore_lcd_text = has_non_root_composited_scrolling_ancestor;
CompositingReasons direct_from_paint_layer =
layer->DirectCompositingReasons();
const bool layer_can_be_composited = compositor->CanBeComposited(layer);
CompositingReasons direct_from_paint_layer = 0;
if (layer_can_be_composited)
direct_from_paint_layer = layer->DirectCompositingReasons();
if (compositing_reason_finder_.RequiresCompositingForScrollDependentPosition(
layer,
......@@ -296,14 +300,18 @@ void CompositingRequirementsUpdater::UpdateRecursive(
direct_from_paint_layer |= CompositingReason::kScrollDependentPosition;
}
DCHECK(
direct_from_paint_layer ==
compositing_reason_finder_.DirectReasons(
layer, ignore_lcd_text || moves_with_respect_to_compositing_ancestor))
<< " Expected: "
<< CompositingReason::ToString(
compositing_reason_finder_.DirectReasons(layer, ignore_lcd_text))
<< " Actual: " << CompositingReason::ToString(direct_from_paint_layer);
#if DCHECK_IS_ON()
if (layer_can_be_composited) {
DCHECK(direct_from_paint_layer ==
compositing_reason_finder_.DirectReasons(
layer,
ignore_lcd_text || moves_with_respect_to_compositing_ancestor))
<< " Expected: "
<< CompositingReason::ToString(
compositing_reason_finder_.DirectReasons(layer, ignore_lcd_text))
<< " Actual: " << CompositingReason::ToString(direct_from_paint_layer);
}
#endif
direct_reasons |= direct_from_paint_layer;
......@@ -320,7 +328,8 @@ void CompositingRequirementsUpdater::UpdateRecursive(
// testing is not used, we must assume we overlap if there is anything
// composited behind us in paint-order.
CompositingReasons overlap_compositing_reason =
current_recursion_data.subtree_is_compositing_
(layer_can_be_composited &&
current_recursion_data.subtree_is_compositing_)
? CompositingReason::kAssumedOverlap
: CompositingReason::kNone;
......@@ -337,7 +346,8 @@ void CompositingRequirementsUpdater::UpdateRecursive(
unclipped_descendants_to_remove.push_back(i);
continue;
}
if (layer->ScrollsWithRespectTo(unclipped_descendant))
if (layer_can_be_composited &&
layer->ScrollsWithRespectTo(unclipped_descendant))
reasons_to_composite |= CompositingReason::kAssumedOverlap;
}
......@@ -372,7 +382,7 @@ void CompositingRequirementsUpdater::UpdateRecursive(
}
absolute_descendant_bounding_box = abs_bounds;
if (current_recursion_data.testing_overlap_ &&
if (layer_can_be_composited && current_recursion_data.testing_overlap_ &&
!RequiresCompositingOrSquashing(direct_reasons)) {
bool overlaps =
overlap_map.OverlapsLayers(abs_bounds, use_clipped_bounding_rect);
......@@ -573,7 +583,8 @@ void CompositingRequirementsUpdater::UpdateRecursive(
compositing_reason_finder_, layer,
child_recursion_data.subtree_is_compositing_,
any_descendant_has3d_transform);
reasons_to_composite |= subtree_compositing_reasons;
if (layer_can_be_composited)
reasons_to_composite |= subtree_compositing_reasons;
if (!will_be_composited_or_squashed && can_be_composited &&
RequiresCompositingOrSquashing(subtree_compositing_reasons)) {
child_recursion_data.compositing_ancestor_ = layer;
......
......@@ -47,4 +47,86 @@ TEST_F(CompositingRequirementsUpdaterTest, FixedPosOverlap) {
EXPECT_EQ(CompositingReason::kNone, fixed->Layer()->GetCompositingReasons());
}
TEST_F(CompositingRequirementsUpdaterTest,
NoOverlapReasonForNonSelfPaintingLayer) {
SetBodyInnerHTML(R"HTML(
<style>
#target {
overflow: auto;
width: 100px;
height: 100px;
margin-top: -50px;
}
</style>
<div style="position: relative; width: 500px; height: 300px;
will-change: transform"></div>
<div id=target></div>
)HTML");
PaintLayer* target =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
EXPECT_FALSE(target->GetCompositingReasons());
// Now make |target| self-painting.
GetDocument().getElementById("target")->setAttribute(HTMLNames::styleAttr,
"position: relative");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(CompositingReason::kOverlap, target->GetCompositingReasons());
}
TEST_F(CompositingRequirementsUpdaterTest,
NoAssumedOverlapReasonForNonSelfPaintingLayer) {
SetBodyInnerHTML(R"HTML(
<style>
#target {
overflow: auto;
width: 100px;
height: 100px;
}
</style>
<div style="position: relative; width: 500px; height: 300px;
transform: translateZ(0)"></div>
<div id=target></div>
)HTML");
PaintLayer* target =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
EXPECT_FALSE(target->GetCompositingReasons());
// Now make |target| self-painting.
GetDocument().getElementById("target")->setAttribute(HTMLNames::styleAttr,
"position: relative");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(CompositingReason::kAssumedOverlap,
target->GetCompositingReasons());
}
TEST_F(CompositingRequirementsUpdaterTest,
NoDescendantReasonForNonSelfPaintingLayer) {
SetBodyInnerHTML(R"HTML(
<style>
#target {
overflow: auto;
width: 100px;
height: 100px;
}
</style>
<div id=target>
<div style="backface-visibility: hidden"></div>
</div>
)HTML");
PaintLayer* target =
ToLayoutBoxModelObject(GetLayoutObjectByElementId("target"))->Layer();
EXPECT_FALSE(target->GetCompositingReasons());
// Now make |target| self-painting.
GetDocument().getElementById("target")->setAttribute(HTMLNames::styleAttr,
"position: relative");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(CompositingReason::kClipsCompositingDescendants,
target->GetCompositingReasons());
}
} // namespace blink
......@@ -233,7 +233,6 @@ TEST_P(PaintLayerTest, CompositedScrollingNoNeedsRepaint) {
if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled())
return;
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='scroll' style='width: 100px; height: 100px; overflow: scroll;
will-change: transform'>
......@@ -486,7 +485,6 @@ TEST_P(PaintLayerTest, HasDescendantWithClipPath) {
}
TEST_P(PaintLayerTest, HasVisibleDescendant) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='invisible' style='position:relative'>
<div id='visible' style='visibility: visible; position: relative'>
......@@ -504,7 +502,6 @@ TEST_P(PaintLayerTest, HasVisibleDescendant) {
}
TEST_P(PaintLayerTest, Has3DTransformedDescendant) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='parent' style='position:relative; z-index: 0'>
<div id='child' style='transform: translateZ(1px)'>
......@@ -519,7 +516,6 @@ TEST_P(PaintLayerTest, Has3DTransformedDescendant) {
}
TEST_P(PaintLayerTest, Has3DTransformedDescendantChangeStyle) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='parent' style='position:relative; z-index: 0'>
<div id='child' style='position:relative '>
......@@ -541,7 +537,6 @@ TEST_P(PaintLayerTest, Has3DTransformedDescendantChangeStyle) {
}
TEST_P(PaintLayerTest, Has3DTransformedDescendantNotStacking) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='parent' style='position:relative;'>
<div id='child' style='transform: translateZ(1px)'>
......@@ -558,7 +553,6 @@ TEST_P(PaintLayerTest, Has3DTransformedDescendantNotStacking) {
}
TEST_P(PaintLayerTest, Has3DTransformedGrandchildWithPreserve3d) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='parent' style='position:relative; z-index: 0'>
<div id='child' style='transform-style: preserve-3d'>
......@@ -577,7 +571,6 @@ TEST_P(PaintLayerTest, Has3DTransformedGrandchildWithPreserve3d) {
}
TEST_P(PaintLayerTest, DescendantDependentFlagsStopsAtThrottledFrames) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<style>body { margin: 0; }</style>
<div id='transform' style='transform: translate3d(4px, 5px, 6px);'>
......@@ -669,7 +662,6 @@ TEST_P(PaintLayerTest, PaintInvalidationOnNonCompositedScroll) {
}
TEST_P(PaintLayerTest, PaintInvalidationOnCompositedScroll) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<style>* { margin: 0 } ::-webkit-scrollbar { display: none }</style>
<div id='scroller' style='overflow: scroll; width: 50px; height: 50px;
......@@ -699,7 +691,6 @@ TEST_P(PaintLayerTest, PaintInvalidationOnCompositedScroll) {
}
TEST_P(PaintLayerTest, CompositingContainerStackedFloatUnderStackingInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -724,7 +715,6 @@ TEST_P(PaintLayerTest, CompositingContainerStackedFloatUnderStackingInline) {
TEST_P(PaintLayerTest,
CompositingContainerStackedFloatUnderStackingCompositedInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -749,7 +739,6 @@ TEST_P(PaintLayerTest,
}
TEST_P(PaintLayerTest, CompositingContainerNonStackedFloatUnderStackingInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -775,7 +764,6 @@ TEST_P(PaintLayerTest, CompositingContainerNonStackedFloatUnderStackingInline) {
TEST_P(PaintLayerTest,
CompositingContainerNonStackedFloatUnderStackingCompositedInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -801,7 +789,6 @@ TEST_P(PaintLayerTest,
TEST_P(PaintLayerTest,
CompositingContainerStackedUnderFloatUnderStackingInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -828,7 +815,6 @@ TEST_P(PaintLayerTest,
TEST_P(PaintLayerTest,
CompositingContainerStackedUnderFloatUnderStackingCompositedInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -856,7 +842,6 @@ TEST_P(PaintLayerTest,
TEST_P(PaintLayerTest,
CompositingContainerNonStackedUnderFloatUnderStackingInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -884,7 +869,6 @@ TEST_P(PaintLayerTest,
TEST_P(PaintLayerTest,
CompositingContainerNonStackedUnderFloatUnderStackingCompositedInline) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -1090,7 +1074,6 @@ TEST_P(PaintLayerTest, LayerUnderFloatUnderInlineLayer) {
}
TEST_P(PaintLayerTest, CompositingContainerFloatingIframe) {
EnableCompositing();
SetBodyInnerHTML(R"HTML(
<div id='compositedContainer' style='position: relative;
will-change: transform'>
......@@ -1229,7 +1212,6 @@ TEST_P(PaintLayerTest, NeedsRepaintOnSelfPaintingStatusChange) {
}
TEST_P(PaintLayerTest, NeedsRepaintOnRemovingStackedLayer) {
EnableCompositing();
SetBodyInnerHTML(
"<style>body {margin-top: 200px; backface-visibility: hidden}</style>"
"<div id='target' style='position: absolute; top: 0'>Text</div>");
......
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