mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Avoid manual paint-order glue code.
Differential Revision: https://phabricator.services.mozilla.com/D42913
This commit is contained in:
parent
14c7e133ad
commit
432b417d98
2 changed files with 6 additions and 16 deletions
|
@ -106,13 +106,13 @@ pub enum PaintOrder {
|
|||
}
|
||||
|
||||
/// Number of non-normal components
|
||||
const PAINT_ORDER_COUNT: u8 = 3;
|
||||
pub const PAINT_ORDER_COUNT: u8 = 3;
|
||||
|
||||
/// Number of bits for each component
|
||||
const PAINT_ORDER_SHIFT: u8 = 2;
|
||||
pub const PAINT_ORDER_SHIFT: u8 = 2;
|
||||
|
||||
/// Mask with above bits set
|
||||
const PAINT_ORDER_MASK: u8 = 0b11;
|
||||
pub const PAINT_ORDER_MASK: u8 = 0b11;
|
||||
|
||||
/// The specified value is tree `PaintOrder` values packed into the
|
||||
/// bitfields below, as a six-bit field, of 3 two-bit pairs
|
||||
|
@ -135,6 +135,7 @@ const PAINT_ORDER_MASK: u8 = 0b11;
|
|||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
pub struct SVGPaintOrder(pub u8);
|
||||
|
||||
impl SVGPaintOrder {
|
||||
|
@ -146,7 +147,7 @@ impl SVGPaintOrder {
|
|||
/// Get variant of `paint-order`
|
||||
pub fn order_at(&self, pos: u8) -> PaintOrder {
|
||||
// Safe because PaintOrder covers all possible patterns.
|
||||
unsafe { ::std::mem::transmute((self.0 >> pos * PAINT_ORDER_SHIFT) & PAINT_ORDER_MASK) }
|
||||
unsafe { std::mem::transmute((self.0 >> pos * PAINT_ORDER_SHIFT) & PAINT_ORDER_MASK) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue