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 = CompositorElementId(2); |
718 CompositorElementId(2, 0); | |
719 RefPtr<TransformPaintPropertyNode> scroll_translation = | 718 RefPtr<TransformPaintPropertyNode> scroll_translation = |
720 TransformPaintPropertyNode::CreateScrollTranslation( | 719 TransformPaintPropertyNode::CreateScrollTranslation( |
721 TransformPaintPropertyNode::Root(), | 720 TransformPaintPropertyNode::Root(), |
722 TransformationMatrix().Translate(7, 9), FloatPoint3D(), false, 0, | 721 TransformationMatrix().Translate(7, 9), FloatPoint3D(), false, 0, |
723 kCompositingReasonNone, expected_compositor_element_id, | 722 kCompositingReasonNone, expected_compositor_element_id, |
724 ScrollPaintPropertyNode::Root(), IntSize(11, 13), IntSize(27, 31), | 723 ScrollPaintPropertyNode::Root(), IntSize(11, 13), IntSize(27, 31), |
725 true, false, 0 /* mainThreadScrollingReasons */, &scroll_client); | 724 true, false, 0 /* mainThreadScrollingReasons */, &scroll_client); |
726 | 725 |
727 TestPaintArtifact artifact; | 726 TestPaintArtifact artifact; |
728 artifact | 727 artifact |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 EXPECT_EQ(scroll_transform_node.id, | 815 EXPECT_EQ(scroll_transform_node.id, |
817 ContentLayerAt(0)->transform_tree_index()); | 816 ContentLayerAt(0)->transform_tree_index()); |
818 EXPECT_NE(scroll_transform_node.id, | 817 EXPECT_NE(scroll_transform_node.id, |
819 ContentLayerAt(1)->transform_tree_index()); | 818 ContentLayerAt(1)->transform_tree_index()); |
820 } | 819 } |
821 | 820 |
822 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 821 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
823 RefPtr<EffectPaintPropertyNode> effect = | 822 RefPtr<EffectPaintPropertyNode> effect = |
824 CreateOpacityOnlyEffect(EffectPaintPropertyNode::Root(), 0.5); | 823 CreateOpacityOnlyEffect(EffectPaintPropertyNode::Root(), 0.5); |
825 | 824 |
826 CompositorElementId expected_compositor_element_id_a = | 825 CompositorElementId expected_compositor_element_id_a = CompositorElementId(2); |
827 CompositorElementId(2, 0); | |
828 RefPtr<TransformPaintPropertyNode> scroll_translation_a = | 826 RefPtr<TransformPaintPropertyNode> scroll_translation_a = |
829 TransformPaintPropertyNode::CreateScrollTranslation( | 827 TransformPaintPropertyNode::CreateScrollTranslation( |
830 TransformPaintPropertyNode::Root(), | 828 TransformPaintPropertyNode::Root(), |
831 TransformationMatrix().Translate(11, 13), FloatPoint3D(), false, 0, | 829 TransformationMatrix().Translate(11, 13), FloatPoint3D(), false, 0, |
832 kCompositingReasonLayerForScrollingContents, | 830 kCompositingReasonLayerForScrollingContents, |
833 expected_compositor_element_id_a, ScrollPaintPropertyNode::Root(), | 831 expected_compositor_element_id_a, ScrollPaintPropertyNode::Root(), |
834 IntSize(2, 3), IntSize(5, 7), false, true, | 832 IntSize(2, 3), IntSize(5, 7), false, true, |
835 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, | 833 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects, |
836 nullptr); | 834 nullptr); |
837 | 835 |
838 CompositorElementId expected_compositor_element_id_b = | 836 CompositorElementId expected_compositor_element_id_b = CompositorElementId(3); |
839 CompositorElementId(3, 0); | |
840 RefPtr<TransformPaintPropertyNode> scroll_translation_b = | 837 RefPtr<TransformPaintPropertyNode> scroll_translation_b = |
841 TransformPaintPropertyNode::CreateScrollTranslation( | 838 TransformPaintPropertyNode::CreateScrollTranslation( |
842 scroll_translation_a, TransformationMatrix().Translate(37, 41), | 839 scroll_translation_a, TransformationMatrix().Translate(37, 41), |
843 FloatPoint3D(), false, 0, kCompositingReasonNone, | 840 FloatPoint3D(), false, 0, kCompositingReasonNone, |
844 expected_compositor_element_id_b, scroll_translation_a->ScrollNode(), | 841 expected_compositor_element_id_b, scroll_translation_a->ScrollNode(), |
845 IntSize(19, 23), IntSize(29, 31), true, false, | 842 IntSize(19, 23), IntSize(29, 31), true, false, |
846 0 /* mainThreadScrollingReasons */, nullptr); | 843 0 /* mainThreadScrollingReasons */, nullptr); |
847 TestPaintArtifact artifact; | 844 TestPaintArtifact artifact; |
848 artifact.Chunk(scroll_translation_a, ClipPaintPropertyNode::Root(), effect) | 845 artifact.Chunk(scroll_translation_a, ClipPaintPropertyNode::Root(), effect) |
849 .RectDrawing(FloatRect(7, 11, 13, 17), Color::kWhite); | 846 .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; | 1634 chunk3.properties.property_tree_state = chunk1.properties.property_tree_state; |
1638 chunk3.bounds = FloatRect(0, 0, 50, 60); | 1635 chunk3.bounds = FloatRect(0, 0, 50, 60); |
1639 chunk3.known_to_be_opaque = true; | 1636 chunk3.known_to_be_opaque = true; |
1640 pending_layer.Merge(PaintArtifactCompositor::PendingLayer(chunk3, false)); | 1637 pending_layer.Merge(PaintArtifactCompositor::PendingLayer(chunk3, false)); |
1641 | 1638 |
1642 // Chunk 3 covers the entire layer, so now it's opaque. | 1639 // Chunk 3 covers the entire layer, so now it's opaque. |
1643 EXPECT_TRUE(pending_layer.known_to_be_opaque); | 1640 EXPECT_TRUE(pending_layer.known_to_be_opaque); |
1644 } | 1641 } |
1645 | 1642 |
1646 PassRefPtr<EffectPaintPropertyNode> CreateSampleEffectNodeWithElementId() { | 1643 PassRefPtr<EffectPaintPropertyNode> CreateSampleEffectNodeWithElementId() { |
1647 CompositorElementId expected_compositor_element_id(2, 0); | 1644 CompositorElementId expected_compositor_element_id(2); |
1648 float opacity = 2.0 / 255.0; | 1645 float opacity = 2.0 / 255.0; |
1649 return EffectPaintPropertyNode::Create( | 1646 return EffectPaintPropertyNode::Create( |
1650 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), | 1647 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), |
1651 ClipPaintPropertyNode::Root(), kColorFilterNone, | 1648 ClipPaintPropertyNode::Root(), kColorFilterNone, |
1652 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver, | 1649 CompositorFilterOperations(), opacity, SkBlendMode::kSrcOver, |
1653 kCompositingReasonActiveAnimation, expected_compositor_element_id); | 1650 kCompositingReasonActiveAnimation, expected_compositor_element_id); |
1654 } | 1651 } |
1655 | 1652 |
1656 PassRefPtr<TransformPaintPropertyNode> | 1653 PassRefPtr<TransformPaintPropertyNode> |
1657 CreateSampleTransformNodeWithElementId() { | 1654 CreateSampleTransformNodeWithElementId() { |
1658 CompositorElementId expected_compositor_element_id(3, 0); | 1655 CompositorElementId expected_compositor_element_id(3); |
1659 return TransformPaintPropertyNode::Create( | 1656 return TransformPaintPropertyNode::Create( |
1660 TransformPaintPropertyNode::Root(), TransformationMatrix().Rotate(90), | 1657 TransformPaintPropertyNode::Root(), TransformationMatrix().Rotate(90), |
1661 FloatPoint3D(100, 100, 0), false, 0, kCompositingReason3DTransform, | 1658 FloatPoint3D(100, 100, 0), false, 0, kCompositingReason3DTransform, |
1662 expected_compositor_element_id); | 1659 expected_compositor_element_id); |
1663 } | 1660 } |
1664 | 1661 |
1665 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { | 1662 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformWithElementId) { |
1666 RefPtr<TransformPaintPropertyNode> transform = | 1663 RefPtr<TransformPaintPropertyNode> transform = |
1667 CreateSampleTransformNodeWithElementId(); | 1664 CreateSampleTransformNodeWithElementId(); |
1668 TestPaintArtifact artifact; | 1665 TestPaintArtifact artifact; |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2260 TestPaintArtifact artifact; | 2257 TestPaintArtifact artifact; |
2261 artifact | 2258 artifact |
2262 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), | 2259 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), |
2263 visibleEffect) | 2260 visibleEffect) |
2264 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack); | 2261 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kBlack); |
2265 Update(artifact.Build()); | 2262 Update(artifact.Build()); |
2266 ASSERT_EQ(0u, ContentLayerCount()); | 2263 ASSERT_EQ(0u, ContentLayerCount()); |
2267 } | 2264 } |
2268 | 2265 |
2269 } // namespace blink | 2266 } // namespace blink |
OLD | NEW |