|
18 | 18 | #include "impeller/aiks/paint_pass_delegate.h" |
19 | 19 | #include "impeller/aiks/testing/context_spy.h" |
20 | 20 | #include "impeller/entity/contents/color_source_contents.h" |
| 21 | +#include "impeller/entity/contents/conical_gradient_contents.h" |
21 | 22 | #include "impeller/entity/contents/filters/inputs/filter_input.h" |
| 23 | +#include "impeller/entity/contents/linear_gradient_contents.h" |
22 | 24 | #include "impeller/entity/contents/scene_contents.h" |
23 | 25 | #include "impeller/entity/contents/solid_color_contents.h" |
24 | 26 | #include "impeller/entity/contents/tiled_texture_contents.h" |
@@ -2851,5 +2853,35 @@ TEST_P(AiksTest, CanCanvasDrawPicture) { |
2851 | 2853 | ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture())); |
2852 | 2854 | } |
2853 | 2855 |
|
| 2856 | +TEST_P(AiksTest, SolidColorApplyColorFilter) { |
| 2857 | + auto contents = SolidColorContents(); |
| 2858 | + contents.SetColor(Color::CornflowerBlue().WithAlpha(0.75)); |
| 2859 | + auto result = contents.ApplyColorFilter([](const Color& color) { |
| 2860 | + return color.Blend(Color::LimeGreen().WithAlpha(0.75), BlendMode::kScreen); |
| 2861 | + }); |
| 2862 | + ASSERT_TRUE(result); |
| 2863 | + ASSERT_COLOR_NEAR(contents.GetColor(), |
| 2864 | + Color(0.433247, 0.879523, 0.825324, 0.75)); |
| 2865 | +} |
| 2866 | + |
| 2867 | +#define APPLY_COLOR_FILTER_GRADIENT_TEST(name) \ |
| 2868 | + TEST_P(AiksTest, name##GradientApplyColorFilter) { \ |
| 2869 | + auto contents = name##GradientContents(); \ |
| 2870 | + contents.SetColors({Color::CornflowerBlue().WithAlpha(0.75)}); \ |
| 2871 | + auto result = contents.ApplyColorFilter([](const Color& color) { \ |
| 2872 | + return color.Blend(Color::LimeGreen().WithAlpha(0.75), \ |
| 2873 | + BlendMode::kScreen); \ |
| 2874 | + }); \ |
| 2875 | + ASSERT_TRUE(result); \ |
| 2876 | + \ |
| 2877 | + std::vector<Color> expected = {Color(0.433247, 0.879523, 0.825324, 0.75)}; \ |
| 2878 | + ASSERT_COLORS_NEAR(contents.GetColors(), expected); \ |
| 2879 | + } |
| 2880 | + |
| 2881 | +APPLY_COLOR_FILTER_GRADIENT_TEST(Linear); |
| 2882 | +APPLY_COLOR_FILTER_GRADIENT_TEST(Radial); |
| 2883 | +APPLY_COLOR_FILTER_GRADIENT_TEST(Conical); |
| 2884 | +APPLY_COLOR_FILTER_GRADIENT_TEST(Sweep); |
| 2885 | + |
2854 | 2886 | } // namespace testing |
2855 | 2887 | } // namespace impeller |
0 commit comments