[Impeller] Do not use fast mask blur for stroked shapes (flutter/engine#56247)

A compound test for whether to use the fast blur mechanism for shapes was failing to check for a stroked shape due to misplaced parentheses.
This commit is contained in:
Jim Graham
2024-10-31 14:33:18 -07:00
committed by GitHub
parent 14df054f9c
commit 861a9a4ac8
3 changed files with 33 additions and 2 deletions

View File

@@ -310,9 +310,12 @@ void Canvas::DrawPaint(const Paint& paint) {
bool Canvas::AttemptDrawBlurredRRect(const Rect& rect,
Size corner_radii,
const Paint& paint) {
if (paint.style != Paint::Style::kFill) {
return false;
}
if (paint.color_source &&
(paint.color_source->type() != flutter::DlColorSourceType::kColor ||
paint.style != Paint::Style::kFill)) {
paint.color_source->type() != flutter::DlColorSourceType::kColor) {
return false;
}

View File

@@ -6,6 +6,7 @@
#include "flutter/display_list/dl_builder.h"
#include "flutter/display_list/effects/dl_mask_filter.h"
#include "flutter/impeller/geometry/round_rect.h"
#include "flutter/impeller/golden_tests/screenshot.h"
#include "flutter/testing/testing.h"
#include "gtest/gtest.h"
@@ -226,5 +227,29 @@ TEST_P(DlGoldenTest, ShimmerTest) {
EXPECT_TRUE(average_rmse >= 0.0) << "average_rmse: " << average_rmse;
}
TEST_P(DlGoldenTest, StrokedRRectFastBlur) {
impeller::Point content_scale = GetContentScale();
DlRect rect = DlRect::MakeXYWH(50, 50, 100, 100);
DlRoundRect rrect = DlRoundRect::MakeRectRadius(rect, 10.0f);
DlPaint fill = DlPaint().setColor(DlColor::kBlue());
DlPaint stroke =
DlPaint(fill).setDrawStyle(DlDrawStyle::kStroke).setStrokeWidth(10.0f);
DlPaint blur = DlPaint(fill).setMaskFilter(
DlBlurMaskFilter::Make(DlBlurStyle::kNormal, 5.0, true));
DlPaint blur_stroke =
DlPaint(blur).setDrawStyle(DlDrawStyle::kStroke).setStrokeWidth(10.0f);
DisplayListBuilder builder;
builder.DrawColor(DlColor(0xff111111), DlBlendMode::kSrc);
builder.Scale(content_scale.x, content_scale.y);
builder.DrawRoundRect(rrect, fill);
builder.DrawRoundRect(rrect.Shift(150, 0), stroke);
builder.DrawRoundRect(rrect.Shift(0, 150), blur);
builder.DrawRoundRect(rrect.Shift(150, 150), blur_stroke);
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
} // namespace testing
} // namespace flutter

View File

@@ -948,6 +948,9 @@ impeller_Play_DlGoldenTest_GaussianVsRRectBlurScaled_Vulkan.png
impeller_Play_DlGoldenTest_GaussianVsRRectBlur_Metal.png
impeller_Play_DlGoldenTest_GaussianVsRRectBlur_OpenGLES.png
impeller_Play_DlGoldenTest_GaussianVsRRectBlur_Vulkan.png
impeller_Play_DlGoldenTest_StrokedRRectFastBlur_Metal.png
impeller_Play_DlGoldenTest_StrokedRRectFastBlur_OpenGLES.png
impeller_Play_DlGoldenTest_StrokedRRectFastBlur_Vulkan.png
impeller_Play_DlGoldenTest_TextBlurMaskFilterDisrespectCTM_Metal.png
impeller_Play_DlGoldenTest_TextBlurMaskFilterDisrespectCTM_OpenGLES.png
impeller_Play_DlGoldenTest_TextBlurMaskFilterDisrespectCTM_Vulkan.png