mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[web] Fix RRect scaleRadii for negative width/height (flutter/engine#24140)
This commit is contained in:
parent
d39b828df7
commit
9b870e3556
@ -1,2 +1,2 @@
|
||||
repository: https://github.com/flutter/goldens.git
|
||||
revision: 99caeb1bcb8b7a856a78bd8d55816cc97db56112
|
||||
revision: 6839c709f859a1abe50e6322dfee17a3a3817c5c
|
||||
|
||||
@ -701,10 +701,12 @@ class RRect {
|
||||
|
||||
RRect scaleRadii() {
|
||||
double scale = 1.0;
|
||||
scale = _getMin(scale, blRadiusY, tlRadiusY, height);
|
||||
scale = _getMin(scale, tlRadiusX, trRadiusX, width);
|
||||
scale = _getMin(scale, trRadiusY, brRadiusY, height);
|
||||
scale = _getMin(scale, brRadiusX, blRadiusX, width);
|
||||
final double absWidth = width.abs();
|
||||
final double absHeight = height.abs();
|
||||
scale = _getMin(scale, blRadiusY, tlRadiusY, absHeight);
|
||||
scale = _getMin(scale, tlRadiusX, trRadiusX, absWidth);
|
||||
scale = _getMin(scale, trRadiusY, brRadiusY, absHeight);
|
||||
scale = _getMin(scale, brRadiusX, blRadiusX, absWidth);
|
||||
|
||||
if (scale < 1.0) {
|
||||
return RRect._raw(
|
||||
|
||||
@ -52,6 +52,20 @@ void testMain() async {
|
||||
await matchGoldenFile('canvas_rrect_round_square.png', region: region);
|
||||
});
|
||||
|
||||
/// Regression test for https://github.com/flutter/flutter/issues/62631
|
||||
test('round square with flipped left/right coordinates', () async {
|
||||
canvas.translate(35, 320);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(
|
||||
Rect.fromLTRB(-30, -100, 30, -300),
|
||||
Radius.circular(30)),
|
||||
niceRRectPaint);
|
||||
canvas.drawPath(Path()..moveTo(0, 0)..lineTo(20, 0), niceRRectPaint);
|
||||
html.document.body.append(canvas.rootElement);
|
||||
await matchGoldenFile('canvas_rrect_flipped.png',
|
||||
region: Rect.fromLTWH(0, 0, 100, 200));
|
||||
});
|
||||
|
||||
test('round rect with big radius scale down smaller radius', () async {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final Radius growingRadius = Radius.circular(rRectRadii[i]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user