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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 last_scroll_offset = scroll_offset; | 707 last_scroll_offset = scroll_offset; |
708 }; | 708 }; |
709 | 709 |
710 gfx::ScrollOffset last_scroll_offset; | 710 gfx::ScrollOffset last_scroll_offset; |
711 unsigned did_scroll_count; | 711 unsigned did_scroll_count; |
712 }; | 712 }; |
713 | 713 |
714 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { | 714 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneScrollNode) { |
715 FakeScrollClient scroll_client; | 715 FakeScrollClient scroll_client; |
716 | 716 |
717 CompositorElementId expected_compositor_element_id = | 717 CompositorElementId expected_compositor_element_id; |
718 CompositorElementId(2, 0); | 718 expected_compositor_element_id.id = 2; |
719 RefPtr<TransformPaintPropertyNode> scroll_translation = | 719 RefPtr<TransformPaintPropertyNode> scroll_translation = |
720 TransformPaintPropertyNode::CreateScrollTranslation( | 720 TransformPaintPropertyNode::CreateScrollTranslation( |
721 TransformPaintPropertyNode::Root(), | 721 TransformPaintPropertyNode::Root(), |
722 TransformationMatrix().Translate(7, 9), FloatPoint3D(), false, 0, | 722 TransformationMatrix().Translate(7, 9), FloatPoint3D(), false, 0, |
723 kCompositingReasonNone, expected_compositor_element_id, | 723 kCompositingReasonNone, expected_compositor_element_id, |
724 ScrollPaintPropertyNode::Root(), IntSize(11, 13), IntSize(27, 31), | 724 ScrollPaintPropertyNode::Root(), IntSize(11, 13), IntSize(27, 31), |
725 true, false, 0 /* mainThreadScrollingReasons */, &scroll_client); | 725 true, false, 0 /* mainThreadScrollingReasons */, &scroll_client); |
726 | 726 |
727 TestPaintArtifact artifact; | 727 TestPaintArtifact artifact; |
728 artifact | 728 artifact |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 EXPECT_EQ(scroll_transform_node.id, | 816 EXPECT_EQ(scroll_transform_node.id, |
817 ContentLayerAt(0)->transform_tree_index()); | 817 ContentLayerAt(0)->transform_tree_index()); |
818 EXPECT_NE(scroll_transform_node.id, | 818 EXPECT_NE(scroll_transform_node.id, |
819 ContentLayerAt(1)->transform_tree_index()); | 819 ContentLayerAt(1)->transform_tree_index()); |
820 } | 820 } |
821 | 821 |
822 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 822 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
823 RefPtr<EffectPaintPropertyNode> effect = | 823 RefPtr<EffectPaintPropertyNode> effect = |
824 CreateOpacityOnlyEffect(EffectPaintPropertyNode::Root(), 0.5); | 824 CreateOpacityOnlyEffect(EffectPaintPropertyNode::Root(), 0.5); |
825 | 825 |
826 CompositorElementId expected_compositor_element_id_a = | 826 CompositorElementId expected_compositor_element_id_a; |
827 CompositorElementId(2, 0); | 827 expected_compositor_element_id_a.id = 2; |
828 RefPtr<TransformPaintPropertyNode> scroll_translation_a = | 828 RefPtr<TransformPaintPropertyNode> scroll_translation_a = |
829 TransformPaintPropertyNode::CreateScrollTranslation( | 829 TransformPaintPropertyNode::CreateScrollTranslation( |
830 TransformPaintPropertyNode::Root(), | 830 TransformPaintPropertyNode::Root(), |
831 TransformationMatrix().Translate(11, 13), FloatPoint3D(), false, 0, | 831 TransformationMatrix().Translate(11, 13), FloatPoint3D(), false, 0, |
832 kCompositingReasonLayerForScrollingContents, | 832 kCompositingReasonLayerForScrollingContents, |
833 expected_compositor_element_id_a, ScrollPaintPropertyNode::Root(), | 833 expected_compositor_element_id_a, ScrollPaintPropertyNode::Root(), |
834 IntSize(2, 3), IntSize(5, 7), false, true, | 834 IntSize(2, 3), IntSize(5, 7), false, true, |
835 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 835 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
836 nullptr); | 836 nullptr); |
837 | 837 |
838 CompositorElementId expected_compositor_element_id_b = | 838 CompositorElementId expected_compositor_element_id_b; |
839 CompositorElementId(3, 0); | 839 expected_compositor_element_id_b.id = 3; |
840 RefPtr<TransformPaintPropertyNode> scroll_translation_b = | 840 RefPtr<TransformPaintPropertyNode> scroll_translation_b = |
841 TransformPaintPropertyNode::CreateScrollTranslation( | 841 TransformPaintPropertyNode::CreateScrollTranslation( |
842 scroll_translation_a, TransformationMatrix().Translate(37, 41), | 842 scroll_translation_a, TransformationMatrix().Translate(37, 41), |
843 FloatPoint3D(), false, 0, kCompositingReasonNone, | 843 FloatPoint3D(), false, 0, kCompositingReasonNone, |
844 expected_compositor_element_id_b, scroll_translation_a->ScrollNode(), | 844 expected_compositor_element_id_b, scroll_translation_a->ScrollNode(), |
845 IntSize(19, 23), IntSize(29, 31), true, false, | 845 IntSize(19, 23), IntSize(29, 31), true, false, |
846 0 /* mainThreadScrollingReasons */, nullptr); | 846 0 /* mainThreadScrollingReasons */, nullptr); |
847 TestPaintArtifact artifact; | 847 TestPaintArtifact artifact; |
848 artifact.Chunk(scroll_translation_a, ClipPaintPropertyNode::Root(), effect) | 848 artifact.Chunk(scroll_translation_a, ClipPaintPropertyNode::Root(), effect) |
849 .RectDrawing(FloatRect(7, 11, 13, 17), Color::kWhite); | 849 .RectDrawing(FloatRect(7, 11, 13, 17), Color::kWhite); |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 chunk3.properties.property_tree_state = chunk1.properties.property_tree_state; | 1637 chunk3.properties.property_tree_state = chunk1.properties.property_tree_state; |
1638 chunk3.bounds = FloatRect(0, 0, 50, 60); | 1638 chunk3.bounds = FloatRect(0, 0, 50, 60); |
1639 chunk3.known_to_be_opaque = true; | 1639 chunk3.known_to_be_opaque = true; |
1640 pending_layer.Merge(PaintArtifactCompositor::PendingLayer(chunk3, false)); | 1640 pending_layer.Merge(PaintArtifactCompositor::PendingLayer(chunk3, false)); |
1641 | 1641 |
1642 // Chunk 3 covers the entire layer, so now it's opaque. | 1642 // Chunk 3 covers the entire layer, so now it's opaque. |
1643 EXPECT_TRUE(pending_layer.known_to_be_opaque); | 1643 EXPECT_TRUE(pending_layer.known_to_be_opaque); |
1644 } | 1644 } |
1645 | 1645 |
1646 PassRefPtr<EffectPaintPropertyNode> CreateSampleEffectNodeWithElementId() { | 1646 PassRefPtr<EffectPaintPropertyNode> CreateSampleEffectNodeWithElementId() { |
1647 CompositorElementId expected_compositor_element_id(2, 0); | 1647 CompositorElementId expected_compositor_element_id; |
| 1648 expected_compositor_element_id.id = 2; |
1648 float opacity = 2.0 / 255.0; | 1649 float opacity = 2.0 / 255.0; |
1649 return EffectPaintPropertyNode::Create( | 1650 return EffectPaintPropertyNode::Create( |
1650 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 1651 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
1651 ClipPaintPropertyNode::Root(), kColorFilterNone, | 1652 ClipPaintPropertyNode::Root(), kColorFilterNone, |
1652 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver, | 1653 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver, |
1653 kCompositingReasonActiveAnimation, expected_compositor_element_id); | 1654 kCompositingReasonActiveAnimation, expected_compositor_element_id); |
1654 } | 1655 } |
1655 | 1656 |
1656 PassRefPtr<TransformPaintPropertyNode> | 1657 PassRefPtr<TransformPaintPropertyNode> |
1657 CreateSampleTransformNodeWithElementId() { | 1658 CreateSampleTransformNodeWithElementId() { |
1658 CompositorElementId expected_compositor_element_id(3, 0); | 1659 CompositorElementId expected_compositor_element_id; |
| 1660 expected_compositor_element_id.id = 3; |
1659 return TransformPaintPropertyNode::Create( | 1661 return TransformPaintPropertyNode::Create( |
1660 TransformPaintPropertyNode::Root(), TransformationMatrix().Rotate(90), | 1662 TransformPaintPropertyNode::Root(), TransformationMatrix().Rotate(90), |
1661 FloatPoint3D(100, 100, 0), false, 0, kCompositingReason3DTransform, | 1663 FloatPoint3D(100, 100, 0), false, 0, kCompositingReason3DTransform, |
1662 expected_compositor_element_id); | 1664 expected_compositor_element_id); |
1663 } | 1665 } |
1664 | 1666 |
1665 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { | 1667 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { |
1666 RefPtr<TransformPaintPropertyNode> transform = | 1668 RefPtr<TransformPaintPropertyNode> transform = |
1667 CreateSampleTransformNodeWithElementId(); | 1669 CreateSampleTransformNodeWithElementId(); |
1668 TestPaintArtifact artifact; | 1670 TestPaintArtifact artifact; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack) | 2089 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack) |
2088 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), | 2090 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), |
2089 effect.Get()) | 2091 effect.Get()) |
2090 .RectDrawing(FloatRect(100, 100, 200, 100), Color::kBlack); | 2092 .RectDrawing(FloatRect(100, 100, 200, 100), Color::kBlack); |
2091 | 2093 |
2092 CompositorElementIdSet composited_element_ids; | 2094 CompositorElementIdSet composited_element_ids; |
2093 Update(artifact.Build(), composited_element_ids); | 2095 Update(artifact.Build(), composited_element_ids); |
2094 | 2096 |
2095 EXPECT_EQ(2u, composited_element_ids.size()); | 2097 EXPECT_EQ(2u, composited_element_ids.size()); |
2096 EXPECT_TRUE( | 2098 EXPECT_TRUE( |
2097 composited_element_ids.Contains(transform->GetCompositorElementId())); | 2099 composited_element_ids.Contains(transform->GetCompositorElementId().id)); |
2098 EXPECT_TRUE( | 2100 EXPECT_TRUE( |
2099 composited_element_ids.Contains(effect->GetCompositorElementId())); | 2101 composited_element_ids.Contains(effect->GetCompositorElementId().id)); |
2100 } | 2102 } |
2101 | 2103 |
2102 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SkipChunkWithOpacityZero) { | 2104 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SkipChunkWithOpacityZero) { |
2103 { | 2105 { |
2104 TestPaintArtifact artifact; | 2106 TestPaintArtifact artifact; |
2105 CreateSimpleArtifactWithOpacity(artifact, 0, false, false); | 2107 CreateSimpleArtifactWithOpacity(artifact, 0, false, false); |
2106 ASSERT_EQ(0u, ContentLayerCount()); | 2108 ASSERT_EQ(0u, ContentLayerCount()); |
2107 } | 2109 } |
2108 { | 2110 { |
2109 TestPaintArtifact artifact; | 2111 TestPaintArtifact artifact; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 TestPaintArtifact artifact; | 2262 TestPaintArtifact artifact; |
2261 artifact | 2263 artifact |
2262 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), | 2264 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), |
2263 visibleEffect) | 2265 visibleEffect) |
2264 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack); | 2266 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack); |
2265 Update(artifact.Build()); | 2267 Update(artifact.Build()); |
2266 ASSERT_EQ(0u, ContentLayerCount()); | 2268 ASSERT_EQ(0u, ContentLayerCount()); |
2267 } | 2269 } |
2268 | 2270 |
2269 } // namespace blink | 2271 } // namespace blink |
OLD | NEW |