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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); | 530 .foreignLayer(FloatPoint(50, 100), IntSize(400, 300), layer); |
514 update(artifact.build()); | 531 update(artifact.build()); |
515 | 532 |
516 ASSERT_EQ(1u, contentLayerCount()); | 533 ASSERT_EQ(1u, contentLayerCount()); |
517 EXPECT_EQ(layer, contentLayerAt(0)); | 534 EXPECT_EQ(layer, contentLayerAt(0)); |
518 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); | 535 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); |
519 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); | 536 EXPECT_EQ(translation(50, 100), layer->screen_space_transform()); |
520 } | 537 } |
521 | 538 |
522 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { | 539 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { |
523 RefPtr<EffectPaintPropertyNode> effect1 = | 540 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::create( |
524 EffectPaintPropertyNode::create(dummyRootEffect(), 0.5); | 541 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
525 RefPtr<EffectPaintPropertyNode> effect2 = | 542 CompositorFilterOperations(), 0.5); |
526 EffectPaintPropertyNode::create(effect1, 0.3); | 543 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::create( |
527 RefPtr<EffectPaintPropertyNode> effect3 = | 544 effect1, dummyRootTransform(), dummyRootClip(), |
528 EffectPaintPropertyNode::create(dummyRootEffect(), 0.2); | 545 CompositorFilterOperations(), 0.3); |
| 546 RefPtr<EffectPaintPropertyNode> effect3 = EffectPaintPropertyNode::create( |
| 547 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 548 CompositorFilterOperations(), 0.2); |
529 | 549 |
530 TestPaintArtifact artifact; | 550 TestPaintArtifact artifact; |
531 artifact.chunk(nullptr, nullptr, effect2.get()) | 551 artifact.chunk(nullptr, nullptr, effect2.get()) |
532 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 552 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
533 artifact.chunk(nullptr, nullptr, effect1.get()) | 553 artifact.chunk(nullptr, nullptr, effect1.get()) |
534 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 554 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
535 artifact.chunk(nullptr, nullptr, effect3.get()) | 555 artifact.chunk(nullptr, nullptr, effect3.get()) |
536 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); | 556 .rectDrawing(FloatRect(0, 0, 100, 100), Color::white); |
537 update(artifact.build()); | 557 update(artifact.build()); |
538 | 558 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 EXPECT_TRUE(transformNode.local.IsIdentity()); | 612 EXPECT_TRUE(transformNode.local.IsIdentity()); |
593 | 613 |
594 EXPECT_EQ(gfx::ScrollOffset(-7, -9), | 614 EXPECT_EQ(gfx::ScrollOffset(-7, -9), |
595 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); | 615 scrollTree.current_scroll_offset(contentLayerAt(0)->id())); |
596 | 616 |
597 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, | 617 EXPECT_EQ(MainThreadScrollingReason::kNotScrollingOnMain, |
598 scrollNode.main_thread_scrolling_reasons); | 618 scrollNode.main_thread_scrolling_reasons); |
599 } | 619 } |
600 | 620 |
601 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { | 621 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedScrollNodes) { |
602 RefPtr<EffectPaintPropertyNode> effect = | 622 RefPtr<EffectPaintPropertyNode> effect = EffectPaintPropertyNode::create( |
603 EffectPaintPropertyNode::create(dummyRootEffect(), 0.5); | 623 dummyRootEffect(), dummyRootTransform(), dummyRootClip(), |
| 624 CompositorFilterOperations(), 0.5); |
604 | 625 |
605 RefPtr<TransformPaintPropertyNode> scrollTranslationA = | 626 RefPtr<TransformPaintPropertyNode> scrollTranslationA = |
606 TransformPaintPropertyNode::create( | 627 TransformPaintPropertyNode::create( |
607 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D()); | 628 nullptr, TransformationMatrix().translate(11, 13), FloatPoint3D()); |
608 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( | 629 RefPtr<ScrollPaintPropertyNode> scrollA = ScrollPaintPropertyNode::create( |
609 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true); | 630 nullptr, scrollTranslationA, IntSize(2, 3), IntSize(5, 7), false, true); |
610 scrollA->addMainThreadScrollingReasons( | 631 scrollA->addMainThreadScrollingReasons( |
611 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 632 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
612 RefPtr<TransformPaintPropertyNode> scrollTranslationB = | 633 RefPtr<TransformPaintPropertyNode> scrollTranslationB = |
613 TransformPaintPropertyNode::create( | 634 TransformPaintPropertyNode::create( |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); | 674 scrollTree.current_scroll_offset(contentLayerAt(1)->id())); |
654 | 675 |
655 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & | 676 EXPECT_TRUE(scrollNodeA.main_thread_scrolling_reasons & |
656 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 677 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
657 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & | 678 EXPECT_FALSE(scrollNodeB.main_thread_scrolling_reasons & |
658 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 679 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
659 } | 680 } |
660 | 681 |
661 } // namespace | 682 } // namespace |
662 } // namespace blink | 683 } // namespace blink |
OLD | NEW |