mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[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:
parent
a01daf5555
commit
d8d3d6ac4b
@ -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;
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user