Avoid implicit conversions to floats in dart:ui (#40098)
Avoid implicit conversions to floats in dart:ui
diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter
index 06a1547..dd1c6b5 100644
--- a/ci/licenses_golden/licenses_flutter
+++ b/ci/licenses_golden/licenses_flutter
@@ -1644,6 +1644,7 @@
ORIGIN: ../../../flutter/lib/ui/experiments/scene.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/experiments/setup_hooks.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/experiments/ui.dart + ../../../flutter/LICENSE
+ORIGIN: ../../../flutter/lib/ui/floating_point.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/geometry.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/hash_codes.dart + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/lib/ui/hooks.dart + ../../../flutter/LICENSE
@@ -4186,6 +4187,7 @@
FILE: ../../../flutter/lib/ui/experiments/scene.dart
FILE: ../../../flutter/lib/ui/experiments/setup_hooks.dart
FILE: ../../../flutter/lib/ui/experiments/ui.dart
+FILE: ../../../flutter/lib/ui/floating_point.h
FILE: ../../../flutter/lib/ui/geometry.dart
FILE: ../../../flutter/lib/ui/hash_codes.dart
FILE: ../../../flutter/lib/ui/hooks.dart
diff --git a/display_list/dl_color.h b/display_list/dl_color.h
index c52a166..d926e58 100644
--- a/display_list/dl_color.h
+++ b/display_list/dl_color.h
@@ -84,7 +84,7 @@
bool operator!=(uint32_t const& other) const { return argb != other; }
private:
- static float toF(uint8_t comp) { return comp * (1.0 / 255); }
+ static float toF(uint8_t comp) { return comp * (1.0f / 255); }
static uint8_t toC(float fComp) { return round(fComp * 255); }
};
diff --git a/display_list/effects/dl_image_filter.h b/display_list/effects/dl_image_filter.h
index 70dcc30..6e6c68f 100644
--- a/display_list/effects/dl_image_filter.h
+++ b/display_list/effects/dl_image_filter.h
@@ -249,14 +249,14 @@
SkRect* map_local_bounds(const SkRect& input_bounds,
SkRect& output_bounds) const override {
- output_bounds = input_bounds.makeOutset(sigma_x_ * 3, sigma_y_ * 3);
+ output_bounds = input_bounds.makeOutset(sigma_x_ * 3.0f, sigma_y_ * 3.0f);
return &output_bounds;
}
SkIRect* map_device_bounds(const SkIRect& input_bounds,
const SkMatrix& ctm,
SkIRect& output_bounds) const override {
- return outset_device_bounds(input_bounds, sigma_x_ * 3.0, sigma_y_ * 3.0,
+ return outset_device_bounds(input_bounds, sigma_x_ * 3.0f, sigma_y_ * 3.0f,
ctm, output_bounds);
}
diff --git a/flow/embedded_views.h b/flow/embedded_views.h
index c23c12e..1654820 100644
--- a/flow/embedded_views.h
+++ b/flow/embedded_views.h
@@ -118,7 +118,7 @@
return *filter_mutation_;
}
const int& GetAlpha() const { return alpha_; }
- float GetAlphaFloat() const { return (alpha_ / 255.0); }
+ float GetAlphaFloat() const { return (alpha_ / 255.0f); }
bool operator==(const Mutator& other) const {
if (type_ != other.type_) {
diff --git a/flow/layers/opacity_layer.h b/flow/layers/opacity_layer.h
index 041efce..53dae89 100644
--- a/flow/layers/opacity_layer.h
+++ b/flow/layers/opacity_layer.h
@@ -45,7 +45,7 @@
children_can_accept_opacity_ = value;
}
- SkScalar opacity() const { return alpha_ * 1.0 / SK_AlphaOPAQUE; }
+ SkScalar opacity() const { return alpha_ * 1.0f / SK_AlphaOPAQUE; }
private:
SkAlpha alpha_;
diff --git a/impeller/geometry/color.h b/impeller/geometry/color.h
index 90a9c49..8faf9c0 100644
--- a/impeller/geometry/color.h
+++ b/impeller/geometry/color.h
@@ -91,16 +91,17 @@
: red(r), green(g), blue(b), alpha(a) {}
static constexpr Color MakeRGBA8(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
- return Color(static_cast<Scalar>(r) / 255, static_cast<Scalar>(g) / 255,
- static_cast<Scalar>(b) / 255, static_cast<Scalar>(a) / 255);
+ return Color(
+ static_cast<Scalar>(r) / 255.0f, static_cast<Scalar>(g) / 255.0f,
+ static_cast<Scalar>(b) / 255.0f, static_cast<Scalar>(a) / 255.0f);
}
/// @brief Convert this color to a 32-bit representation.
static constexpr uint32_t ToIColor(Color color) {
- return (((std::lround(color.alpha * 255) & 0xff) << 24) |
- ((std::lround(color.red * 255) & 0xff) << 16) |
- ((std::lround(color.green * 255) & 0xff) << 8) |
- ((std::lround(color.blue * 255) & 0xff) << 0)) &
+ return (((std::lround(color.alpha * 255.0f) & 0xff) << 24) |
+ ((std::lround(color.red * 255.0f) & 0xff) << 16) |
+ ((std::lround(color.green * 255.0f) & 0xff) << 8) |
+ ((std::lround(color.blue * 255.0f) & 0xff) << 0)) &
0xFFFFFFFF;
}
@@ -114,7 +115,7 @@
}
constexpr Color Unpremultiply() const {
- if (ScalarNearlyEqual(alpha, 0.0)) {
+ if (ScalarNearlyEqual(alpha, 0.0f)) {
return Color::BlackTransparent();
}
return {red / alpha, green / alpha, blue / alpha, alpha};
@@ -126,11 +127,11 @@
*
* @param a The lower color.
* @param b The upper color.
- * @param t A value between 0.0 and 1.0, inclusive.
+ * @param t A value between 0.0f and 1.0f, inclusive.
* @return constexpr Color
*/
constexpr static Color lerp(Color a, Color b, Scalar t) {
- Scalar tt = 1.0 - t;
+ Scalar tt = 1.0f - t;
return {a.red * tt + b.red * t, a.green * tt + b.green * t,
a.blue * tt + b.blue * t, a.alpha * tt + b.alpha * t};
}
@@ -141,605 +142,605 @@
* @return constexpr std::array<u_int8, 4>
*/
constexpr std::array<uint8_t, 4> ToR8G8B8A8() const {
- uint8_t r = std::round(red * 255);
- uint8_t g = std::round(green * 255);
- uint8_t b = std::round(blue * 255);
- uint8_t a = std::round(alpha * 255);
+ uint8_t r = std::round(red * 255.0f);
+ uint8_t g = std::round(green * 255.0f);
+ uint8_t b = std::round(blue * 255.0f);
+ uint8_t a = std::round(alpha * 255.0f);
return {r, g, b, a};
}
- static constexpr Color White() { return {1.0, 1.0, 1.0, 1.0}; }
+ static constexpr Color White() { return {1.0f, 1.0f, 1.0f, 1.0f}; }
- static constexpr Color Black() { return {0.0, 0.0, 0.0, 1.0}; }
+ static constexpr Color Black() { return {0.0f, 0.0f, 0.0f, 1.0f}; }
- static constexpr Color WhiteTransparent() { return {1.0, 1.0, 1.0, 0.0}; }
+ static constexpr Color WhiteTransparent() { return {1.0f, 1.0f, 1.0f, 0.0f}; }
- static constexpr Color BlackTransparent() { return {0.0, 0.0, 0.0, 0.0}; }
+ static constexpr Color BlackTransparent() { return {0.0f, 0.0f, 0.0f, 0.0f}; }
- static constexpr Color Red() { return {1.0, 0.0, 0.0, 1.0}; }
+ static constexpr Color Red() { return {1.0f, 0.0f, 0.0f, 1.0f}; }
- static constexpr Color Green() { return {0.0, 1.0, 0.0, 1.0}; }
+ static constexpr Color Green() { return {0.0f, 1.0f, 0.0f, 1.0f}; }
- static constexpr Color Blue() { return {0.0, 0.0, 1.0, 1.0}; }
+ static constexpr Color Blue() { return {0.0f, 0.0f, 1.0f, 1.0f}; }
constexpr Color WithAlpha(Scalar new_alpha) const {
return {red, green, blue, new_alpha};
}
static constexpr Color AliceBlue() {
- return {240.0 / 255.0, 248.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {240.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color AntiqueWhite() {
- return {250.0 / 255.0, 235.0 / 255.0, 215.0 / 255.0, 1.0};
+ return {250.0f / 255.0f, 235.0f / 255.0f, 215.0f / 255.0f, 1.0f};
}
static constexpr Color Aqua() {
- return {0.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color AquaMarine() {
- return {127.0 / 255.0, 255.0 / 255.0, 212.0 / 255.0, 1.0};
+ return {127.0f / 255.0f, 255.0f / 255.0f, 212.0f / 255.0f, 1.0f};
}
static constexpr Color Azure() {
- return {240.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {240.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color Beige() {
- return {245.0 / 255.0, 245.0 / 255.0, 220.0 / 255.0, 1.0};
+ return {245.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f, 1.0f};
}
static constexpr Color Bisque() {
- return {255.0 / 255.0, 228.0 / 255.0, 196.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 228.0f / 255.0f, 196.0f / 255.0f, 1.0f};
}
static constexpr Color BlanchedAlmond() {
- return {255.0 / 255.0, 235.0 / 255.0, 205.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 235.0f / 255.0f, 205.0f / 255.0f, 1.0f};
}
static constexpr Color BlueViolet() {
- return {138.0 / 255.0, 43.0 / 255.0, 226.0 / 255.0, 1.0};
+ return {138.0f / 255.0f, 43.0f / 255.0f, 226.0f / 255.0f, 1.0f};
}
static constexpr Color Brown() {
- return {165.0 / 255.0, 42.0 / 255.0, 42.0 / 255.0, 1.0};
+ return {165.0f / 255.0f, 42.0f / 255.0f, 42.0f / 255.0f, 1.0f};
}
static constexpr Color BurlyWood() {
- return {222.0 / 255.0, 184.0 / 255.0, 135.0 / 255.0, 1.0};
+ return {222.0f / 255.0f, 184.0f / 255.0f, 135.0f / 255.0f, 1.0f};
}
static constexpr Color CadetBlue() {
- return {95.0 / 255.0, 158.0 / 255.0, 160.0 / 255.0, 1.0};
+ return {95.0f / 255.0f, 158.0f / 255.0f, 160.0f / 255.0f, 1.0f};
}
static constexpr Color Chartreuse() {
- return {127.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {127.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color Chocolate() {
- return {210.0 / 255.0, 105.0 / 255.0, 30.0 / 255.0, 1.0};
+ return {210.0f / 255.0f, 105.0f / 255.0f, 30.0f / 255.0f, 1.0f};
}
static constexpr Color Coral() {
- return {255.0 / 255.0, 127.0 / 255.0, 80.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 127.0f / 255.0f, 80.0f / 255.0f, 1.0f};
}
static constexpr Color CornflowerBlue() {
- return {100.0 / 255.0, 149.0 / 255.0, 237.0 / 255.0, 1.0};
+ return {100.0f / 255.0f, 149.0f / 255.0f, 237.0f / 255.0f, 1.0f};
}
static constexpr Color Cornsilk() {
- return {255.0 / 255.0, 248.0 / 255.0, 220.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 248.0f / 255.0f, 220.0f / 255.0f, 1.0f};
}
static constexpr Color Crimson() {
- return {220.0 / 255.0, 20.0 / 255.0, 60.0 / 255.0, 1.0};
+ return {220.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, 1.0f};
}
static constexpr Color Cyan() {
- return {0.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color DarkBlue() {
- return {0.0 / 255.0, 0.0 / 255.0, 139.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
}
static constexpr Color DarkCyan() {
- return {0.0 / 255.0, 139.0 / 255.0, 139.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 139.0f / 255.0f, 139.0f / 255.0f, 1.0f};
}
static constexpr Color DarkGoldenrod() {
- return {184.0 / 255.0, 134.0 / 255.0, 11.0 / 255.0, 1.0};
+ return {184.0f / 255.0f, 134.0f / 255.0f, 11.0f / 255.0f, 1.0f};
}
static constexpr Color DarkGray() {
- return {169.0 / 255.0, 169.0 / 255.0, 169.0 / 255.0, 1.0};
+ return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
}
static constexpr Color DarkGreen() {
- return {0.0 / 255.0, 100.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 100.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color DarkGrey() {
- return {169.0 / 255.0, 169.0 / 255.0, 169.0 / 255.0, 1.0};
+ return {169.0f / 255.0f, 169.0f / 255.0f, 169.0f / 255.0f, 1.0f};
}
static constexpr Color DarkKhaki() {
- return {189.0 / 255.0, 183.0 / 255.0, 107.0 / 255.0, 1.0};
+ return {189.0f / 255.0f, 183.0f / 255.0f, 107.0f / 255.0f, 1.0f};
}
static constexpr Color DarkMagenta() {
- return {139.0 / 255.0, 0.0 / 255.0, 139.0 / 255.0, 1.0};
+ return {139.0f / 255.0f, 0.0f / 255.0f, 139.0f / 255.0f, 1.0f};
}
static constexpr Color DarkOliveGreen() {
- return {85.0 / 255.0, 107.0 / 255.0, 47.0 / 255.0, 1.0};
+ return {85.0f / 255.0f, 107.0f / 255.0f, 47.0f / 255.0f, 1.0f};
}
static constexpr Color DarkOrange() {
- return {255.0 / 255.0, 140.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 140.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color DarkOrchid() {
- return {153.0 / 255.0, 50.0 / 255.0, 204.0 / 255.0, 1.0};
+ return {153.0f / 255.0f, 50.0f / 255.0f, 204.0f / 255.0f, 1.0f};
}
static constexpr Color DarkRed() {
- return {139.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {139.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color DarkSalmon() {
- return {233.0 / 255.0, 150.0 / 255.0, 122.0 / 255.0, 1.0};
+ return {233.0f / 255.0f, 150.0f / 255.0f, 122.0f / 255.0f, 1.0f};
}
static constexpr Color DarkSeagreen() {
- return {143.0 / 255.0, 188.0 / 255.0, 143.0 / 255.0, 1.0};
+ return {143.0f / 255.0f, 188.0f / 255.0f, 143.0f / 255.0f, 1.0f};
}
static constexpr Color DarkSlateBlue() {
- return {72.0 / 255.0, 61.0 / 255.0, 139.0 / 255.0, 1.0};
+ return {72.0f / 255.0f, 61.0f / 255.0f, 139.0f / 255.0f, 1.0f};
}
static constexpr Color DarkSlateGray() {
- return {47.0 / 255.0, 79.0 / 255.0, 79.0 / 255.0, 1.0};
+ return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
}
static constexpr Color DarkSlateGrey() {
- return {47.0 / 255.0, 79.0 / 255.0, 79.0 / 255.0, 1.0};
+ return {47.0f / 255.0f, 79.0f / 255.0f, 79.0f / 255.0f, 1.0f};
}
static constexpr Color DarkTurquoise() {
- return {0.0 / 255.0, 206.0 / 255.0, 209.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 206.0f / 255.0f, 209.0f / 255.0f, 1.0f};
}
static constexpr Color DarkViolet() {
- return {148.0 / 255.0, 0.0 / 255.0, 211.0 / 255.0, 1.0};
+ return {148.0f / 255.0f, 0.0f / 255.0f, 211.0f / 255.0f, 1.0f};
}
static constexpr Color DeepPink() {
- return {255.0 / 255.0, 20.0 / 255.0, 147.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 20.0f / 255.0f, 147.0f / 255.0f, 1.0f};
}
static constexpr Color DeepSkyBlue() {
- return {0.0 / 255.0, 191.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 191.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color DimGray() {
- return {105.0 / 255.0, 105.0 / 255.0, 105.0 / 255.0, 1.0};
+ return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
}
static constexpr Color DimGrey() {
- return {105.0 / 255.0, 105.0 / 255.0, 105.0 / 255.0, 1.0};
+ return {105.0f / 255.0f, 105.0f / 255.0f, 105.0f / 255.0f, 1.0f};
}
static constexpr Color DodgerBlue() {
- return {30.0 / 255.0, 144.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {30.0f / 255.0f, 144.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color Firebrick() {
- return {178.0 / 255.0, 34.0 / 255.0, 34.0 / 255.0, 1.0};
+ return {178.0f / 255.0f, 34.0f / 255.0f, 34.0f / 255.0f, 1.0f};
}
static constexpr Color FloralWhite() {
- return {255.0 / 255.0, 250.0 / 255.0, 240.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 250.0f / 255.0f, 240.0f / 255.0f, 1.0f};
}
static constexpr Color ForestGreen() {
- return {34.0 / 255.0, 139.0 / 255.0, 34.0 / 255.0, 1.0};
+ return {34.0f / 255.0f, 139.0f / 255.0f, 34.0f / 255.0f, 1.0f};
}
static constexpr Color Fuchsia() {
- return {255.0 / 255.0, 0.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color Gainsboro() {
- return {220.0 / 255.0, 220.0 / 255.0, 220.0 / 255.0, 1.0};
+ return {220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f, 1.0f};
}
static constexpr Color Ghostwhite() {
- return {248.0 / 255.0, 248.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {248.0f / 255.0f, 248.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color Gold() {
- return {255.0 / 255.0, 215.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 215.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color Goldenrod() {
- return {218.0 / 255.0, 165.0 / 255.0, 32.0 / 255.0, 1.0};
+ return {218.0f / 255.0f, 165.0f / 255.0f, 32.0f / 255.0f, 1.0f};
}
static constexpr Color Gray() {
- return {128.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 1.0};
+ return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
}
static constexpr Color GreenYellow() {
- return {173.0 / 255.0, 255.0 / 255.0, 47.0 / 255.0, 1.0};
+ return {173.0f / 255.0f, 255.0f / 255.0f, 47.0f / 255.0f, 1.0f};
}
static constexpr Color Grey() {
- return {128.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 1.0};
+ return {128.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
}
static constexpr Color Honeydew() {
- return {240.0 / 255.0, 255.0 / 255.0, 240.0 / 255.0, 1.0};
+ return {240.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
}
static constexpr Color HotPink() {
- return {255.0 / 255.0, 105.0 / 255.0, 180.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 105.0f / 255.0f, 180.0f / 255.0f, 1.0f};
}
static constexpr Color IndianRed() {
- return {205.0 / 255.0, 92.0 / 255.0, 92.0 / 255.0, 1.0};
+ return {205.0f / 255.0f, 92.0f / 255.0f, 92.0f / 255.0f, 1.0f};
}
static constexpr Color Indigo() {
- return {75.0 / 255.0, 0.0 / 255.0, 130.0 / 255.0, 1.0};
+ return {75.0f / 255.0f, 0.0f / 255.0f, 130.0f / 255.0f, 1.0f};
}
static constexpr Color Ivory() {
- return {255.0 / 255.0, 255.0 / 255.0, 240.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 255.0f / 255.0f, 240.0f / 255.0f, 1.0f};
}
static constexpr Color Khaki() {
- return {240.0 / 255.0, 230.0 / 255.0, 140.0 / 255.0, 1.0};
+ return {240.0f / 255.0f, 230.0f / 255.0f, 140.0f / 255.0f, 1.0f};
}
static constexpr Color Lavender() {
- return {230.0 / 255.0, 230.0 / 255.0, 250.0 / 255.0, 1.0};
+ return {230.0f / 255.0f, 230.0f / 255.0f, 250.0f / 255.0f, 1.0f};
}
static constexpr Color LavenderBlush() {
- return {255.0 / 255.0, 240.0 / 255.0, 245.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 240.0f / 255.0f, 245.0f / 255.0f, 1.0f};
}
static constexpr Color LawnGreen() {
- return {124.0 / 255.0, 252.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {124.0f / 255.0f, 252.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color LemonChiffon() {
- return {255.0 / 255.0, 250.0 / 255.0, 205.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 250.0f / 255.0f, 205.0f / 255.0f, 1.0f};
}
static constexpr Color LightBlue() {
- return {173.0 / 255.0, 216.0 / 255.0, 230.0 / 255.0, 1.0};
+ return {173.0f / 255.0f, 216.0f / 255.0f, 230.0f / 255.0f, 1.0f};
}
static constexpr Color LightCoral() {
- return {240.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 1.0};
+ return {240.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
}
static constexpr Color LightCyan() {
- return {224.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {224.0f / 255.0f, 255.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color LightGoldenrodYellow() {
- return {50.0 / 255.0, 250.0 / 255.0, 210.0 / 255.0, 1.0};
+ return {50.0f / 255.0f, 250.0f / 255.0f, 210.0f / 255.0f, 1.0f};
}
static constexpr Color LightGray() {
- return {211.0 / 255.0, 211.0 / 255.0, 211.0 / 255.0, 1.0};
+ return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
}
static constexpr Color LightGreen() {
- return {144.0 / 255.0, 238.0 / 255.0, 144.0 / 255.0, 1.0};
+ return {144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, 1.0f};
}
static constexpr Color LightGrey() {
- return {211.0 / 255.0, 211.0 / 255.0, 211.0 / 255.0, 1.0};
+ return {211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f};
}
static constexpr Color LightPink() {
- return {255.0 / 255.0, 182.0 / 255.0, 193.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 182.0f / 255.0f, 193.0f / 255.0f, 1.0f};
}
static constexpr Color LightSalmon() {
- return {255.0 / 255.0, 160.0 / 255.0, 122.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 160.0f / 255.0f, 122.0f / 255.0f, 1.0f};
}
static constexpr Color LightSeaGreen() {
- return {32.0 / 255.0, 178.0 / 255.0, 170.0 / 255.0, 1.0};
+ return {32.0f / 255.0f, 178.0f / 255.0f, 170.0f / 255.0f, 1.0f};
}
static constexpr Color LightSkyBlue() {
- return {135.0 / 255.0, 206.0 / 255.0, 250.0 / 255.0, 1.0};
+ return {135.0f / 255.0f, 206.0f / 255.0f, 250.0f / 255.0f, 1.0f};
}
static constexpr Color LightSlateGray() {
- return {119.0 / 255.0, 136.0 / 255.0, 153.0 / 255.0, 1.0};
+ return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
}
static constexpr Color LightSlateGrey() {
- return {119.0 / 255.0, 136.0 / 255.0, 153.0 / 255.0, 1.0};
+ return {119.0f / 255.0f, 136.0f / 255.0f, 153.0f / 255.0f, 1.0f};
}
static constexpr Color LightSteelBlue() {
- return {176.0 / 255.0, 196.0 / 255.0, 222.0 / 255.0, 1.0};
+ return {176.0f / 255.0f, 196.0f / 255.0f, 222.0f / 255.0f, 1.0f};
}
static constexpr Color LightYellow() {
- return {255.0 / 255.0, 255.0 / 255.0, 224.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 255.0f / 255.0f, 224.0f / 255.0f, 1.0f};
}
static constexpr Color Lime() {
- return {0.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color LimeGreen() {
- return {50.0 / 255.0, 205.0 / 255.0, 50.0 / 255.0, 1.0};
+ return {50.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
}
static constexpr Color Linen() {
- return {250.0 / 255.0, 240.0 / 255.0, 230.0 / 255.0, 1.0};
+ return {250.0f / 255.0f, 240.0f / 255.0f, 230.0f / 255.0f, 1.0f};
}
static constexpr Color Magenta() {
- return {255.0 / 255.0, 0.0 / 255.0, 255.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 0.0f / 255.0f, 255.0f / 255.0f, 1.0f};
}
static constexpr Color Maroon() {
- return {128.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {128.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color MediumAquamarine() {
- return {102.0 / 255.0, 205.0 / 255.0, 170.0 / 255.0, 1.0};
+ return {102.0f / 255.0f, 205.0f / 255.0f, 170.0f / 255.0f, 1.0f};
}
static constexpr Color MediumBlue() {
- return {0.0 / 255.0, 0.0 / 255.0, 205.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 0.0f / 255.0f, 205.0f / 255.0f, 1.0f};
}
static constexpr Color MediumOrchid() {
- return {186.0 / 255.0, 85.0 / 255.0, 211.0 / 255.0, 1.0};
+ return {186.0f / 255.0f, 85.0f / 255.0f, 211.0f / 255.0f, 1.0f};
}
static constexpr Color MediumPurple() {
- return {147.0 / 255.0, 112.0 / 255.0, 219.0 / 255.0, 1.0};
+ return {147.0f / 255.0f, 112.0f / 255.0f, 219.0f / 255.0f, 1.0f};
}
static constexpr Color MediumSeagreen() {
- return {60.0 / 255.0, 179.0 / 255.0, 113.0 / 255.0, 1.0};
+ return {60.0f / 255.0f, 179.0f / 255.0f, 113.0f / 255.0f, 1.0f};
}
static constexpr Color MediumSlateBlue() {
- return {123.0 / 255.0, 104.0 / 255.0, 238.0 / 255.0, 1.0};
+ return {123.0f / 255.0f, 104.0f / 255.0f, 238.0f / 255.0f, 1.0f};
}
static constexpr Color MediumSpringGreen() {
- return {0.0 / 255.0, 250.0 / 255.0, 154.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 250.0f / 255.0f, 154.0f / 255.0f, 1.0f};
}
static constexpr Color MediumTurquoise() {
- return {72.0 / 255.0, 209.0 / 255.0, 204.0 / 255.0, 1.0};
+ return {72.0f / 255.0f, 209.0f / 255.0f, 204.0f / 255.0f, 1.0f};
}
static constexpr Color MediumVioletRed() {
- return {199.0 / 255.0, 21.0 / 255.0, 133.0 / 255.0, 1.0};
+ return {199.0f / 255.0f, 21.0f / 255.0f, 133.0f / 255.0f, 1.0f};
}
static constexpr Color MidnightBlue() {
- return {25.0 / 255.0, 25.0 / 255.0, 112.0 / 255.0, 1.0};
+ return {25.0f / 255.0f, 25.0f / 255.0f, 112.0f / 255.0f, 1.0f};
}
static constexpr Color MintCream() {
- return {245.0 / 255.0, 255.0 / 255.0, 250.0 / 255.0, 1.0};
+ return {245.0f / 255.0f, 255.0f / 255.0f, 250.0f / 255.0f, 1.0f};
}
static constexpr Color MistyRose() {
- return {255.0 / 255.0, 228.0 / 255.0, 225.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 228.0f / 255.0f, 225.0f / 255.0f, 1.0f};
}
static constexpr Color Moccasin() {
- return {255.0 / 255.0, 228.0 / 255.0, 181.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 228.0f / 255.0f, 181.0f / 255.0f, 1.0f};
}
static constexpr Color NavajoWhite() {
- return {255.0 / 255.0, 222.0 / 255.0, 173.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 222.0f / 255.0f, 173.0f / 255.0f, 1.0f};
}
static constexpr Color Navy() {
- return {0.0 / 255.0, 0.0 / 255.0, 128.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
}
static constexpr Color OldLace() {
- return {253.0 / 255.0, 245.0 / 255.0, 230.0 / 255.0, 1.0};
+ return {253.0f / 255.0f, 245.0f / 255.0f, 230.0f / 255.0f, 1.0f};
}
static constexpr Color Olive() {
- return {128.0 / 255.0, 128.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {128.0f / 255.0f, 128.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color OliveDrab() {
- return {107.0 / 255.0, 142.0 / 255.0, 35.0 / 255.0, 1.0};
+ return {107.0f / 255.0f, 142.0f / 255.0f, 35.0f / 255.0f, 1.0f};
}
static constexpr Color Orange() {
- return {255.0 / 255.0, 165.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 165.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color OrangeRed() {
- return {255.0 / 255.0, 69.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 69.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color Orchid() {
- return {218.0 / 255.0, 112.0 / 255.0, 214.0 / 255.0, 1.0};
+ return {218.0f / 255.0f, 112.0f / 255.0f, 214.0f / 255.0f, 1.0f};
}
static constexpr Color PaleGoldenrod() {
- return {238.0 / 255.0, 232.0 / 255.0, 170.0 / 255.0, 1.0};
+ return {238.0f / 255.0f, 232.0f / 255.0f, 170.0f / 255.0f, 1.0f};
}
static constexpr Color PaleGreen() {
- return {152.0 / 255.0, 251.0 / 255.0, 152.0 / 255.0, 1.0};
+ return {152.0f / 255.0f, 251.0f / 255.0f, 152.0f / 255.0f, 1.0f};
}
static constexpr Color PaleTurquoise() {
- return {175.0 / 255.0, 238.0 / 255.0, 238.0 / 255.0, 1.0};
+ return {175.0f / 255.0f, 238.0f / 255.0f, 238.0f / 255.0f, 1.0f};
}
static constexpr Color PaleVioletRed() {
- return {219.0 / 255.0, 112.0 / 255.0, 147.0 / 255.0, 1.0};
+ return {219.0f / 255.0f, 112.0f / 255.0f, 147.0f / 255.0f, 1.0f};
}
static constexpr Color PapayaWhip() {
- return {255.0 / 255.0, 239.0 / 255.0, 213.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 239.0f / 255.0f, 213.0f / 255.0f, 1.0f};
}
static constexpr Color Peachpuff() {
- return {255.0 / 255.0, 218.0 / 255.0, 185.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 218.0f / 255.0f, 185.0f / 255.0f, 1.0f};
}
static constexpr Color Peru() {
- return {205.0 / 255.0, 133.0 / 255.0, 63.0 / 255.0, 1.0};
+ return {205.0f / 255.0f, 133.0f / 255.0f, 63.0f / 255.0f, 1.0f};
}
static constexpr Color Pink() {
- return {255.0 / 255.0, 192.0 / 255.0, 203.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 192.0f / 255.0f, 203.0f / 255.0f, 1.0f};
}
static constexpr Color Plum() {
- return {221.0 / 255.0, 160.0 / 255.0, 221.0 / 255.0, 1.0};
+ return {221.0f / 255.0f, 160.0f / 255.0f, 221.0f / 255.0f, 1.0f};
}
static constexpr Color PowderBlue() {
- return {176.0 / 255.0, 224.0 / 255.0, 230.0 / 255.0, 1.0};
+ return {176.0f / 255.0f, 224.0f / 255.0f, 230.0f / 255.0f, 1.0f};
}
static constexpr Color Purple() {
- return {128.0 / 255.0, 0.0 / 255.0, 128.0 / 255.0, 1.0};
+ return {128.0f / 255.0f, 0.0f / 255.0f, 128.0f / 255.0f, 1.0f};
}
static constexpr Color RosyBrown() {
- return {188.0 / 255.0, 143.0 / 255.0, 143.0 / 255.0, 1.0};
+ return {188.0f / 255.0f, 143.0f / 255.0f, 143.0f / 255.0f, 1.0f};
}
static constexpr Color RoyalBlue() {
- return {65.0 / 255.0, 105.0 / 255.0, 225.0 / 255.0, 1.0};
+ return {65.0f / 255.0f, 105.0f / 255.0f, 225.0f / 255.0f, 1.0f};
}
static constexpr Color SaddleBrown() {
- return {139.0 / 255.0, 69.0 / 255.0, 19.0 / 255.0, 1.0};
+ return {139.0f / 255.0f, 69.0f / 255.0f, 19.0f / 255.0f, 1.0f};
}
static constexpr Color Salmon() {
- return {250.0 / 255.0, 128.0 / 255.0, 114.0 / 255.0, 1.0};
+ return {250.0f / 255.0f, 128.0f / 255.0f, 114.0f / 255.0f, 1.0f};
}
static constexpr Color SandyBrown() {
- return {244.0 / 255.0, 164.0 / 255.0, 96.0 / 255.0, 1.0};
+ return {244.0f / 255.0f, 164.0f / 255.0f, 96.0f / 255.0f, 1.0f};
}
static constexpr Color Seagreen() {
- return {46.0 / 255.0, 139.0 / 255.0, 87.0 / 255.0, 1.0};
+ return {46.0f / 255.0f, 139.0f / 255.0f, 87.0f / 255.0f, 1.0f};
}
static constexpr Color Seashell() {
- return {255.0 / 255.0, 245.0 / 255.0, 238.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 245.0f / 255.0f, 238.0f / 255.0f, 1.0f};
}
static constexpr Color Sienna() {
- return {160.0 / 255.0, 82.0 / 255.0, 45.0 / 255.0, 1.0};
+ return {160.0f / 255.0f, 82.0f / 255.0f, 45.0f / 255.0f, 1.0f};
}
static constexpr Color Silver() {
- return {192.0 / 255.0, 192.0 / 255.0, 192.0 / 255.0, 1.0};
+ return {192.0f / 255.0f, 192.0f / 255.0f, 192.0f / 255.0f, 1.0f};
}
static constexpr Color SkyBlue() {
- return {135.0 / 255.0, 206.0 / 255.0, 235.0 / 255.0, 1.0};
+ return {135.0f / 255.0f, 206.0f / 255.0f, 235.0f / 255.0f, 1.0f};
}
static constexpr Color SlateBlue() {
- return {106.0 / 255.0, 90.0 / 255.0, 205.0 / 255.0, 1.0};
+ return {106.0f / 255.0f, 90.0f / 255.0f, 205.0f / 255.0f, 1.0f};
}
static constexpr Color SlateGray() {
- return {112.0 / 255.0, 128.0 / 255.0, 144.0 / 255.0, 1.0};
+ return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
}
static constexpr Color SlateGrey() {
- return {112.0 / 255.0, 128.0 / 255.0, 144.0 / 255.0, 1.0};
+ return {112.0f / 255.0f, 128.0f / 255.0f, 144.0f / 255.0f, 1.0f};
}
static constexpr Color Snow() {
- return {255.0 / 255.0, 250.0 / 255.0, 250.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 250.0f / 255.0f, 250.0f / 255.0f, 1.0f};
}
static constexpr Color SpringGreen() {
- return {0.0 / 255.0, 255.0 / 255.0, 127.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 255.0f / 255.0f, 127.0f / 255.0f, 1.0f};
}
static constexpr Color SteelBlue() {
- return {70.0 / 255.0, 130.0 / 255.0, 180.0 / 255.0, 1.0};
+ return {70.0f / 255.0f, 130.0f / 255.0f, 180.0f / 255.0f, 1.0f};
}
static constexpr Color Tan() {
- return {210.0 / 255.0, 180.0 / 255.0, 140.0 / 255.0, 1.0};
+ return {210.0f / 255.0f, 180.0f / 255.0f, 140.0f / 255.0f, 1.0f};
}
static constexpr Color Teal() {
- return {0.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0, 1.0};
+ return {0.0f / 255.0f, 128.0f / 255.0f, 128.0f / 255.0f, 1.0f};
}
static constexpr Color Thistle() {
- return {216.0 / 255.0, 191.0 / 255.0, 216.0 / 255.0, 1.0};
+ return {216.0f / 255.0f, 191.0f / 255.0f, 216.0f / 255.0f, 1.0f};
}
static constexpr Color Tomato() {
- return {255.0 / 255.0, 99.0 / 255.0, 71.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 99.0f / 255.0f, 71.0f / 255.0f, 1.0f};
}
static constexpr Color Turquoise() {
- return {64.0 / 255.0, 224.0 / 255.0, 208.0 / 255.0, 1.0};
+ return {64.0f / 255.0f, 224.0f / 255.0f, 208.0f / 255.0f, 1.0f};
}
static constexpr Color Violet() {
- return {238.0 / 255.0, 130.0 / 255.0, 238.0 / 255.0, 1.0};
+ return {238.0f / 255.0f, 130.0f / 255.0f, 238.0f / 255.0f, 1.0f};
}
static constexpr Color Wheat() {
- return {245.0 / 255.0, 222.0 / 255.0, 179.0 / 255.0, 1.0};
+ return {245.0f / 255.0f, 222.0f / 255.0f, 179.0f / 255.0f, 1.0f};
}
static constexpr Color Whitesmoke() {
- return {245.0 / 255.0, 245.0 / 255.0, 245.0 / 255.0, 1.0};
+ return {245.0f / 255.0f, 245.0f / 255.0f, 245.0f / 255.0f, 1.0f};
}
static constexpr Color Yellow() {
- return {255.0 / 255.0, 255.0 / 255.0, 0.0 / 255.0, 1.0};
+ return {255.0f / 255.0f, 255.0f / 255.0f, 0.0f / 255.0f, 1.0f};
}
static constexpr Color YellowGreen() {
- return {154.0 / 255.0, 205.0 / 255.0, 50.0 / 255.0, 1.0};
+ return {154.0f / 255.0f, 205.0f / 255.0f, 50.0f / 255.0f, 1.0f};
}
static Color Random() {
return {
- static_cast<Scalar>((std::rand() % 255) / 255.0), //
- static_cast<Scalar>((std::rand() % 255) / 255.0), //
- static_cast<Scalar>((std::rand() % 255) / 255.0), //
- 1.0 //
+ static_cast<Scalar>((std::rand() % 255) / 255.0f), //
+ static_cast<Scalar>((std::rand() % 255) / 255.0f), //
+ static_cast<Scalar>((std::rand() % 255) / 255.0f), //
+ 1.0f //
};
}
@@ -757,9 +758,9 @@
Color operator*(Scalar value) const;
- constexpr bool IsTransparent() const { return alpha == 0.0; }
+ constexpr bool IsTransparent() const { return alpha == 0.0f; }
- constexpr bool IsOpaque() const { return alpha == 1.0; }
+ constexpr bool IsOpaque() const { return alpha == 1.0f; }
};
/**
diff --git a/impeller/geometry/constants.h b/impeller/geometry/constants.h
index 5e775b5..f475807 100644
--- a/impeller/geometry/constants.h
+++ b/impeller/geometry/constants.h
@@ -7,51 +7,51 @@
namespace impeller {
// e
-constexpr float kE = 2.7182818284590452354;
+constexpr float kE = 2.7182818284590452354f;
// log_2 e
-constexpr float kLog2_E = 1.4426950408889634074;
+constexpr float kLog2_E = 1.4426950408889634074f;
// log_10 e
-constexpr float kLog10_E = 0.43429448190325182765;
+constexpr float kLog10_E = 0.43429448190325182765f;
// log_e 2
-constexpr float klogE_2 = 0.69314718055994530942;
+constexpr float klogE_2 = 0.69314718055994530942f;
// log_e 10
-constexpr float klogE_10 = 2.30258509299404568402;
+constexpr float klogE_10 = 2.30258509299404568402f;
// pi
-constexpr float kPi = 3.14159265358979323846;
+constexpr float kPi = 3.14159265358979323846f;
// pi*2
-constexpr float k2Pi = 6.28318530717958647693;
+constexpr float k2Pi = 6.28318530717958647693f;
// pi/2
-constexpr float kPiOver2 = 1.57079632679489661923;
+constexpr float kPiOver2 = 1.57079632679489661923f;
// pi/4
-constexpr float kPiOver4 = 0.78539816339744830962;
+constexpr float kPiOver4 = 0.78539816339744830962f;
// 1/pi
-constexpr float k1OverPi = 0.31830988618379067154;
+constexpr float k1OverPi = 0.31830988618379067154f;
// 2/pi
-constexpr float k2OverPi = 0.63661977236758134308;
+constexpr float k2OverPi = 0.63661977236758134308f;
// 2/sqrt(pi)
-constexpr float k2OverSqrtPi = 1.12837916709551257390;
+constexpr float k2OverSqrtPi = 1.12837916709551257390f;
// sqrt(2)
-constexpr float kSqrt2 = 1.41421356237309504880;
+constexpr float kSqrt2 = 1.41421356237309504880f;
// 1/sqrt(2)
-constexpr float k1OverSqrt2 = 0.70710678118654752440;
+constexpr float k1OverSqrt2 = 0.70710678118654752440f;
// phi
-constexpr float kPhi = 1.61803398874989484820;
+constexpr float kPhi = 1.61803398874989484820f;
// 0.001
-constexpr float kEhCloseEnough = 1e-3;
+constexpr float kEhCloseEnough = 1e-3f;
} // namespace impeller
diff --git a/impeller/geometry/matrix.h b/impeller/geometry/matrix.h
index 6468882..d30d803 100644
--- a/impeller/geometry/matrix.h
+++ b/impeller/geometry/matrix.h
@@ -28,11 +28,11 @@
/// device coordinates must use the following convention:
/// * Left-handed coordinate system. Positive rotation is
/// clockwise about axis of rotation.
-/// * Lower left corner is -1.0, -1.0.
-/// * Upper right corner is 1.0, 1.0.
+/// * Lower left corner is -1.0f, -1.0.
+/// * Upper right corner is 1.0f, 1.0.
/// * Visible z-space is from 0.0 to 1.0.
/// * This is NOT the same as OpenGL! Be careful.
-/// * NDC origin is at (0.0, 0.0, 0.5).
+/// * NDC origin is at (0.0f, 0.0f, 0.5f).
struct Matrix {
union {
Scalar m[16];
@@ -45,10 +45,10 @@
///
constexpr Matrix()
// clang-format off
- : vec{ Vector4(1.0, 0.0, 0.0, 0.0),
- Vector4(0.0, 1.0, 0.0, 0.0),
- Vector4(0.0, 0.0, 1.0, 0.0),
- Vector4(0.0, 0.0, 0.0, 1.0)} {}
+ : vec{ Vector4(1.0f, 0.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 1.0f, 0.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 1.0f, 0.0f),
+ Vector4(0.0f, 0.0f, 0.0f, 1.0f)} {}
// clang-format on
// clang-format off
@@ -93,57 +93,57 @@
static constexpr Matrix MakeTranslation(const Vector3& t) {
// clang-format off
- return Matrix(1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- t.x, t.y, t.z, 1.0);
+ return Matrix(1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ t.x, t.y, t.z, 1.0f);
// clang-format on
}
static constexpr Matrix MakeScale(const Vector3& s) {
// clang-format off
- return Matrix(s.x, 0.0, 0.0, 0.0,
- 0.0, s.y, 0.0, 0.0,
- 0.0, 0.0, s.z, 0.0,
- 0.0, 0.0, 0.0, 1.0);
+ return Matrix(s.x, 0.0f, 0.0f, 0.0f,
+ 0.0f, s.y, 0.0f, 0.0f,
+ 0.0f, 0.0f, s.z, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f);
// clang-format on
}
static constexpr Matrix MakeScale(const Vector2& s) {
- return MakeScale(Vector3(s.x, s.y, 1.0));
+ return MakeScale(Vector3(s.x, s.y, 1.0f));
}
static constexpr Matrix MakeSkew(Scalar sx, Scalar sy) {
// clang-format off
- return Matrix(1.0, sy , 0.0, 0.0,
- sx , 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0);
+ return Matrix(1.0f, sy , 0.0f, 0.0f,
+ sx , 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f);
// clang-format on
}
static Matrix MakeRotation(Quaternion q) {
// clang-format off
return Matrix(
- 1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z,
- 2.0 * q.x * q.y + 2.0 * q.z * q.w,
- 2.0 * q.x * q.z - 2.0 * q.y * q.w,
- 0.0,
+ 1.0f - 2.0f * q.y * q.y - 2.0f * q.z * q.z,
+ 2.0f * q.x * q.y + 2.0f * q.z * q.w,
+ 2.0f * q.x * q.z - 2.0f * q.y * q.w,
+ 0.0f,
- 2.0 * q.x * q.y - 2.0 * q.z * q.w,
- 1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z,
- 2.0 * q.y * q.z + 2.0 * q.x * q.w,
- 0.0,
+ 2.0f * q.x * q.y - 2.0f * q.z * q.w,
+ 1.0f - 2.0f * q.x * q.x - 2.0f * q.z * q.z,
+ 2.0f * q.y * q.z + 2.0f * q.x * q.w,
+ 0.0f,
- 2.0 * q.x * q.z + 2.0 * q.y * q.w,
- 2.0 * q.y * q.z - 2.0 * q.x * q.w,
- 1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y,
- 0.0,
+ 2.0f * q.x * q.z + 2.0f * q.y * q.w,
+ 2.0f * q.y * q.z - 2.0f * q.x * q.w,
+ 1.0f - 2.0f * q.x * q.x - 2.0f * q.y * q.y,
+ 0.0f,
- 0.0,
- 0.0,
- 0.0,
- 1.0);
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ 1.0f);
// clang-format on
}
@@ -159,22 +159,22 @@
cosine + cosp * v.x * v.x,
cosp * v.x * v.y + v.z * sine,
cosp * v.x * v.z - v.y * sine,
- 0.0,
+ 0.0f,
cosp * v.x * v.y - v.z * sine,
cosine + cosp * v.y * v.y,
cosp * v.y * v.z + v.x * sine,
- 0.0,
+ 0.0f,
cosp * v.x * v.z + v.y * sine,
cosp * v.y * v.z - v.x * sine,
cosine + cosp * v.z * v.z,
- 0.0,
+ 0.0f,
- 0.0,
- 0.0,
- 0.0,
- 1.0);
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ 1.0f);
// clang-format on
}
@@ -183,10 +183,10 @@
const Scalar sine = sin(r.radians);
// clang-format off
return Matrix(
- 1.0, 0.0, 0.0, 0.0,
- 0.0, cosine, sine, 0.0,
- 0.0, -sine, cosine, 0.0,
- 0.0, 0.0, 0.0, 1.0
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, cosine, sine, 0.0f,
+ 0.0f, -sine, cosine, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
);
// clang-format on
}
@@ -197,10 +197,10 @@
// clang-format off
return Matrix(
- cosine, 0.0, -sine, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- sine, 0.0, cosine, 0.0,
- 0.0, 0.0, 0.0, 1.0
+ cosine, 0.0f, -sine, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ sine, 0.0f, cosine, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f
);
// clang-format on
}
@@ -211,10 +211,10 @@
// clang-format off
return Matrix (
- cosine, sine, 0.0, 0.0,
- -sine, cosine, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
+ cosine, sine, 0.0f, 0.0f,
+ -sine, cosine, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0
);
// clang-format on
}
@@ -222,10 +222,10 @@
constexpr Matrix Basis() const {
// clang-format off
return Matrix(
- m[0], m[1], m[2], 0.0,
- m[4], m[5], m[6], 0.0,
- m[8], m[9], m[10], 0.0,
- 0.0, 0.0, 0.0, 1.0
+ m[0], m[1], m[2], 0.0f,
+ m[4], m[5], m[6], 0.0f,
+ m[8], m[9], m[10], 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0
);
// clang-format on
}
@@ -302,7 +302,7 @@
}
constexpr Scalar GetDirectionScale(Vector3 direction) const {
- return 1.0 / (this->Basis().Invert() * direction.Normalize()).Length() *
+ return 1.0f / (this->Basis().Invert() * direction.Normalize()).Length() *
direction.Length();
}
@@ -339,10 +339,10 @@
constexpr bool IsIdentity() const {
return (
// clang-format off
- m[0] == 1.0 && m[1] == 0.0 && m[2] == 0.0 && m[3] == 0.0 &&
- m[4] == 0.0 && m[5] == 1.0 && m[6] == 0.0 && m[7] == 0.0 &&
- m[8] == 0.0 && m[9] == 0.0 && m[10] == 1.0 && m[11] == 0.0 &&
- m[12] == 0.0 && m[13] == 0.0 && m[14] == 0.0 && m[15] == 1.0
+ m[0] == 1.0f && m[1] == 0.0f && m[2] == 0.0f && m[3] == 0.0f &&
+ m[4] == 0.0f && m[5] == 1.0f && m[6] == 0.0f && m[7] == 0.0f &&
+ m[8] == 0.0f && m[9] == 0.0f && m[10] == 1.0f && m[11] == 0.0f &&
+ m[12] == 0.0f && m[13] == 0.0f && m[14] == 0.0f && m[15] == 1.0f
// clang-format on
);
}
@@ -443,8 +443,8 @@
// Per assumptions about NDC documented above.
const auto scale =
MakeScale({2.0f / static_cast<Scalar>(size.width),
- -2.0f / static_cast<Scalar>(size.height), 0.0});
- const auto translate = MakeTranslation({-1.0, 1.0, 0.5});
+ -2.0f / static_cast<Scalar>(size.height), 0.0f});
+ const auto translate = MakeTranslation({-1.0f, 1.0f, 0.5f});
return translate * scale;
}
@@ -452,7 +452,7 @@
Scalar aspect_ratio,
Scalar z_near,
Scalar z_far) {
- Scalar height = std::tan(fov_y.radians * 0.5);
+ Scalar height = std::tan(fov_y.radians * 0.5f);
Scalar width = height * aspect_ratio;
// clang-format off
diff --git a/impeller/geometry/quaternion.h b/impeller/geometry/quaternion.h
index 0dacf04..3a57382 100644
--- a/impeller/geometry/quaternion.h
+++ b/impeller/geometry/quaternion.h
@@ -13,35 +13,35 @@
struct Quaternion {
union {
struct {
- double x = 0.0;
- double y = 0.0;
- double z = 0.0;
- double w = 1.0;
+ Scalar x = 0.0;
+ Scalar y = 0.0;
+ Scalar z = 0.0;
+ Scalar w = 1.0;
};
- double e[4];
+ Scalar e[4];
};
Quaternion() {}
- Quaternion(double px, double py, double pz, double pw)
+ Quaternion(Scalar px, Scalar py, Scalar pz, Scalar pw)
: x(px), y(py), z(pz), w(pw) {}
- Quaternion(const Vector3& axis, double angle) {
- const auto sine = sin(angle * 0.5);
+ Quaternion(const Vector3& axis, Scalar angle) {
+ const auto sine = sin(angle * 0.5f);
x = sine * axis.x;
y = sine * axis.y;
z = sine * axis.z;
- w = cos(angle * 0.5);
+ w = cos(angle * 0.5f);
}
- double Dot(const Quaternion& q) const {
+ Scalar Dot(const Quaternion& q) const {
return x * q.x + y * q.y + z * q.z + w * q.w;
}
- double Length() const { return sqrt(x * x + y * y + z * z + w * w); }
+ Scalar Length() const { return sqrt(x * x + y * y + z * z + w * w); }
Quaternion Normalize() const {
- auto m = 1.0 / Length();
+ auto m = 1.0f / Length();
return {x * m, y * m, z * m, w * m};
}
@@ -58,7 +58,7 @@
};
}
- Quaternion operator*(double scale) const {
+ Quaternion operator*(Scalar scale) const {
return {scale * x, scale * y, scale * z, scale * w};
}
diff --git a/impeller/geometry/vector.h b/impeller/geometry/vector.h
index 705a88c..ef83ce9 100644
--- a/impeller/geometry/vector.h
+++ b/impeller/geometry/vector.h
@@ -17,9 +17,9 @@
struct Vector3 {
union {
struct {
- Scalar x = 0.0;
- Scalar y = 0.0;
- Scalar z = 0.0;
+ Scalar x = 0.0f;
+ Scalar y = 0.0f;
+ Scalar z = 0.0f;
};
Scalar e[3];
};
@@ -207,10 +207,10 @@
struct Vector4 {
union {
struct {
- Scalar x = 0.0;
- Scalar y = 0.0;
- Scalar z = 0.0;
- Scalar w = 1.0;
+ Scalar x = 0.0f;
+ Scalar y = 0.0f;
+ Scalar z = 0.0f;
+ Scalar w = 1.0f;
};
Scalar e[4];
};
@@ -228,7 +228,7 @@
constexpr Vector4(const Point& p) : x(p.x), y(p.y) {}
Vector4 Normalize() const {
- const Scalar inverse = 1.0 / sqrt(x * x + y * y + z * z + w * w);
+ const Scalar inverse = 1.0f / sqrt(x * x + y * y + z * z + w * w);
return Vector4(x * inverse, y * inverse, z * inverse, w * inverse);
}
diff --git a/lib/ui/BUILD.gn b/lib/ui/BUILD.gn
index 9355c08..0e7960a 100644
--- a/lib/ui/BUILD.gn
+++ b/lib/ui/BUILD.gn
@@ -9,6 +9,21 @@
import("//flutter/testing/testing.gni")
source_set("ui") {
+ cflags = [
+ # Dart gives us doubles. Skia and Impeller work in floats.
+ # If Dart gives us a double > FLT_MAX or < -FLT_MAX, implicit conversion
+ # will convert it to either inf/-inf or FLT_MAX/-FLT_MAX (undefined
+ # behavior). This can result in surprising and difficult to debug behavior
+ # for Flutter application developers, so it should be explicitly handled
+ # via SafeNarrow.
+ "-Wimplicit-float-conversion",
+ ]
+
+ if (is_win) {
+ # This causes build failures in third_party dependencies on Windows.
+ cflags += [ "-Wno-implicit-int-float-conversion" ]
+ }
+
sources = [
"compositing/scene.cc",
"compositing/scene.h",
@@ -19,6 +34,7 @@
"dart_ui.cc",
"dart_ui.h",
"dart_wrapper.h",
+ "floating_point.h",
"io_manager.cc",
"io_manager.h",
"isolate_name_server/isolate_name_server.cc",
diff --git a/lib/ui/compositing/scene_builder.cc b/lib/ui/compositing/scene_builder.cc
index 4a56612..6c3e83b 100644
--- a/lib/ui/compositing/scene_builder.cc
+++ b/lib/ui/compositing/scene_builder.cc
@@ -22,6 +22,7 @@
#include "flutter/flow/layers/texture_layer.h"
#include "flutter/flow/layers/transform_layer.h"
#include "flutter/fml/build_config.h"
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/painting/shader.h"
#include "third_party/tonic/converter/dart_converter.h"
@@ -60,7 +61,7 @@
double dx,
double dy,
const fml::RefPtr<EngineLayer>& oldLayer) {
- SkMatrix sk_matrix = SkMatrix::Translate(dx, dy);
+ SkMatrix sk_matrix = SkMatrix::Translate(SafeNarrow(dx), SafeNarrow(dy));
auto layer = std::make_shared<flutter::TransformLayer>(sk_matrix);
PushLayer(layer);
EngineLayer::MakeRetained(layer_handle, layer);
@@ -77,7 +78,8 @@
double bottom,
int clipBehavior,
const fml::RefPtr<EngineLayer>& oldLayer) {
- SkRect clipRect = SkRect::MakeLTRB(left, top, right, bottom);
+ SkRect clipRect = SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom));
flutter::Clip clip_behavior = static_cast<flutter::Clip>(clipBehavior);
auto layer =
std::make_shared<flutter::ClipRectLayer>(clipRect, clip_behavior);
@@ -125,8 +127,8 @@
double dx,
double dy,
const fml::RefPtr<EngineLayer>& oldLayer) {
- auto layer =
- std::make_shared<flutter::OpacityLayer>(alpha, SkPoint::Make(dx, dy));
+ auto layer = std::make_shared<flutter::OpacityLayer>(
+ alpha, SkPoint::Make(SafeNarrow(dx), SafeNarrow(dy)));
PushLayer(layer);
EngineLayer::MakeRetained(layer_handle, layer);
@@ -154,7 +156,7 @@
double dy,
const fml::RefPtr<EngineLayer>& oldLayer) {
auto layer = std::make_shared<flutter::ImageFilterLayer>(
- image_filter->filter(), SkPoint::Make(dx, dy));
+ image_filter->filter(), SkPoint::Make(SafeNarrow(dx), SafeNarrow(dy)));
PushLayer(layer);
EngineLayer::MakeRetained(layer_handle, layer);
@@ -187,8 +189,9 @@
int blendMode,
int filterQualityIndex,
const fml::RefPtr<EngineLayer>& oldLayer) {
- SkRect rect = SkRect::MakeLTRB(maskRectLeft, maskRectTop, maskRectRight,
- maskRectBottom);
+ SkRect rect =
+ SkRect::MakeLTRB(SafeNarrow(maskRectLeft), SafeNarrow(maskRectTop),
+ SafeNarrow(maskRectRight), SafeNarrow(maskRectBottom));
auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
auto layer = std::make_shared<flutter::ShaderMaskLayer>(
shader->shader(sampling), rect, static_cast<DlBlendMode>(blendMode));
@@ -240,7 +243,7 @@
// been disposed but not collected yet, but the display list is null.
if (picture->display_list()) {
auto layer = std::make_unique<flutter::DisplayListLayer>(
- SkPoint::Make(dx, dy),
+ SkPoint::Make(SafeNarrow(dx), SafeNarrow(dy)),
UIDartState::CreateGPUObject(picture->display_list()), !!(hints & 1),
!!(hints & 2));
AddLayer(std::move(layer));
@@ -256,7 +259,8 @@
int filterQualityIndex) {
auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
auto layer = std::make_unique<flutter::TextureLayer>(
- SkPoint::Make(dx, dy), SkSize::Make(width, height), textureId, freeze,
+ SkPoint::Make(SafeNarrow(dx), SafeNarrow(dy)),
+ SkSize::Make(SafeNarrow(width), SafeNarrow(height)), textureId, freeze,
sampling);
AddLayer(std::move(layer));
}
@@ -267,7 +271,8 @@
double height,
int64_t viewId) {
auto layer = std::make_unique<flutter::PlatformViewLayer>(
- SkPoint::Make(dx, dy), SkSize::Make(width, height), viewId);
+ SkPoint::Make(SafeNarrow(dx), SafeNarrow(dy)),
+ SkSize::Make(SafeNarrow(width), SafeNarrow(height)), viewId);
AddLayer(std::move(layer));
}
@@ -276,7 +281,8 @@
double right,
double top,
double bottom) {
- SkRect rect = SkRect::MakeLTRB(left, top, right, bottom);
+ SkRect rect = SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom));
auto layer =
std::make_unique<flutter::PerformanceOverlayLayer>(enabledOptions);
layer->set_paint_bounds(rect);
diff --git a/lib/ui/floating_point.h b/lib/ui/floating_point.h
new file mode 100644
index 0000000..eb58760
--- /dev/null
+++ b/lib/ui/floating_point.h
@@ -0,0 +1,28 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FLUTTER_LIB_UI_FLOATING_POINT_H_
+#define FLUTTER_LIB_UI_FLOATING_POINT_H_
+
+#include <algorithm>
+#include <limits>
+
+namespace flutter {
+
+/// Converts a double to a float, truncating finite values that are larger than
+/// FLT_MAX or smaller than FLT_MIN to those values.
+static float SafeNarrow(double value) {
+ if (std::isinf(value) || std::isnan(value)) {
+ return static_cast<float>(value);
+ } else {
+ // Avoid truncation to inf/-inf.
+ return std::clamp(static_cast<float>(value),
+ std::numeric_limits<float>::lowest(),
+ std::numeric_limits<float>::max());
+ }
+}
+
+} // namespace flutter
+
+#endif // FLUTTER_LIB_UI_FLOATING_POINT_H_
diff --git a/lib/ui/painting.dart b/lib/ui/painting.dart
index f5e1f7a..8cbacfc 100644
--- a/lib/ui/painting.dart
+++ b/lib/ui/painting.dart
@@ -2615,21 +2615,21 @@
external void _setFillType(int fillType);
/// Starts a new sub-path at the given coordinate.
- @Native<Void Function(Pointer<Void>, Float, Float)>(symbol: 'Path::moveTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double)>(symbol: 'Path::moveTo', isLeaf: true)
external void moveTo(double x, double y);
/// Starts a new sub-path at the given offset from the current point.
- @Native<Void Function(Pointer<Void>, Float, Float)>(symbol: 'Path::relativeMoveTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double)>(symbol: 'Path::relativeMoveTo', isLeaf: true)
external void relativeMoveTo(double dx, double dy);
/// Adds a straight line segment from the current point to the given
/// point.
- @Native<Void Function(Pointer<Void>, Float, Float)>(symbol: 'Path::lineTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double)>(symbol: 'Path::lineTo', isLeaf: true)
external void lineTo(double x, double y);
/// Adds a straight line segment from the current point to the point
/// at the given offset from the current point.
- @Native<Void Function(Pointer<Void>, Float, Float)>(symbol: 'Path::relativeLineTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double)>(symbol: 'Path::relativeLineTo', isLeaf: true)
external void relativeLineTo(double dx, double dy);
/// Adds a quadratic bezier segment that curves from the current
@@ -2638,14 +2638,14 @@
///
/// 
/// 
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float)>(symbol: 'Path::quadraticBezierTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double)>(symbol: 'Path::quadraticBezierTo', isLeaf: true)
external void quadraticBezierTo(double x1, double y1, double x2, double y2);
/// Adds a quadratic bezier segment that curves from the current
/// point to the point at the offset (x2,y2) from the current point,
/// using the control point at the offset (x1,y1) from the current
/// point.
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float)>(symbol: 'Path::relativeQuadraticBezierTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double)>(symbol: 'Path::relativeQuadraticBezierTo', isLeaf: true)
external void relativeQuadraticBezierTo(
double x1, double y1, double x2, double y2);
@@ -2655,14 +2655,14 @@
///
/// 
/// 
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float, Float)>(symbol: 'Path::cubicTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Double)>(symbol: 'Path::cubicTo', isLeaf: true)
external void cubicTo(double x1, double y1, double x2, double y2, double x3, double y3);
/// Adds a cubic bezier segment that curves from the current point
/// to the point at the offset (x3,y3) from the current point, using
/// the control points at the offsets (x1,y1) and (x2,y2) from the
/// current point.
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float, Float)>(symbol: 'Path::relativeCubicTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Double)>(symbol: 'Path::relativeCubicTo', isLeaf: true)
external void relativeCubicTo(double x1, double y1, double x2, double y2, double x3, double y3);
/// Adds a bezier segment that curves from the current point to the
@@ -2673,7 +2673,7 @@
///
/// 
/// 
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float)>(symbol: 'Path::conicTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double)>(symbol: 'Path::conicTo', isLeaf: true)
external void conicTo(double x1, double y1, double x2, double y2, double w);
/// Adds a bezier segment that curves from the current point to the
@@ -2682,7 +2682,7 @@
/// the weight w. If the weight is greater than 1, then the curve is
/// a hyperbola; if the weight equals 1, it's a parabola; and if it
/// is less than 1, it is an ellipse.
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float)>(symbol: 'Path::relativeConicTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double)>(symbol: 'Path::relativeConicTo', isLeaf: true)
external void relativeConicTo(double x1, double y1, double x2, double y2, double w);
/// If the `forceMoveTo` argument is false, adds a straight line
@@ -2706,7 +2706,7 @@
_arcTo(rect.left, rect.top, rect.right, rect.bottom, startAngle, sweepAngle, forceMoveTo);
}
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float, Float, Bool)>(symbol: 'Path::arcTo', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Double, Bool)>(symbol: 'Path::arcTo', isLeaf: true)
external void _arcTo(double left, double top, double right, double bottom, double startAngle, double sweepAngle, bool forceMoveTo);
/// Appends up to four conic curves weighted to describe an oval of `radius`
@@ -2732,7 +2732,7 @@
_arcToPoint(arcEnd.dx, arcEnd.dy, radius.x, radius.y, rotation, largeArc, clockwise);
}
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float, Bool, Bool)>(symbol: 'Path::arcToPoint', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Bool, Bool)>(symbol: 'Path::arcToPoint', isLeaf: true)
external void _arcToPoint(double arcEndX, double arcEndY, double radiusX, double radiusY, double rotation, bool largeArc, bool clockwise);
/// Appends up to four conic curves weighted to describe an oval of `radius`
@@ -2761,7 +2761,7 @@
_relativeArcToPoint(arcEndDelta.dx, arcEndDelta.dy, radius.x, radius.y, rotation, largeArc, clockwise);
}
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float, Bool, Bool)>(symbol: 'Path::relativeArcToPoint', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Bool, Bool)>(symbol: 'Path::relativeArcToPoint', isLeaf: true)
external void _relativeArcToPoint(
double arcEndX,
double arcEndY,
@@ -2778,7 +2778,7 @@
_addRect(rect.left, rect.top, rect.right, rect.bottom);
}
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float)>(symbol: 'Path::addRect', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double)>(symbol: 'Path::addRect', isLeaf: true)
external void _addRect(double left, double top, double right, double bottom);
/// Adds a new sub-path that consists of a curve that forms the
@@ -2791,7 +2791,7 @@
_addOval(oval.left, oval.top, oval.right, oval.bottom);
}
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float)>(symbol: 'Path::addOval', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double)>(symbol: 'Path::addOval', isLeaf: true)
external void _addOval(double left, double top, double right, double bottom);
/// Adds a new sub-path with one arc segment that consists of the arc
@@ -2813,7 +2813,7 @@
_addArc(oval.left, oval.top, oval.right, oval.bottom, startAngle, sweepAngle);
}
- @Native<Void Function(Pointer<Void>, Float, Float, Float, Float, Float, Float)>(symbol: 'Path::addArc', isLeaf: true)
+ @Native<Void Function(Pointer<Void>, Double, Double, Double, Double, Double, Double)>(symbol: 'Path::addArc', isLeaf: true)
external void _addArc(double left, double top, double right, double bottom, double startAngle, double sweepAngle);
/// Adds a new sub-path with a sequence of line segments that connect the given
@@ -3203,7 +3203,7 @@
return _length(contourIndex);
}
- @Native<Float Function(Pointer<Void>, Int32)>(symbol: 'PathMeasure::getLength', isLeaf: true)
+ @Native<Double Function(Pointer<Void>, Int32)>(symbol: 'PathMeasure::getLength', isLeaf: true)
external double _length(int contourIndex);
Tangent? getTangentForOffset(int contourIndex, double distance) {
@@ -3221,7 +3221,7 @@
}
}
- @Native<Handle Function(Pointer<Void>, Int32, Float)>(symbol: 'PathMeasure::getPosTan')
+ @Native<Handle Function(Pointer<Void>, Int32, Double)>(symbol: 'PathMeasure::getPosTan')
external Float32List _getPosTan(int contourIndex, double distance);
Path extractPath(int contourIndex, double start, double end,
@@ -3232,7 +3232,7 @@
return path;
}
- @Native<Void Function(Pointer<Void>, Handle, Int32, Float, Float, Bool)>(symbol: 'PathMeasure::getSegment')
+ @Native<Void Function(Pointer<Void>, Handle, Int32, Double, Double, Bool)>(symbol: 'PathMeasure::getSegment')
external void _extractPath(Path outPath, int contourIndex, double start, double end, bool startWithMoveTo);
bool isClosed(int contourIndex) {
diff --git a/lib/ui/painting/canvas.cc b/lib/ui/painting/canvas.cc
index 5f6c7fc..403a4c3 100644
--- a/lib/ui/painting/canvas.cc
+++ b/lib/ui/painting/canvas.cc
@@ -7,6 +7,7 @@
#include <cmath>
#include "flutter/display_list/dl_builder.h"
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/painting/image.h"
#include "flutter/lib/ui/painting/image_filter.h"
#include "flutter/lib/ui/painting/paint.h"
@@ -34,8 +35,10 @@
return;
}
- fml::RefPtr<Canvas> canvas = fml::MakeRefCounted<Canvas>(
- recorder->BeginRecording(SkRect::MakeLTRB(left, top, right, bottom)));
+ fml::RefPtr<Canvas> canvas =
+ fml::MakeRefCounted<Canvas>(recorder->BeginRecording(
+ SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top), SafeNarrow(right),
+ SafeNarrow(bottom))));
recorder->set_canvas(canvas);
canvas->AssociateWithDartWrapper(wrapper);
}
@@ -74,7 +77,8 @@
Paint paint(paint_objects, paint_data);
FML_DCHECK(paint.isNotNull());
- SkRect bounds = SkRect::MakeLTRB(left, top, right, bottom);
+ SkRect bounds = SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom));
if (display_list_builder_) {
DlPaint dl_paint;
const DlPaint* save_paint = paint.paint(dl_paint, kSaveLayerWithPaintFlags);
@@ -106,25 +110,25 @@
void Canvas::translate(double dx, double dy) {
if (display_list_builder_) {
- builder()->Translate(dx, dy);
+ builder()->Translate(SafeNarrow(dx), SafeNarrow(dy));
}
}
void Canvas::scale(double sx, double sy) {
if (display_list_builder_) {
- builder()->Scale(sx, sy);
+ builder()->Scale(SafeNarrow(sx), SafeNarrow(sy));
}
}
void Canvas::rotate(double radians) {
if (display_list_builder_) {
- builder()->Rotate(radians * 180.0 / M_PI);
+ builder()->Rotate(SafeNarrow(radians) * 180.0f / static_cast<float>(M_PI));
}
}
void Canvas::skew(double sx, double sy) {
if (display_list_builder_) {
- builder()->Skew(sx, sy);
+ builder()->Skew(SafeNarrow(sx), SafeNarrow(sy));
}
}
@@ -134,10 +138,10 @@
if (display_list_builder_) {
// clang-format off
builder()->TransformFullPerspective(
- matrix4[ 0], matrix4[ 4], matrix4[ 8], matrix4[12],
- matrix4[ 1], matrix4[ 5], matrix4[ 9], matrix4[13],
- matrix4[ 2], matrix4[ 6], matrix4[10], matrix4[14],
- matrix4[ 3], matrix4[ 7], matrix4[11], matrix4[15]);
+ SafeNarrow(matrix4[ 0]), SafeNarrow(matrix4[ 4]), SafeNarrow(matrix4[ 8]), SafeNarrow(matrix4[12]),
+ SafeNarrow(matrix4[ 1]), SafeNarrow(matrix4[ 5]), SafeNarrow(matrix4[ 9]), SafeNarrow(matrix4[13]),
+ SafeNarrow(matrix4[ 2]), SafeNarrow(matrix4[ 6]), SafeNarrow(matrix4[10]), SafeNarrow(matrix4[14]),
+ SafeNarrow(matrix4[ 3]), SafeNarrow(matrix4[ 7]), SafeNarrow(matrix4[11]), SafeNarrow(matrix4[15]));
// clang-format on
}
}
@@ -162,8 +166,9 @@
DlCanvas::ClipOp clipOp,
bool doAntiAlias) {
if (display_list_builder_) {
- builder()->ClipRect(SkRect::MakeLTRB(left, top, right, bottom), clipOp,
- doAntiAlias);
+ builder()->ClipRect(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom)),
+ clipOp, doAntiAlias);
}
}
@@ -226,7 +231,9 @@
if (display_list_builder_) {
DlPaint dl_paint;
paint.paint(dl_paint, kDrawLineFlags);
- builder()->DrawLine(SkPoint::Make(x1, y1), SkPoint::Make(x2, y2), dl_paint);
+ builder()->DrawLine(SkPoint::Make(SafeNarrow(x1), SafeNarrow(y1)),
+ SkPoint::Make(SafeNarrow(x2), SafeNarrow(y2)),
+ dl_paint);
}
}
@@ -259,7 +266,9 @@
if (display_list_builder_) {
DlPaint dl_paint;
paint.paint(dl_paint, kDrawRectFlags);
- builder()->DrawRect(SkRect::MakeLTRB(left, top, right, bottom), dl_paint);
+ builder()->DrawRect(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom)),
+ dl_paint);
}
}
@@ -302,7 +311,9 @@
if (display_list_builder_) {
DlPaint dl_paint;
paint.paint(dl_paint, kDrawOvalFlags);
- builder()->DrawOval(SkRect::MakeLTRB(left, top, right, bottom), dl_paint);
+ builder()->DrawOval(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom)),
+ dl_paint);
}
}
@@ -317,7 +328,8 @@
if (display_list_builder_) {
DlPaint dl_paint;
paint.paint(dl_paint, kDrawCircleFlags);
- builder()->DrawCircle(SkPoint::Make(x, y), radius, dl_paint);
+ builder()->DrawCircle(SkPoint::Make(SafeNarrow(x), SafeNarrow(y)),
+ SafeNarrow(radius), dl_paint);
}
}
@@ -338,9 +350,12 @@
paint.paint(dl_paint, useCenter //
? kDrawArcWithCenterFlags
: kDrawArcNoCenterFlags);
- builder()->DrawArc(SkRect::MakeLTRB(left, top, right, bottom),
- startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI,
- useCenter, dl_paint);
+ builder()->DrawArc(
+ SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top), SafeNarrow(right),
+ SafeNarrow(bottom)),
+ SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
+ SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI), useCenter,
+ dl_paint);
}
}
@@ -388,7 +403,8 @@
if (display_list_builder_) {
DlPaint dl_paint;
const DlPaint* opt_paint = paint.paint(dl_paint, kDrawImageWithPaintFlags);
- builder()->DrawImage(dl_image, SkPoint::Make(x, y), sampling, opt_paint);
+ builder()->DrawImage(dl_image, SkPoint::Make(SafeNarrow(x), SafeNarrow(y)),
+ sampling, opt_paint);
}
return Dart_Null();
}
@@ -421,8 +437,10 @@
return ToDart(error.value());
}
- SkRect src = SkRect::MakeLTRB(src_left, src_top, src_right, src_bottom);
- SkRect dst = SkRect::MakeLTRB(dst_left, dst_top, dst_right, dst_bottom);
+ SkRect src = SkRect::MakeLTRB(SafeNarrow(src_left), SafeNarrow(src_top),
+ SafeNarrow(src_right), SafeNarrow(src_bottom));
+ SkRect dst = SkRect::MakeLTRB(SafeNarrow(dst_left), SafeNarrow(dst_top),
+ SafeNarrow(dst_right), SafeNarrow(dst_bottom));
auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
if (display_list_builder_) {
DlPaint dl_paint;
@@ -462,10 +480,12 @@
}
SkRect center =
- SkRect::MakeLTRB(center_left, center_top, center_right, center_bottom);
+ SkRect::MakeLTRB(SafeNarrow(center_left), SafeNarrow(center_top),
+ SafeNarrow(center_right), SafeNarrow(center_bottom));
SkIRect icenter;
center.round(&icenter);
- SkRect dst = SkRect::MakeLTRB(dst_left, dst_top, dst_right, dst_bottom);
+ SkRect dst = SkRect::MakeLTRB(SafeNarrow(dst_left), SafeNarrow(dst_top),
+ SafeNarrow(dst_right), SafeNarrow(dst_bottom));
auto filter = ImageFilter::FilterModeFromIndex(bitmapSamplingIndex);
if (display_list_builder_) {
DlPaint dl_paint;
@@ -599,11 +619,13 @@
ToDart("Canvas.drawShader called with non-genuine Path."));
return;
}
- SkScalar dpr = UIDartState::Current()
- ->platform_configuration()
- ->get_window(0)
- ->viewport_metrics()
- .device_pixel_ratio;
+
+ // Not using SafeNarrow because DPR will always be a relatively small number.
+ SkScalar dpr = static_cast<float>(UIDartState::Current()
+ ->platform_configuration()
+ ->get_window(0)
+ ->viewport_metrics()
+ .device_pixel_ratio);
if (display_list_builder_) {
// The DrawShadow mechanism results in non-public operations to be
// performed on the canvas involving an SkDrawShadowRec. Since we
@@ -612,8 +634,8 @@
// that situation we bypass the canvas interface and inject the
// shadow parameters directly into the underlying DisplayList.
// See: https://bugs.chromium.org/p/skia/issues/detail?id=12125
- builder()->DrawShadow(path->path(), color, elevation, transparentOccluder,
- dpr);
+ builder()->DrawShadow(path->path(), color, SafeNarrow(elevation),
+ transparentOccluder, dpr);
}
}
diff --git a/lib/ui/painting/gradient.cc b/lib/ui/painting/gradient.cc
index 5f586a3..6f692ad 100644
--- a/lib/ui/painting/gradient.cc
+++ b/lib/ui/painting/gradient.cc
@@ -4,6 +4,7 @@
#include "flutter/lib/ui/painting/gradient.h"
+#include "flutter/lib/ui/floating_point.h"
#include "third_party/tonic/converter/dart_converter.h"
#include "third_party/tonic/dart_args.h"
#include "third_party/tonic/dart_binding_macros.h"
@@ -73,9 +74,9 @@
const DlColor* colors_array = reinterpret_cast<const DlColor*>(colors.data());
dl_shader_ = DlColorSource::MakeRadial(
- SkPoint::Make(center_x, center_y), radius, colors.num_elements(),
- colors_array, color_stops.data(), tile_mode,
- has_matrix ? &sk_matrix : nullptr);
+ SkPoint::Make(SafeNarrow(center_x), SafeNarrow(center_y)),
+ SafeNarrow(radius), colors.num_elements(), colors_array,
+ color_stops.data(), tile_mode, has_matrix ? &sk_matrix : nullptr);
}
void CanvasGradient::initSweep(double center_x,
@@ -101,9 +102,11 @@
const DlColor* colors_array = reinterpret_cast<const DlColor*>(colors.data());
dl_shader_ = DlColorSource::MakeSweep(
- SkPoint::Make(center_x, center_y), start_angle * 180.0 / M_PI,
- end_angle * 180.0 / M_PI, colors.num_elements(), colors_array,
- color_stops.data(), tile_mode, has_matrix ? &sk_matrix : nullptr);
+ SkPoint::Make(SafeNarrow(center_x), SafeNarrow(center_y)),
+ SafeNarrow(start_angle) * 180.0f / static_cast<float>(M_PI),
+ SafeNarrow(end_angle) * 180.0f / static_cast<float>(M_PI),
+ colors.num_elements(), colors_array, color_stops.data(), tile_mode,
+ has_matrix ? &sk_matrix : nullptr);
}
void CanvasGradient::initTwoPointConical(double start_x,
@@ -131,10 +134,11 @@
const DlColor* colors_array = reinterpret_cast<const DlColor*>(colors.data());
dl_shader_ = DlColorSource::MakeConical(
- SkPoint::Make(start_x, start_y), start_radius, //
- SkPoint::Make(end_x, end_y), end_radius, //
- colors.num_elements(), colors_array, color_stops.data(), //
- tile_mode, has_matrix ? &sk_matrix : nullptr);
+ SkPoint::Make(SafeNarrow(start_x), SafeNarrow(start_y)),
+ SafeNarrow(start_radius),
+ SkPoint::Make(SafeNarrow(end_x), SafeNarrow(end_y)),
+ SafeNarrow(end_radius), colors.num_elements(), colors_array,
+ color_stops.data(), tile_mode, has_matrix ? &sk_matrix : nullptr);
}
CanvasGradient::CanvasGradient() = default;
diff --git a/lib/ui/painting/image_decoder_impeller.cc b/lib/ui/painting/image_decoder_impeller.cc
index 223cff5..6e834f0 100644
--- a/lib/ui/painting/image_decoder_impeller.cc
+++ b/lib/ui/painting/image_decoder_impeller.cc
@@ -141,8 +141,8 @@
auto decode_size = source_size;
if (descriptor->is_compressed()) {
decode_size = descriptor->get_scaled_dimensions(std::max(
- static_cast<double>(target_size.width()) / source_size.width(),
- static_cast<double>(target_size.height()) / source_size.height()));
+ static_cast<float>(target_size.width()) / source_size.width(),
+ static_cast<float>(target_size.height()) / source_size.height()));
}
//----------------------------------------------------------------------------
diff --git a/lib/ui/painting/image_decoder_skia.cc b/lib/ui/painting/image_decoder_skia.cc
index 4ed9de4..e8167e4 100644
--- a/lib/ui/painting/image_decoder_skia.cc
+++ b/lib/ui/painting/image_decoder_skia.cc
@@ -115,9 +115,9 @@
static_cast<int32_t>(target_height)};
auto decode_dimensions = descriptor->get_scaled_dimensions(
- std::max(static_cast<double>(resized_dimensions.width()) /
+ std::max(static_cast<float>(resized_dimensions.width()) /
source_dimensions.width(),
- static_cast<double>(resized_dimensions.height()) /
+ static_cast<float>(resized_dimensions.height()) /
source_dimensions.height()));
// If the codec supports efficient sub-pixel decoding, decoded at a resolution
diff --git a/lib/ui/painting/image_filter.cc b/lib/ui/painting/image_filter.cc
index d92db00..74f8983 100644
--- a/lib/ui/painting/image_filter.cc
+++ b/lib/ui/painting/image_filter.cc
@@ -4,6 +4,7 @@
#include "flutter/lib/ui/painting/image_filter.h"
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "third_party/tonic/converter/dart_converter.h"
@@ -53,15 +54,18 @@
void ImageFilter::initBlur(double sigma_x,
double sigma_y,
DlTileMode tile_mode) {
- filter_ = DlBlurImageFilter::Make(sigma_x, sigma_y, tile_mode);
+ filter_ = DlBlurImageFilter::Make(SafeNarrow(sigma_x), SafeNarrow(sigma_y),
+ tile_mode);
}
void ImageFilter::initDilate(double radius_x, double radius_y) {
- filter_ = DlDilateImageFilter::Make(radius_x, radius_y);
+ filter_ =
+ DlDilateImageFilter::Make(SafeNarrow(radius_x), SafeNarrow(radius_y));
}
void ImageFilter::initErode(double radius_x, double radius_y) {
- filter_ = DlErodeImageFilter::Make(radius_x, radius_y);
+ filter_ =
+ DlErodeImageFilter::Make(SafeNarrow(radius_x), SafeNarrow(radius_y));
}
void ImageFilter::initMatrix(const tonic::Float64List& matrix4,
diff --git a/lib/ui/painting/matrix.cc b/lib/ui/painting/matrix.cc
index f4f22c2..edaef8b 100644
--- a/lib/ui/painting/matrix.cc
+++ b/lib/ui/painting/matrix.cc
@@ -5,6 +5,7 @@
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/fml/logging.h"
+#include "flutter/lib/ui/floating_point.h"
namespace flutter {
@@ -23,9 +24,9 @@
for (int i = 0; i < 9; ++i) {
int matrix4_index = kSkMatrixIndexToMatrix4Index[i];
if (matrix4_index < matrix4.num_elements()) {
- sk_matrix[i] = matrix4[matrix4_index];
+ sk_matrix[i] = SafeNarrow(matrix4[matrix4_index]);
} else {
- sk_matrix[i] = 0.0;
+ sk_matrix[i] = 0.0f;
}
}
return sk_matrix;
diff --git a/lib/ui/painting/paint.cc b/lib/ui/painting/paint.cc
index a3252a1..592643b 100644
--- a/lib/ui/painting/paint.cc
+++ b/lib/ui/painting/paint.cc
@@ -6,6 +6,7 @@
#include "flutter/display_list/dl_builder.h"
#include "flutter/fml/logging.h"
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/painting/color_filter.h"
#include "flutter/lib/ui/painting/image_filter.h"
#include "flutter/lib/ui/painting/shader.h"
@@ -51,7 +52,7 @@
// Must be kept in sync with the default in painting.dart, and also with the
// default SkPaintDefaults_MiterLimit in Skia (which is not in a public header).
-constexpr double kStrokeMiterLimitDefault = 4.0;
+constexpr float kStrokeMiterLimitDefault = 4.0f;
// Must be kept in sync with the MaskFilter private constants in painting.dart.
enum MaskFilterType { kNull, kBlur };
@@ -187,7 +188,8 @@
DlBlurStyle blur_style =
static_cast<DlBlurStyle>(uint_data[kMaskFilterBlurStyleIndex]);
double sigma = float_data[kMaskFilterSigmaIndex];
- paint.setMaskFilter(DlBlurMaskFilter::Make(blur_style, sigma));
+ paint.setMaskFilter(
+ DlBlurMaskFilter::Make(blur_style, SafeNarrow(sigma)));
break;
}
}
@@ -277,7 +279,7 @@
case kBlur:
DlBlurStyle blur_style =
static_cast<DlBlurStyle>(uint_data[kMaskFilterBlurStyleIndex]);
- double sigma = float_data[kMaskFilterSigmaIndex];
+ float sigma = SafeNarrow(float_data[kMaskFilterSigmaIndex]);
// Make could return a nullptr here if the values are NOP or
// do not make sense. We could interpret that as if there was
// no value passed from Dart at all (i.e. don't change the
diff --git a/lib/ui/painting/path.cc b/lib/ui/painting/path.cc
index 647250e..4b03ae7 100644
--- a/lib/ui/painting/path.cc
+++ b/lib/ui/painting/path.cc
@@ -6,6 +6,7 @@
#include <cmath>
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "third_party/tonic/converter/dart_converter.h"
@@ -48,91 +49,99 @@
resetVolatility();
}
-void CanvasPath::moveTo(float x, float y) {
- mutable_path().moveTo(x, y);
+void CanvasPath::moveTo(double x, double y) {
+ mutable_path().moveTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
-void CanvasPath::relativeMoveTo(float x, float y) {
- mutable_path().rMoveTo(x, y);
+void CanvasPath::relativeMoveTo(double x, double y) {
+ mutable_path().rMoveTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
-void CanvasPath::lineTo(float x, float y) {
- mutable_path().lineTo(x, y);
+void CanvasPath::lineTo(double x, double y) {
+ mutable_path().lineTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
-void CanvasPath::relativeLineTo(float x, float y) {
- mutable_path().rLineTo(x, y);
+void CanvasPath::relativeLineTo(double x, double y) {
+ mutable_path().rLineTo(SafeNarrow(x), SafeNarrow(y));
resetVolatility();
}
-void CanvasPath::quadraticBezierTo(float x1, float y1, float x2, float y2) {
- mutable_path().quadTo(x1, y1, x2, y2);
+void CanvasPath::quadraticBezierTo(double x1, double y1, double x2, double y2) {
+ mutable_path().quadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2));
resetVolatility();
}
-void CanvasPath::relativeQuadraticBezierTo(float x1,
- float y1,
- float x2,
- float y2) {
- mutable_path().rQuadTo(x1, y1, x2, y2);
+void CanvasPath::relativeQuadraticBezierTo(double x1,
+ double y1,
+ double x2,
+ double y2) {
+ mutable_path().rQuadTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2));
resetVolatility();
}
-void CanvasPath::cubicTo(float x1,
- float y1,
- float x2,
- float y2,
- float x3,
- float y3) {
- mutable_path().cubicTo(x1, y1, x2, y2, x3, y3);
+void CanvasPath::cubicTo(double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3) {
+ mutable_path().cubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
resetVolatility();
}
-void CanvasPath::relativeCubicTo(float x1,
- float y1,
- float x2,
- float y2,
- float x3,
- float y3) {
- mutable_path().rCubicTo(x1, y1, x2, y2, x3, y3);
+void CanvasPath::relativeCubicTo(double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3) {
+ mutable_path().rCubicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(x3), SafeNarrow(y3));
resetVolatility();
}
-void CanvasPath::conicTo(float x1, float y1, float x2, float y2, float w) {
- mutable_path().conicTo(x1, y1, x2, y2, w);
+void CanvasPath::conicTo(double x1, double y1, double x2, double y2, double w) {
+ mutable_path().conicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(w));
resetVolatility();
}
-void CanvasPath::relativeConicTo(float x1,
- float y1,
- float x2,
- float y2,
- float w) {
- mutable_path().rConicTo(x1, y1, x2, y2, w);
+void CanvasPath::relativeConicTo(double x1,
+ double y1,
+ double x2,
+ double y2,
+ double w) {
+ mutable_path().rConicTo(SafeNarrow(x1), SafeNarrow(y1), SafeNarrow(x2),
+ SafeNarrow(y2), SafeNarrow(w));
resetVolatility();
}
-void CanvasPath::arcTo(float left,
- float top,
- float right,
- float bottom,
- float startAngle,
- float sweepAngle,
+void CanvasPath::arcTo(double left,
+ double top,
+ double right,
+ double bottom,
+ double startAngle,
+ double sweepAngle,
bool forceMoveTo) {
- mutable_path().arcTo(SkRect::MakeLTRB(left, top, right, bottom),
- startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI,
- forceMoveTo);
+ mutable_path().arcTo(
+ SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top), SafeNarrow(right),
+ SafeNarrow(bottom)),
+ SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
+ SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI), forceMoveTo);
resetVolatility();
}
-void CanvasPath::arcToPoint(float arcEndX,
- float arcEndY,
- float radiusX,
- float radiusY,
- float xAxisRotation,
+void CanvasPath::arcToPoint(double arcEndX,
+ double arcEndY,
+ double radiusX,
+ double radiusY,
+ double xAxisRotation,
bool isLargeArc,
bool isClockwiseDirection) {
const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
@@ -140,45 +149,54 @@
const auto direction =
isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
- mutable_path().arcTo(radiusX, radiusY, xAxisRotation, arcSize, direction,
- arcEndX, arcEndY);
+ mutable_path().arcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
+ SafeNarrow(xAxisRotation), arcSize, direction,
+ SafeNarrow(arcEndX), SafeNarrow(arcEndY));
resetVolatility();
}
-void CanvasPath::relativeArcToPoint(float arcEndDeltaX,
- float arcEndDeltaY,
- float radiusX,
- float radiusY,
- float xAxisRotation,
+void CanvasPath::relativeArcToPoint(double arcEndDeltaX,
+ double arcEndDeltaY,
+ double radiusX,
+ double radiusY,
+ double xAxisRotation,
bool isLargeArc,
bool isClockwiseDirection) {
const auto arcSize = isLargeArc ? SkPath::ArcSize::kLarge_ArcSize
: SkPath::ArcSize::kSmall_ArcSize;
const auto direction =
isClockwiseDirection ? SkPathDirection::kCW : SkPathDirection::kCCW;
- mutable_path().rArcTo(radiusX, radiusY, xAxisRotation, arcSize, direction,
- arcEndDeltaX, arcEndDeltaY);
+ mutable_path().rArcTo(SafeNarrow(radiusX), SafeNarrow(radiusY),
+ SafeNarrow(xAxisRotation), arcSize, direction,
+ SafeNarrow(arcEndDeltaX), SafeNarrow(arcEndDeltaY));
resetVolatility();
}
-void CanvasPath::addRect(float left, float top, float right, float bottom) {
- mutable_path().addRect(SkRect::MakeLTRB(left, top, right, bottom));
+void CanvasPath::addRect(double left, double top, double right, double bottom) {
+ mutable_path().addRect(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right),
+ SafeNarrow(bottom)));
resetVolatility();
}
-void CanvasPath::addOval(float left, float top, float right, float bottom) {
- mutable_path().addOval(SkRect::MakeLTRB(left, top, right, bottom));
+void CanvasPath::addOval(double left, double top, double right, double bottom) {
+ mutable_path().addOval(SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right),
+ SafeNarrow(bottom)));
resetVolatility();
}
-void CanvasPath::addArc(float left,
- float top,
- float right,
- float bottom,
- float startAngle,
- float sweepAngle) {
- mutable_path().addArc(SkRect::MakeLTRB(left, top, right, bottom),
- startAngle * 180.0 / M_PI, sweepAngle * 180.0 / M_PI);
+void CanvasPath::addArc(double left,
+ double top,
+ double right,
+ double bottom,
+ double startAngle,
+ double sweepAngle) {
+ mutable_path().addArc(
+ SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top), SafeNarrow(right),
+ SafeNarrow(bottom)),
+ SafeNarrow(startAngle) * 180.0f / static_cast<float>(M_PI),
+ SafeNarrow(sweepAngle) * 180.0f / static_cast<float>(M_PI));
resetVolatility();
}
@@ -198,7 +216,8 @@
Dart_ThrowException(ToDart("Path.addPath called with non-genuine Path."));
return;
}
- mutable_path().addPath(path->path(), dx, dy, SkPath::kAppend_AddPathMode);
+ mutable_path().addPath(path->path(), SafeNarrow(dx), SafeNarrow(dy),
+ SkPath::kAppend_AddPathMode);
resetVolatility();
}
@@ -217,8 +236,8 @@
SkMatrix matrix = ToSkMatrix(matrix4);
matrix4.Release();
- matrix.setTranslateX(matrix.getTranslateX() + dx);
- matrix.setTranslateY(matrix.getTranslateY() + dy);
+ matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
+ matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
mutable_path().addPath(path->path(), matrix, SkPath::kAppend_AddPathMode);
resetVolatility();
}
@@ -229,7 +248,8 @@
ToDart("Path.extendWithPath called with non-genuine Path."));
return;
}
- mutable_path().addPath(path->path(), dx, dy, SkPath::kExtend_AddPathMode);
+ mutable_path().addPath(path->path(), SafeNarrow(dx), SafeNarrow(dy),
+ SkPath::kExtend_AddPathMode);
resetVolatility();
}
@@ -248,8 +268,8 @@
SkMatrix matrix = ToSkMatrix(matrix4);
matrix4.Release();
- matrix.setTranslateX(matrix.getTranslateX() + dx);
- matrix.setTranslateY(matrix.getTranslateY() + dy);
+ matrix.setTranslateX(matrix.getTranslateX() + SafeNarrow(dx));
+ matrix.setTranslateY(matrix.getTranslateY() + SafeNarrow(dy));
mutable_path().addPath(path->path(), matrix, SkPath::kExtend_AddPathMode);
resetVolatility();
}
@@ -265,13 +285,13 @@
}
bool CanvasPath::contains(double x, double y) {
- return path().contains(x, y);
+ return path().contains(SafeNarrow(x), SafeNarrow(y));
}
void CanvasPath::shift(Dart_Handle path_handle, double dx, double dy) {
fml::RefPtr<CanvasPath> path = Create(path_handle);
auto& other_mutable_path = path->mutable_path();
- mutable_path().offset(dx, dy, &other_mutable_path);
+ mutable_path().offset(SafeNarrow(dx), SafeNarrow(dy), &other_mutable_path);
resetVolatility();
}
diff --git a/lib/ui/painting/path.h b/lib/ui/painting/path.h
index 60f07e5..c1a30eb 100644
--- a/lib/ui/painting/path.h
+++ b/lib/ui/painting/path.h
@@ -38,50 +38,55 @@
int getFillType();
void setFillType(int fill_type);
- void moveTo(float x, float y);
- void relativeMoveTo(float x, float y);
- void lineTo(float x, float y);
- void relativeLineTo(float x, float y);
- void quadraticBezierTo(float x1, float y1, float x2, float y2);
- void relativeQuadraticBezierTo(float x1, float y1, float x2, float y2);
- void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3);
- void relativeCubicTo(float x1,
- float y1,
- float x2,
- float y2,
- float x3,
- float y3);
- void conicTo(float x1, float y1, float x2, float y2, float w);
- void relativeConicTo(float x1, float y1, float x2, float y2, float w);
- void arcTo(float left,
- float top,
- float right,
- float bottom,
- float startAngle,
- float sweepAngle,
+ void moveTo(double x, double y);
+ void relativeMoveTo(double x, double y);
+ void lineTo(double x, double y);
+ void relativeLineTo(double x, double y);
+ void quadraticBezierTo(double x1, double y1, double x2, double y2);
+ void relativeQuadraticBezierTo(double x1, double y1, double x2, double y2);
+ void cubicTo(double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3);
+ void relativeCubicTo(double x1,
+ double y1,
+ double x2,
+ double y2,
+ double x3,
+ double y3);
+ void conicTo(double x1, double y1, double x2, double y2, double w);
+ void relativeConicTo(double x1, double y1, double x2, double y2, double w);
+ void arcTo(double left,
+ double top,
+ double right,
+ double bottom,
+ double startAngle,
+ double sweepAngle,
bool forceMoveTo);
- void arcToPoint(float arcEndX,
- float arcEndY,
- float radiusX,
- float radiusY,
- float xAxisRotation,
+ void arcToPoint(double arcEndX,
+ double arcEndY,
+ double radiusX,
+ double radiusY,
+ double xAxisRotation,
bool isLargeArc,
bool isClockwiseDirection);
- void relativeArcToPoint(float arcEndDeltaX,
- float arcEndDeltaY,
- float radiusX,
- float radiusY,
- float xAxisRotation,
+ void relativeArcToPoint(double arcEndDeltaX,
+ double arcEndDeltaY,
+ double radiusX,
+ double radiusY,
+ double xAxisRotation,
bool isLargeArc,
bool isClockwiseDirection);
- void addRect(float left, float top, float right, float bottom);
- void addOval(float left, float top, float right, float bottom);
- void addArc(float left,
- float top,
- float right,
- float bottom,
- float startAngle,
- float sweepAngle);
+ void addRect(double left, double top, double right, double bottom);
+ void addOval(double left, double top, double right, double bottom);
+ void addArc(double left,
+ double top,
+ double right,
+ double bottom,
+ double startAngle,
+ double sweepAngle);
void addPolygon(const tonic::Float32List& points, bool close);
void addRRect(const RRect& rrect);
void addPath(CanvasPath* path, double dx, double dy);
diff --git a/lib/ui/painting/path_measure.cc b/lib/ui/painting/path_measure.cc
index a620efd..ecb54a4 100644
--- a/lib/ui/painting/path_measure.cc
+++ b/lib/ui/painting/path_measure.cc
@@ -6,6 +6,7 @@
#include <cmath>
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/painting/matrix.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "third_party/tonic/converter/dart_converter.h"
@@ -45,7 +46,7 @@
path_measure_->reset(skPath, isClosed);
}
-float CanvasPathMeasure::getLength(int contour_index) {
+double CanvasPathMeasure::getLength(int contour_index) {
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) < measures_.size()) {
return measures_[contour_index]->length();
@@ -54,7 +55,7 @@
}
tonic::Float32List CanvasPathMeasure::getPosTan(int contour_index,
- float distance) {
+ double distance) {
tonic::Float32List posTan(Dart_NewTypedData(Dart_TypedData_kFloat32, 5));
posTan[0] = 0; // dart code will check for this for failure
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
@@ -64,7 +65,8 @@
SkPoint pos;
SkVector tan;
- bool success = measures_[contour_index]->getPosTan(distance, &pos, &tan);
+ float fdistance = SafeNarrow(distance);
+ bool success = measures_[contour_index]->getPosTan(fdistance, &pos, &tan);
if (success) {
posTan[0] = 1; // dart code will check for this for success
@@ -79,16 +81,16 @@
void CanvasPathMeasure::getSegment(Dart_Handle path_handle,
int contour_index,
- float start_d,
- float stop_d,
+ double start_d,
+ double stop_d,
bool start_with_move_to) {
if (static_cast<std::vector<sk_sp<SkContourMeasure>>::size_type>(
contour_index) >= measures_.size()) {
CanvasPath::Create(path_handle);
}
SkPath dst;
- bool success = measures_[contour_index]->getSegment(start_d, stop_d, &dst,
- start_with_move_to);
+ bool success = measures_[contour_index]->getSegment(
+ SafeNarrow(start_d), SafeNarrow(stop_d), &dst, start_with_move_to);
if (!success) {
CanvasPath::Create(path_handle);
} else {
diff --git a/lib/ui/painting/path_measure.h b/lib/ui/painting/path_measure.h
index 32ee021..f52b394 100644
--- a/lib/ui/painting/path_measure.h
+++ b/lib/ui/painting/path_measure.h
@@ -29,12 +29,12 @@
bool forceClosed);
void setPath(const CanvasPath* path, bool isClosed);
- float getLength(int contour_index);
- tonic::Float32List getPosTan(int contour_index, float distance);
+ double getLength(int contour_index);
+ tonic::Float32List getPosTan(int contour_index, double distance);
void getSegment(Dart_Handle path_handle,
int contour_index,
- float start_d,
- float stop_d,
+ double start_d,
+ double stop_d,
bool start_with_move_to);
bool isClosed(int contour_index);
bool nextContour();
diff --git a/lib/ui/semantics/semantics_update_builder.cc b/lib/ui/semantics/semantics_update_builder.cc
index 595ecf8..2382a90 100644
--- a/lib/ui/semantics/semantics_update_builder.cc
+++ b/lib/ui/semantics/semantics_update_builder.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "flutter/lib/ui/floating_point.h"
#include "flutter/lib/ui/ui_dart_state.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/tonic/converter/dart_converter.h"
@@ -65,8 +66,6 @@
const tonic::Int32List& childrenInTraversalOrder,
const tonic::Int32List& childrenInHitTestOrder,
const tonic::Int32List& localContextActions) {
- FML_CHECK(transform.data() && SkScalarsAreFinite(*transform.data(), 9))
- << "Semantics update transform was not set or not finite.";
FML_CHECK(scrollChildren == 0 ||
(scrollChildren > 0 && childrenInHitTestOrder.data()))
<< "Semantics update contained scrollChildren but did not have "
@@ -85,7 +84,8 @@
node.scrollPosition = scrollPosition;
node.scrollExtentMax = scrollExtentMax;
node.scrollExtentMin = scrollExtentMin;
- node.rect = SkRect::MakeLTRB(left, top, right, bottom);
+ node.rect = SkRect::MakeLTRB(SafeNarrow(left), SafeNarrow(top),
+ SafeNarrow(right), SafeNarrow(bottom));
node.elevation = elevation;
node.thickness = thickness;
node.label = std::move(label);
@@ -102,7 +102,7 @@
node.textDirection = textDirection;
SkScalar scalarTransform[16];
for (int i = 0; i < 16; ++i) {
- scalarTransform[i] = transform.data()[i];
+ scalarTransform[i] = SafeNarrow(transform.data()[i]);
}
node.transform = SkM44::ColMajor(scalarTransform);
node.childrenInTraversalOrder =
diff --git a/runtime/type_conversions_unittests.cc b/runtime/type_conversions_unittests.cc
index 345eb78..80e00af 100644
--- a/runtime/type_conversions_unittests.cc
+++ b/runtime/type_conversions_unittests.cc
@@ -147,32 +147,6 @@
event.Wait();
}
-TEST_F(TypeConversionsTest, CanConvertListOfFloatsToListOfDartDoubles) {
- fml::AutoResetWaitableEvent event;
- AddNativeCallback(
- "NotifySuccess", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments args) {
- auto bool_handle = Dart_GetNativeArgument(args, 0);
- ASSERT_FALSE(tonic::CheckAndHandleError(bool_handle));
- ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(bool_handle));
- event.Signal();
- }));
- AddNativeCallback(
- "NotifyNative", CREATE_NATIVE_ENTRY([&](Dart_NativeArguments) {
- std::vector<float> items;
- items.push_back(1.0f);
- items.push_back(2.0f);
- items.push_back(3.0f);
- items.push_back(4.0f);
- auto items_handle = tonic::ToDart(items);
- ASSERT_FALSE(tonic::CheckAndHandleError(items_handle));
- // This will fail on type mismatch.
- tonic::DartInvokeField(::Dart_RootLibrary(),
- "testCanConvertListOfDoubles", {items_handle});
- }));
- ASSERT_TRUE(RunWithEntrypoint("trampoline"));
- event.Wait();
-}
-
} // namespace testing
} // namespace flutter
diff --git a/shell/platform/embedder/fixtures/arc_end_caps.png b/shell/platform/embedder/fixtures/arc_end_caps.png
index 149eea0..b9701b3 100644
--- a/shell/platform/embedder/fixtures/arc_end_caps.png
+++ b/shell/platform/embedder/fixtures/arc_end_caps.png
Binary files differ
diff --git a/third_party/tonic/converter/dart_converter.h b/third_party/tonic/converter/dart_converter.h
index b96faeb..cec01ac 100644
--- a/third_party/tonic/converter/dart_converter.h
+++ b/third_party/tonic/converter/dart_converter.h
@@ -202,48 +202,39 @@
}
};
-template <typename T>
-struct DartConverterFloatingPoint {
- using FfiType = T;
+// There is intentionally no DartConverter<float>, to avoid UB when Dart code
+// gives us a double that is greater than the max float or less than -max float.
+template <>
+struct DartConverter<double> {
+ using FfiType = double;
+ static constexpr const char* kFfiRepresentation = "Double";
+ static constexpr const char* kDartRepresentation = "double";
static constexpr bool kAllowedInLeafCall = true;
- static Dart_Handle ToDart(T val) { return Dart_NewDouble(val); }
+ static Dart_Handle ToDart(double val) { return Dart_NewDouble(val); }
- static void SetReturnValue(Dart_NativeArguments args, T val) {
+ static void SetReturnValue(Dart_NativeArguments args, double val) {
Dart_SetDoubleReturnValue(args, val);
}
- static T FromDart(Dart_Handle handle) {
+ static double FromDart(Dart_Handle handle) {
double result = 0;
Dart_DoubleValue(handle, &result);
return result;
}
- static T FromArguments(Dart_NativeArguments args,
- int index,
- Dart_Handle& exception) {
+ static double FromArguments(Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
double result = 0;
Dart_GetNativeDoubleArgument(args, index, &result);
return result;
}
- static T FromFfi(FfiType val) { return val; }
- static FfiType ToFfi(T val) { return val; }
+ static double FromFfi(FfiType val) { return val; }
+ static FfiType ToFfi(double val) { return val; }
static bool AllowedInLeafCall() { return kAllowedInLeafCall; }
-};
-template <>
-struct DartConverter<float> : public DartConverterFloatingPoint<float> {
- static constexpr const char* kFfiRepresentation = "Float";
- static constexpr const char* kDartRepresentation = "double";
- static const char* GetFfiRepresentation() { return kFfiRepresentation; }
- static const char* GetDartRepresentation() { return kDartRepresentation; }
-};
-
-template <>
-struct DartConverter<double> : public DartConverterFloatingPoint<double> {
- static constexpr const char* kFfiRepresentation = "Double";
- static constexpr const char* kDartRepresentation = "double";
static const char* GetFfiRepresentation() { return kFfiRepresentation; }
static const char* GetDartRepresentation() { return kDartRepresentation; }
};
diff --git a/third_party/tonic/tests/ffi_native_unittest.cc b/third_party/tonic/tests/ffi_native_unittest.cc
index 2800f35..62416f3 100644
--- a/third_party/tonic/tests/ffi_native_unittest.cc
+++ b/third_party/tonic/tests/ffi_native_unittest.cc
@@ -188,23 +188,6 @@
}
}
-// Call and serialise function with float.
-
-float EchoFloat(float arg) {
- EXPECT_EQ(arg, 23.0);
- return arg;
-}
-
-TEST_F(FfiNativeTest, FfiBindingCallEchoFloat) {
- DoCallThroughTest<void, decltype(&EchoFloat), &EchoFloat>("EchoFloat",
- "callEchoFloat");
-}
-
-TEST_F(FfiNativeTest, SerialiseEchoFloat) {
- DoSerialiseTest<void, decltype(&EchoFloat), &EchoFloat>(
- /*leaf=*/true, "Float", "double", "Float", "double");
-}
-
// Call and serialise function with double.
double EchoDouble(double arg) {
diff --git a/third_party/tonic/tests/fixtures/tonic_test.dart b/third_party/tonic/tests/fixtures/tonic_test.dart
index 4d408fd..b9e992b 100644
--- a/third_party/tonic/tests/fixtures/tonic_test.dart
+++ b/third_party/tonic/tests/fixtures/tonic_test.dart
@@ -65,18 +65,6 @@
}
}
-// Test helpers for calls with float through Tonic.
-
-@Native<Float Function(Float)>(symbol: 'EchoFloat')
-external double echoFloat(double arg);
-
-@pragma('vm:entry-point')
-void callEchoFloat() {
- if (echoFloat(23.0) == 23.0) {
- signalDone();
- }
-}
-
// Test helpers for calls with double through Tonic.
@Native<Double Function(Double)>(symbol: 'EchoDouble')