| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 using ::testing::Pointee; | 32 using ::testing::Pointee; |
| 33 | 33 |
| 34 gfx::Transform translation(SkMScalar x, SkMScalar y) { | 34 gfx::Transform translation(SkMScalar x, SkMScalar y) { |
| 35 gfx::Transform transform; | 35 gfx::Transform transform; |
| 36 transform.Translate(x, y); | 36 transform.Translate(x, y); |
| 37 return transform; | 37 return transform; |
| 38 } | 38 } |
| 39 | 39 |
| 40 TransformPaintPropertyNode* dummyRootTransform() { |
| 41 DEFINE_STATIC_REF(TransformPaintPropertyNode, rootTransform, |
| 42 (TransformPaintPropertyNode::create( |
| 43 nullptr, TransformationMatrix(), FloatPoint3D()))); |
| 44 return rootTransform; |
| 45 } |
| 46 |
| 47 ClipPaintPropertyNode* dummyRootClip() { |
| 48 DEFINE_STATIC_REF(ClipPaintPropertyNode, rootClip, |
| 49 (ClipPaintPropertyNode::create( |
| 50 nullptr, dummyRootTransform(), |
| 51 FloatRoundedRect(LayoutRect::infiniteIntRect())))); |
| 52 return rootClip; |
| 53 } |
| 54 |
| 40 EffectPaintPropertyNode* dummyRootEffect() { | 55 EffectPaintPropertyNode* dummyRootEffect() { |
| 41 DEFINE_STATIC_REF(EffectPaintPropertyNode, node, | 56 DEFINE_STATIC_REF(EffectPaintPropertyNode, rootEffect, |
| 42 EffectPaintPropertyNode::create(nullptr, 1.0)); | 57 (EffectPaintPropertyNode::create( |
| 43 return node; | 58 nullptr, dummyRootTransform(), dummyRootClip(), |
| 59 CompositorFilterOperations(), 1.0))); |
| 60 return rootEffect; |
| 44 } | 61 } |
| 45 | 62 |
| 46 class WebLayerTreeViewWithCompositorFrameSink | 63 class WebLayerTreeViewWithCompositorFrameSink |
| 47 : public WebLayerTreeViewImplForTesting { | 64 : public WebLayerTreeViewImplForTesting { |
| 48 public: | 65 public: |
| 49 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) | 66 WebLayerTreeViewWithCompositorFrameSink(const cc::LayerTreeSettings& settings) |
| 50 : WebLayerTreeViewImplForTesting(settings) {} | 67 : WebLayerTreeViewImplForTesting(settings) {} |
| 51 | 68 |
| 52 // cc::LayerTreeHostClient | 69 // cc::LayerTreeHostClient |
| 53 void RequestNewCompositorFrameSink() override { | 70 void RequestNewCompositorFrameSink() override { |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); | 529 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); |
| 513 update(artifact.build()); | 530 update(artifact.build()); |
| 514 | 531 |
| 515 ASSERT_EQ(1u, contentLayerCount()); | 532 ASSERT_EQ(1u, contentLayerCount()); |
| 516 EXPECT_EQ(layer, contentLayerAt(0)); | 533 EXPECT_EQ(layer, contentLayerAt(0)); |
| 517 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); | 534 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); |
| 518 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 535 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
| 519 } | 536 } |
| 520 | 537 |
| 521 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { | 538 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { |
| 522 RefPtr<EffectPaintPropertyNode> effect1 = | 539 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( |
| 523 EffectPaintPropertyNode::create(dummyRootEffect(), 0.5); | 540 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 524 RefPtr<EffectPaintPropertyNode> effect2 = | 541 CompositorFilterOperations(), 0.5); |
| 525 EffectPaintPropertyNode::create(effect1, 0.3); | 542 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( |
| 526 RefPtr<EffectPaintPropertyNode> effect3 = | 543 effect1, dummyRootTransform(), dummyRootClip(), |
| 527 EffectPaintPropertyNode::create(dummyRootEffect(), 0.2); | 544 CompositorFilterOperations(), 0.3); |
| 545 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create( |
| 546 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 547 CompositorFilterOperations(), 0.2); |
| 528 | 548 |
| 529 TestPaintArtifact artifact; | 549 TestPaintArtifact artifact; |
| 530 artifact.chunk(nullptr, nullptr, effect2.get()) | 550 artifact.chunk(nullptr, nullptr, effect2.get()) |
| 531 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 551 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 532 artifact.chunk(nullptr, nullptr, effect1.get()) | 552 artifact.chunk(nullptr, nullptr, effect1.get()) |
| 533 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 553 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 534 artifact.chunk(nullptr, nullptr, effect3.get()) | 554 artifact.chunk(nullptr, nullptr, effect3.get()) |
| 535 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 555 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
| 536 update(artifact.build()); | 556 update(artifact.build()); |
| 537 | 557 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 EXPECT_TRUE(transformNode.local.IsIdentity()); | 611 EXPECT_TRUE(transformNode.local.IsIdentity()); |
| 592 | 612 |
| 593 EXPECT_EQ(gfx::ScrollOffset(-7, -9), | 613 EXPECT_EQ(gfx::ScrollOffset(-7, -9), |
| 594 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); | 614 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); |
| 595 | 615 |
| 596 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 616 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
| 597 scrollNode.main_thread_scrolling_reasons); | 617 scrollNode.main_thread_scrolling_reasons); |
| 598 } | 618 } |
| 599 | 619 |
| 600 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 620 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
| 601 RefPtr<EffectPaintPropertyNode> effect = | 621 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
| 602 EffectPaintPropertyNode::create(dummyRootEffect(), 0.5); | 622 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 623 CompositorFilterOperations(), 0.5); |
| 603 | 624 |
| 604 RefPtr<TransformPaintPropertyNode> scrollTranslationA = | 625 RefPtr<TransformPaintPropertyNode> scrollTranslationA = |
| 605 TransformPaintPropertyNode::create( | 626 TransformPaintPropertyNode::create( |
| 606 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D()); | 627 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D()); |
| 607 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( | 628 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( |
| 608 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true); | 629 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true); |
| 609 scrollA->addMainThreadScrollingReasons( | 630 scrollA->addMainThreadScrollingReasons( |
| 610 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 631 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 611 RefPtr<TransformPaintPropertyNode> scrollTranslationB = | 632 RefPtr<TransformPaintPropertyNode> scrollTranslationB = |
| 612 TransformPaintPropertyNode::create( | 633 TransformPaintPropertyNode::create( |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); | 673 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); |
| 653 | 674 |
| 654 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & | 675 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & |
| 655 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 676 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 656 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & | 677 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & |
| 657 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 678 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
| 658 } | 679 } |
| 659 | 680 |
| 660 } // namespace | 681 } // namespace |
| 661 } // namespace blink | 682 } // namespace blink |
| OLD | NEW |