Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a1b5507

Browse files
authored
Add playground to demonstrate mask blur problems (#37574)
1 parent b7567b9 commit a1b5507

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "impeller/aiks/aiks_playground.h"
1313
#include "impeller/aiks/canvas.h"
1414
#include "impeller/aiks/image.h"
15+
#include "impeller/entity/contents/filters/inputs/filter_input.h"
1516
#include "impeller/entity/contents/tiled_texture_contents.h"
1617
#include "impeller/geometry/color.h"
1718
#include "impeller/geometry/geometry_unittests.h"

impeller/aiks/canvas.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
161161
Scalar corner_radius,
162162
const Paint& paint) {
163163
// TODO(114184): This should return false when the paint's ColorSource is not
164-
// solid color.
164+
// color.
165165
if (!paint.mask_blur_descriptor.has_value() ||
166166
paint.mask_blur_descriptor->style != FilterContents::BlurStyle::kNormal ||
167167
paint.style != Paint::Style::kFill) {

impeller/display_list/display_list_unittests.cc

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#include <array>
56
#include <cmath>
7+
#include <memory>
68
#include <vector>
79

810
#include "display_list/display_list_blend_mode.h"
911
#include "display_list/display_list_color.h"
1012
#include "display_list/display_list_color_filter.h"
13+
#include "display_list/display_list_color_source.h"
1114
#include "display_list/display_list_image_filter.h"
1215
#include "display_list/display_list_paint.h"
1316
#include "display_list/display_list_tile_mode.h"
@@ -20,11 +23,12 @@
2023
#include "impeller/geometry/constants.h"
2124
#include "impeller/geometry/point.h"
2225
#include "impeller/playground/widgets.h"
23-
#include "include/core/SkRRect.h"
2426
#include "third_party/imgui/imgui.h"
27+
#include "third_party/skia/include/core/SkBlurTypes.h"
2528
#include "third_party/skia/include/core/SkClipOp.h"
2629
#include "third_party/skia/include/core/SkColor.h"
2730
#include "third_party/skia/include/core/SkPathBuilder.h"
31+
#include "third_party/skia/include/core/SkRRect.h"
2832

2933
namespace impeller {
3034
namespace testing {
@@ -1013,5 +1017,42 @@ TEST_P(DisplayListTest, CanDrawCorrectlyWithColorFilterAndImageFilter) {
10131017
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
10141018
}
10151019

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+
10161057
} // namespace testing
10171058
} // namespace impeller

0 commit comments

Comments
 (0)