Brandon DeRosier 549dd82f2f [Impeller] Fix division by zero for transparent shadows (flutter/engine#41391)
A division by zero happens if the shadow color is fully transparent, and
the NaNs are getting assigned to the RGB values of the paint color being
handed to the rrect shadow draw. This doesn't cause a problem when wide
gamut is off because NaN output ends up being interpreted as zero (thus
making the shadow output fully transparent black, which happens to be
the expected and correct result). However, when a wide gamut attachment
is present, the NaN output ends up being interpreted as a negative
value.

Reproduction app:
```dart
import 'package:flutter/material.dart';

void main() => runApp(const GeneralDialogApp());

class EvilPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final Rect rect = Offset.zero & size;
    canvas.drawPaint(Paint()..color = Colors.white);
    canvas.saveLayer(null, Paint()..blendMode = BlendMode.srcOver);
    canvas.drawShadow(Path()..addRect(Rect.fromLTRB(100, 100, 300, 300)),
        Colors.black54, 15, false);
    canvas.drawShadow(Path()..addRect(Rect.fromLTRB(100, 100, 300, 300)),
        Colors.black54, 15, false);
    canvas.drawShadow(Path()..addRect(Rect.fromLTRB(100, 100, 300, 300)),
        Colors.transparent, 15, false);
    canvas.restore();
  }

  @override
  bool shouldRepaint(EvilPainter oldDelegate) => false;
  @override
  bool shouldRebuildSemantics(EvilPainter oldDelegate) => false;
}

class GeneralDialogApp extends StatelessWidget {
  const GeneralDialogApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      restorationScopeId: 'app',
      home: CustomPaint(painter: EvilPainter()),
    );
  }
}
```

Before:

![image](https://user-images.githubusercontent.com/919017/233558512-0bfdcdc0-017d-4df3-870f-bd8808ef73b7.png)


After:

![image](https://user-images.githubusercontent.com/919017/233558076-b56c7f43-c81e-4ca6-897d-246251dae930.png)
2023-04-21 08:58:05 -07:00
Languages
Dart 75%
C++ 16.5%
Objective-C++ 2.9%
Java 2.8%
Objective-C 0.7%
Other 1.9%