Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Unified Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 2714673002: [SPv2] Implement effect compositing for indirect reasons (Closed)
Patch Set: address review comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
index 4d8e2bb5a8cea6a96de438efec67770db247303d..d963224820fc0ab7a5c5100d96a61cfa6a9b2177 100644
--- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
@@ -547,7 +547,6 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) {
EffectPaintPropertyNode::root())
.rectDrawing(FloatRect(0, 0, 640, 480), Color::black);
update(artifact.build());
-
ASSERT_EQ(2u, contentLayerCount());
const cc::Layer* whiteLayer = contentLayerAt(0);
@@ -596,18 +595,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
.rectDrawing(FloatRect(0, 0, 100, 100), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer1(
- artifact.paintChunks()[0]);
- // Foreign layers can't merge.
- EXPECT_FALSE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer1));
- PaintArtifactCompositor::PendingLayer pendingLayer2(
- artifact.paintChunks()[1]);
- EXPECT_FALSE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer2));
-
update(artifact);
ASSERT_EQ(3u, contentLayerCount());
@@ -617,12 +605,21 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
}
TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
- RefPtr<EffectPaintPropertyNode> effect1 =
- createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
- RefPtr<EffectPaintPropertyNode> effect2 =
- createOpacityOnlyEffect(effect1, 0.3);
- RefPtr<EffectPaintPropertyNode> effect3 =
- createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.2);
+ RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create(
+ EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
+ ClipPaintPropertyNode::root(), ColorFilterNone,
+ CompositorFilterOperations(), 0.5, SkBlendMode::kSrcOver,
+ CompositingReasonAll);
+ RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(
+ effect1, TransformPaintPropertyNode::root(),
+ ClipPaintPropertyNode::root(), ColorFilterNone,
+ CompositorFilterOperations(), 0.3, SkBlendMode::kSrcOver,
+ CompositingReasonAll);
+ RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create(
+ EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
+ ClipPaintPropertyNode::root(), ColorFilterNone,
+ CompositorFilterOperations(), 0.2, SkBlendMode::kSrcOver,
+ CompositingReasonAll);
TestPaintArtifact artifact;
artifact
@@ -784,9 +781,10 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) {
TransformPaintPropertyNode::createScrollTranslation(
TransformPaintPropertyNode::root(),
TransformationMatrix().translate(11, 13), FloatPoint3D(), false, 0,
- CompositingReasonNone, expectedCompositorElementIdA,
- ScrollPaintPropertyNode::root(), IntSize(2, 3), IntSize(5, 7), false,
- true, MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
+ CompositingReasonLayerForScrollingContents,
+ expectedCompositorElementIdA, ScrollPaintPropertyNode::root(),
+ IntSize(2, 3), IntSize(5, 7), false, true,
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects,
nullptr);
CompositorElementId expectedCompositorElementIdB = CompositorElementId(3, 0);
@@ -841,12 +839,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeSimpleChunks) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(2u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
-
update(artifact);
ASSERT_EQ(1u, contentLayerCount());
@@ -884,15 +877,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeClip) {
const PaintArtifact& artifact = testArtifact.build();
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
-
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -931,15 +916,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, Merge2DTransform) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
-
update(artifact);
ASSERT_EQ(1u, contentLayerCount());
@@ -983,14 +960,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
.rectDrawing(FloatRect(0, 0, 100, 100), Color::black);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(2u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
-
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1026,16 +997,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeTransformOrigin) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1072,17 +1035,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeOpacity) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
-
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1133,16 +1087,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MergeNested) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1195,16 +1141,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ClipPushedUp) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1222,7 +1160,10 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ClipPushedUp) {
}
}
-TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp) {
+// TODO(crbug.com/696842): The effect refuses to "decomposite" because it's in
+// a deeper transform space than its chunk. We should allow decomposite if
+// the two transform nodes share the same direct compositing ancestor.
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp_DISABLED) {
// Tests merging of an element which has an effect applied to it,
// but has an ancestor transform of them. This can happen for fixed-
// or absolute-position elements which escape scroll transforms.
@@ -1259,16 +1200,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1285,7 +1218,11 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp) {
}
}
-TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectAndClipPushedUp) {
+// TODO(crbug.com/696842): The effect refuses to "decomposite" because it's in
+// a deeper transform space than its chunk. We should allow decomposite if
+// the two transform nodes share the same direct compositing ancestor.
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
+ EffectAndClipPushedUp_DISABLED) {
// Tests merging of an element which has an effect applied to it,
// but has an ancestor transform of them. This can happen for fixed-
// or absolute-position elements which escape scroll transforms.
@@ -1325,16 +1262,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectAndClipPushedUp) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1381,16 +1310,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, ClipAndEffectNoTransform) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1434,16 +1355,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TwoClips) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
-
ASSERT_EQ(1u, contentLayerCount());
{
Vector<RectWithColor> rectsWithColor;
@@ -1485,14 +1398,9 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TwoTransformsClipBetween) {
.chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
EffectPaintPropertyNode::root())
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
+
const PaintArtifact& artifact = testArtifact.build();
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
- pendingLayer.add(artifact.paintChunks()[1], nullptr);
- EXPECT_TRUE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer));
update(artifact);
ASSERT_EQ(1u, contentLayerCount());
{
@@ -1526,161 +1434,14 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OverlapTransform) {
.rectDrawing(FloatRect(0, 0, 200, 300), Color::gray);
const PaintArtifact& artifact = testArtifact.build();
-
ASSERT_EQ(3u, artifact.paintChunks().size());
- PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]);
-
- EXPECT_FALSE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[1], pendingLayer));
-
- PaintArtifactCompositor::PendingLayer pendingLayer2(
- artifact.paintChunks()[1]);
- EXPECT_FALSE(PaintArtifactCompositor::canMergeInto(
- artifact, artifact.paintChunks()[2], pendingLayer2));
-
- std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
- EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(
- artifact.paintChunks()[2], pendingLayer2, *geometryMapper));
-
update(artifact);
-
// The third paint chunk overlaps the second but can't merge due to
// incompatible transform. The second paint chunk can't merge into the first
// due to a direct compositing reason.
ASSERT_EQ(3u, contentLayerCount());
}
-TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MightOverlap) {
chrishtr 2017/03/09 01:41:01 Why did you delete the tests for mightOverlap?
trchen 2017/03/15 22:46:53 Was thinking to hide more internal details. Revert
- PaintChunk paintChunk;
- paintChunk.properties = defaultPaintChunkProperties();
- paintChunk.bounds = FloatRect(0, 0, 100, 100);
-
- PaintChunk paintChunk2;
- paintChunk2.properties = defaultPaintChunkProperties();
- paintChunk2.bounds = FloatRect(0, 0, 100, 100);
-
- std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
- PaintArtifactCompositor::PendingLayer pendingLayer(paintChunk);
- EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer,
- *geometryMapper));
-
- RefPtr<TransformPaintPropertyNode> transform =
- TransformPaintPropertyNode::create(
- TransformPaintPropertyNode::root(),
- TransformationMatrix().translate(99, 0), FloatPoint3D(100, 100, 0),
- false);
-
- paintChunk2.properties.propertyTreeState.setTransform(transform.get());
- EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer,
- *geometryMapper));
-
- RefPtr<TransformPaintPropertyNode> transform2 =
- TransformPaintPropertyNode::create(
- TransformPaintPropertyNode::root(),
- TransformationMatrix().translate(100, 0), FloatPoint3D(100, 100, 0),
- false);
- paintChunk2.properties.propertyTreeState.setTransform(transform2.get());
-
- EXPECT_FALSE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer,
- *geometryMapper));
-}
-
-TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayer) {
chrishtr 2017/03/09 01:41:01 The PendingLayer tests seem still relevant, in par
trchen 2017/03/15 22:46:53 That makes sense. I'll resurrect these tests. Thou
- PaintChunk chunk1;
- chunk1.properties.propertyTreeState = PropertyTreeState(
- TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
- EffectPaintPropertyNode::root());
- chunk1.properties.backfaceHidden = true;
- chunk1.knownToBeOpaque = true;
- chunk1.bounds = FloatRect(0, 0, 30, 40);
-
- PaintArtifactCompositor::PendingLayer pendingLayer(chunk1);
-
- EXPECT_TRUE(pendingLayer.backfaceHidden);
- EXPECT_TRUE(pendingLayer.knownToBeOpaque);
- EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds);
-
- PaintChunk chunk2;
- chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState;
- chunk2.properties.backfaceHidden = true;
- chunk2.knownToBeOpaque = true;
- chunk2.bounds = FloatRect(10, 20, 30, 40);
- pendingLayer.add(chunk2, nullptr);
-
- EXPECT_TRUE(pendingLayer.backfaceHidden);
- // Bounds not equal to one PaintChunk.
- EXPECT_FALSE(pendingLayer.knownToBeOpaque);
- EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 40, 60), pendingLayer.bounds);
-
- PaintChunk chunk3;
- chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState;
- chunk3.properties.backfaceHidden = true;
- chunk3.knownToBeOpaque = true;
- chunk3.bounds = FloatRect(-5, -25, 20, 20);
- pendingLayer.add(chunk3, nullptr);
-
- EXPECT_TRUE(pendingLayer.backfaceHidden);
- EXPECT_FALSE(pendingLayer.knownToBeOpaque);
- EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds);
-}
-
-TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) {
- RefPtr<TransformPaintPropertyNode> transform =
- TransformPaintPropertyNode::create(
- TransformPaintPropertyNode::root(),
- TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0),
- false, 0);
-
- PaintChunk chunk1;
- chunk1.properties.propertyTreeState = PropertyTreeState(
- TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
- EffectPaintPropertyNode::root());
- chunk1.bounds = FloatRect(0, 0, 30, 40);
-
- PaintArtifactCompositor::PendingLayer pendingLayer(chunk1);
-
- EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds);
-
- PaintChunk chunk2;
- chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState;
- chunk2.properties.propertyTreeState.setTransform(transform);
- chunk2.bounds = FloatRect(0, 0, 50, 60);
- std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create();
- pendingLayer.add(chunk2, geometryMapper.get());
-
- EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds);
-}
-
-TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerKnownOpaque) {
- PaintChunk chunk1;
- chunk1.properties.propertyTreeState = PropertyTreeState(
- TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
- EffectPaintPropertyNode::root());
- chunk1.bounds = FloatRect(0, 0, 30, 40);
- chunk1.knownToBeOpaque = false;
- PaintArtifactCompositor::PendingLayer pendingLayer(chunk1);
-
- EXPECT_FALSE(pendingLayer.knownToBeOpaque);
-
- PaintChunk chunk2;
- chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState;
- chunk2.bounds = FloatRect(0, 0, 25, 35);
- chunk2.knownToBeOpaque = true;
- pendingLayer.add(chunk2, nullptr);
-
- // Chunk 2 doesn't cover the entire layer, so not opaque.
- EXPECT_FALSE(pendingLayer.knownToBeOpaque);
-
- PaintChunk chunk3;
- chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState;
- chunk3.bounds = FloatRect(0, 0, 50, 60);
- chunk3.knownToBeOpaque = true;
- pendingLayer.add(chunk3, nullptr);
-
- // Chunk 3 covers the entire layer, so now it's opaque.
- EXPECT_TRUE(pendingLayer.knownToBeOpaque);
-}
-
TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) {
CompositorElementId expectedCompositorElementId(2, 0);
RefPtr<TransformPaintPropertyNode> transform =
@@ -1706,7 +1467,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectWithElementId) {
EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
ClipPaintPropertyNode::root(), ColorFilterNone,
CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver,
- CompositingReasonNone, expectedCompositorElementId);
+ CompositingReasonActiveAnimation, expectedCompositorElementId);
TestPaintArtifact artifact;
artifact
@@ -1739,7 +1500,6 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, CompositedLuminanceMask) {
masking.get())
.rectDrawing(FloatRect(150, 150, 100, 100), Color::white);
update(artifact.build());
-
ASSERT_EQ(2u, contentLayerCount());
const cc::Layer* maskedLayer = contentLayerAt(0);
@@ -1813,4 +1573,198 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
}
}
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DecompositeClip) {
+ // A clipped paint chunk that gets merged into a previous layer should
+ // only contribute clipped bounds to the layer bound.
+
+ RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
+ ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
+ FloatRoundedRect(75, 75, 100, 100));
+
+ TestPaintArtifact artifact;
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(50, 50, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), clip.get(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(100, 100, 100, 100), Color::gray);
+ update(artifact.build());
+ ASSERT_EQ(1u, contentLayerCount());
+
+ const cc::Layer* layer = contentLayerAt(0);
+ EXPECT_EQ(gfx::Vector2dF(50.f, 50.f), layer->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(125, 125), layer->bounds());
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DecompositeEffect) {
+ // An effect node without direct compositing reason and does not need to
+ // group compositing descendants should not be composited and can merge
+ // with other chunks.
+
+ RefPtr<EffectPaintPropertyNode> effect =
+ createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5);
+
+ TestPaintArtifact artifact;
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ effect.get())
+ .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray);
+ update(artifact.build());
+ ASSERT_EQ(1u, contentLayerCount());
+
+ const cc::Layer* layer = contentLayerAt(0);
+ EXPECT_EQ(gfx::Vector2dF(25.f, 25.f), layer->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(150, 150), layer->bounds());
+ EXPECT_EQ(1, layer->effect_tree_index());
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DirectlyCompositedEffect) {
+ // An effect node with direct compositing shall be composited.
+ RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create(
+ EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
+ ClipPaintPropertyNode::root(), ColorFilterNone,
+ CompositorFilterOperations(), 0.5f, SkBlendMode::kSrcOver,
+ CompositingReasonAll);
+
+ TestPaintArtifact artifact;
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ effect.get())
+ .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray);
+ update(artifact.build());
+ ASSERT_EQ(3u, contentLayerCount());
+
+ const cc::Layer* layer1 = contentLayerAt(0);
+ EXPECT_EQ(gfx::Vector2dF(50.f, 25.f), layer1->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer1->bounds());
+ EXPECT_EQ(1, layer1->effect_tree_index());
+
+ const cc::Layer* layer2 = contentLayerAt(1);
+ EXPECT_EQ(gfx::Vector2dF(25.f, 75.f), layer2->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer2->bounds());
+ const cc::EffectNode* effectNode =
+ propertyTrees().effect_tree.Node(layer2->effect_tree_index());
+ EXPECT_EQ(1, effectNode->parent_id);
+ EXPECT_EQ(0.5f, effectNode->opacity);
+
+ const cc::Layer* layer3 = contentLayerAt(2);
+ EXPECT_EQ(gfx::Vector2dF(75.f, 75.f), layer3->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer3->bounds());
+ EXPECT_EQ(1, layer3->effect_tree_index());
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DecompositeDeepEffect) {
+ // A paint chunk may enter multiple level effects with or without compositing
+ // reasons. This test verifies we still decomposite effects without a direct
+ // reason, but stop at a directly composited effect.
+ RefPtr<EffectPaintPropertyNode> effect1 =
+ createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.1f);
+ RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create(
+ effect1, TransformPaintPropertyNode::root(),
+ ClipPaintPropertyNode::root(), ColorFilterNone,
+ CompositorFilterOperations(), 0.2f, SkBlendMode::kSrcOver,
+ CompositingReasonAll);
+ RefPtr<EffectPaintPropertyNode> effect3 =
+ createOpacityOnlyEffect(effect2, 0.3f);
+
+ TestPaintArtifact artifact;
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ effect3.get())
+ .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray);
+ update(artifact.build());
+ ASSERT_EQ(3u, contentLayerCount());
+
+ const cc::Layer* layer1 = contentLayerAt(0);
+ EXPECT_EQ(gfx::Vector2dF(50.f, 25.f), layer1->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer1->bounds());
+ EXPECT_EQ(1, layer1->effect_tree_index());
+
+ const cc::Layer* layer2 = contentLayerAt(1);
+ EXPECT_EQ(gfx::Vector2dF(25.f, 75.f), layer2->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer2->bounds());
+ const cc::EffectNode* effectNode2 =
+ propertyTrees().effect_tree.Node(layer2->effect_tree_index());
+ EXPECT_EQ(0.2f, effectNode2->opacity);
+ const cc::EffectNode* effectNode1 =
+ propertyTrees().effect_tree.Node(effectNode2->parent_id);
+ EXPECT_EQ(1, effectNode1->parent_id);
+ EXPECT_EQ(0.1f, effectNode1->opacity);
+
+ const cc::Layer* layer3 = contentLayerAt(2);
+ EXPECT_EQ(gfx::Vector2dF(75.f, 75.f), layer3->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer3->bounds());
+ EXPECT_EQ(1, layer3->effect_tree_index());
+}
+
+TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
+ IndirectlyCompositedEffect) {
+ // An effect node without direct compositing still needs to be composited
+ // for grouping, if some chunks need to be composited.
+ RefPtr<EffectPaintPropertyNode> effect =
+ createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f);
+ RefPtr<TransformPaintPropertyNode> transform =
+ TransformPaintPropertyNode::create(
+ TransformPaintPropertyNode::root(), TransformationMatrix(),
+ FloatPoint3D(), false, 0, CompositingReason3DTransform);
+
+ TestPaintArtifact artifact;
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ EffectPaintPropertyNode::root())
+ .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray);
+ artifact
+ .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
+ effect.get())
+ .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray);
+ artifact.chunk(transform.get(), ClipPaintPropertyNode::root(), effect.get())
+ .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray);
+ update(artifact.build());
+ ASSERT_EQ(3u, contentLayerCount());
+
+ const cc::Layer* layer1 = contentLayerAt(0);
+ EXPECT_EQ(gfx::Vector2dF(50.f, 25.f), layer1->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer1->bounds());
+ EXPECT_EQ(1, layer1->effect_tree_index());
+
+ const cc::Layer* layer2 = contentLayerAt(1);
+ EXPECT_EQ(gfx::Vector2dF(25.f, 75.f), layer2->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer2->bounds());
+ const cc::EffectNode* effectNode =
+ propertyTrees().effect_tree.Node(layer2->effect_tree_index());
+ EXPECT_EQ(1, effectNode->parent_id);
+ EXPECT_EQ(0.5f, effectNode->opacity);
+
+ const cc::Layer* layer3 = contentLayerAt(2);
+ EXPECT_EQ(gfx::Vector2dF(75.f, 75.f), layer3->offset_to_transform_parent());
+ EXPECT_EQ(gfx::Size(100, 100), layer3->bounds());
+ EXPECT_EQ(effectNode->id, layer3->effect_tree_index());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698