| 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 "base/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "cc/test/fake_compositor_frame_sink.h" | 10 #include "cc/test/fake_compositor_frame_sink.h" |
| 11 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
| 12 #include "cc/trees/clip_node.h" | 12 #include "cc/trees/clip_node.h" |
| 13 #include "cc/trees/effect_node.h" | 13 #include "cc/trees/effect_node.h" |
| 14 #include "cc/trees/layer_tree_host.h" | 14 #include "cc/trees/layer_tree_host.h" |
| 15 #include "cc/trees/layer_tree_settings.h" | 15 #include "cc/trees/layer_tree_settings.h" |
| 16 #include "cc/trees/scroll_node.h" | 16 #include "cc/trees/scroll_node.h" |
| 17 #include "cc/trees/transform_node.h" | 17 #include "cc/trees/transform_node.h" |
| 18 #include "platform/RuntimeEnabledFeatures.h" | 18 #include "platform/RuntimeEnabledFeatures.h" |
| 19 #include "platform/graphics/paint/EffectPaintPropertyNode.h" | 19 #include "platform/graphics/paint/EffectPaintPropertyNode.h" |
| 20 #include "platform/graphics/paint/PaintArtifact.h" | 20 #include "platform/graphics/paint/PaintArtifact.h" |
| 21 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" | 21 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" |
| 22 #include "platform/testing/PaintPropertyTestHelpers.h" |
| 22 #include "platform/testing/PictureMatchers.h" | 23 #include "platform/testing/PictureMatchers.h" |
| 23 #include "platform/testing/TestPaintArtifact.h" | 24 #include "platform/testing/TestPaintArtifact.h" |
| 24 #include "platform/testing/WebLayerTreeViewImplForTesting.h" | 25 #include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include <memory> | 28 #include <memory> |
| 28 | 29 |
| 29 namespace blink { | 30 namespace blink { |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 33 using ::blink::testing::createOpacityOnlyEffect; |
| 32 using ::testing::Pointee; | 34 using ::testing::Pointee; |
| 33 | 35 |
| 34 PaintChunkProperties defaultPaintChunkProperties() { | 36 PaintChunkProperties defaultPaintChunkProperties() { |
| 35 PaintChunkProperties properties; | 37 PaintChunkProperties properties; |
| 36 properties.transform = TransformPaintPropertyNode::root(); | 38 properties.transform = TransformPaintPropertyNode::root(); |
| 37 properties.clip = ClipPaintPropertyNode::root(); | 39 properties.clip = ClipPaintPropertyNode::root(); |
| 38 properties.effect = EffectPaintPropertyNode::root(); | 40 properties.effect = EffectPaintPropertyNode::root(); |
| 39 properties.scroll = ScrollPaintPropertyNode::root(); | 41 properties.scroll = ScrollPaintPropertyNode::root(); |
| 40 return properties; | 42 return properties; |
| 41 } | 43 } |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); | 564 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); |
| 563 update(artifact.build()); | 565 update(artifact.build()); |
| 564 | 566 |
| 565 ASSERT_EQ(1u, contentLayerCount()); | 567 ASSERT_EQ(1u, contentLayerCount()); |
| 566 EXPECT_EQ(layer, contentLayerAt(0)); | 568 EXPECT_EQ(layer, contentLayerAt(0)); |
| 567 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); | 569 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); |
| 568 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 570 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
| 569 } | 571 } |
| 570 | 572 |
| 571 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { | 573 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { |
| 572 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( | 574 RefPtr<EffectPaintPropertyNode> effect1 = |
| 573 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 575 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); |
| 574 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); | 576 RefPtr<EffectPaintPropertyNode> effect2 = |
| 575 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( | 577 createOpacityOnlyEffect(effect1, 0.3); |
| 576 effect1, TransformPaintPropertyNode::root(), | 578 RefPtr<EffectPaintPropertyNode> effect3 = |
| 577 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.3); | 579 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.2); |
| 578 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create( | |
| 579 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | |
| 580 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.2); | |
| 581 | 580 |
| 582 TestPaintArtifact artifact; | 581 TestPaintArtifact artifact; |
| 583 artifact | 582 artifact |
| 584 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 583 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 585 effect2.get()) | 584 effect2.get()) |
| 586 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 585 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 587 artifact | 586 artifact |
| 588 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), | 587 .chunk(TransformPaintPropertyNode::root(), ClipPaintPropertyNode::root(), |
| 589 effect1.get()) | 588 effect1.get()) |
| 590 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 589 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 EXPECT_TRUE(transformNode.local.IsIdentity()); | 653 EXPECT_TRUE(transformNode.local.IsIdentity()); |
| 655 | 654 |
| 656 EXPECT_EQ(gfx::ScrollOffset(-7, -9), | 655 EXPECT_EQ(gfx::ScrollOffset(-7, -9), |
| 657 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); | 656 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); |
| 658 | 657 |
| 659 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 658 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 660 scrollNode.main_thread_scrolling_reasons); | 659 scrollNode.main_thread_scrolling_reasons); |
| 661 } | 660 } |
| 662 | 661 |
| 663 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 662 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
| 664 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( | 663 RefPtr<EffectPaintPropertyNode> effect = |
| 665 EffectPaintPropertyNode::root(), TransformPaintPropertyNode::root(), | 664 createOpacityOnlyEffect(EffectPaintPropertyNode::root(), 0.5); |
| 666 ClipPaintPropertyNode::root(), CompositorFilterOperations(), 0.5); | |
| 667 | 665 |
| 668 RefPtr<TransformPaintPropertyNode> scrollTranslationA = | 666 RefPtr<TransformPaintPropertyNode> scrollTranslationA = |
| 669 TransformPaintPropertyNode::create( | 667 TransformPaintPropertyNode::create( |
| 670 TransformPaintPropertyNode::root(), | 668 TransformPaintPropertyNode::root(), |
| 671 TransformationMatrix().translate(11, 13), FloatPoint3D()); | 669 TransformationMatrix().translate(11, 13), FloatPoint3D()); |
| 672 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( | 670 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( |
| 673 ScrollPaintPropertyNode::root(), scrollTranslationA, IntSize(2, 3), | 671 ScrollPaintPropertyNode::root(), scrollTranslationA, IntSize(2, 3), |
| 674 IntSize(5, 7), false, true, | 672 IntSize(5, 7), false, true, |
| 675 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 673 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 676 RefPtr<TransformPaintPropertyNode> scrollTranslationB = | 674 RefPtr<TransformPaintPropertyNode> scrollTranslationB = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); | 717 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); |
| 720 | 718 |
| 721 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & | 719 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & |
| 722 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 720 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 723 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & | 721 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & |
| 724 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 722 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 725 } | 723 } |
| 726 | 724 |
| 727 } // namespace | 725 } // namespace |
| 728 } // namespace blink | 726 } // namespace blink |
| OLD | NEW |