diff --git a/impeller/aiks/aiks_unittests.cc b/impeller/aiks/aiks_unittests.cc index 368a400a2d806..9b06d08802be8 100644 --- a/impeller/aiks/aiks_unittests.cc +++ b/impeller/aiks/aiks_unittests.cc @@ -12,6 +12,7 @@ #include "impeller/aiks/aiks_playground.h" #include "impeller/aiks/canvas.h" #include "impeller/aiks/image.h" +#include "impeller/entity/contents/filters/inputs/filter_input.h" #include "impeller/entity/contents/tiled_texture_contents.h" #include "impeller/geometry/color.h" #include "impeller/geometry/geometry_unittests.h" diff --git a/impeller/aiks/canvas.cc b/impeller/aiks/canvas.cc index 6ff111b31f725..f1a2ae48b596a 100644 --- a/impeller/aiks/canvas.cc +++ b/impeller/aiks/canvas.cc @@ -161,7 +161,7 @@ bool Canvas::AttemptDrawBlurredRRect(const Rect& rect, Scalar corner_radius, const Paint& paint) { // TODO(114184): This should return false when the paint's ColorSource is not - // solid color. + // color. if (!paint.mask_blur_descriptor.has_value() || paint.mask_blur_descriptor->style != FilterContents::BlurStyle::kNormal || paint.style != Paint::Style::kFill) { diff --git a/impeller/display_list/display_list_unittests.cc b/impeller/display_list/display_list_unittests.cc index 47cf96ebf720a..91e886316598d 100644 --- a/impeller/display_list/display_list_unittests.cc +++ b/impeller/display_list/display_list_unittests.cc @@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include #include +#include #include #include "display_list/display_list_blend_mode.h" #include "display_list/display_list_color.h" #include "display_list/display_list_color_filter.h" +#include "display_list/display_list_color_source.h" #include "display_list/display_list_image_filter.h" #include "display_list/display_list_paint.h" #include "display_list/display_list_tile_mode.h" @@ -20,11 +23,12 @@ #include "impeller/geometry/constants.h" #include "impeller/geometry/point.h" #include "impeller/playground/widgets.h" -#include "include/core/SkRRect.h" #include "third_party/imgui/imgui.h" +#include "third_party/skia/include/core/SkBlurTypes.h" #include "third_party/skia/include/core/SkClipOp.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkPathBuilder.h" +#include "third_party/skia/include/core/SkRRect.h" namespace impeller { namespace testing { @@ -1013,5 +1017,42 @@ TEST_P(DisplayListTest, CanDrawCorrectlyWithColorFilterAndImageFilter) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } +TEST_P(DisplayListTest, MaskBlursApplyCorrectlyToColorSources) { + auto blur_filter = std::make_shared( + SkBlurStyle::kNormal_SkBlurStyle, 10); + + flutter::DisplayListBuilder builder; + + std::array colors = {flutter::DlColor::kBlue(), + flutter::DlColor::kGreen()}; + std::array stops = {0, 1}; + std::array, 2> color_sources = { + std::make_shared(flutter::DlColor::kWhite()), + flutter::DlColorSource::MakeLinear( + SkPoint::Make(0, 0), SkPoint::Make(100, 50), 2, colors.data(), + stops.data(), flutter::DlTileMode::kClamp)}; + + int offset = 100; + for (auto color_source : color_sources) { + flutter::DlPaint paint; + paint.setColorSource(color_source); + paint.setMaskFilter(blur_filter); + + paint.setDrawStyle(flutter::DlDrawStyle::kFill); + builder.drawRRect( + SkRRect::MakeRectXY(SkRect::MakeXYWH(100, offset, 100, 50), 30, 30), + paint); + paint.setDrawStyle(flutter::DlDrawStyle::kStroke); + paint.setStrokeWidth(10); + builder.drawRRect( + SkRRect::MakeRectXY(SkRect::MakeXYWH(300, offset, 100, 50), 30, 30), + paint); + + offset += 100; + } + + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); +} + } // namespace testing } // namespace impeller