Commit e2bc7c0f authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Treat trivial 3D transforms as triggers for composited scrolling

Trivial 3D transforms are not considered direct compositing reasons when
the DoNotCompositeTrivial3D experiment is active (see:
CompositingReasonFinder::RequiresCompositingFor3DTransform). This has
caused a performance regression on top sites (google.com and many
others) where we no longer use composited scrolling. This change
continues to use trivial 3D transforms as a reason for composited
scrolling.

Bug: 1012775
Change-Id: Ibef9b9b3de4d57afe30d0fc3dc75da29855b7deb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907415Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714480}
parent 1abe1578
......@@ -2353,6 +2353,18 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling(
if (layer_->Size().IsEmpty())
return false;
const auto* box = GetLayoutBox();
// Although trivial 3D transforms are not always a direct compositing reason
// (see CompositingReasonFinder::RequiresCompositingFor3DTransform), we treat
// them as one for composited scrolling. This is because of the amount of
// content that depends on this optimization, and because of the long-term
// desire to use composited scrolling whenever possible.
if (box->HasTransformRelatedProperty() &&
box->StyleRef().Has3DTransformOperation()) {
return true;
}
if (!force_prefer_compositing_to_lcd_text &&
!LayerNodeMayNeedCompositedScrolling(layer_)) {
return false;
......@@ -2362,7 +2374,6 @@ bool PaintLayerScrollableArea::ComputeNeedsCompositedScrolling(
// TODO(flackr): Allow integer transforms as long as all of the ancestor
// transforms are also integer.
const LayoutBox* box = GetLayoutBox();
bool background_supports_lcd_text =
box->StyleRef().IsStackingContext() &&
(box->GetBackgroundPaintLocation(
......
......@@ -4,7 +4,9 @@
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/layout/layout_box_model_object.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
......@@ -1287,4 +1289,55 @@ TEST_P(PaintLayerScrollableAreaTest, ShowCustomResizerInTextarea) {
EXPECT_NE(paint_layer->GetScrollableArea()->Resizer(), nullptr);
}
class PaintLayerScrollableAreaCompositingTest
: public PaintLayerScrollableAreaTestBase,
public testing::WithParamInterface<unsigned>,
private ScopedCompositeAfterPaintForTest {
public:
PaintLayerScrollableAreaCompositingTest()
: ScopedCompositeAfterPaintForTest(GetParam() & kCompositeAfterPaint) {
if (GetParam() & kDoNotCompositeTrivial3D) {
scoped_feature_list_.InitAndEnableFeature(
blink::features::kDoNotCompositeTrivial3D);
} else {
scoped_feature_list_.InitAndDisableFeature(
blink::features::kDoNotCompositeTrivial3D);
}
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
INSTANTIATE_DO_NOT_COMPOSITE_TRIVIAL_3D_P(
PaintLayerScrollableAreaCompositingTest);
// Test that a trivial 3D transform results in composited scrolling.
TEST_P(PaintLayerScrollableAreaCompositingTest, CompositeWithTrivial3D) {
SetBodyInnerHTML(R"HTML(
<style>
#scroller {
width: 100px;
height: 100px;
overflow: scroll;
transform: translateZ(0);
}
#scrolled {
width: 200px;
height: 200px;
}
</style>
<div id="scroller">
<div id="scrolled"></div>
</div>
)HTML");
LayoutBox* scroller = ToLayoutBox(GetLayoutObjectByElementId("scroller"));
PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
EXPECT_TRUE(scrollable_area->NeedsCompositedScrolling());
const auto* properties = scroller->FirstFragment().PaintProperties();
EXPECT_TRUE(properties->ScrollTranslation()->HasDirectCompositingReasons());
}
} // namespace blink
......@@ -15,6 +15,7 @@ enum {
kCompositeAfterPaint = 1 << 0,
kUnderInvalidationChecking = 1 << 1,
kFastBorderRadius = 1 << 2,
kDoNotCompositeTrivial3D = 1 << 3,
};
class PaintTestConfigurations
......@@ -51,6 +52,12 @@ class PaintTestConfigurations
INSTANTIATE_TEST_SUITE_P(All, test_class, \
::testing::Values(0, kCompositeAfterPaint))
#define INSTANTIATE_DO_NOT_COMPOSITE_TRIVIAL_3D_P(test_class) \
INSTANTIATE_TEST_SUITE_P( \
All, test_class, \
::testing::Values(0, kCompositeAfterPaint, kDoNotCompositeTrivial3D, \
kCompositeAfterPaint | kDoNotCompositeTrivial3D))
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_PAINT_TEST_CONFIGURATIONS_H_
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