Struct style::values::computed::font::FixedPoint

source ·
#[repr(C)]
pub struct FixedPoint<T, const FRACTION_BITS: u16> { pub value: T, }
Expand description

Generic template for font property type classes that use a fixed-point internal representation with FRACTION_BITS for the fractional part.

Values are constructed from and exposed as floating-point, but stored internally as fixed point, so there will be a quantization effect on fractional values, depending on the number of fractional bits used.

Using (16-bit) fixed-point types rather than floats for these style attributes reduces the memory footprint of gfxFontEntry and gfxFontStyle; it will also tend to reduce the number of distinct font instances that get created, particularly when styles are animated or set to arbitrary values (e.g. by sliders in the UI), which should reduce pressure on graphics resources and improve cache hit rates.

cbindgen:derive-lt cbindgen:derive-lte cbindgen:derive-gt cbindgen:derive-gte

Fields§

§value: T

The actual representation.

Implementations§

source§

impl<T, const FRACTION_BITS: u16> FixedPoint<T, FRACTION_BITS>

source

const SCALE: u16 = _

source

const INVERSE_SCALE: f32 = _

source

pub fn from_float(v: f32) -> Self

Returns a fixed-point bit from a floating-point context.

source

pub fn to_float(&self) -> f32

Returns the floating-point representation.

Trait Implementations§

source§

impl<T: Clone, const FRACTION_BITS: u16> Clone for FixedPoint<T, FRACTION_BITS>

source§

fn clone(&self) -> FixedPoint<T, FRACTION_BITS>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T, const FRACTION_BITS: u16> ComputeSquaredDistance for FixedPoint<T, FRACTION_BITS>

source§

fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>

Computes the squared distance between two animatable values.
source§

impl<T: Debug, const FRACTION_BITS: u16> Debug for FixedPoint<T, FRACTION_BITS>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, T, const FRACTION_BITS: u16> Deserialize<'de> for FixedPoint<T, FRACTION_BITS>
where T: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<const FRACTION_BITS: u16> Div for FixedPoint<u16, FRACTION_BITS>

§

type Output = FixedPoint<u16, FRACTION_BITS>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self

Performs the / operation. Read more
source§

impl<T: Hash, const FRACTION_BITS: u16> Hash for FixedPoint<T, FRACTION_BITS>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T, const FRACTION_BITS: u16> MallocSizeOf for FixedPoint<T, FRACTION_BITS>
where T: MallocSizeOf,

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.
source§

impl<const FRACTION_BITS: u16> Mul for FixedPoint<u16, FRACTION_BITS>

§

type Output = FixedPoint<u16, FRACTION_BITS>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self

Performs the * operation. Read more
source§

impl<T: PartialEq, const FRACTION_BITS: u16> PartialEq for FixedPoint<T, FRACTION_BITS>

source§

fn eq(&self, other: &FixedPoint<T, FRACTION_BITS>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd, const FRACTION_BITS: u16> PartialOrd for FixedPoint<T, FRACTION_BITS>

source§

fn partial_cmp(&self, other: &FixedPoint<T, FRACTION_BITS>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T, const FRACTION_BITS: u16> Serialize for FixedPoint<T, FRACTION_BITS>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T, const FRACTION_BITS: u16> ToResolvedValue for FixedPoint<T, FRACTION_BITS>
where T: ToResolvedValue,

§

type ResolvedValue = FixedPoint<<T as ToResolvedValue>::ResolvedValue, FRACTION_BITS>

The resolved value type we’re going to be converted to.
source§

fn from_resolved_value(from: Self::ResolvedValue) -> Self

Convert a resolved value to resolved value form.
source§

fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue

Convert a resolved value to a resolved value.
source§

impl<T: Copy, const FRACTION_BITS: u16> Copy for FixedPoint<T, FRACTION_BITS>

source§

impl<T: Eq, const FRACTION_BITS: u16> Eq for FixedPoint<T, FRACTION_BITS>

source§

impl<T, const FRACTION_BITS: u16> StructuralPartialEq for FixedPoint<T, FRACTION_BITS>

Auto Trait Implementations§

§

impl<T, const FRACTION_BITS: u16> Freeze for FixedPoint<T, FRACTION_BITS>
where T: Freeze,

§

impl<T, const FRACTION_BITS: u16> RefUnwindSafe for FixedPoint<T, FRACTION_BITS>
where T: RefUnwindSafe,

§

impl<T, const FRACTION_BITS: u16> Send for FixedPoint<T, FRACTION_BITS>
where T: Send,

§

impl<T, const FRACTION_BITS: u16> Sync for FixedPoint<T, FRACTION_BITS>
where T: Sync,

§

impl<T, const FRACTION_BITS: u16> Unpin for FixedPoint<T, FRACTION_BITS>
where T: Unpin,

§

impl<T, const FRACTION_BITS: u16> UnwindSafe for FixedPoint<T, FRACTION_BITS>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T