|
22 | 22 | #include "flutter/testing/testing.h" |
23 | 23 |
|
24 | 24 | #include "third_party/skia/include/core/SkPictureRecorder.h" |
25 | | -#include "third_party/skia/include/core/SkRSXform.h" |
26 | 25 | #include "third_party/skia/include/core/SkSurface.h" |
27 | 26 |
|
28 | 27 | namespace flutter { |
@@ -2640,164 +2639,5 @@ TEST_F(DisplayListTest, DrawSaveDrawCannotInheritOpacity) { |
2640 | 2639 | ASSERT_FALSE(display_list->can_apply_group_opacity()); |
2641 | 2640 | } |
2642 | 2641 |
|
2643 | | -TEST_F(DisplayListTest, NopOperationsOmittedFromRecords) { |
2644 | | - auto run_tests = [](const std::string& name, |
2645 | | - void init(DisplayListBuilder & builder, DlPaint & paint), |
2646 | | - uint32_t expected_op_count = 0u) { |
2647 | | - auto run_one_test = |
2648 | | - [init](const std::string& name, |
2649 | | - void build(DisplayListBuilder & builder, DlPaint & paint), |
2650 | | - uint32_t expected_op_count = 0u) { |
2651 | | - DisplayListBuilder builder; |
2652 | | - DlPaint paint; |
2653 | | - init(builder, paint); |
2654 | | - build(builder, paint); |
2655 | | - auto list = builder.Build(); |
2656 | | - if (list->op_count() != expected_op_count) { |
2657 | | - FML_LOG(ERROR) << *list; |
2658 | | - } |
2659 | | - ASSERT_EQ(list->op_count(), expected_op_count) << name; |
2660 | | - ASSERT_TRUE(list->bounds().isEmpty()) << name; |
2661 | | - }; |
2662 | | - run_one_test( |
2663 | | - name + " DrawColor", |
2664 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2665 | | - builder.DrawColor(paint.getColor(), paint.getBlendMode()); |
2666 | | - }, |
2667 | | - expected_op_count); |
2668 | | - run_one_test( |
2669 | | - name + " DrawPaint", |
2670 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2671 | | - builder.DrawPaint(paint); |
2672 | | - }, |
2673 | | - expected_op_count); |
2674 | | - run_one_test( |
2675 | | - name + " DrawRect", |
2676 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2677 | | - builder.DrawRect({10, 10, 20, 20}, paint); |
2678 | | - }, |
2679 | | - expected_op_count); |
2680 | | - run_one_test( |
2681 | | - name + " Other Draw Ops", |
2682 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2683 | | - builder.DrawLine({10, 10}, {20, 20}, paint); |
2684 | | - builder.DrawOval({10, 10, 20, 20}, paint); |
2685 | | - builder.DrawCircle({50, 50}, 20, paint); |
2686 | | - builder.DrawRRect(SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5), paint); |
2687 | | - builder.DrawDRRect(SkRRect::MakeRectXY({5, 5, 100, 100}, 5, 5), |
2688 | | - SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5), |
2689 | | - paint); |
2690 | | - builder.DrawPath(kTestPath1, paint); |
2691 | | - builder.DrawArc({10, 10, 20, 20}, 45, 90, true, paint); |
2692 | | - SkPoint pts[] = {{10, 10}, {20, 20}}; |
2693 | | - builder.DrawPoints(PointMode::kLines, 2, pts, paint); |
2694 | | - builder.DrawVertices(TestVertices1, DlBlendMode::kSrcOver, paint); |
2695 | | - builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear, |
2696 | | - &paint); |
2697 | | - builder.DrawImageRect(TestImage1, SkRect{0.0f, 0.0f, 10.0f, 10.0f}, |
2698 | | - SkRect{10.0f, 10.0f, 25.0f, 25.0f}, |
2699 | | - DlImageSampling::kLinear, &paint); |
2700 | | - builder.DrawImageNine(TestImage1, {10, 10, 20, 20}, |
2701 | | - {10, 10, 100, 100}, DlFilterMode::kLinear, |
2702 | | - &paint); |
2703 | | - SkRSXform xforms[] = {{1, 0, 10, 10}, {0, 1, 10, 10}}; |
2704 | | - SkRect rects[] = {{10, 10, 20, 20}, {10, 20, 30, 20}}; |
2705 | | - builder.DrawAtlas(TestImage1, xforms, rects, nullptr, 2, |
2706 | | - DlBlendMode::kSrcOver, DlImageSampling::kLinear, |
2707 | | - nullptr, &paint); |
2708 | | - builder.DrawTextBlob(TestBlob1, 10, 10, paint); |
2709 | | - |
2710 | | - // Dst mode eliminates most rendering ops except for |
2711 | | - // the following two, so we'll prune those manually... |
2712 | | - if (paint.getBlendMode() != DlBlendMode::kDst) { |
2713 | | - builder.DrawDisplayList(TestDisplayList1, paint.getOpacity()); |
2714 | | - builder.DrawShadow(kTestPath1, paint.getColor(), 1, true, 1); |
2715 | | - } |
2716 | | - }, |
2717 | | - expected_op_count); |
2718 | | - run_one_test( |
2719 | | - name + " SaveLayer", |
2720 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2721 | | - builder.SaveLayer(nullptr, &paint, nullptr); |
2722 | | - builder.DrawRect({10, 10, 20, 20}, DlPaint()); |
2723 | | - builder.Restore(); |
2724 | | - }, |
2725 | | - expected_op_count); |
2726 | | - run_one_test( |
2727 | | - name + " inside Save", |
2728 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2729 | | - builder.Save(); |
2730 | | - builder.DrawRect({10, 10, 20, 20}, paint); |
2731 | | - builder.Restore(); |
2732 | | - }, |
2733 | | - expected_op_count); |
2734 | | - }; |
2735 | | - run_tests("transparent color", // |
2736 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2737 | | - paint.setColor(DlColor::kTransparent()); |
2738 | | - }); |
2739 | | - run_tests("0 alpha", // |
2740 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2741 | | - // The transparent test above already tested transparent |
2742 | | - // black (all 0s), we set White color here so we can test |
2743 | | - // the case of all 1s with a 0 alpha |
2744 | | - paint.setColor(DlColor::kWhite()); |
2745 | | - paint.setAlpha(0); |
2746 | | - }); |
2747 | | - run_tests("BlendMode::kDst", // |
2748 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2749 | | - paint.setBlendMode(DlBlendMode::kDst); |
2750 | | - }); |
2751 | | - run_tests("Empty rect clip", // |
2752 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2753 | | - builder.ClipRect(SkRect::MakeEmpty(), ClipOp::kIntersect, false); |
2754 | | - }); |
2755 | | - run_tests("Empty rrect clip", // |
2756 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2757 | | - builder.ClipRRect(SkRRect::MakeEmpty(), ClipOp::kIntersect, |
2758 | | - false); |
2759 | | - }); |
2760 | | - run_tests("Empty path clip", // |
2761 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2762 | | - builder.ClipPath(SkPath(), ClipOp::kIntersect, false); |
2763 | | - }); |
2764 | | - run_tests("Transparent SaveLayer", // |
2765 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2766 | | - DlPaint save_paint; |
2767 | | - save_paint.setColor(DlColor::kTransparent()); |
2768 | | - builder.SaveLayer(nullptr, &save_paint); |
2769 | | - }); |
2770 | | - run_tests("0 alpha SaveLayer", // |
2771 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2772 | | - DlPaint save_paint; |
2773 | | - // The transparent test above already tested transparent |
2774 | | - // black (all 0s), we set White color here so we can test |
2775 | | - // the case of all 1s with a 0 alpha |
2776 | | - save_paint.setColor(DlColor::kWhite()); |
2777 | | - save_paint.setAlpha(0); |
2778 | | - builder.SaveLayer(nullptr, &save_paint); |
2779 | | - }); |
2780 | | - run_tests("Dst blended SaveLayer", // |
2781 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2782 | | - DlPaint save_paint; |
2783 | | - save_paint.setBlendMode(DlBlendMode::kDst); |
2784 | | - builder.SaveLayer(nullptr, &save_paint); |
2785 | | - }); |
2786 | | - run_tests( |
2787 | | - "Nop inside SaveLayer", |
2788 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2789 | | - builder.SaveLayer(nullptr, nullptr); |
2790 | | - paint.setBlendMode(DlBlendMode::kDst); |
2791 | | - }, |
2792 | | - 2u); |
2793 | | - run_tests("DrawImage inside Culled SaveLayer", // |
2794 | | - [](DisplayListBuilder& builder, DlPaint& paint) { |
2795 | | - DlPaint save_paint; |
2796 | | - save_paint.setColor(DlColor::kTransparent()); |
2797 | | - builder.SaveLayer(nullptr, &save_paint); |
2798 | | - builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear); |
2799 | | - }); |
2800 | | -} |
2801 | | - |
2802 | 2642 | } // namespace testing |
2803 | 2643 | } // namespace flutter |
0 commit comments