Use SkTextBlob::bounds instead of TextFrame::getBounds(). (flutter/engine#45148)
Closes https://github.com/flutter/flutter/issues/133157.
This commit is contained in:
@@ -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_ //
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user