/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/// Represents the information about a transform palette /// entry that is passed to shaders. It includes an index /// into the transform palette, and a set of flags. #[derive(Copy, Clone, PartialEq, MallocSizeOf)] #[cfg_attr(feature = "capture", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] #[repr(C)] pubstruct GpuTransformId(pub u32);
// Note: we use unset bits instead of set bits to denote certain // properties of the transform so that the identity transform id // remains zero.
/// if *not* set, the transform is axis-aligned. const AXIS_ALIGNED_2D_BIT: u32 = 1 << 23; /// If *not* set, the transform can be represented as a 2d scale + offset. const SCALE_OFFSET_2D_BIT: u32 = 1 << 22;
/// Extract the transform kind from the id. pubfn transform_kind(&self) -> TransformedRectKind { if (self.0 & Self::AXIS_ALIGNED_2D_BIT) == 0 {
TransformedRectKind::AxisAligned
} else {
TransformedRectKind::Complex
}
}
/// Note: There are transformations that preserve axis-alignment without /// being scale + offsets. pubfn is_2d_axis_aligned(&self) -> bool { self.0 & Self::AXIS_ALIGNED_2D_BIT == 0
}
/// Returns true if the transform can be represented by a 2d scale + offset. pubfn is_2d_scale_offset(&self) -> bool { self.0 & Self::SCALE_OFFSET_2D_BIT == 0
}
/// Override the kind of transform stored in this id. This can be useful in /// cases where we don't want shaders to consider certain transforms axis- /// aligned (i.e. perspective warp) even though we may still want to for the /// general case. pubfn override_transform_kind(&self, kind: TransformedRectKind) -> Self {
GpuTransformId((self.0 & (1 << 23)) | ((kind as u32) << 23))
}
}
// Stores a contiguous list of TransformData structs, that // are ready for upload to the GPU. // TODO(gw): For now, this only stores the complete local // to world transform for each spatial node. In // the future, the transform palette will support // specifying a coordinate system that the transform // should be relative to. pubstruct GpuTransforms {
transforms: FrameVec<TransformData>,
metadata: Vec<TransformMetadata>,
map: FastHashMap<RelativeTransformKey, usize>,
}
// Get a transform palette id for the given spatial node. // TODO(gw): In the future, it will be possible to specify // a coordinate system id here, to allow retrieving // transforms in the local space of a given spatial node. pubfn get_id(
&mutself,
from_index: SpatialNodeIndex,
to_index: SpatialNodeIndex,
spatial_tree: &SpatialTree,
) -> GpuTransformId { let index = self.get_index(
from_index,
to_index,
None, false,
spatial_tree,
);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.