Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" | 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/test/test_simple_task_runner.h" | 9 #include "base/test/test_simple_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 TestPaintArtifact artifact; | 540 TestPaintArtifact artifact; |
| 541 artifact | 541 artifact |
| 542 .chunk(TransformPaintPropertyNode::root(), clip1, | 542 .chunk(TransformPaintPropertyNode::root(), clip1, |
| 543 EffectPaintPropertyNode::root()) | 543 EffectPaintPropertyNode::root()) |
| 544 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); | 544 .rectDrawing(FloatRect(0, 0, 640, 480), Color::white); |
| 545 artifact | 545 artifact |
| 546 .chunk(TransformPaintPropertyNode::root(), clip2, | 546 .chunk(TransformPaintPropertyNode::root(), clip2, |
| 547 EffectPaintPropertyNode::root()) | 547 EffectPaintPropertyNode::root()) |
| 548 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); | 548 .rectDrawing(FloatRect(0, 0, 640, 480), Color::black); |
| 549 update(artifact.build()); | 549 update(artifact.build()); |
| 550 | |
| 551 ASSERT_EQ(2u, contentLayerCount()); | 550 ASSERT_EQ(2u, contentLayerCount()); |
| 552 | 551 |
| 553 const cc::Layer* whiteLayer = contentLayerAt(0); | 552 const cc::Layer* whiteLayer = contentLayerAt(0); |
| 554 EXPECT_THAT(whiteLayer->GetPicture(), | 553 EXPECT_THAT(whiteLayer->GetPicture(), |
| 555 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); | 554 Pointee(drawsRectangle(FloatRect(0, 0, 640, 480), Color::white))); |
| 556 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); | 555 EXPECT_EQ(gfx::Transform(), whiteLayer->screen_space_transform()); |
| 557 const cc::ClipNode* whiteClip = | 556 const cc::ClipNode* whiteClip = |
| 558 propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index()); | 557 propertyTrees().clip_tree.Node(whiteLayer->clip_tree_index()); |
| 559 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, whiteClip->clip_type); | 558 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, whiteClip->clip_type); |
| 560 EXPECT_TRUE(whiteClip->layers_are_clipped); | 559 EXPECT_TRUE(whiteClip->layers_are_clipped); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 589 EffectPaintPropertyNode::root()) | 588 EffectPaintPropertyNode::root()) |
| 590 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 589 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 591 testArtifact.chunk(defaultPaintChunkProperties()) | 590 testArtifact.chunk(defaultPaintChunkProperties()) |
| 592 .foreignLayer(FloatPoint(50, 60), IntSize(400, 300), layer); | 591 .foreignLayer(FloatPoint(50, 60), IntSize(400, 300), layer); |
| 593 testArtifact | 592 testArtifact |
| 594 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 593 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 595 EffectPaintPropertyNode::root()) | 594 EffectPaintPropertyNode::root()) |
| 596 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); | 595 .rectDrawing(FloatRect(0, 0, 100, 100), Color::gray); |
| 597 | 596 |
| 598 const PaintArtifact& artifact = testArtifact.build(); | 597 const PaintArtifact& artifact = testArtifact.build(); |
| 599 | |
| 600 ASSERT_EQ(3u, artifact.paintChunks().size()); | 598 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 601 PaintArtifactCompositor::PendingLayer pendingLayer1( | |
| 602 artifact.paintChunks()[0]); | |
| 603 // Foreign layers can't merge. | |
| 604 EXPECT_FALSE(PaintArtifactCompositor::canMergeInto( | |
| 605 artifact, artifact.paintChunks()[1], pendingLayer1)); | |
| 606 PaintArtifactCompositor::PendingLayer pendingLayer2( | |
| 607 artifact.paintChunks()[1]); | |
| 608 EXPECT_FALSE(PaintArtifactCompositor::canMergeInto( | |
| 609 artifact, artifact.paintChunks()[2], pendingLayer2)); | |
| 610 | |
| 611 update(artifact); | 599 update(artifact); |
| 612 | 600 |
| 613 ASSERT_EQ(3u, contentLayerCount()); | 601 ASSERT_EQ(3u, contentLayerCount()); |
| 614 EXPECT_EQ(layer, contentLayerAt(1)); | 602 EXPECT_EQ(layer, contentLayerAt(1)); |
| 615 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); | 603 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); |
| 616 EXPECT_EQ(translation(50, 60), layer->screen_space_transform()); | 604 EXPECT_EQ(translation(50, 60), layer->screen_space_transform()); |
| 617 } | 605 } |
| 618 | 606 |
| 619 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { | 607 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { |
| 620 RefPtr<EffectPaintPropertyNode> effect1 = | 608 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( |
|
chrishtr
2017/02/28 22:50:36
Why can't you use createOpacityOnlyEffect and add
trchen
2017/03/01 01:26:11
Actually I'm thinking to abuse designated initiali
| |
| 621 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 609 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 622 RefPtr<EffectPaintPropertyNode> effect2 = | 610 ClipPaintPropertyNode::root(), ColorFilterNone, |
| 623 createOpacityOnlyEffect(effect1, 0.3); | 611 CompositorFilterOperations(), 0.5, SkBlendMode::kSrcOver, |
| 624 RefPtr<EffectPaintPropertyNode> effect3 = | 612 CompositingReasonAll); |
| 625 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.2); | 613 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( |
| 614 effect1, TransformPaintPropertyNode::root(), | |
| 615 ClipPaintPropertyNode::root(), ColorFilterNone, | |
| 616 CompositorFilterOperations(), 0.3, SkBlendMode::kSrcOver, | |
| 617 CompositingReasonAll); | |
| 618 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create( | |
| 619 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | |
| 620 ClipPaintPropertyNode::root(), ColorFilterNone, | |
| 621 CompositorFilterOperations(), 0.2, SkBlendMode::kSrcOver, | |
| 622 CompositingReasonAll); | |
| 626 | 623 |
| 627 TestPaintArtifact artifact; | 624 TestPaintArtifact artifact; |
| 628 artifact | 625 artifact |
| 629 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 626 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 630 effect2.get()) | 627 effect2.get()) |
| 631 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 628 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 632 artifact | 629 artifact |
| 633 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 630 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 634 effect1.get()) | 631 effect1.get()) |
| 635 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 632 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 | 774 |
| 778 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 775 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
| 779 RefPtr<EffectPaintPropertyNode> effect = | 776 RefPtr<EffectPaintPropertyNode> effect = |
| 780 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | 777 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); |
| 781 | 778 |
| 782 CompositorElementId expectedCompositorElementIdA = CompositorElementId(2, 0); | 779 CompositorElementId expectedCompositorElementIdA = CompositorElementId(2, 0); |
| 783 RefPtr<TransformPaintPropertyNode> scrollTranslationA = | 780 RefPtr<TransformPaintPropertyNode> scrollTranslationA = |
| 784 TransformPaintPropertyNode::createScrollTranslation( | 781 TransformPaintPropertyNode::createScrollTranslation( |
| 785 TransformPaintPropertyNode::root(), | 782 TransformPaintPropertyNode::root(), |
| 786 TransformationMatrix().translate(11, 13), FloatPoint3D(), false, 0, | 783 TransformationMatrix().translate(11, 13), FloatPoint3D(), false, 0, |
| 787 CompositingReasonNone, expectedCompositorElementIdA, | 784 CompositingReasonLayerForScrollingContents, |
| 788 ScrollPaintPropertyNode::root(), IntSize(2, 3), IntSize(5, 7), false, | 785 expectedCompositorElementIdA, ScrollPaintPropertyNode::root(), |
| 789 true, MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 786 IntSize(2, 3), IntSize(5, 7), false, true, |
| 787 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | |
| 790 nullptr); | 788 nullptr); |
| 791 | 789 |
| 792 CompositorElementId expectedCompositorElementIdB = CompositorElementId(3, 0); | 790 CompositorElementId expectedCompositorElementIdB = CompositorElementId(3, 0); |
| 793 RefPtr<TransformPaintPropertyNode> scrollTranslationB = | 791 RefPtr<TransformPaintPropertyNode> scrollTranslationB = |
| 794 TransformPaintPropertyNode::createScrollTranslation( | 792 TransformPaintPropertyNode::createScrollTranslation( |
| 795 scrollTranslationA, TransformationMatrix().translate(37, 41), | 793 scrollTranslationA, TransformationMatrix().translate(37, 41), |
| 796 FloatPoint3D(), false, 0, CompositingReasonNone, | 794 FloatPoint3D(), false, 0, CompositingReasonNone, |
| 797 expectedCompositorElementIdB, scrollTranslationA->scrollNode(), | 795 expectedCompositorElementIdB, scrollTranslationA->scrollNode(), |
| 798 IntSize(19, 23), IntSize(29, 31), true, false, | 796 IntSize(19, 23), IntSize(29, 31), true, false, |
| 799 0 /* mainThreadScrollingReasons */, nullptr); | 797 0 /* mainThreadScrollingReasons */, nullptr); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 testArtifact | 832 testArtifact |
| 835 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 833 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 836 EffectPaintPropertyNode::root()) | 834 EffectPaintPropertyNode::root()) |
| 837 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 835 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 838 testArtifact | 836 testArtifact |
| 839 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 837 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 840 EffectPaintPropertyNode::root()) | 838 EffectPaintPropertyNode::root()) |
| 841 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 839 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 842 | 840 |
| 843 const PaintArtifact& artifact = testArtifact.build(); | 841 const PaintArtifact& artifact = testArtifact.build(); |
| 844 | |
| 845 ASSERT_EQ(2u, artifact.paintChunks().size()); | 842 ASSERT_EQ(2u, artifact.paintChunks().size()); |
| 846 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 847 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 848 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 849 | |
| 850 update(artifact); | 843 update(artifact); |
| 851 | 844 |
| 852 ASSERT_EQ(1u, contentLayerCount()); | 845 ASSERT_EQ(1u, contentLayerCount()); |
| 853 { | 846 { |
| 854 Vector<RectWithColor> rectsWithColor; | 847 Vector<RectWithColor> rectsWithColor; |
| 855 rectsWithColor.push_back( | 848 rectsWithColor.push_back( |
| 856 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 849 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 857 rectsWithColor.push_back( | 850 rectsWithColor.push_back( |
| 858 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); | 851 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); |
| 859 | 852 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 877 EffectPaintPropertyNode::root()) | 870 EffectPaintPropertyNode::root()) |
| 878 .rectDrawing(FloatRect(0, 0, 200, 300), Color::black); | 871 .rectDrawing(FloatRect(0, 0, 200, 300), Color::black); |
| 879 testArtifact | 872 testArtifact |
| 880 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 873 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 881 EffectPaintPropertyNode::root()) | 874 EffectPaintPropertyNode::root()) |
| 882 .rectDrawing(FloatRect(0, 0, 300, 400), Color::gray); | 875 .rectDrawing(FloatRect(0, 0, 300, 400), Color::gray); |
| 883 | 876 |
| 884 const PaintArtifact& artifact = testArtifact.build(); | 877 const PaintArtifact& artifact = testArtifact.build(); |
| 885 | 878 |
| 886 ASSERT_EQ(3u, artifact.paintChunks().size()); | 879 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 887 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 888 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 889 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 890 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 891 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 892 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 893 | |
| 894 update(artifact); | 880 update(artifact); |
| 895 | |
| 896 ASSERT_EQ(1u, contentLayerCount()); | 881 ASSERT_EQ(1u, contentLayerCount()); |
| 897 { | 882 { |
| 898 Vector<RectWithColor> rectsWithColor; | 883 Vector<RectWithColor> rectsWithColor; |
| 899 rectsWithColor.push_back( | 884 rectsWithColor.push_back( |
| 900 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 885 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 901 // Clip is applied to this PaintChunk. | 886 // Clip is applied to this PaintChunk. |
| 902 rectsWithColor.push_back( | 887 rectsWithColor.push_back( |
| 903 RectWithColor(FloatRect(10, 20, 50, 60), Color::black)); | 888 RectWithColor(FloatRect(10, 20, 50, 60), Color::black)); |
| 904 rectsWithColor.push_back( | 889 rectsWithColor.push_back( |
| 905 RectWithColor(FloatRect(0, 0, 300, 400), Color::gray)); | 890 RectWithColor(FloatRect(0, 0, 300, 400), Color::gray)); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 924 testArtifact | 909 testArtifact |
| 925 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 910 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 926 EffectPaintPropertyNode::root()) | 911 EffectPaintPropertyNode::root()) |
| 927 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 912 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 928 testArtifact | 913 testArtifact |
| 929 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 914 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 930 EffectPaintPropertyNode::root()) | 915 EffectPaintPropertyNode::root()) |
| 931 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 916 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 932 | 917 |
| 933 const PaintArtifact& artifact = testArtifact.build(); | 918 const PaintArtifact& artifact = testArtifact.build(); |
| 934 | |
| 935 ASSERT_EQ(3u, artifact.paintChunks().size()); | 919 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 936 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 937 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 938 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 939 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 940 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 941 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 942 | |
| 943 update(artifact); | 920 update(artifact); |
| 944 | 921 |
| 945 ASSERT_EQ(1u, contentLayerCount()); | 922 ASSERT_EQ(1u, contentLayerCount()); |
| 946 { | 923 { |
| 947 Vector<RectWithColor> rectsWithColor; | 924 Vector<RectWithColor> rectsWithColor; |
| 948 rectsWithColor.push_back( | 925 rectsWithColor.push_back( |
| 949 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 926 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 950 // Transform is applied to this PaintChunk. | 927 // Transform is applied to this PaintChunk. |
| 951 rectsWithColor.push_back( | 928 rectsWithColor.push_back( |
| 952 RectWithColor(FloatRect(50, 50, 100, 100), Color::black)); | 929 RectWithColor(FloatRect(50, 50, 100, 100), Color::black)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 976 EffectPaintPropertyNode::root()) | 953 EffectPaintPropertyNode::root()) |
| 977 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 954 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 978 // The second chunk can merge into the first because it has a descendant | 955 // The second chunk can merge into the first because it has a descendant |
| 979 // state of the first's transform and no direct compositing reason. | 956 // state of the first's transform and no direct compositing reason. |
| 980 testArtifact | 957 testArtifact |
| 981 .chunk(transform2.get(), ClipPaintPropertyNode::root(), | 958 .chunk(transform2.get(), ClipPaintPropertyNode::root(), |
| 982 EffectPaintPropertyNode::root()) | 959 EffectPaintPropertyNode::root()) |
| 983 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 960 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 984 | 961 |
| 985 const PaintArtifact& artifact = testArtifact.build(); | 962 const PaintArtifact& artifact = testArtifact.build(); |
| 986 | |
| 987 ASSERT_EQ(2u, artifact.paintChunks().size()); | 963 ASSERT_EQ(2u, artifact.paintChunks().size()); |
| 988 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 989 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 990 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 991 | |
| 992 update(artifact); | 964 update(artifact); |
| 993 | |
| 994 ASSERT_EQ(1u, contentLayerCount()); | 965 ASSERT_EQ(1u, contentLayerCount()); |
| 995 { | 966 { |
| 996 Vector<RectWithColor> rectsWithColor; | 967 Vector<RectWithColor> rectsWithColor; |
| 997 rectsWithColor.push_back( | 968 rectsWithColor.push_back( |
| 998 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 969 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 999 // Transform is applied to this PaintChunk. | 970 // Transform is applied to this PaintChunk. |
| 1000 rectsWithColor.push_back( | 971 rectsWithColor.push_back( |
| 1001 RectWithColor(FloatRect(50, 50, 100, 100), Color::black)); | 972 RectWithColor(FloatRect(50, 50, 100, 100), Color::black)); |
| 1002 | 973 |
| 1003 const cc::Layer* layer = contentLayerAt(0); | 974 const cc::Layer* layer = contentLayerAt(0); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1019 testArtifact | 990 testArtifact |
| 1020 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 991 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 1021 EffectPaintPropertyNode::root()) | 992 EffectPaintPropertyNode::root()) |
| 1022 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 993 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 1023 testArtifact | 994 testArtifact |
| 1024 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 995 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1025 EffectPaintPropertyNode::root()) | 996 EffectPaintPropertyNode::root()) |
| 1026 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 997 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1027 | 998 |
| 1028 const PaintArtifact& artifact = testArtifact.build(); | 999 const PaintArtifact& artifact = testArtifact.build(); |
| 1029 | |
| 1030 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1000 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1031 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1032 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1033 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1034 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1035 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1036 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1037 update(artifact); | 1001 update(artifact); |
| 1038 | |
| 1039 ASSERT_EQ(1u, contentLayerCount()); | 1002 ASSERT_EQ(1u, contentLayerCount()); |
| 1040 { | 1003 { |
| 1041 Vector<RectWithColor> rectsWithColor; | 1004 Vector<RectWithColor> rectsWithColor; |
| 1042 rectsWithColor.push_back( | 1005 rectsWithColor.push_back( |
| 1043 RectWithColor(FloatRect(0, 42, 100, 100), Color::white)); | 1006 RectWithColor(FloatRect(0, 42, 100, 100), Color::white)); |
| 1044 // Transform is applied to this PaintChunk. | 1007 // Transform is applied to this PaintChunk. |
| 1045 rectsWithColor.push_back(RectWithColor( | 1008 rectsWithColor.push_back(RectWithColor( |
| 1046 FloatRect(29.2893, 0.578644, 141.421, 141.421), Color::black)); | 1009 FloatRect(29.2893, 0.578644, 141.421, 141.421), Color::black)); |
| 1047 rectsWithColor.push_back( | 1010 rectsWithColor.push_back( |
| 1048 RectWithColor(FloatRect(00, 42, 200, 300), Color::gray)); | 1011 RectWithColor(FloatRect(00, 42, 200, 300), Color::gray)); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1065 testArtifact | 1028 testArtifact |
| 1066 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1029 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1067 effect.get()) | 1030 effect.get()) |
| 1068 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 1031 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 1069 testArtifact | 1032 testArtifact |
| 1070 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1033 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1071 EffectPaintPropertyNode::root()) | 1034 EffectPaintPropertyNode::root()) |
| 1072 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1035 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1073 | 1036 |
| 1074 const PaintArtifact& artifact = testArtifact.build(); | 1037 const PaintArtifact& artifact = testArtifact.build(); |
| 1075 | |
| 1076 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1038 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1077 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1078 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1079 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1080 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1081 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1082 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1083 | |
| 1084 update(artifact); | 1039 update(artifact); |
| 1085 | |
| 1086 ASSERT_EQ(1u, contentLayerCount()); | 1040 ASSERT_EQ(1u, contentLayerCount()); |
| 1087 { | 1041 { |
| 1088 Vector<RectWithColor> rectsWithColor; | 1042 Vector<RectWithColor> rectsWithColor; |
| 1089 rectsWithColor.push_back( | 1043 rectsWithColor.push_back( |
| 1090 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1044 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1091 // Transform is applied to this PaintChunk. | 1045 // Transform is applied to this PaintChunk. |
| 1092 rectsWithColor.push_back( | 1046 rectsWithColor.push_back( |
| 1093 RectWithColor(FloatRect(0, 0, 100, 100), | 1047 RectWithColor(FloatRect(0, 0, 100, 100), |
| 1094 Color(Color::black).combineWithAlpha(opacity).rgb())); | 1048 Color(Color::black).combineWithAlpha(opacity).rgb())); |
| 1095 rectsWithColor.push_back( | 1049 rectsWithColor.push_back( |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 1126 EffectPaintPropertyNode::root()) | 1080 EffectPaintPropertyNode::root()) |
| 1127 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1081 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1128 testArtifact.chunk(transform.get(), clip.get(), effect.get()) | 1082 testArtifact.chunk(transform.get(), clip.get(), effect.get()) |
| 1129 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 1083 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 1130 testArtifact | 1084 testArtifact |
| 1131 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1085 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1132 EffectPaintPropertyNode::root()) | 1086 EffectPaintPropertyNode::root()) |
| 1133 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1087 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1134 | 1088 |
| 1135 const PaintArtifact& artifact = testArtifact.build(); | 1089 const PaintArtifact& artifact = testArtifact.build(); |
| 1136 | |
| 1137 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1090 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1138 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1139 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1140 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1141 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1142 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1143 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1144 update(artifact); | 1091 update(artifact); |
| 1145 | |
| 1146 ASSERT_EQ(1u, contentLayerCount()); | 1092 ASSERT_EQ(1u, contentLayerCount()); |
| 1147 { | 1093 { |
| 1148 Vector<RectWithColor> rectsWithColor; | 1094 Vector<RectWithColor> rectsWithColor; |
| 1149 rectsWithColor.push_back( | 1095 rectsWithColor.push_back( |
| 1150 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1096 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1151 // Transform is applied to this PaintChunk. | 1097 // Transform is applied to this PaintChunk. |
| 1152 rectsWithColor.push_back( | 1098 rectsWithColor.push_back( |
| 1153 RectWithColor(FloatRect(60, 70, 50, 60), | 1099 RectWithColor(FloatRect(60, 70, 50, 60), |
| 1154 Color(Color::black).combineWithAlpha(opacity).rgb())); | 1100 Color(Color::black).combineWithAlpha(opacity).rgb())); |
| 1155 rectsWithColor.push_back( | 1101 rectsWithColor.push_back( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1188 testArtifact | 1134 testArtifact |
| 1189 .chunk(TransformPaintPropertyNode::root(), clip.get(), | 1135 .chunk(TransformPaintPropertyNode::root(), clip.get(), |
| 1190 EffectPaintPropertyNode::root()) | 1136 EffectPaintPropertyNode::root()) |
| 1191 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1137 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1192 testArtifact | 1138 testArtifact |
| 1193 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1139 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1194 EffectPaintPropertyNode::root()) | 1140 EffectPaintPropertyNode::root()) |
| 1195 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1141 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1196 | 1142 |
| 1197 const PaintArtifact& artifact = testArtifact.build(); | 1143 const PaintArtifact& artifact = testArtifact.build(); |
| 1198 | |
| 1199 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1144 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1200 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1201 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1202 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1203 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1204 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1205 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1206 update(artifact); | 1145 update(artifact); |
| 1207 | |
| 1208 ASSERT_EQ(1u, contentLayerCount()); | 1146 ASSERT_EQ(1u, contentLayerCount()); |
| 1209 { | 1147 { |
| 1210 Vector<RectWithColor> rectsWithColor; | 1148 Vector<RectWithColor> rectsWithColor; |
| 1211 rectsWithColor.push_back( | 1149 rectsWithColor.push_back( |
| 1212 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1150 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1213 // The two transforms (combined translation of (40, 50)) are applied here, | 1151 // The two transforms (combined translation of (40, 50)) are applied here, |
| 1214 // before clipping. | 1152 // before clipping. |
| 1215 rectsWithColor.push_back( | 1153 rectsWithColor.push_back( |
| 1216 RectWithColor(FloatRect(50, 70, 50, 60), Color(Color::black))); | 1154 RectWithColor(FloatRect(50, 70, 50, 60), Color(Color::black))); |
| 1217 rectsWithColor.push_back( | 1155 rectsWithColor.push_back( |
| 1218 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); | 1156 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); |
| 1219 | 1157 |
| 1220 const cc::Layer* layer = contentLayerAt(0); | 1158 const cc::Layer* layer = contentLayerAt(0); |
| 1221 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 1159 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 1222 } | 1160 } |
| 1223 } | 1161 } |
| 1224 | 1162 |
| 1225 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp) { | 1163 // TODO(crbug.com/696842): The effect refuses to "decomposite" because it's in |
| 1164 // a deeper transform space than its chunk. We should allow decomposite if | |
| 1165 // the two transform nodes share the same direct compositing ancestor. | |
| 1166 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectPushedUp_DISABLED) { | |
| 1226 // Tests merging of an element which has an effect applied to it, | 1167 // Tests merging of an element which has an effect applied to it, |
| 1227 // but has an ancestor transform of them. This can happen for fixed- | 1168 // but has an ancestor transform of them. This can happen for fixed- |
| 1228 // or absolute-position elements which escape scroll transforms. | 1169 // or absolute-position elements which escape scroll transforms. |
| 1229 | 1170 |
| 1230 RefPtr<TransformPaintPropertyNode> transform = | 1171 RefPtr<TransformPaintPropertyNode> transform = |
| 1231 TransformPaintPropertyNode::create( | 1172 TransformPaintPropertyNode::create( |
| 1232 TransformPaintPropertyNode::root(), | 1173 TransformPaintPropertyNode::root(), |
| 1233 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1174 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1234 false, 0); | 1175 false, 0); |
| 1235 | 1176 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1252 testArtifact | 1193 testArtifact |
| 1253 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1194 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1254 effect.get()) | 1195 effect.get()) |
| 1255 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1196 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1256 testArtifact | 1197 testArtifact |
| 1257 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1198 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1258 EffectPaintPropertyNode::root()) | 1199 EffectPaintPropertyNode::root()) |
| 1259 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1200 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1260 | 1201 |
| 1261 const PaintArtifact& artifact = testArtifact.build(); | 1202 const PaintArtifact& artifact = testArtifact.build(); |
| 1262 | |
| 1263 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1203 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1264 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1265 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1266 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1267 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1268 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1269 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1270 update(artifact); | 1204 update(artifact); |
| 1271 | |
| 1272 ASSERT_EQ(1u, contentLayerCount()); | 1205 ASSERT_EQ(1u, contentLayerCount()); |
| 1273 { | 1206 { |
| 1274 Vector<RectWithColor> rectsWithColor; | 1207 Vector<RectWithColor> rectsWithColor; |
| 1275 rectsWithColor.push_back( | 1208 rectsWithColor.push_back( |
| 1276 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1209 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1277 rectsWithColor.push_back( | 1210 rectsWithColor.push_back( |
| 1278 RectWithColor(FloatRect(0, 0, 300, 400), | 1211 RectWithColor(FloatRect(0, 0, 300, 400), |
| 1279 Color(Color::black).combineWithAlpha(opacity).rgb())); | 1212 Color(Color::black).combineWithAlpha(opacity).rgb())); |
| 1280 rectsWithColor.push_back( | 1213 rectsWithColor.push_back( |
| 1281 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); | 1214 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); |
| 1282 | 1215 |
| 1283 const cc::Layer* layer = contentLayerAt(0); | 1216 const cc::Layer* layer = contentLayerAt(0); |
| 1284 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); | 1217 EXPECT_THAT(layer->GetPicture(), Pointee(drawsRectangles(rectsWithColor))); |
| 1285 } | 1218 } |
| 1286 } | 1219 } |
| 1287 | 1220 |
| 1288 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectAndClipPushedUp) { | 1221 // TODO(crbug.com/696842): The effect refuses to "decomposite" because it's in |
| 1222 // a deeper transform space than its chunk. We should allow decomposite if | |
| 1223 // the two transform nodes share the same direct compositing ancestor. | |
| 1224 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, | |
| 1225 EffectAndClipPushedUp_DISABLED) { | |
| 1289 // Tests merging of an element which has an effect applied to it, | 1226 // Tests merging of an element which has an effect applied to it, |
| 1290 // but has an ancestor transform of them. This can happen for fixed- | 1227 // but has an ancestor transform of them. This can happen for fixed- |
| 1291 // or absolute-position elements which escape scroll transforms. | 1228 // or absolute-position elements which escape scroll transforms. |
| 1292 | 1229 |
| 1293 RefPtr<TransformPaintPropertyNode> transform = | 1230 RefPtr<TransformPaintPropertyNode> transform = |
| 1294 TransformPaintPropertyNode::create( | 1231 TransformPaintPropertyNode::create( |
| 1295 TransformPaintPropertyNode::root(), | 1232 TransformPaintPropertyNode::root(), |
| 1296 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | 1233 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), |
| 1297 false, 0); | 1234 false, 0); |
| 1298 | 1235 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1318 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1255 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1319 testArtifact | 1256 testArtifact |
| 1320 .chunk(TransformPaintPropertyNode::root(), clip.get(), effect.get()) | 1257 .chunk(TransformPaintPropertyNode::root(), clip.get(), effect.get()) |
| 1321 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1258 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1322 testArtifact | 1259 testArtifact |
| 1323 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1260 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1324 EffectPaintPropertyNode::root()) | 1261 EffectPaintPropertyNode::root()) |
| 1325 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1262 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1326 | 1263 |
| 1327 const PaintArtifact& artifact = testArtifact.build(); | 1264 const PaintArtifact& artifact = testArtifact.build(); |
| 1328 | |
| 1329 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1265 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1330 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1331 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1332 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1333 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1334 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1335 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1336 update(artifact); | 1266 update(artifact); |
| 1337 | |
| 1338 ASSERT_EQ(1u, contentLayerCount()); | 1267 ASSERT_EQ(1u, contentLayerCount()); |
| 1339 { | 1268 { |
| 1340 Vector<RectWithColor> rectsWithColor; | 1269 Vector<RectWithColor> rectsWithColor; |
| 1341 rectsWithColor.push_back( | 1270 rectsWithColor.push_back( |
| 1342 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1271 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1343 // The clip is under |transform| but not |transform2|, so only an adjustment | 1272 // The clip is under |transform| but not |transform2|, so only an adjustment |
| 1344 // of (20, 25) occurs. | 1273 // of (20, 25) occurs. |
| 1345 rectsWithColor.push_back( | 1274 rectsWithColor.push_back( |
| 1346 RectWithColor(FloatRect(30, 45, 50, 60), | 1275 RectWithColor(FloatRect(30, 45, 50, 60), |
| 1347 Color(Color::black).combineWithAlpha(opacity).rgb())); | 1276 Color(Color::black).combineWithAlpha(opacity).rgb())); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1374 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1303 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1375 testArtifact | 1304 testArtifact |
| 1376 .chunk(TransformPaintPropertyNode::root(), clip.get(), effect.get()) | 1305 .chunk(TransformPaintPropertyNode::root(), clip.get(), effect.get()) |
| 1377 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1306 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1378 testArtifact | 1307 testArtifact |
| 1379 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1308 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1380 EffectPaintPropertyNode::root()) | 1309 EffectPaintPropertyNode::root()) |
| 1381 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1310 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1382 | 1311 |
| 1383 const PaintArtifact& artifact = testArtifact.build(); | 1312 const PaintArtifact& artifact = testArtifact.build(); |
| 1384 | |
| 1385 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1313 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1386 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1387 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1388 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1389 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1390 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1391 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1392 update(artifact); | 1314 update(artifact); |
| 1393 | |
| 1394 ASSERT_EQ(1u, contentLayerCount()); | 1315 ASSERT_EQ(1u, contentLayerCount()); |
| 1395 { | 1316 { |
| 1396 Vector<RectWithColor> rectsWithColor; | 1317 Vector<RectWithColor> rectsWithColor; |
| 1397 rectsWithColor.push_back( | 1318 rectsWithColor.push_back( |
| 1398 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1319 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1399 rectsWithColor.push_back( | 1320 rectsWithColor.push_back( |
| 1400 RectWithColor(FloatRect(10, 20, 50, 60), | 1321 RectWithColor(FloatRect(10, 20, 50, 60), |
| 1401 Color(Color::black).combineWithAlpha(opacity).rgb())); | 1322 Color(Color::black).combineWithAlpha(opacity).rgb())); |
| 1402 rectsWithColor.push_back( | 1323 rectsWithColor.push_back( |
| 1403 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); | 1324 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1427 testArtifact | 1348 testArtifact |
| 1428 .chunk(TransformPaintPropertyNode::root(), clip2.get(), | 1349 .chunk(TransformPaintPropertyNode::root(), clip2.get(), |
| 1429 EffectPaintPropertyNode::root()) | 1350 EffectPaintPropertyNode::root()) |
| 1430 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1351 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1431 testArtifact | 1352 testArtifact |
| 1432 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1353 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1433 EffectPaintPropertyNode::root()) | 1354 EffectPaintPropertyNode::root()) |
| 1434 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1355 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1435 | 1356 |
| 1436 const PaintArtifact& artifact = testArtifact.build(); | 1357 const PaintArtifact& artifact = testArtifact.build(); |
| 1437 | |
| 1438 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1358 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1439 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1440 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1441 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1442 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1443 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1444 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1445 update(artifact); | 1359 update(artifact); |
| 1446 | |
| 1447 ASSERT_EQ(1u, contentLayerCount()); | 1360 ASSERT_EQ(1u, contentLayerCount()); |
| 1448 { | 1361 { |
| 1449 Vector<RectWithColor> rectsWithColor; | 1362 Vector<RectWithColor> rectsWithColor; |
| 1450 rectsWithColor.push_back( | 1363 rectsWithColor.push_back( |
| 1451 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1364 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1452 // The interesction of the two clips is (20, 30, 10, 20). | 1365 // The interesction of the two clips is (20, 30, 10, 20). |
| 1453 rectsWithColor.push_back( | 1366 rectsWithColor.push_back( |
| 1454 RectWithColor(FloatRect(20, 30, 10, 20), Color(Color::black))); | 1367 RectWithColor(FloatRect(20, 30, 10, 20), Color(Color::black))); |
| 1455 rectsWithColor.push_back( | 1368 rectsWithColor.push_back( |
| 1456 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); | 1369 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1478 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1391 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1479 EffectPaintPropertyNode::root()) | 1392 EffectPaintPropertyNode::root()) |
| 1480 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1393 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1481 testArtifact | 1394 testArtifact |
| 1482 .chunk(transform2.get(), clip.get(), EffectPaintPropertyNode::root()) | 1395 .chunk(transform2.get(), clip.get(), EffectPaintPropertyNode::root()) |
| 1483 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); | 1396 .rectDrawing(FloatRect(0, 0, 300, 400), Color::black); |
| 1484 testArtifact | 1397 testArtifact |
| 1485 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1398 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1486 EffectPaintPropertyNode::root()) | 1399 EffectPaintPropertyNode::root()) |
| 1487 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1400 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1401 | |
| 1488 const PaintArtifact& artifact = testArtifact.build(); | 1402 const PaintArtifact& artifact = testArtifact.build(); |
| 1489 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1403 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1490 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1491 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1492 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1493 pendingLayer.add(artifact.paintChunks()[1], nullptr); | |
| 1494 EXPECT_TRUE(PaintArtifactCompositor::canMergeInto( | |
| 1495 artifact, artifact.paintChunks()[2], pendingLayer)); | |
| 1496 update(artifact); | 1404 update(artifact); |
| 1497 ASSERT_EQ(1u, contentLayerCount()); | 1405 ASSERT_EQ(1u, contentLayerCount()); |
| 1498 { | 1406 { |
| 1499 Vector<RectWithColor> rectsWithColor; | 1407 Vector<RectWithColor> rectsWithColor; |
| 1500 rectsWithColor.push_back( | 1408 rectsWithColor.push_back( |
| 1501 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); | 1409 RectWithColor(FloatRect(0, 0, 100, 100), Color::white)); |
| 1502 rectsWithColor.push_back( | 1410 rectsWithColor.push_back( |
| 1503 RectWithColor(FloatRect(40, 50, 50, 60), Color(Color::black))); | 1411 RectWithColor(FloatRect(40, 50, 50, 60), Color(Color::black))); |
| 1504 rectsWithColor.push_back( | 1412 rectsWithColor.push_back( |
| 1505 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); | 1413 RectWithColor(FloatRect(0, 0, 200, 300), Color::gray)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1519 testArtifact.chunk(defaultPaintChunkProperties()) | 1427 testArtifact.chunk(defaultPaintChunkProperties()) |
| 1520 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 1428 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 1521 testArtifact | 1429 testArtifact |
| 1522 .chunk(transform.get(), ClipPaintPropertyNode::root(), | 1430 .chunk(transform.get(), ClipPaintPropertyNode::root(), |
| 1523 EffectPaintPropertyNode::root()) | 1431 EffectPaintPropertyNode::root()) |
| 1524 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); | 1432 .rectDrawing(FloatRect(0, 0, 100, 100), Color::black); |
| 1525 testArtifact.chunk(defaultPaintChunkProperties()) | 1433 testArtifact.chunk(defaultPaintChunkProperties()) |
| 1526 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); | 1434 .rectDrawing(FloatRect(0, 0, 200, 300), Color::gray); |
| 1527 | 1435 |
| 1528 const PaintArtifact& artifact = testArtifact.build(); | 1436 const PaintArtifact& artifact = testArtifact.build(); |
| 1529 | |
| 1530 ASSERT_EQ(3u, artifact.paintChunks().size()); | 1437 ASSERT_EQ(3u, artifact.paintChunks().size()); |
| 1531 PaintArtifactCompositor::PendingLayer pendingLayer(artifact.paintChunks()[0]); | |
| 1532 | |
| 1533 EXPECT_FALSE(PaintArtifactCompositor::canMergeInto( | |
| 1534 artifact, artifact.paintChunks()[1], pendingLayer)); | |
| 1535 | |
| 1536 PaintArtifactCompositor::PendingLayer pendingLayer2( | |
| 1537 artifact.paintChunks()[1]); | |
| 1538 EXPECT_FALSE(PaintArtifactCompositor::canMergeInto( | |
| 1539 artifact, artifact.paintChunks()[2], pendingLayer2)); | |
| 1540 | |
| 1541 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | |
| 1542 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap( | |
| 1543 artifact.paintChunks()[2], pendingLayer2, *geometryMapper)); | |
| 1544 | |
| 1545 update(artifact); | 1438 update(artifact); |
| 1546 | |
| 1547 // The third paint chunk overlaps the second but can't merge due to | 1439 // The third paint chunk overlaps the second but can't merge due to |
| 1548 // incompatible transform. The second paint chunk can't merge into the first | 1440 // incompatible transform. The second paint chunk can't merge into the first |
| 1549 // due to a direct compositing reason. | 1441 // due to a direct compositing reason. |
| 1550 ASSERT_EQ(3u, contentLayerCount()); | 1442 ASSERT_EQ(3u, contentLayerCount()); |
| 1551 } | 1443 } |
| 1552 | 1444 |
| 1553 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, MightOverlap) { | |
| 1554 PaintChunk paintChunk; | |
| 1555 paintChunk.properties = defaultPaintChunkProperties(); | |
| 1556 paintChunk.bounds = FloatRect(0, 0, 100, 100); | |
| 1557 | |
| 1558 PaintChunk paintChunk2; | |
| 1559 paintChunk2.properties = defaultPaintChunkProperties(); | |
| 1560 paintChunk2.bounds = FloatRect(0, 0, 100, 100); | |
| 1561 | |
| 1562 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | |
| 1563 PaintArtifactCompositor::PendingLayer pendingLayer(paintChunk); | |
| 1564 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, | |
| 1565 *geometryMapper)); | |
| 1566 | |
| 1567 RefPtr<TransformPaintPropertyNode> transform = | |
| 1568 TransformPaintPropertyNode::create( | |
| 1569 TransformPaintPropertyNode::root(), | |
| 1570 TransformationMatrix().translate(99, 0), FloatPoint3D(100, 100, 0), | |
| 1571 false); | |
| 1572 | |
| 1573 paintChunk2.properties.propertyTreeState.setTransform(transform.get()); | |
| 1574 EXPECT_TRUE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, | |
| 1575 *geometryMapper)); | |
| 1576 | |
| 1577 RefPtr<TransformPaintPropertyNode> transform2 = | |
| 1578 TransformPaintPropertyNode::create( | |
| 1579 TransformPaintPropertyNode::root(), | |
| 1580 TransformationMatrix().translate(100, 0), FloatPoint3D(100, 100, 0), | |
| 1581 false); | |
| 1582 paintChunk2.properties.propertyTreeState.setTransform(transform2.get()); | |
| 1583 | |
| 1584 EXPECT_FALSE(PaintArtifactCompositor::mightOverlap(paintChunk2, pendingLayer, | |
| 1585 *geometryMapper)); | |
| 1586 } | |
| 1587 | |
| 1588 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayer) { | |
| 1589 PaintChunk chunk1; | |
| 1590 chunk1.properties.propertyTreeState = PropertyTreeState( | |
| 1591 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1592 EffectPaintPropertyNode::root()); | |
| 1593 chunk1.properties.backfaceHidden = true; | |
| 1594 chunk1.knownToBeOpaque = true; | |
| 1595 chunk1.bounds = FloatRect(0, 0, 30, 40); | |
| 1596 | |
| 1597 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | |
| 1598 | |
| 1599 EXPECT_TRUE(pendingLayer.backfaceHidden); | |
| 1600 EXPECT_TRUE(pendingLayer.knownToBeOpaque); | |
| 1601 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); | |
| 1602 | |
| 1603 PaintChunk chunk2; | |
| 1604 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | |
| 1605 chunk2.properties.backfaceHidden = true; | |
| 1606 chunk2.knownToBeOpaque = true; | |
| 1607 chunk2.bounds = FloatRect(10, 20, 30, 40); | |
| 1608 pendingLayer.add(chunk2, nullptr); | |
| 1609 | |
| 1610 EXPECT_TRUE(pendingLayer.backfaceHidden); | |
| 1611 // Bounds not equal to one PaintChunk. | |
| 1612 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | |
| 1613 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 40, 60), pendingLayer.bounds); | |
| 1614 | |
| 1615 PaintChunk chunk3; | |
| 1616 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; | |
| 1617 chunk3.properties.backfaceHidden = true; | |
| 1618 chunk3.knownToBeOpaque = true; | |
| 1619 chunk3.bounds = FloatRect(-5, -25, 20, 20); | |
| 1620 pendingLayer.add(chunk3, nullptr); | |
| 1621 | |
| 1622 EXPECT_TRUE(pendingLayer.backfaceHidden); | |
| 1623 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | |
| 1624 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(-5, -25, 45, 85), pendingLayer.bounds); | |
| 1625 } | |
| 1626 | |
| 1627 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerWithGeometry) { | |
| 1628 RefPtr<TransformPaintPropertyNode> transform = | |
| 1629 TransformPaintPropertyNode::create( | |
| 1630 TransformPaintPropertyNode::root(), | |
| 1631 TransformationMatrix().translate(20, 25), FloatPoint3D(100, 100, 0), | |
| 1632 false, 0); | |
| 1633 | |
| 1634 PaintChunk chunk1; | |
| 1635 chunk1.properties.propertyTreeState = PropertyTreeState( | |
| 1636 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1637 EffectPaintPropertyNode::root()); | |
| 1638 chunk1.bounds = FloatRect(0, 0, 30, 40); | |
| 1639 | |
| 1640 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | |
| 1641 | |
| 1642 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 30, 40), pendingLayer.bounds); | |
| 1643 | |
| 1644 PaintChunk chunk2; | |
| 1645 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | |
| 1646 chunk2.properties.propertyTreeState.setTransform(transform); | |
| 1647 chunk2.bounds = FloatRect(0, 0, 50, 60); | |
| 1648 std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); | |
| 1649 pendingLayer.add(chunk2, geometryMapper.get()); | |
| 1650 | |
| 1651 EXPECT_BLINK_FLOAT_RECT_EQ(FloatRect(0, 0, 70, 85), pendingLayer.bounds); | |
| 1652 } | |
| 1653 | |
| 1654 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, PendingLayerKnownOpaque) { | |
| 1655 PaintChunk chunk1; | |
| 1656 chunk1.properties.propertyTreeState = PropertyTreeState( | |
| 1657 TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1658 EffectPaintPropertyNode::root()); | |
| 1659 chunk1.bounds = FloatRect(0, 0, 30, 40); | |
| 1660 chunk1.knownToBeOpaque = false; | |
| 1661 PaintArtifactCompositor::PendingLayer pendingLayer(chunk1); | |
| 1662 | |
| 1663 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | |
| 1664 | |
| 1665 PaintChunk chunk2; | |
| 1666 chunk2.properties.propertyTreeState = chunk1.properties.propertyTreeState; | |
| 1667 chunk2.bounds = FloatRect(0, 0, 25, 35); | |
| 1668 chunk2.knownToBeOpaque = true; | |
| 1669 pendingLayer.add(chunk2, nullptr); | |
| 1670 | |
| 1671 // Chunk 2 doesn't cover the entire layer, so not opaque. | |
| 1672 EXPECT_FALSE(pendingLayer.knownToBeOpaque); | |
| 1673 | |
| 1674 PaintChunk chunk3; | |
| 1675 chunk3.properties.propertyTreeState = chunk1.properties.propertyTreeState; | |
| 1676 chunk3.bounds = FloatRect(0, 0, 50, 60); | |
| 1677 chunk3.knownToBeOpaque = true; | |
| 1678 pendingLayer.add(chunk3, nullptr); | |
| 1679 | |
| 1680 // Chunk 3 covers the entire layer, so now it's opaque. | |
| 1681 EXPECT_TRUE(pendingLayer.knownToBeOpaque); | |
| 1682 } | |
| 1683 | |
| 1684 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { | 1445 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { |
| 1685 CompositorElementId expectedCompositorElementId(2, 0); | 1446 CompositorElementId expectedCompositorElementId(2, 0); |
| 1686 RefPtr<TransformPaintPropertyNode> transform = | 1447 RefPtr<TransformPaintPropertyNode> transform = |
| 1687 TransformPaintPropertyNode::create( | 1448 TransformPaintPropertyNode::create( |
| 1688 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), | 1449 TransformPaintPropertyNode::root(), TransformationMatrix().rotate(90), |
| 1689 FloatPoint3D(100, 100, 0), false, 0, CompositingReason3DTransform, | 1450 FloatPoint3D(100, 100, 0), false, 0, CompositingReason3DTransform, |
| 1690 expectedCompositorElementId); | 1451 expectedCompositorElementId); |
| 1691 | 1452 |
| 1692 TestPaintArtifact artifact; | 1453 TestPaintArtifact artifact; |
| 1693 artifact | 1454 artifact |
| 1694 .chunk(transform, ClipPaintPropertyNode::root(), | 1455 .chunk(transform, ClipPaintPropertyNode::root(), |
| 1695 EffectPaintPropertyNode::root()) | 1456 EffectPaintPropertyNode::root()) |
| 1696 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 1457 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 1697 update(artifact.build()); | 1458 update(artifact.build()); |
| 1698 | 1459 |
| 1699 EXPECT_EQ(2, elementIdToTransformNodeIndex(expectedCompositorElementId)); | 1460 EXPECT_EQ(2, elementIdToTransformNodeIndex(expectedCompositorElementId)); |
| 1700 } | 1461 } |
| 1701 | 1462 |
| 1702 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectWithElementId) { | 1463 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectWithElementId) { |
| 1703 CompositorElementId expectedCompositorElementId(2, 0); | 1464 CompositorElementId expectedCompositorElementId(2, 0); |
| 1704 float opacity = 2.0 / 255.0; | 1465 float opacity = 2.0 / 255.0; |
| 1705 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 1466 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
| 1706 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 1467 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), |
| 1707 ClipPaintPropertyNode::root(), ColorFilterNone, | 1468 ClipPaintPropertyNode::root(), ColorFilterNone, |
| 1708 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver, | 1469 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver, |
| 1709 CompositingReasonNone, expectedCompositorElementId); | 1470 CompositingReasonActiveAnimation, expectedCompositorElementId); |
| 1710 | 1471 |
| 1711 TestPaintArtifact artifact; | 1472 TestPaintArtifact artifact; |
| 1712 artifact | 1473 artifact |
| 1713 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1474 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1714 effect.get()) | 1475 effect.get()) |
| 1715 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); | 1476 .rectDrawing(FloatRect(100, 100, 200, 100), Color::black); |
| 1716 update(artifact.build()); | 1477 update(artifact.build()); |
| 1717 | 1478 |
| 1718 EXPECT_EQ(2, elementIdToEffectNodeIndex(expectedCompositorElementId)); | 1479 EXPECT_EQ(2, elementIdToEffectNodeIndex(expectedCompositorElementId)); |
| 1719 } | 1480 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1732 TestPaintArtifact artifact; | 1493 TestPaintArtifact artifact; |
| 1733 artifact | 1494 artifact |
| 1734 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1495 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1735 masked.get()) | 1496 masked.get()) |
| 1736 .rectDrawing(FloatRect(100, 100, 200, 200), Color::gray); | 1497 .rectDrawing(FloatRect(100, 100, 200, 200), Color::gray); |
| 1737 artifact | 1498 artifact |
| 1738 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 1499 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 1739 masking.get()) | 1500 masking.get()) |
| 1740 .rectDrawing(FloatRect(150, 150, 100, 100), Color::white); | 1501 .rectDrawing(FloatRect(150, 150, 100, 100), Color::white); |
| 1741 update(artifact.build()); | 1502 update(artifact.build()); |
| 1742 | |
| 1743 ASSERT_EQ(2u, contentLayerCount()); | 1503 ASSERT_EQ(2u, contentLayerCount()); |
| 1744 | 1504 |
| 1745 const cc::Layer* maskedLayer = contentLayerAt(0); | 1505 const cc::Layer* maskedLayer = contentLayerAt(0); |
| 1746 EXPECT_THAT(maskedLayer->GetPicture(), | 1506 EXPECT_THAT(maskedLayer->GetPicture(), |
| 1747 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::gray))); | 1507 Pointee(drawsRectangle(FloatRect(0, 0, 200, 200), Color::gray))); |
| 1748 EXPECT_EQ(translation(100, 100), maskedLayer->screen_space_transform()); | 1508 EXPECT_EQ(translation(100, 100), maskedLayer->screen_space_transform()); |
| 1749 EXPECT_EQ(gfx::Size(200, 200), maskedLayer->bounds()); | 1509 EXPECT_EQ(gfx::Size(200, 200), maskedLayer->bounds()); |
| 1750 const cc::EffectNode* maskedGroup = | 1510 const cc::EffectNode* maskedGroup = |
| 1751 propertyTrees().effect_tree.Node(maskedLayer->effect_tree_index()); | 1511 propertyTrees().effect_tree.Node(maskedLayer->effect_tree_index()); |
| 1752 EXPECT_TRUE(maskedGroup->has_render_surface); | 1512 EXPECT_TRUE(maskedGroup->has_render_surface); |
| 1753 | 1513 |
| 1754 const cc::Layer* maskingLayer = contentLayerAt(1); | 1514 const cc::Layer* maskingLayer = contentLayerAt(1); |
| 1755 EXPECT_THAT(maskingLayer->GetPicture(), | 1515 EXPECT_THAT(maskingLayer->GetPicture(), |
| 1756 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); | 1516 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| 1757 EXPECT_EQ(translation(150, 150), maskingLayer->screen_space_transform()); | 1517 EXPECT_EQ(translation(150, 150), maskingLayer->screen_space_transform()); |
| 1758 EXPECT_EQ(gfx::Size(100, 100), maskingLayer->bounds()); | 1518 EXPECT_EQ(gfx::Size(100, 100), maskingLayer->bounds()); |
| 1759 const cc::EffectNode* maskingGroup = | 1519 const cc::EffectNode* maskingGroup = |
| 1760 propertyTrees().effect_tree.Node(maskingLayer->effect_tree_index()); | 1520 propertyTrees().effect_tree.Node(maskingLayer->effect_tree_index()); |
| 1761 EXPECT_TRUE(maskingGroup->has_render_surface); | 1521 EXPECT_TRUE(maskingGroup->has_render_surface); |
| 1762 EXPECT_EQ(maskedGroup->id, maskingGroup->parent_id); | 1522 EXPECT_EQ(maskedGroup->id, maskingGroup->parent_id); |
| 1763 ASSERT_EQ(1u, maskingGroup->filters.size()); | 1523 ASSERT_EQ(1u, maskingGroup->filters.size()); |
| 1764 EXPECT_EQ(cc::FilterOperation::REFERENCE, maskingGroup->filters.at(0).type()); | 1524 EXPECT_EQ(cc::FilterOperation::REFERENCE, maskingGroup->filters.at(0).type()); |
| 1765 } | 1525 } |
| 1766 | 1526 |
| 1527 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DecompositeEffect) { | |
| 1528 // An effect node without direct compositing reason and does not need to | |
| 1529 // group compositing descendants should not be composited and can merge | |
| 1530 // with other chunks. | |
| 1531 | |
| 1532 RefPtr<EffectPaintPropertyNode> effect = | |
| 1533 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); | |
| 1534 | |
| 1535 TestPaintArtifact artifact; | |
| 1536 artifact | |
| 1537 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1538 EffectPaintPropertyNode::root()) | |
| 1539 .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray); | |
| 1540 artifact | |
| 1541 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1542 effect.get()) | |
| 1543 .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray); | |
| 1544 artifact | |
| 1545 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1546 EffectPaintPropertyNode::root()) | |
| 1547 .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray); | |
| 1548 update(artifact.build()); | |
| 1549 ASSERT_EQ(1u, contentLayerCount()); | |
| 1550 | |
| 1551 const cc::Layer* layer = contentLayerAt(0); | |
| 1552 EXPECT_EQ(gfx::Vector2dF(25.f, 25.f), layer->offset_to_transform_parent()); | |
| 1553 EXPECT_EQ(gfx::Size(150, 150), layer->bounds()); | |
| 1554 EXPECT_EQ(1, layer->effect_tree_index()); | |
| 1555 } | |
| 1556 | |
| 1557 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DirectlyCompositedEffect) { | |
| 1558 // An effect node with direct compositing shall be composited. | |
| 1559 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | |
| 1560 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | |
| 1561 ClipPaintPropertyNode::root(), ColorFilterNone, | |
| 1562 CompositorFilterOperations(), 0.5f, SkBlendMode::kSrcOver, | |
| 1563 CompositingReasonAll); | |
| 1564 | |
| 1565 TestPaintArtifact artifact; | |
| 1566 artifact | |
| 1567 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1568 EffectPaintPropertyNode::root()) | |
| 1569 .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray); | |
| 1570 artifact | |
| 1571 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1572 effect.get()) | |
| 1573 .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray); | |
| 1574 artifact | |
| 1575 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1576 EffectPaintPropertyNode::root()) | |
| 1577 .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray); | |
| 1578 update(artifact.build()); | |
| 1579 ASSERT_EQ(3u, contentLayerCount()); | |
| 1580 | |
| 1581 const cc::Layer* layer1 = contentLayerAt(0); | |
| 1582 EXPECT_EQ(gfx::Vector2dF(50.f, 25.f), layer1->offset_to_transform_parent()); | |
| 1583 EXPECT_EQ(gfx::Size(100, 100), layer1->bounds()); | |
| 1584 EXPECT_EQ(1, layer1->effect_tree_index()); | |
| 1585 | |
| 1586 const cc::Layer* layer2 = contentLayerAt(1); | |
| 1587 EXPECT_EQ(gfx::Vector2dF(25.f, 75.f), layer2->offset_to_transform_parent()); | |
| 1588 EXPECT_EQ(gfx::Size(100, 100), layer2->bounds()); | |
| 1589 const cc::EffectNode* effectNode = | |
| 1590 propertyTrees().effect_tree.Node(layer2->effect_tree_index()); | |
| 1591 EXPECT_EQ(1, effectNode->parent_id); | |
| 1592 EXPECT_EQ(0.5f, effectNode->opacity); | |
| 1593 | |
| 1594 const cc::Layer* layer3 = contentLayerAt(2); | |
| 1595 EXPECT_EQ(gfx::Vector2dF(75.f, 75.f), layer3->offset_to_transform_parent()); | |
| 1596 EXPECT_EQ(gfx::Size(100, 100), layer3->bounds()); | |
| 1597 EXPECT_EQ(1, layer3->effect_tree_index()); | |
| 1598 } | |
| 1599 | |
| 1600 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, DecompositeDeepEffect) { | |
| 1601 // A paint chunk may enter multiple level effects with or without compositing | |
| 1602 // reasons. This test verifies we still decomposite effects without a direct | |
| 1603 // reason, but stop at a directly composited effect. | |
| 1604 RefPtr<EffectPaintPropertyNode> effect1 = | |
| 1605 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.1f); | |
| 1606 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( | |
| 1607 effect1, TransformPaintPropertyNode::root(), | |
| 1608 ClipPaintPropertyNode::root(), ColorFilterNone, | |
| 1609 CompositorFilterOperations(), 0.2f, SkBlendMode::kSrcOver, | |
| 1610 CompositingReasonAll); | |
| 1611 RefPtr<EffectPaintPropertyNode> effect3 = | |
| 1612 createOpacityOnlyEffect(effect2, 0.3f); | |
| 1613 | |
| 1614 TestPaintArtifact artifact; | |
| 1615 artifact | |
| 1616 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1617 EffectPaintPropertyNode::root()) | |
| 1618 .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray); | |
| 1619 artifact | |
| 1620 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1621 effect3.get()) | |
| 1622 .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray); | |
| 1623 artifact | |
| 1624 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1625 EffectPaintPropertyNode::root()) | |
| 1626 .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray); | |
| 1627 update(artifact.build()); | |
| 1628 ASSERT_EQ(3u, contentLayerCount()); | |
| 1629 | |
| 1630 const cc::Layer* layer1 = contentLayerAt(0); | |
| 1631 EXPECT_EQ(gfx::Vector2dF(50.f, 25.f), layer1->offset_to_transform_parent()); | |
| 1632 EXPECT_EQ(gfx::Size(100, 100), layer1->bounds()); | |
| 1633 EXPECT_EQ(1, layer1->effect_tree_index()); | |
| 1634 | |
| 1635 const cc::Layer* layer2 = contentLayerAt(1); | |
| 1636 EXPECT_EQ(gfx::Vector2dF(25.f, 75.f), layer2->offset_to_transform_parent()); | |
| 1637 EXPECT_EQ(gfx::Size(100, 100), layer2->bounds()); | |
| 1638 const cc::EffectNode* effectNode2 = | |
| 1639 propertyTrees().effect_tree.Node(layer2->effect_tree_index()); | |
| 1640 EXPECT_EQ(0.2f, effectNode2->opacity); | |
| 1641 const cc::EffectNode* effectNode1 = | |
| 1642 propertyTrees().effect_tree.Node(effectNode2->parent_id); | |
| 1643 EXPECT_EQ(1, effectNode1->parent_id); | |
| 1644 EXPECT_EQ(0.1f, effectNode1->opacity); | |
| 1645 | |
| 1646 const cc::Layer* layer3 = contentLayerAt(2); | |
| 1647 EXPECT_EQ(gfx::Vector2dF(75.f, 75.f), layer3->offset_to_transform_parent()); | |
| 1648 EXPECT_EQ(gfx::Size(100, 100), layer3->bounds()); | |
| 1649 EXPECT_EQ(1, layer3->effect_tree_index()); | |
| 1650 } | |
| 1651 | |
| 1652 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, | |
| 1653 IndirectlyCompositedEffect) { | |
| 1654 // An effect node without direct compositing still needs to be composited | |
| 1655 // for grouping, if some chunks need to be composited. | |
| 1656 RefPtr<EffectPaintPropertyNode> effect = | |
| 1657 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5f); | |
| 1658 RefPtr<TransformPaintPropertyNode> transform = | |
| 1659 TransformPaintPropertyNode::create( | |
| 1660 TransformPaintPropertyNode::root(), TransformationMatrix(), | |
| 1661 FloatPoint3D(), false, 0, CompositingReason3DTransform); | |
| 1662 | |
| 1663 TestPaintArtifact artifact; | |
| 1664 artifact | |
| 1665 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1666 EffectPaintPropertyNode::root()) | |
| 1667 .rectDrawing(FloatRect(50, 25, 100, 100), Color::gray); | |
| 1668 artifact | |
| 1669 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | |
| 1670 effect.get()) | |
| 1671 .rectDrawing(FloatRect(25, 75, 100, 100), Color::gray); | |
| 1672 artifact.chunk(transform.get(), ClipPaintPropertyNode::root(), effect.get()) | |
| 1673 .rectDrawing(FloatRect(75, 75, 100, 100), Color::gray); | |
| 1674 update(artifact.build()); | |
| 1675 ASSERT_EQ(3u, contentLayerCount()); | |
| 1676 | |
| 1677 const cc::Layer* layer1 = contentLayerAt(0); | |
| 1678 EXPECT_EQ(gfx::Vector2dF(50.f, 25.f), layer1->offset_to_transform_parent()); | |
| 1679 EXPECT_EQ(gfx::Size(100, 100), layer1->bounds()); | |
| 1680 EXPECT_EQ(1, layer1->effect_tree_index()); | |
| 1681 | |
| 1682 const cc::Layer* layer2 = contentLayerAt(1); | |
| 1683 EXPECT_EQ(gfx::Vector2dF(25.f, 75.f), layer2->offset_to_transform_parent()); | |
| 1684 EXPECT_EQ(gfx::Size(100, 100), layer2->bounds()); | |
| 1685 const cc::EffectNode* effectNode = | |
| 1686 propertyTrees().effect_tree.Node(layer2->effect_tree_index()); | |
| 1687 EXPECT_EQ(1, effectNode->parent_id); | |
| 1688 EXPECT_EQ(0.5f, effectNode->opacity); | |
| 1689 | |
| 1690 const cc::Layer* layer3 = contentLayerAt(2); | |
| 1691 EXPECT_EQ(gfx::Vector2dF(75.f, 75.f), layer3->offset_to_transform_parent()); | |
| 1692 EXPECT_EQ(gfx::Size(100, 100), layer3->bounds()); | |
| 1693 EXPECT_EQ(effectNode->id, layer3->effect_tree_index()); | |
| 1694 } | |
| 1695 | |
| 1767 } // namespace blink | 1696 } // namespace blink |
| OLD | NEW |