Skip to content

Commit

Permalink
Normalize round rect bounds when coming from Flutter (#57171)
Browse files Browse the repository at this point in the history
A flaw in #57153 - SkRRect would normalize the rect (make it right-side up), a feature that Flutter code takes advantage of. We need to do that manually when we ingest a round rect from Flutter.
  • Loading branch information
flar authored Dec 13, 2024
1 parent 4402232 commit 5eedfef
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/ui/painting/rrect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,23 @@ RRect DartConverter<flutter::RRect>::FromDart(Dart_Handle value) {
return result;
}

impeller::RoundingRadii radii = {{buffer[4], buffer[5]},
{buffer[6], buffer[7]},
{buffer[10], buffer[11]},
{buffer[8], buffer[9]}};

result.rrect = flutter::DlRoundRect::MakeRectRadii(
flutter::DlRect::MakeLTRB(buffer[0], buffer[1], buffer[2], buffer[3]),
radii);
// The Flutter rect may be inverted (upside down, backward, or both)
// Historically, Skia would normalize such rects but we will do that
// manually below when we construct the Impeller RoundRect
flutter::DlRect raw_rect =
flutter::DlRect::MakeLTRB(buffer[0], buffer[1], buffer[2], buffer[3]);

// Flutter has radii in TL,TR,BR,BL (clockwise) order,
// but Impeller uses TL,TR,BL,BR (zig-zag) order
impeller::RoundingRadii radii = {
.top_left = flutter::DlSize(buffer[4], buffer[5]),
.top_right = flutter::DlSize(buffer[6], buffer[7]),
.bottom_left = flutter::DlSize(buffer[10], buffer[11]),
.bottom_right = flutter::DlSize(buffer[8], buffer[9]),
};

result.rrect =
flutter::DlRoundRect::MakeRectRadii(raw_rect.GetPositive(), radii);

result.is_null = false;
return result;
Expand Down

0 comments on commit 5eedfef

Please sign in to comment.