From bd7ae44737dd77f2d39a6ec5e33144869536d23e Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 16 Aug 2017 16:21:52 -0700 Subject: [PATCH] Allow infinity values in the Dart wrappers for Skia Canvas (flutter/engine#3985) Fixes https://github.com/flutter/flutter/issues/11586 --- engine/src/flutter/lib/ui/painting.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting.dart b/engine/src/flutter/lib/ui/painting.dart index d1b1a2ecab..25b7c1fefe 100644 --- a/engine/src/flutter/lib/ui/painting.dart +++ b/engine/src/flutter/lib/ui/painting.dart @@ -13,19 +13,25 @@ part of dart.ui; // would cause a crash. It is, however, acceptable for error messages to be much // less useful or correct in release mode than in debug mode. // -// Painting APIs will also warn about arguments representing NaN or infinite -// coordinates, which can not be rendered by Skia. +// Painting APIs will also warn about arguments representing NaN coordinates, +// which can not be rendered by Skia. bool _rectIsValid(Rect rect) { - return rect != null && rect.isFinite; + assert(rect != null, 'Rect argument was null.'); + assert(!rect._value.any((double value) => value.isNaN), 'Rect argument contained a NaN value.'); + return true; } bool _rrectIsValid(RRect rrect) { - return rrect != null && rrect.isFinite; + assert(rrect != null, 'RRect argument was null.'); + assert(!rrect._value.any((double value) => value.isNaN), 'RRect argument contained a NaN value.'); + return true; } bool _offsetIsValid(Offset offset) { - return offset != null && offset.isFinite; + assert(offset != null, 'Offset argument was null.'); + assert(!offset.dx.isNaN && !offset.dy.isNaN, 'Offset argument contained a NaN value.'); + return true; } Color _scaleAlpha(Color a, double factor) {