| 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 d4ff05f793829ea82cd5fa3117805d3424846373..7bbdda1f9f53b7bb54c75538c1004ca1e3e8a275 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
|
| @@ -143,6 +143,30 @@ class PaintArtifactCompositorTestWithPropertyTrees
|
| .get();
|
| }
|
|
|
| + void AddSimpleRectChunk(TestPaintArtifact& artifact) {
|
| + artifact
|
| + .Chunk(TransformPaintPropertyNode::Root(),
|
| + ClipPaintPropertyNode::Root(), EffectPaintPropertyNode::Root())
|
| + .RectDrawing(FloatRect(100, 100, 200, 100), Color::kBlack);
|
| + }
|
| +
|
| + void CreateSimpleArtifactWithOpacity(TestPaintArtifact& artifact,
|
| + float opacity,
|
| + bool include_preceding_chunk,
|
| + bool include_subsequent_chunk) {
|
| + if (include_preceding_chunk)
|
| + AddSimpleRectChunk(artifact);
|
| + RefPtr<EffectPaintPropertyNode> effect =
|
| + CreateOpacityOnlyEffect(EffectPaintPropertyNode::Root(), opacity);
|
| + artifact
|
| + .Chunk(TransformPaintPropertyNode::Root(),
|
| + ClipPaintPropertyNode::Root(), effect)
|
| + .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack);
|
| + if (include_subsequent_chunk)
|
| + AddSimpleRectChunk(artifact);
|
| + Update(artifact.Build());
|
| + }
|
| +
|
| private:
|
| std::unique_ptr<PaintArtifactCompositor> paint_artifact_compositor_;
|
| scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
|
| @@ -2075,4 +2099,98 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| composited_element_ids.Contains(effect->GetCompositorElementId()));
|
| }
|
|
|
| +TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SkipChunkWithOpacityZero) {
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0, false, false);
|
| + ASSERT_EQ(0u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0, true, false);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0, true, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0, false, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| +}
|
| +
|
| +TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SkipChunkWithTinyOpacity) {
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0003f, false, false);
|
| + ASSERT_EQ(0u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0003f, true, false);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0003f, true, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0003f, false, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| +}
|
| +
|
| +TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| + DontSkipChunkWithMinimumOpacity) {
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0004f, false, false);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0004f, true, false);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0004f, true, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.0004f, false, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| +}
|
| +
|
| +TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| + DontSkipChunkWithAboveMinimumOpacity) {
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.3f, false, false);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.3f, true, false);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.3f, true, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| + {
|
| + TestPaintArtifact artifact;
|
| + CreateSimpleArtifactWithOpacity(artifact, 0.3f, false, true);
|
| + ASSERT_EQ(1u, ContentLayerCount());
|
| + }
|
| +}
|
| +
|
| } // namespace blink
|
|
|