Commit 812a74e7 authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Don't composite trivial 3D on low-end devices.

Bug: 810544
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: Ieec17582540cf79f4f73bc4221226dbdbf20c2d3
Reviewed-on: https://chromium-review.googlesource.com/909951
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#535611}
parent d95b0a5c
......@@ -13,6 +13,8 @@
#include "core/page/scrolling/RootScrollerUtil.h"
#include "core/paint/PaintLayer.h"
#include "public/platform/Platform.h"
namespace blink {
CompositingReasonFinder::CompositingReasonFinder(LayoutView& layout_view)
......@@ -136,7 +138,12 @@ bool CompositingReasonFinder::RequiresCompositingForTransform(
// may have transforms, but the layoutObject may be an inline that doesn't
// support them.
return layout_object.HasTransformRelatedProperty() &&
layout_object.StyleRef().Has3DTransform();
layout_object.StyleRef().Has3DTransform() &&
// Don't composite "trivial" 3D transforms such as translateZ(0) on
// low-end devices. These devices are much more sensitive to memory
// and per-composited-layer commit overhead.
(!Platform::Current()->IsLowEndDevice() ||
layout_object.StyleRef().Transform().HasNonTrivial3DComponent());
}
CompositingReasons CompositingReasonFinder::NonStyleDeterminedDirectReasons(
......
......@@ -11,6 +11,7 @@
#include "platform/graphics/GraphicsLayer.h"
#include "platform/scroll/ScrollTypes.h"
#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
#include "platform/testing/TestingPlatformSupport.h"
namespace blink {
......@@ -26,6 +27,63 @@ class CompositingReasonFinderTest : public RenderingTest {
}
};
class CompositingReasonFinderTestPlatform : public TestingPlatformSupport {
public:
bool IsLowEndDevice() override { return true; }
};
TEST_F(CompositingReasonFinderTest, DontPromoteTrivial3DLowEnd) {
ScopedTestingPlatformSupport<CompositingReasonFinderTestPlatform> platform;
SetBodyInnerHTML(R"HTML(
<div id='target'
style='width: 100px; height: 100px; transform: translateZ(0)'></div>
)HTML");
Element* target = GetDocument().getElementById("target");
PaintLayer* paint_layer =
ToLayoutBoxModelObject(target->GetLayoutObject())->Layer();
EXPECT_EQ(kNotComposited, paint_layer->GetCompositingState());
}
TEST_F(CompositingReasonFinderTest, PromoteNonTrivial3DLowEnd) {
ScopedTestingPlatformSupport<CompositingReasonFinderTestPlatform> platform;
SetBodyInnerHTML(R"HTML(
<div id='target'
style='width: 100px; height: 100px; transform: translateZ(1px)'></div>
)HTML");
Element* target = GetDocument().getElementById("target");
PaintLayer* paint_layer =
ToLayoutBoxModelObject(target->GetLayoutObject())->Layer();
EXPECT_EQ(kPaintsIntoOwnBacking, paint_layer->GetCompositingState());
}
TEST_F(CompositingReasonFinderTest, PromoteTrivial3DByDefault) {
SetBodyInnerHTML(R"HTML(
<div id='target'
style='width: 100px; height: 100px; transform: translateZ(0)'></div>
)HTML");
Element* target = GetDocument().getElementById("target");
PaintLayer* paint_layer =
ToLayoutBoxModelObject(target->GetLayoutObject())->Layer();
EXPECT_EQ(kPaintsIntoOwnBacking, paint_layer->GetCompositingState());
}
TEST_F(CompositingReasonFinderTest, PromoteNonTrivial3DByDefault) {
SetBodyInnerHTML(R"HTML(
<div id='target'
style='width: 100px; height: 100px; transform: translateZ(1px)'></div>
)HTML");
Element* target = GetDocument().getElementById("target");
PaintLayer* paint_layer =
ToLayoutBoxModelObject(target->GetLayoutObject())->Layer();
EXPECT_EQ(kPaintsIntoOwnBacking, paint_layer->GetCompositingState());
}
TEST_F(CompositingReasonFinderTest, PromoteOpaqueFixedPosition) {
ScopedCompositeOpaqueFixedPositionForTest composite_fixed_position(true);
......@@ -40,8 +98,6 @@ TEST_F(CompositingReasonFinderTest, PromoteOpaqueFixedPosition) {
<div id='spacer' style='height: 2000px'></div>
)HTML");
GetDocument().View()->UpdateAllLifecyclePhases();
// The translucent fixed box should not be promoted.
Element* element = GetDocument().getElementById("translucent");
PaintLayer* paint_layer =
......@@ -74,7 +130,6 @@ TEST_F(CompositingReasonFinderTest, OnlyAnchoredStickyPositionPromoted) {
<div style='height: 2000px;'></div>
</div>
)HTML");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(kPaintsIntoOwnBacking,
ToLayoutBoxModelObject(GetLayoutObjectByElementId("sticky-top"))
......@@ -100,7 +155,6 @@ TEST_F(CompositingReasonFinderTest, OnlyScrollingStickyPositionPromoted) {
<div id='sticky-no-scrolling' class='sticky'></div>
</div>
)HTML");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_EQ(
kPaintsIntoOwnBacking,
......@@ -131,7 +185,6 @@ TEST_F(CompositingReasonFinderTest, OnlyNonTransformedFixedLayersPromoted) {
<div id="spacer"></div>
</div>
)HTML");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_TRUE(RuntimeEnabledFeatures::CompositeOpaqueScrollersEnabled());
Element* parent = GetDocument().getElementById("parent");
......@@ -181,7 +234,6 @@ TEST_F(CompositingReasonFinderTest, OnlyOpaqueFixedLayersPromoted) {
<div id="spacer"></div>
</div>
)HTML");
GetDocument().View()->UpdateAllLifecyclePhases();
EXPECT_TRUE(RuntimeEnabledFeatures::CompositeOpaqueScrollersEnabled());
Element* parent = GetDocument().getElementById("parent");
......@@ -319,7 +371,6 @@ TEST_F(CompositingReasonFinderTest, CompositeNestedSticky) {
</div>
</div>
)HTML");
GetDocument().View()->UpdateAllLifecyclePhases();
Element* outer_sticky = GetDocument().getElementById("outerSticky");
PaintLayer* outer_sticky_layer =
......
......@@ -80,6 +80,8 @@ class PLATFORM_EXPORT ScaleTransformOperation final
return x_ == s->x_ && y_ == s->y_ && z_ == s->z_;
}
virtual bool HasNonTrivial3DComponent() const { return z_ != 1.0; }
scoped_refptr<TransformOperation> Zoom(double factor) final { return this; }
ScaleTransformOperation(double sx, double sy, double sz, OperationType type)
......
......@@ -101,6 +101,8 @@ class PLATFORM_EXPORT TransformOperation
op_type == kInterpolated;
}
virtual bool HasNonTrivial3DComponent() const { return Is3DOperation(); }
virtual bool DependsOnBoxSize() const { return false; }
};
......
......@@ -49,22 +49,32 @@ class PLATFORM_EXPORT TransformOperations {
bool operator!=(const TransformOperations& o) const { return !(*this == o); }
void Apply(const FloatSize& sz, TransformationMatrix& t) const {
for (unsigned i = 0; i < operations_.size(); ++i)
operations_[i]->Apply(t, sz);
for (auto& operation : operations_)
operation->Apply(t, sz);
}
// Return true if any of the operation types are 3D operation types (even if
// the values describe affine transforms)
bool Has3DOperation() const {
for (unsigned i = 0; i < operations_.size(); ++i)
if (operations_[i]->Is3DOperation())
for (auto& operation : operations_)
if (operation->Is3DOperation())
return true;
return false;
}
// Returns true if any operation has a non-trivial component in the Z
// axis.
bool HasNonTrivial3DComponent() const {
for (auto& operation : operations_) {
if (operation->HasNonTrivial3DComponent())
return true;
}
return false;
}
bool DependsOnBoxSize() const {
for (unsigned i = 0; i < operations_.size(); ++i) {
if (operations_[i]->DependsOnBoxSize())
for (auto& operation : operations_) {
if (operation->DependsOnBoxSize())
return true;
}
return false;
......
......@@ -107,6 +107,8 @@ class PLATFORM_EXPORT TranslateTransformOperation final
DCHECK(IsMatchingOperationType(type));
}
bool HasNonTrivial3DComponent() const override { return z_ != 0.0; }
Length x_;
Length y_;
double z_;
......
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