Make floating point operations compile with no_std

Use num_traits and libm instead, also for euclid.
This commit is contained in:
Simon Hausmann 2021-11-30 14:54:45 +01:00 committed by Simon Hausmann
parent e8302452b5
commit bf84bb2ab6
5 changed files with 15 additions and 0 deletions

View file

@ -27,6 +27,8 @@ default = ["std"]
# from a single core, and not in a interrupt or signal handler.
unsafe_single_core = []
libm = ["num-traits/libm", "euclid/libm"]
[dependencies]
const-field-offset = { version = "0.1", path = "../../helper_crates/const-field-offset" }
vtable = { version="0.1.1", path = "../../helper_crates/vtable" }
@ -52,6 +54,7 @@ unicode-segmentation = "1.8.0"
rgb = "0.8.27"
pin-project = "1"
atomic-polyfill = { version = "0.1.5" }
num-traits = { version = "0.2", default-features = false }
[target.'cfg(target_arch = "wasm32")'.dependencies]
instant = { version = "0.1", features = [ "wasm-bindgen", "now" ] }

View file

@ -15,6 +15,9 @@ use super::{Color, Point};
use crate::properties::InterpolatedPropertyValue;
use crate::SharedVector;
#[cfg(not(feature = "std"))]
use num_traits::float::Float;
/// A brush is a data structure that is used to describe how
/// a shape, such as a rectangle, path or even text, shall be filled.
/// A brush can also be applied to the outline of a shape, that means

View file

@ -13,6 +13,9 @@ This module contains color related types for the run-time library.
use crate::properties::InterpolatedPropertyValue;
#[cfg(not(feature = "std"))]
use num_traits::float::Float;
/// RgbaColor stores the red, green, blue and alpha components of a color
/// with the precision of the generic parameter T. For example if T is f32,
/// the values are normalized between 0 and 1. If T is u8, they values range

View file

@ -32,6 +32,9 @@ use const_field_offset::FieldOffsets;
use core::pin::Pin;
use sixtyfps_corelib_macros::*;
#[cfg(not(feature = "std"))]
use num_traits::float::Float;
#[derive(Copy, Clone, Debug, PartialEq, strum::EnumString, strum::Display)]
#[repr(C)]
#[allow(non_camel_case_types)]

View file

@ -27,6 +27,9 @@ use once_cell::unsync::OnceCell;
use pin_project::pin_project;
use pin_weak::rc::{PinWeak, Rc};
#[cfg(not(feature = "std"))]
use num_traits::float::Float;
type DependencyListHead =
crate::properties::dependency_tracker::DependencyListHead<*const dyn ErasedRepeater>;
type ComponentRc<C> = vtable::VRc<crate::component::ComponentVTable, C>;