|
2 | 2 | // Use of this source code is governed by a BSD-style license that can be
|
3 | 3 | // found in the LICENSE file.
|
4 | 4 |
|
| 5 | +#include <array> |
5 | 6 | #include <cmath>
|
| 7 | +#include <memory> |
6 | 8 | #include <vector>
|
7 | 9 |
|
8 | 10 | #include "display_list/display_list_blend_mode.h"
|
9 | 11 | #include "display_list/display_list_color.h"
|
10 | 12 | #include "display_list/display_list_color_filter.h"
|
| 13 | +#include "display_list/display_list_color_source.h" |
11 | 14 | #include "display_list/display_list_image_filter.h"
|
12 | 15 | #include "display_list/display_list_paint.h"
|
13 | 16 | #include "display_list/display_list_tile_mode.h"
|
|
20 | 23 | #include "impeller/geometry/constants.h"
|
21 | 24 | #include "impeller/geometry/point.h"
|
22 | 25 | #include "impeller/playground/widgets.h"
|
23 |
| -#include "include/core/SkRRect.h" |
24 | 26 | #include "third_party/imgui/imgui.h"
|
| 27 | +#include "third_party/skia/include/core/SkBlurTypes.h" |
25 | 28 | #include "third_party/skia/include/core/SkClipOp.h"
|
26 | 29 | #include "third_party/skia/include/core/SkColor.h"
|
27 | 30 | #include "third_party/skia/include/core/SkPathBuilder.h"
|
| 31 | +#include "third_party/skia/include/core/SkRRect.h" |
28 | 32 |
|
29 | 33 | namespace impeller {
|
30 | 34 | namespace testing {
|
@@ -1013,5 +1017,42 @@ TEST_P(DisplayListTest, CanDrawCorrectlyWithColorFilterAndImageFilter) {
|
1013 | 1017 | ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
|
1014 | 1018 | }
|
1015 | 1019 |
|
| 1020 | +TEST_P(DisplayListTest, MaskBlursApplyCorrectlyToColorSources) { |
| 1021 | + auto blur_filter = std::make_shared<flutter::DlBlurMaskFilter>( |
| 1022 | + SkBlurStyle::kNormal_SkBlurStyle, 10); |
| 1023 | + |
| 1024 | + flutter::DisplayListBuilder builder; |
| 1025 | + |
| 1026 | + std::array<flutter::DlColor, 2> colors = {flutter::DlColor::kBlue(), |
| 1027 | + flutter::DlColor::kGreen()}; |
| 1028 | + std::array<float, 2> stops = {0, 1}; |
| 1029 | + std::array<std::shared_ptr<flutter::DlColorSource>, 2> color_sources = { |
| 1030 | + std::make_shared<flutter::DlColorColorSource>(flutter::DlColor::kWhite()), |
| 1031 | + flutter::DlColorSource::MakeLinear( |
| 1032 | + SkPoint::Make(0, 0), SkPoint::Make(100, 50), 2, colors.data(), |
| 1033 | + stops.data(), flutter::DlTileMode::kClamp)}; |
| 1034 | + |
| 1035 | + int offset = 100; |
| 1036 | + for (auto color_source : color_sources) { |
| 1037 | + flutter::DlPaint paint; |
| 1038 | + paint.setColorSource(color_source); |
| 1039 | + paint.setMaskFilter(blur_filter); |
| 1040 | + |
| 1041 | + paint.setDrawStyle(flutter::DlDrawStyle::kFill); |
| 1042 | + builder.drawRRect( |
| 1043 | + SkRRect::MakeRectXY(SkRect::MakeXYWH(100, offset, 100, 50), 30, 30), |
| 1044 | + paint); |
| 1045 | + paint.setDrawStyle(flutter::DlDrawStyle::kStroke); |
| 1046 | + paint.setStrokeWidth(10); |
| 1047 | + builder.drawRRect( |
| 1048 | + SkRRect::MakeRectXY(SkRect::MakeXYWH(300, offset, 100, 50), 30, 30), |
| 1049 | + paint); |
| 1050 | + |
| 1051 | + offset += 100; |
| 1052 | + } |
| 1053 | + |
| 1054 | + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); |
| 1055 | +} |
| 1056 | + |
1016 | 1057 | } // namespace testing
|
1017 | 1058 | } // namespace impeller
|
0 commit comments