[Impeller] Do not scale the miter limit applied to stroked text (flutter/engine#55745)

Fixes https://github.com/flutter/flutter/issues/156224
This commit is contained in:
Jason Simmons 2024-10-08 15:07:19 -07:00 committed by GitHub
parent a01daf5555
commit d8d3d6ac4b
4 changed files with 24 additions and 3 deletions

View File

@ -32,6 +32,7 @@ namespace testing {
struct TextRenderOptions {
bool stroke = false;
Scalar font_size = 50;
Scalar stroke_width = 1;
DlColor color = DlColor::kYellow();
SkPoint position = SkPoint::Make(100, 200);
std::shared_ptr<DlMaskFilter> filter;
@ -72,7 +73,7 @@ bool RenderTextInCanvasSkia(const std::shared_ptr<Context>& context,
DlPaint text_paint;
text_paint.setColor(options.color);
text_paint.setMaskFilter(options.filter);
text_paint.setStrokeWidth(1);
text_paint.setStrokeWidth(options.stroke_width);
text_paint.setDrawStyle(options.stroke ? DlDrawStyle::kStroke
: DlDrawStyle::kFill);
canvas.DrawTextFrame(frame, options.position.x(), options.position.y(),
@ -159,6 +160,22 @@ TEST_P(AiksTest, CanRenderStrokedTextFrame) {
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, CanRenderTextStrokeWidth) {
DisplayListBuilder builder;
DlPaint paint;
paint.setColor(DlColor::ARGB(1, 0.1, 0.1, 0.1));
builder.DrawPaint(paint);
ASSERT_TRUE(RenderTextInCanvasSkia(GetContext(), builder, "LMNOP VWXYZ",
"Roboto-Medium.ttf",
{
.stroke = true,
.stroke_width = 4,
}));
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}
TEST_P(AiksTest, CanRenderTextFrameWithHalfScaling) {
DisplayListBuilder builder;

View File

@ -103,6 +103,7 @@ test_fixtures("file_fixtures") {
fixtures = [
"//flutter/third_party/txt/third_party/fonts/HomemadeApple.ttf",
"//flutter/third_party/txt/third_party/fonts/NotoColorEmoji.ttf",
"//flutter/third_party/txt/third_party/fonts/Roboto-Medium.ttf",
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf",
"airplane.jpg",
"bay_bridge.jpg",

View File

@ -232,7 +232,7 @@ static void DrawGlyph(SkCanvas* canvas,
glyph_paint.setStrokeWidth(prop->stroke_width * scaled_font.scale);
glyph_paint.setStrokeCap(ToSkiaCap(prop->stroke_cap));
glyph_paint.setStrokeJoin(ToSkiaJoin(prop->stroke_join));
glyph_paint.setStrokeMiter(prop->stroke_miter * scaled_font.scale);
glyph_paint.setStrokeMiter(prop->stroke_miter);
}
canvas->save();
canvas->translate(glyph.subpixel_offset.x, glyph.subpixel_offset.y);
@ -388,7 +388,7 @@ static Rect ComputeGlyphSize(const SkFont& font,
glyph_paint.setStrokeWidth(glyph.properties->stroke_width * scale);
glyph_paint.setStrokeCap(ToSkiaCap(glyph.properties->stroke_cap));
glyph_paint.setStrokeJoin(ToSkiaJoin(glyph.properties->stroke_join));
glyph_paint.setStrokeMiter(glyph.properties->stroke_miter * scale);
glyph_paint.setStrokeMiter(glyph.properties->stroke_miter);
}
font.getBounds(&glyph.glyph.index, 1, &scaled_bounds, &glyph_paint);

View File

@ -466,6 +466,9 @@ impeller_Play_AiksTest_CanRenderTextInSaveLayer_Vulkan.png
impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_Metal.png
impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_OpenGLES.png
impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_Vulkan.png
impeller_Play_AiksTest_CanRenderTextStrokeWidth_Metal.png
impeller_Play_AiksTest_CanRenderTextStrokeWidth_OpenGLES.png
impeller_Play_AiksTest_CanRenderTextStrokeWidth_Vulkan.png
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_Metal.png
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_OpenGLES.png
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_Vulkan.png