mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add playground to demonstrate mask blur problems (flutter/engine#37574)
This commit is contained in:
parent
6a870018be
commit
fc8604ed09
@ -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"
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 <array>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#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<flutter::DlBlurMaskFilter>(
|
||||
SkBlurStyle::kNormal_SkBlurStyle, 10);
|
||||
|
||||
flutter::DisplayListBuilder builder;
|
||||
|
||||
std::array<flutter::DlColor, 2> colors = {flutter::DlColor::kBlue(),
|
||||
flutter::DlColor::kGreen()};
|
||||
std::array<float, 2> stops = {0, 1};
|
||||
std::array<std::shared_ptr<flutter::DlColorSource>, 2> color_sources = {
|
||||
std::make_shared<flutter::DlColorColorSource>(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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user