|
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 {
|
@@ -2875,164 +2874,5 @@ TEST_F(DisplayListTest, DrawSaveDrawCannotInheritOpacity) {
|
2875 | 2874 | ASSERT_FALSE(display_list->can_apply_group_opacity());
|
2876 | 2875 | }
|
2877 | 2876 |
|
2878 |
| -TEST_F(DisplayListTest, NopOperationsOmittedFromRecords) { |
2879 |
| - auto run_tests = [](const std::string& name, |
2880 |
| - void init(DisplayListBuilder & builder, DlPaint & paint), |
2881 |
| - uint32_t expected_op_count = 0u) { |
2882 |
| - auto run_one_test = |
2883 |
| - [init](const std::string& name, |
2884 |
| - void build(DisplayListBuilder & builder, DlPaint & paint), |
2885 |
| - uint32_t expected_op_count = 0u) { |
2886 |
| - DisplayListBuilder builder; |
2887 |
| - DlPaint paint; |
2888 |
| - init(builder, paint); |
2889 |
| - build(builder, paint); |
2890 |
| - auto list = builder.Build(); |
2891 |
| - if (list->op_count() != expected_op_count) { |
2892 |
| - FML_LOG(ERROR) << *list; |
2893 |
| - } |
2894 |
| - ASSERT_EQ(list->op_count(), expected_op_count) << name; |
2895 |
| - ASSERT_TRUE(list->bounds().isEmpty()) << name; |
2896 |
| - }; |
2897 |
| - run_one_test( |
2898 |
| - name + " DrawColor", |
2899 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2900 |
| - builder.DrawColor(paint.getColor(), paint.getBlendMode()); |
2901 |
| - }, |
2902 |
| - expected_op_count); |
2903 |
| - run_one_test( |
2904 |
| - name + " DrawPaint", |
2905 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2906 |
| - builder.DrawPaint(paint); |
2907 |
| - }, |
2908 |
| - expected_op_count); |
2909 |
| - run_one_test( |
2910 |
| - name + " DrawRect", |
2911 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2912 |
| - builder.DrawRect({10, 10, 20, 20}, paint); |
2913 |
| - }, |
2914 |
| - expected_op_count); |
2915 |
| - run_one_test( |
2916 |
| - name + " Other Draw Ops", |
2917 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2918 |
| - builder.DrawLine({10, 10}, {20, 20}, paint); |
2919 |
| - builder.DrawOval({10, 10, 20, 20}, paint); |
2920 |
| - builder.DrawCircle({50, 50}, 20, paint); |
2921 |
| - builder.DrawRRect(SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5), paint); |
2922 |
| - builder.DrawDRRect(SkRRect::MakeRectXY({5, 5, 100, 100}, 5, 5), |
2923 |
| - SkRRect::MakeRectXY({10, 10, 20, 20}, 5, 5), |
2924 |
| - paint); |
2925 |
| - builder.DrawPath(kTestPath1, paint); |
2926 |
| - builder.DrawArc({10, 10, 20, 20}, 45, 90, true, paint); |
2927 |
| - SkPoint pts[] = {{10, 10}, {20, 20}}; |
2928 |
| - builder.DrawPoints(PointMode::kLines, 2, pts, paint); |
2929 |
| - builder.DrawVertices(TestVertices1, DlBlendMode::kSrcOver, paint); |
2930 |
| - builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear, |
2931 |
| - &paint); |
2932 |
| - builder.DrawImageRect(TestImage1, SkRect{0.0f, 0.0f, 10.0f, 10.0f}, |
2933 |
| - SkRect{10.0f, 10.0f, 25.0f, 25.0f}, |
2934 |
| - DlImageSampling::kLinear, &paint); |
2935 |
| - builder.DrawImageNine(TestImage1, {10, 10, 20, 20}, |
2936 |
| - {10, 10, 100, 100}, DlFilterMode::kLinear, |
2937 |
| - &paint); |
2938 |
| - SkRSXform xforms[] = {{1, 0, 10, 10}, {0, 1, 10, 10}}; |
2939 |
| - SkRect rects[] = {{10, 10, 20, 20}, {10, 20, 30, 20}}; |
2940 |
| - builder.DrawAtlas(TestImage1, xforms, rects, nullptr, 2, |
2941 |
| - DlBlendMode::kSrcOver, DlImageSampling::kLinear, |
2942 |
| - nullptr, &paint); |
2943 |
| - builder.DrawTextBlob(TestBlob1, 10, 10, paint); |
2944 |
| - |
2945 |
| - // Dst mode eliminates most rendering ops except for |
2946 |
| - // the following two, so we'll prune those manually... |
2947 |
| - if (paint.getBlendMode() != DlBlendMode::kDst) { |
2948 |
| - builder.DrawDisplayList(TestDisplayList1, paint.getOpacity()); |
2949 |
| - builder.DrawShadow(kTestPath1, paint.getColor(), 1, true, 1); |
2950 |
| - } |
2951 |
| - }, |
2952 |
| - expected_op_count); |
2953 |
| - run_one_test( |
2954 |
| - name + " SaveLayer", |
2955 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2956 |
| - builder.SaveLayer(nullptr, &paint, nullptr); |
2957 |
| - builder.DrawRect({10, 10, 20, 20}, DlPaint()); |
2958 |
| - builder.Restore(); |
2959 |
| - }, |
2960 |
| - expected_op_count); |
2961 |
| - run_one_test( |
2962 |
| - name + " inside Save", |
2963 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2964 |
| - builder.Save(); |
2965 |
| - builder.DrawRect({10, 10, 20, 20}, paint); |
2966 |
| - builder.Restore(); |
2967 |
| - }, |
2968 |
| - expected_op_count); |
2969 |
| - }; |
2970 |
| - run_tests("transparent color", // |
2971 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2972 |
| - paint.setColor(DlColor::kTransparent()); |
2973 |
| - }); |
2974 |
| - run_tests("0 alpha", // |
2975 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2976 |
| - // The transparent test above already tested transparent |
2977 |
| - // black (all 0s), we set White color here so we can test |
2978 |
| - // the case of all 1s with a 0 alpha |
2979 |
| - paint.setColor(DlColor::kWhite()); |
2980 |
| - paint.setAlpha(0); |
2981 |
| - }); |
2982 |
| - run_tests("BlendMode::kDst", // |
2983 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2984 |
| - paint.setBlendMode(DlBlendMode::kDst); |
2985 |
| - }); |
2986 |
| - run_tests("Empty rect clip", // |
2987 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2988 |
| - builder.ClipRect(SkRect::MakeEmpty(), ClipOp::kIntersect, false); |
2989 |
| - }); |
2990 |
| - run_tests("Empty rrect clip", // |
2991 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2992 |
| - builder.ClipRRect(SkRRect::MakeEmpty(), ClipOp::kIntersect, |
2993 |
| - false); |
2994 |
| - }); |
2995 |
| - run_tests("Empty path clip", // |
2996 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
2997 |
| - builder.ClipPath(SkPath(), ClipOp::kIntersect, false); |
2998 |
| - }); |
2999 |
| - run_tests("Transparent SaveLayer", // |
3000 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
3001 |
| - DlPaint save_paint; |
3002 |
| - save_paint.setColor(DlColor::kTransparent()); |
3003 |
| - builder.SaveLayer(nullptr, &save_paint); |
3004 |
| - }); |
3005 |
| - run_tests("0 alpha SaveLayer", // |
3006 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
3007 |
| - DlPaint save_paint; |
3008 |
| - // The transparent test above already tested transparent |
3009 |
| - // black (all 0s), we set White color here so we can test |
3010 |
| - // the case of all 1s with a 0 alpha |
3011 |
| - save_paint.setColor(DlColor::kWhite()); |
3012 |
| - save_paint.setAlpha(0); |
3013 |
| - builder.SaveLayer(nullptr, &save_paint); |
3014 |
| - }); |
3015 |
| - run_tests("Dst blended SaveLayer", // |
3016 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
3017 |
| - DlPaint save_paint; |
3018 |
| - save_paint.setBlendMode(DlBlendMode::kDst); |
3019 |
| - builder.SaveLayer(nullptr, &save_paint); |
3020 |
| - }); |
3021 |
| - run_tests( |
3022 |
| - "Nop inside SaveLayer", |
3023 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
3024 |
| - builder.SaveLayer(nullptr, nullptr); |
3025 |
| - paint.setBlendMode(DlBlendMode::kDst); |
3026 |
| - }, |
3027 |
| - 2u); |
3028 |
| - run_tests("DrawImage inside Culled SaveLayer", // |
3029 |
| - [](DisplayListBuilder& builder, DlPaint& paint) { |
3030 |
| - DlPaint save_paint; |
3031 |
| - save_paint.setColor(DlColor::kTransparent()); |
3032 |
| - builder.SaveLayer(nullptr, &save_paint); |
3033 |
| - builder.DrawImage(TestImage1, {10, 10}, DlImageSampling::kLinear); |
3034 |
| - }); |
3035 |
| -} |
3036 |
| - |
3037 | 2877 | } // namespace testing
|
3038 | 2878 | } // namespace flutter
|
0 commit comments