Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions impeller/display_list/dl_dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,20 +1111,17 @@ void DlDispatcher::drawDisplayList(
void DlDispatcher::drawTextBlob(const sk_sp<SkTextBlob>& blob,
SkScalar x,
SkScalar y) {
const auto text_frame = MakeTextFrameFromTextBlobSkia(blob);
if (paint_.style == Paint::Style::kStroke) {
auto path = skia_conversions::PathDataFromTextBlob(blob);
auto bounds = text_frame.GetBounds();
if (!bounds.has_value()) {
return;
}
auto bounds = blob->bounds();
canvas_.Save();
canvas_.Translate({x + bounds->origin.x, y + bounds->origin.y, 0.0});
canvas_.Translate({x + bounds.left(), y + bounds.top(), 0.0});
canvas_.DrawPath(path, paint_);
canvas_.Restore();
return;
}

const auto text_frame = MakeTextFrameFromTextBlobSkia(blob);
canvas_.DrawTextFrame(text_frame, //
impeller::Point{x, y}, //
paint_ //
Expand Down
26 changes: 26 additions & 0 deletions impeller/display_list/dl_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,32 @@ TEST_P(DisplayListTest, CanDrawStrokedText) {
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

// Regression test for https://github.com/flutter/flutter/issues/133157.
TEST_P(DisplayListTest, StrokedTextNotOffsetFromNormalText) {
flutter::DisplayListBuilder builder;
flutter::DlPaint paint;
auto const& text_blob = SkTextBlob::MakeFromString("00000", CreateTestFont());

// https://api.flutter.dev/flutter/material/Colors/blue-constant.html.
auto const& mat_blue = flutter::DlColor(0xFF2196f3);

// Draw a blue filled rectangle so the text is easier to see.
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
paint.setColor(mat_blue);
builder.DrawRect(SkRect::MakeXYWH(0, 0, 500, 500), paint);

// Draw stacked text, with stroked text on top.
paint.setDrawStyle(flutter::DlDrawStyle::kFill);
paint.setColor(flutter::DlColor::kWhite());
builder.DrawTextBlob(text_blob, 250, 250, paint);

paint.setDrawStyle(flutter::DlDrawStyle::kStroke);
paint.setColor(flutter::DlColor::kBlack());
builder.DrawTextBlob(text_blob, 250, 250, paint);

ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
}

TEST_P(DisplayListTest, IgnoreMaskFilterWhenSavingLayer) {
auto texture = CreateTextureForFixture("embarcadero.jpg");
flutter::DisplayListBuilder builder;
Expand Down