#[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>
impl<T, const FRACTION_BITS: u16> FixedPoint<T, FRACTION_BITS>
Trait Implementations§
source§impl<T: Clone, const FRACTION_BITS: u16> Clone for FixedPoint<T, FRACTION_BITS>
impl<T: Clone, const FRACTION_BITS: u16> Clone for FixedPoint<T, FRACTION_BITS>
source§fn clone(&self) -> FixedPoint<T, FRACTION_BITS>
fn clone(&self) -> FixedPoint<T, FRACTION_BITS>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T, const FRACTION_BITS: u16> ComputeSquaredDistance for FixedPoint<T, FRACTION_BITS>where
T: ComputeSquaredDistance,
impl<T, const FRACTION_BITS: u16> ComputeSquaredDistance for FixedPoint<T, FRACTION_BITS>where
T: ComputeSquaredDistance,
source§fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()>
source§impl<'de, T, const FRACTION_BITS: u16> Deserialize<'de> for FixedPoint<T, FRACTION_BITS>where
T: Deserialize<'de>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<T, const FRACTION_BITS: u16> MallocSizeOf for FixedPoint<T, FRACTION_BITS>where
T: MallocSizeOf,
impl<T, const FRACTION_BITS: u16> MallocSizeOf for FixedPoint<T, FRACTION_BITS>where
T: MallocSizeOf,
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
source§impl<T: PartialEq, const FRACTION_BITS: u16> PartialEq for FixedPoint<T, FRACTION_BITS>
impl<T: PartialEq, const FRACTION_BITS: u16> PartialEq for FixedPoint<T, FRACTION_BITS>
source§fn eq(&self, other: &FixedPoint<T, FRACTION_BITS>) -> bool
fn eq(&self, other: &FixedPoint<T, FRACTION_BITS>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T: PartialOrd, const FRACTION_BITS: u16> PartialOrd for FixedPoint<T, FRACTION_BITS>
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>
fn partial_cmp(&self, other: &FixedPoint<T, FRACTION_BITS>) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T, const FRACTION_BITS: u16> Serialize for FixedPoint<T, FRACTION_BITS>where
T: Serialize,
impl<T, const FRACTION_BITS: u16> Serialize for FixedPoint<T, FRACTION_BITS>where
T: Serialize,
source§impl<T, const FRACTION_BITS: u16> ToResolvedValue for FixedPoint<T, FRACTION_BITS>where
T: ToResolvedValue,
impl<T, const FRACTION_BITS: u16> ToResolvedValue for FixedPoint<T, FRACTION_BITS>where
T: ToResolvedValue,
§type ResolvedValue = FixedPoint<<T as ToResolvedValue>::ResolvedValue, FRACTION_BITS>
type ResolvedValue = FixedPoint<<T as ToResolvedValue>::ResolvedValue, FRACTION_BITS>
source§fn from_resolved_value(from: Self::ResolvedValue) -> Self
fn from_resolved_value(from: Self::ResolvedValue) -> Self
source§fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue
fn to_resolved_value(self, context: &Context<'_>) -> Self::ResolvedValue
impl<T: Copy, const FRACTION_BITS: u16> Copy for FixedPoint<T, FRACTION_BITS>
impl<T: Eq, const FRACTION_BITS: u16> Eq for FixedPoint<T, FRACTION_BITS>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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