| 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 259d7295f569cc18d62138071daa426904a5c727..50dbc35122b1cbacc90d1971bad4da37e9a16689 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp
|
| @@ -31,6 +31,15 @@ namespace {
|
|
|
| using ::testing::Pointee;
|
|
|
| +PaintChunkProperties defaultPaintChunkProperties() {
|
| + PaintChunkProperties properties;
|
| + properties.transform = TransformPaintPropertyNode::root();
|
| + properties.clip = ClipPaintPropertyNode::root();
|
| + properties.effect = EffectPaintPropertyNode::root();
|
| + properties.scroll = ScrollPaintPropertyNode::root();
|
| + return properties;
|
| +}
|
| +
|
| gfx::Transform translation(SkMScalar x, SkMScalar y) {
|
| gfx::Transform transform;
|
| transform.Translate(x, y);
|
| @@ -118,7 +127,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) {
|
|
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) {
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(PaintChunkProperties())
|
| + artifact.chunk(defaultPaintChunkProperties())
|
| .rectDrawing(FloatRect(50, -50, 100, 100), Color::white);
|
| update(artifact.build());
|
|
|
| @@ -133,16 +142,22 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) {
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) {
|
| // A 90 degree clockwise rotation about (100, 100).
|
| RefPtr<TransformPaintPropertyNode> transform =
|
| - TransformPaintPropertyNode::create(nullptr,
|
| + TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
|
| TransformationMatrix().rotate(90),
|
| FloatPoint3D(100, 100, 0));
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(transform, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
|
| - artifact.chunk(nullptr, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray);
|
| - artifact.chunk(transform, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(100, 100, 200, 100), Color::black);
|
| update(artifact.build());
|
|
|
| @@ -177,16 +192,21 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) {
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) {
|
| // A translation by (5, 5) within a 2x scale about (10, 10).
|
| RefPtr<TransformPaintPropertyNode> transform1 =
|
| - TransformPaintPropertyNode::create(
|
| - nullptr, TransformationMatrix().scale(2), FloatPoint3D(10, 10, 0));
|
| + TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
|
| + TransformationMatrix().scale(2),
|
| + FloatPoint3D(10, 10, 0));
|
| RefPtr<TransformPaintPropertyNode> transform2 =
|
| TransformPaintPropertyNode::create(
|
| transform1, TransformationMatrix().translate(5, 5), FloatPoint3D());
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(transform1, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform1, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::white);
|
| - artifact.chunk(transform2, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform2, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::black);
|
| update(artifact.build());
|
|
|
| @@ -223,7 +243,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| // flattening determines whether content within the node's local transform
|
| // is flattened, while cc's notion applies in the parent's coordinate space.
|
| RefPtr<TransformPaintPropertyNode> transform1 =
|
| - TransformPaintPropertyNode::create(nullptr, TransformationMatrix(),
|
| + TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
|
| + TransformationMatrix(),
|
| FloatPoint3D());
|
| RefPtr<TransformPaintPropertyNode> transform2 =
|
| TransformPaintPropertyNode::create(
|
| @@ -235,7 +256,9 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| FloatPoint3D(), transformIsFlattened);
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(transform3, nullptr, nullptr)
|
| + artifact
|
| + .chunk(transform3, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::white);
|
| update(artifact.build());
|
|
|
| @@ -271,7 +294,8 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) {
|
| // Has no 3D rendering context.
|
| RefPtr<TransformPaintPropertyNode> transform1 =
|
| - TransformPaintPropertyNode::create(nullptr, TransformationMatrix(),
|
| + TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
|
| + TransformationMatrix(),
|
| FloatPoint3D());
|
| // Establishes a 3D rendering context.
|
| RefPtr<TransformPaintPropertyNode> transform2 =
|
| @@ -287,13 +311,21 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) {
|
| FloatPoint3D(), false, 2);
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(transform1, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform1, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::white);
|
| - artifact.chunk(transform2, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform2, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::lightGray);
|
| - artifact.chunk(transform3, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform3, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::darkGray);
|
| - artifact.chunk(transform4, nullptr, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(transform4, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 300, 200), Color::black);
|
| update(artifact.build());
|
|
|
| @@ -343,10 +375,13 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) {
|
|
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) {
|
| RefPtr<ClipPaintPropertyNode> clip = ClipPaintPropertyNode::create(
|
| - nullptr, nullptr, FloatRoundedRect(100, 100, 300, 200));
|
| + ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
|
| + FloatRoundedRect(100, 100, 300, 200));
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(nullptr, clip, nullptr)
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(220, 80, 300, 200), Color::black);
|
| update(artifact.build());
|
|
|
| @@ -365,18 +400,28 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneClip) {
|
|
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) {
|
| RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
|
| - nullptr, nullptr, FloatRoundedRect(100, 100, 700, 700));
|
| - RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
|
| - clip1, nullptr, FloatRoundedRect(200, 200, 700, 100));
|
| + ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
|
| + FloatRoundedRect(100, 100, 700, 700));
|
| + RefPtr<ClipPaintPropertyNode> clip2 =
|
| + ClipPaintPropertyNode::create(clip1, TransformPaintPropertyNode::root(),
|
| + FloatRoundedRect(200, 200, 700, 100));
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(nullptr, clip1, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip1,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(300, 350, 100, 100), Color::white);
|
| - artifact.chunk(nullptr, clip2, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip2,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(300, 350, 100, 100), Color::lightGray);
|
| - artifact.chunk(nullptr, clip1, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip1,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(300, 350, 100, 100), Color::darkGray);
|
| - artifact.chunk(nullptr, clip2, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip2,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(300, 350, 100, 100), Color::black);
|
| update(artifact.build());
|
|
|
| @@ -424,12 +469,15 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) {
|
| Vector<RefPtr<ClipPaintPropertyNode>> clips;
|
| for (unsigned i = 1; i <= 10; i++) {
|
| clips.append(ClipPaintPropertyNode::create(
|
| - clips.isEmpty() ? nullptr : clips.last(), nullptr,
|
| + clips.isEmpty() ? ClipPaintPropertyNode::root() : clips.last(),
|
| + TransformPaintPropertyNode::root(),
|
| FloatRoundedRect(5 * i, 0, 100, 200 - 10 * i)));
|
| }
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(nullptr, clips.last(), EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clips.last(),
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 200, 200), Color::white);
|
| update(artifact.build());
|
|
|
| @@ -454,16 +502,23 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DeeplyNestedClips) {
|
|
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SiblingClips) {
|
| RefPtr<ClipPaintPropertyNode> commonClip = ClipPaintPropertyNode::create(
|
| - nullptr, nullptr, FloatRoundedRect(0, 0, 800, 600));
|
| + ClipPaintPropertyNode::root(), TransformPaintPropertyNode::root(),
|
| + FloatRoundedRect(0, 0, 800, 600));
|
| RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::create(
|
| - commonClip, nullptr, FloatRoundedRect(0, 0, 400, 600));
|
| + commonClip, TransformPaintPropertyNode::root(),
|
| + FloatRoundedRect(0, 0, 400, 600));
|
| RefPtr<ClipPaintPropertyNode> clip2 = ClipPaintPropertyNode::create(
|
| - commonClip, nullptr, FloatRoundedRect(400, 0, 400, 600));
|
| + commonClip, TransformPaintPropertyNode::root(),
|
| + FloatRoundedRect(400, 0, 400, 600));
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(nullptr, clip1, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip1,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 640, 480), Color::white);
|
| - artifact.chunk(nullptr, clip2, EffectPaintPropertyNode::root())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), clip2,
|
| + EffectPaintPropertyNode::root())
|
| .rectDrawing(FloatRect(0, 0, 640, 480), Color::black);
|
| update(artifact.build());
|
|
|
| @@ -503,7 +558,7 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
|
| scoped_refptr<cc::Layer> layer = cc::Layer::Create();
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(PaintChunkProperties())
|
| + artifact.chunk(defaultPaintChunkProperties())
|
| .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer);
|
| update(artifact.build());
|
|
|
| @@ -525,11 +580,17 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
|
| ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.2);
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(nullptr, nullptr, effect2.get())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
|
| + effect2.get())
|
| .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
|
| - artifact.chunk(nullptr, nullptr, effect1.get())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
|
| + effect1.get())
|
| .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
|
| - artifact.chunk(nullptr, nullptr, effect3.get())
|
| + artifact
|
| + .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(),
|
| + effect3.get())
|
| .rectDrawing(FloatRect(0, 0, 100, 100), Color::white);
|
| update(artifact.build());
|
|
|
| @@ -539,21 +600,21 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
|
| // Node #0 reserved for null; #1 for root render surface; #2 for
|
| // EffectPaintPropertyNode::root(), plus 3 nodes for those created by
|
| // this test.
|
| - ASSERT_EQ(6u, effectTree.size());
|
| + ASSERT_EQ(5u, effectTree.size());
|
|
|
| - const cc::EffectNode& convertedDummyRootEffect = *effectTree.Node(2);
|
| - EXPECT_EQ(1, convertedDummyRootEffect.parent_id);
|
| + const cc::EffectNode& convertedRootEffect = *effectTree.Node(1);
|
| + EXPECT_EQ(-1, convertedRootEffect.parent_id);
|
|
|
| - const cc::EffectNode& convertedEffect1 = *effectTree.Node(3);
|
| - EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect1.parent_id);
|
| + const cc::EffectNode& convertedEffect1 = *effectTree.Node(2);
|
| + EXPECT_EQ(convertedRootEffect.id, convertedEffect1.parent_id);
|
| EXPECT_FLOAT_EQ(0.5, convertedEffect1.opacity);
|
|
|
| - const cc::EffectNode& convertedEffect2 = *effectTree.Node(4);
|
| + const cc::EffectNode& convertedEffect2 = *effectTree.Node(3);
|
| EXPECT_EQ(convertedEffect1.id, convertedEffect2.parent_id);
|
| EXPECT_FLOAT_EQ(0.3, convertedEffect2.opacity);
|
|
|
| - const cc::EffectNode& convertedEffect3 = *effectTree.Node(5);
|
| - EXPECT_EQ(convertedDummyRootEffect.id, convertedEffect3.parent_id);
|
| + const cc::EffectNode& convertedEffect3 = *effectTree.Node(4);
|
| + EXPECT_EQ(convertedRootEffect.id, convertedEffect3.parent_id);
|
| EXPECT_FLOAT_EQ(0.2, convertedEffect3.opacity);
|
|
|
| EXPECT_EQ(convertedEffect2.id, contentLayerAt(0)->effect_tree_index());
|
| @@ -563,14 +624,17 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
|
|
|
| TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) {
|
| RefPtr<TransformPaintPropertyNode> scrollTranslation =
|
| - TransformPaintPropertyNode::create(
|
| - nullptr, TransformationMatrix().translate(7, 9), FloatPoint3D());
|
| + TransformPaintPropertyNode::create(TransformPaintPropertyNode::root(),
|
| + TransformationMatrix().translate(7, 9),
|
| + FloatPoint3D());
|
| RefPtr<ScrollPaintPropertyNode> scroll = ScrollPaintPropertyNode::create(
|
| - nullptr, scrollTranslation, IntSize(11, 13), IntSize(27, 31), true,
|
| - false);
|
| + ScrollPaintPropertyNode::root(), scrollTranslation, IntSize(11, 13),
|
| + IntSize(27, 31), true, false);
|
|
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(scrollTranslation, nullptr, nullptr, scroll)
|
| + artifact
|
| + .chunk(scrollTranslation, ClipPaintPropertyNode::root(),
|
| + EffectPaintPropertyNode::root(), scroll)
|
| .rectDrawing(FloatRect(11, 13, 17, 19), Color::white);
|
| update(artifact.build());
|
|
|
| @@ -603,9 +667,11 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) {
|
|
|
| RefPtr<TransformPaintPropertyNode> scrollTranslationA =
|
| TransformPaintPropertyNode::create(
|
| - nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D());
|
| + TransformPaintPropertyNode::root(),
|
| + TransformationMatrix().translate(11, 13), FloatPoint3D());
|
| RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create(
|
| - nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true);
|
| + ScrollPaintPropertyNode::root(), scrollTranslationA, IntSize(2, 3),
|
| + IntSize(5, 7), false, true);
|
| scrollA->addMainThreadScrollingReasons(
|
| MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects);
|
| RefPtr<TransformPaintPropertyNode> scrollTranslationB =
|
| @@ -616,9 +682,11 @@ TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) {
|
| scrollA, scrollTranslationB, IntSize(19, 23), IntSize(29, 31), true,
|
| false);
|
| TestPaintArtifact artifact;
|
| - artifact.chunk(scrollTranslationA, nullptr, effect, scrollA)
|
| + artifact
|
| + .chunk(scrollTranslationA, ClipPaintPropertyNode::root(), effect, scrollA)
|
| .rectDrawing(FloatRect(7, 11, 13, 17), Color::white);
|
| - artifact.chunk(scrollTranslationB, nullptr, effect, scrollB)
|
| + artifact
|
| + .chunk(scrollTranslationB, ClipPaintPropertyNode::root(), effect, scrollB)
|
| .rectDrawing(FloatRect(1, 2, 3, 5), Color::white);
|
| update(artifact.build());
|
|
|
|
|